Chart Area Click event as parameter

3 posts, 0 answers
  1. Phil
    Phil avatar
    23 posts
    Member since:
    Sep 2010

    Posted 20 Jun 2011 Link to this post

    Hi ,

    I have a RADChart that is bound to a collection through a ViewModel and I wanted to capture the details when the user clicks on a bar within the chart.
    I can do this in the code behind as below using the DataPoint.XCategory property of the click event but I need to pass the same as a parameter to a MVVMLight RelayCommand in the ViewModel in order to fire off another load event.

    AddHandler Chart.DefaultView.ChartArea.ItemClick, Sub(s, e) stopMe(s, e)
    

        Private Function stopMe(ByVal sender As ObjectByVal e As Telerik.Windows.Controls.Charting.ChartItemClickEventArgsAs Object
            Dim sss As String
            sss = e.DataPoint.XCategory
            Stop
        End Function

            <telerik:RadChart x:Name="Chart" Grid.Row="1" ItemsSource="{Binding Path=ConcernsCounts}">
                <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping>
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:BarSeriesDefinition ShowItemToolTips="True" />
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:ItemMapping FieldName="ConcernsCount" DataPointMember="LegendLabel"/>
                        <telerik:ItemMapping FieldName="BusinessUnit" DataPointMember="XCategory"/>
                        <telerik:ItemMapping FieldName="ConcernsCount" DataPointMember="Label"/>
                        <telerik:ItemMapping FieldName="ConcernsCount" DataPointMember="YValue"/>
                    </telerik:SeriesMapping>
                </telerik:RadChart.SeriesMappings>
                <telerik:RadChart.DefaultView>
                    <telerik:ChartDefaultView>
                        <telerik:ChartDefaultView.ChartTitle>
                            <telerik:ChartTitle Content="PLM Concerns By Business Unit" HorizontalAlignment="Center"/>                           
                        </telerik:ChartDefaultView.ChartTitle>
                        <telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartLegend x:Name="ChartLegend" UseAutoGeneratedItems="True" Visibility="Collapsed"/>
                        </telerik:ChartDefaultView.ChartLegend>                   
                        <telerik:ChartDefaultView.ChartArea>
                            <telerik:ChartArea LegendName="ChartLegend" Name="BusinessChartArea">
                                <telerik:ChartArea.AxisX>
                                    <telerik:AxisX LabelRotationAngle="45"/>
                                </telerik:ChartArea.AxisX>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="ItemClick">
                                        <cmd:EventToCommand Command="{Binding LoadDetails}" CommandParameter="{Binding ???????"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </telerik:ChartArea>
                        </telerik:ChartDefaultView.ChartArea>
                    </telerik:ChartDefaultView>
                </telerik:RadChart.DefaultView>
            </telerik:RadChart>




    How do I do this?

    Thanks
    Phil
  2. Phil
    Phil avatar
    23 posts
    Member since:
    Sep 2010

    Posted 21 Jun 2011 Link to this post

    Anyone???
  3. DevCraft banner
  4. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 23 Jun 2011 Link to this post

    Hi Phil,

    You can take advantage of the ChartArea.Command property. You can find it implemented in this example - see the bar chart.

    Best regards,
    Ves
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top