Adding custom labels to X and Y axis

4 posts, 0 answers
  1. Deepak
    Deepak avatar
    11 posts
    Member since:
    Dec 2014

    Posted 06 May 2015 Link to this post

    Hi,

    I want to ask two questions :

    1) Please can you help as how I can add labels to x axis value with my own duration defined in labels as interval.

     2) How to show data points in Line series graph and add click listener to Line series.

     Thanks

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 07 May 2015 Link to this post

    Hi Deepak,

    Can you please explain in more detail your first point?

    As to your second point, you have to set a SphericalDataPointIndicator on your line series.
    For example:
    lineSeries.setDataPointIndicatorRenderer(new SphericalDataPointIndicatorRenderer(lineSeries));

    To react to click events on your series, you have to use ChartSelectionBehavior.

    Regards,
    Victor
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. DevCraft banner
  4. Deepak
    Deepak avatar
    11 posts
    Member since:
    Dec 2014

    Posted 07 May 2015 in reply to Victor Link to this post

    Thanks Victor, my first point is : I want to show labels on x-axis exactly where I can put put like I want to show for eg. {3,5,9,15 etc} but as of now I have perceived that it takes it automatically like it shows 0 an then it showed directly 5 on x-axis. It does not show 0 then 1,2,3,4 and then 5 like this.

     

    Basically what I needed is simplest mechanism to just add all the labels what ever I want to show on X-axis or Y-axis and it should get display on the graph irrespective of Bar or Line chart.

     

    So for example, I have a, b, c which I want to show on x-axis. And apple, ball and couch to show on Y-axis. Please suggest. I did some R&D and found there is something ChartLabelRenderer but I am not clear on this, Can you please illustrate with simple example which I can use as reference showing the above scenario happening.

     

    Also one request I have that when I try to look for some documentation, I always face problem that the docs does not show properly. I am attaching screenshots for the same. Please advise on this as well.

     

    Thanks,

  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 11 May 2015 Link to this post

    Hello Deepak,

    Thanks for the details. If I understood correctly you just need to show arbitrary labels on the linear axis. You can easily do this with a label value to string converter. For example:

    chart.getVerticalAxis().setLabelValueToStringConverter(new Function<Object, String>() {
    @Override
    public String apply(Object argument) {
    MajorTickModel tick = (MajorTickModel)argument;
    if(tick.value() == 1) {
    return "duck";
    }
    if(tick.value() == 2) {
    return "goose";
    }
    // etc.
    // For the unimportant values return an empty string.
    return "";
    }
    });

    I will forward to code example issue in the help to our help team. Thanks for reporting that. I don't think you can do something to browser to fix that. I suggest copy/pasting the whole code block into Android Studio/Eclipse and inspecting the example there.

    Regards,
    Victor
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
DevCraft banner