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

Bar Chart - Add ID to bar item

1 Answer 41 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
mary
Top achievements
Rank 1
mary asked on 17 Sep 2008, 03:10 PM
In the click event handler for the active regions i'd like access to an identifier for the bar selected but I can't find a way to set this on a databound chart.  There is an itemindex but that requires a known order for the displayed items.  Are there any properties that I could use for this?
I'm binding to a list of custom objects and indicating which properties to use for the bar chart using:

DurationReport.Series[0].DataYColumn =

"Duration";

DurationReport.PlotArea.XAxis.DataLabelsColumn =

"DisplayName";


Thanks

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 19 Sep 2008, 08:28 AM
Hello Mary,

You can use the Name property for this. Usually, it is populated for pie charts as the legend shows an item for each pie slice and the legend items' text is taken from this property. However, it is rarely used with bars, so you can populate it with the ID. Unfortunately, there is no way to do this like it's done with the labels (DataLabelsColumn), so you will need to wire ItemDataBound event and populate it:

e.SeriesItem.Name = ((MyType)e.DataItem)["MyIDField"].ToString();

Hope this helps.

Regards,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
mary
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or