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

getting the Selected Stack Series on item Click

3 Answers 76 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 30 Aug 2012, 04:54 PM
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,

3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 04 Sep 2012, 10:21 AM
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.

0
Vijay
Top achievements
Rank 1
answered on 05 Sep 2012, 12:33 PM
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.
0
Petar Kirov
Telerik team
answered on 10 Sep 2012, 10:18 AM
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.

Tags
Chart
Asked by
Vijay
Top achievements
Rank 1
Answers by
Ves
Telerik team
Vijay
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question
or