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

retrieving X-axis label on Itemdatabound event

2 Answers 99 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
ChrisWalker
Top achievements
Rank 1
ChrisWalker asked on 29 May 2008, 10:08 PM
I have a bar chart that displays just fine but need to add a tooltip for each "bar". The barchart's datasource returns two columns: item and percentComplete. When displayed, the item value is the X Axis label and the percentcomplete is the "value".
On both the itemdatabound and databound events, I was hoping to find the X axis label value so that I can run a query to get the information required for the tooltip text. However I cannot seem to find this value anywhere.

Example- a datasource row returns "Students" in column item and 33 for percent complete. The barchart's X axis label shows "Students" and the bar value is 33. However, on either the itemdatabound or databound event, I cannot find the value "Students" anywhere.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 30 May 2008, 07:38 AM
Hi ChrisWalker,

The ChartItemDataBoundEventArgs object, sent as second parameter to ItemDataBound event handler has a property DataItem. This property holds a reference to the underlying data, so you can extract any information you need. Here is an example:

protected void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e) 
    { 
        string tooltip = (e.DataItem as DataRowView)["LabelsColumn"].ToString(); 
        e.SeriesItem.ActiveRegion.Tooltip = tooltip; 
    } 

Hope this helps.

Best wishes,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
ChrisWalker
Top achievements
Rank 1
answered on 30 May 2008, 04:28 PM
Excellent! Thank you- it works great.
Tags
Chart (Obsolete)
Asked by
ChrisWalker
Top achievements
Rank 1
Answers by
Ves
Telerik team
ChrisWalker
Top achievements
Rank 1
Share this question
or