getting the Selected Stack Series on item Click

4 posts, 0 answers
  1. Vijay
    Vijay avatar
    13 posts
    Member since:
    May 2012

    Posted 30 Aug 2012 Link to this post

    Hi Telerik Support,


    I am trying to build stackedbar chart. On ItemClick event in the stackedBar chart, i am getting the details of respective item from the ItemsSource from e.DataPoint.DataItem . 
    But i would like to perform some action when click on a perticular partition on StackedBar.
    Can i have that feature in StackedBar Chart and in the Histogram type charts?




    Regards,
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 04 Sep 2012 Link to this post

    Hi Vijay,

    I am not really sure I followed you completely. According to your description ItemClick event works as expected. Once you get the DataPoint, you can retrieve the corresponding DataSeries through the DataSeries property. That said, ItemClick will work for any part of the stacked bar and the DataSeries will depend on the clicked item.

    Kind regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Vijay
    Vijay avatar
    13 posts
    Member since:
    May 2012

    Posted 05 Sep 2012 Link to this post

    i have collection object  each object will contains 4 Counts has to be Represented in a stacked Bar Chart
    so, i have taken Rad chart and in side it i have Created SeriesMapping  as Shown to Get the Result as in immage attached.
    <telerik:RadChart TitleStyle="{StaticResource ChartTitleStyle}" x:Name="SurgeriesSlippageChart" PaletteBrushesUseSolidColors="True" PaletteBrushesRepeat="True" >
                    <telerik:RadChart.PaletteBrushes>
                        <SolidColorBrush  Color="#FF8EC441" />
                        <SolidColorBrush  Color="#FF1B9DDE" />
                        <SolidColorBrush  Color="#FFF59700" />
                        <SolidColorBrush  Color="#FFD4DF32" />
                    </telerik:RadChart.PaletteBrushes>
                    <telerik:RadChart.DefaultView>
                        <telerik:ChartDefaultView>
                            <telerik:ChartDefaultView.ChartTitle>
                                <telerik:ChartTitle x:Name="SurgeriesSlippageTitle" Content=""   HorizontalAlignment="Center"/>
                            </telerik:ChartDefaultView.ChartTitle>
                            <telerik:ChartDefaultView.ChartLegend>
                                <telerik:ChartLegend  Visibility="Collapsed" />
                            </telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartDefaultView.ChartArea>
                                <telerik:ChartArea EnableAnimations="True" NoDataString="Loading......" EnableTransitionAnimations="True" Cursor="Hand">
                                    <telerik:ChartArea.AxisX>
                                        <telerik:AxisX LabelRotationAngle="270" LabelStep="1"  LayoutMode="Between" />
                                    </telerik:ChartArea.AxisX>
                                    <telerik:ChartArea.AxisY>
                                        <telerik:AxisY MinorTickPointMultiplier="1"  Title="No. Of Surgeries" />
                                    </telerik:ChartArea.AxisY>
                                </telerik:ChartArea>
                            </telerik:ChartDefaultView.ChartArea>
                        </telerik:ChartDefaultView>
                    </telerik:RadChart.DefaultView>
                    <telerik:RadChart.SeriesMappings>
                        <telerik:SeriesMapping LegendLabel="Allentown" >
                            <telerik:SeriesMapping.SeriesDefinition  >
                                <telerik:StackedBarSeriesDefinition StackGroupName="Actual" ShowItemLabels="False"  ShowItemToolTips="True" LegendDisplayMode="SeriesLabel">
                                    <telerik:StackedBarSeriesDefinition.Appearance>
                                        <telerik:SeriesAppearanceSettings  />
                                    </telerik:StackedBarSeriesDefinition.Appearance>
                                    <telerik:StackedBarSeriesDefinition.LabelSettings >
                                        <telerik:BarLabelSettings LabelDisplayMode="Inside"    />
                                    </telerik:StackedBarSeriesDefinition.LabelSettings>
                                </telerik:StackedBarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XCategory"    FieldName="Xaxis" />
                                <telerik:ItemMapping DataPointMember="YValue"       FieldName="SergeriesAtAllentownCount"  />
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>
                        <telerik:SeriesMapping LegendLabel="Bethlehem">
                            <telerik:SeriesMapping.SeriesDefinition >
                                <telerik:StackedBarSeriesDefinition StackGroupName="Actual" ShowItemLabels="False" ShowItemToolTips="True" LegendDisplayMode="SeriesLabel">
                                    <telerik:StackedBarSeriesDefinition.Appearance>
                                        <telerik:SeriesAppearanceSettings  />
                                    </telerik:StackedBarSeriesDefinition.Appearance>
                                    <telerik:StackedBarSeriesDefinition.LabelSettings>
                                        <telerik:BarLabelSettings  LabelDisplayMode="Outside" />
                                    </telerik:StackedBarSeriesDefinition.LabelSettings>
                                </telerik:StackedBarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XCategory"    FieldName="Xaxis" />
                                <telerik:ItemMapping DataPointMember="YValue"       FieldName="SergeriesAtBethlehemCount" />
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>
                        <telerik:SeriesMapping LegendLabel="East Stroudsburg">
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:StackedBarSeriesDefinition StackGroupName="Actual" ShowItemLabels="False" ShowItemToolTips="True" LegendDisplayMode="SeriesLabel">
                                    <telerik:StackedBarSeriesDefinition.Appearance>
                                        <telerik:SeriesAppearanceSettings  />
                                    </telerik:StackedBarSeriesDefinition.Appearance>
                                    <telerik:StackedBarSeriesDefinition.LabelSettings>
                                        <telerik:BarLabelSettings  LabelDisplayMode="Inside" />
                                    </telerik:StackedBarSeriesDefinition.LabelSettings>
                                </telerik:StackedBarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XCategory" FieldName="Xaxis" />
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="SergeriesAtEastStroudsburgCount" />
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>
                        <telerik:SeriesMapping LegendLabel="Slippage">
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:StackedBarSeriesDefinition StackGroupName="Actual" ShowItemLabels="False" ShowItemToolTips="True" LegendDisplayMode="SeriesLabel" >
                                    <telerik:StackedBarSeriesDefinition.LabelSettings>
                                        <telerik:BarLabelSettings  LabelDisplayMode="Outside" />
                                    </telerik:StackedBarSeriesDefinition.LabelSettings>
                                </telerik:StackedBarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XCategory" FieldName="Xaxis" />
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="SlippageCount" />
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>
                    </telerik:RadChart.SeriesMappings>
                </telerik:RadChart>

    in Chart area item Click 
    void ChartArea_ItemClick(object sender, ChartItemClickEventArgs e)
            {
    }

    i need to get the Series i have Clicked if i take the Data point (e.DataPoint.DataItem) then it is not possible to identify the Seies which is Clicked because that particular Data point has a 4 counts.
  5. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 10 Sep 2012 Link to this post

    Hi Vijay,

    In order to know exactly which series you have selected (or more specifically their LegendLabel) in the ItemClick event handler you can use the ChartItemClickEventArgs parameter e, and its property e.DataSeries. For example: 

    void ChartArea_ItemClick(object sender, ChartItemClickEventArgs e)
    {
        string legendLabel = e.DataSeries.LegendLabel;
     
        if (legendLabel == "Allentown")
        {
            //then...
            //your code here
        }
    }

    Hope this helps. But in case that you want a different selection behaviour, you can have a look at this article.

    If you have any further questions feel free to ask.

    Kind regards,
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top