This is a migrated thread and some comments may be shown as answers.

Adding custom labels to X and Y axis

3 Answers 805 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Deepak
Top achievements
Rank 1
Deepak asked on 06 May 2015, 06:52 AM

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

3 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 07 May 2015, 08:37 AM
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.

 
0
Deepak
Top achievements
Rank 1
answered on 07 May 2015, 09:21 AM

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,

0
Victor
Telerik team
answered on 11 May 2015, 11:30 AM
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.

 
Tags
Chart
Asked by
Deepak
Top achievements
Rank 1
Answers by
Victor
Telerik team
Deepak
Top achievements
Rank 1
Share this question
or