Multiple StackedBarSeries ItemClick

2 posts, 1 answers
  1. Stanescu Mihai
    Stanescu Mihai avatar
    33 posts
    Member since:
    Aug 2009

    Posted 30 Mar 2011 Link to this post

    Hello Telerik Team,

    I have the following scenario, a chart with 2 StackedBarSeriesDefinition. What I did is have an ItemClick event linked up, and what I want to do with it is allow only one StackedBarSeries to trigger the event, and the other to do nothing. What is happenning now is that I can click on either of the BarSeries and trigger the event. 

    What I have for the itemssource is a list of 12 items with 2 values, and also the barseries are not in the same StackGroup.

    Any suggestions?
  2. Answer
    Evgenia avatar
    1437 posts

    Posted 01 Apr 2011 Link to this post

    Hello Stanescu Mihai,

    As I was able to understand you want only one Stack of Bars to be selectable on ItemClick. Here is how you can achieve this:
    void ChartArea_ItemClick(object sender, ChartItemClickEventArgs e)
        if (RadChart1.DefaultView.ChartArea.SelectedItems.Count > 1)
        List<DataPoint> barsInStack = new List<DataPoint>();
        foreach (StackedBar item in this.RadChart1.DefaultView.ChartArea.ChildrenOfType<StackedBar>())
            if (item.DataPoint.XCategory == e.DataPoint.XCategory)

    You may need to compare the XValue of the DataPoint and not the XCategory depending on your scenario. (marked in the code snippet with yellow).
    Have in mind that ChildrenOfType() method is extension method of Telerik.Windows.Controls.dll so you will need to add reference to it.

    the Telerik team
Back to Top