retrieving X-axis label on Itemdatabound event

Thread is closed for posting
3 posts, 1 answers
  1. ChrisWalker
    ChrisWalker avatar
    21 posts
    Member since:
    May 2007

    Posted 29 May 2008 Link to this post

    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. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 30 May 2008 Link to this post

    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
  3. ChrisWalker
    ChrisWalker avatar
    21 posts
    Member since:
    May 2007

    Posted 30 May 2008 Link to this post

    Excellent! Thank you- it works great.
Back to Top