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

XAxis labels from data field?

3 Answers 100 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gary
Top achievements
Rank 1
Gary asked on 10 Nov 2008, 03:28 PM
Hello,

I'm trying to change the default labels on the XAxis from 1,2,3,4,5 etc and use the value from one of the fields in my bound table? I've seen examples that should do the trick, but I've tried and I can't get those labels to change, even when attempting to hard code values into them.

Please advise.

Thanks,

-Gary

3 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 12 Nov 2008, 07:42 AM
Hello Gary,

The easiest way to get labels from the data source is to use:
this.radChart1.PlotArea.XAxis.DataLabelsColumn = "labelsColumn"

If you want to customize the labels by hard-coding the values, you should first disable AutoScale:
this.radChart1.PlotArea.XAxis.AutoScale = false

Best,
Evtim
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Gary
Top achievements
Rank 1
answered on 12 Nov 2008, 04:48 PM
Hello,

Thanks very much for your response. Unfortunately I'm still having problems getting this to work. Where should I put this code? I've tried handling the ItemDataBound event and set the value there and I've also tried just setting the value after calling the DataBind() method, but the labels are not changing.

(I'm setting the AutoScale property to false right after creating my RadChart.)

Based on the name it seems XAxis.DataLabelsColumn is one label for the entire XAxis while I need a label for each individual row in the data source. Is my undestanding incorrect? I don't see my hardcoded text values anywhere so I'm not sure.

One more thing, when I debug the project I can see my value in the property, but I don't see it on the chart. Is there a way for me to send you my project, since I'm probably doing something in the wrong order or something?

Thanks,

-Gary




0
Gary
Top achievements
Rank 1
answered on 13 Nov 2008, 08:06 PM
I see what I was missing, I didn't realize the string "labelsColumn" in your example was supposed to be the name of my column in the datatable (I was expecting "labelsColumn" to show up in the Chart, doh!).

It is working now. (I knew I was just missing it.)

Thanks.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Gary
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Gary
Top achievements
Rank 1
Share this question
or