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

Right-click on a RadCartesianChart

1 Answer 301 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jennifer
Top achievements
Rank 1
Jennifer asked on 11 Nov 2015, 03:24 PM

I'm new to this so I'm hoping to find some direction.  I have a plot on in a RadCartesianChart.  I want to be able to right-click and capture the location of the mouse at that place. Before we had a double click mouse event and were able to do this:

1.private void ChartSelectionBehavior_SelectionChanged(object sender, Telerik.Windows.Controls.ChartView.ChartSelectionChangedEventArgs e)
2.{
3.     if (e.AddedPoints.Count > 0)
4.     {
5.          ViewModel.NotePoint = e.AddedPoints[0].DataItem as GraphPlots;
6.     }
7.}​

Now I have this:

private void standardGraph_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
     //I want to set the NotePoint of the View Model to the location
     //of the right-mouse click here
      
     plotContextMenu.Visibility = System.Windows.Visibility.Visible;
}​

I can get the location of the MouseButtonEvent, but once I do I'm not sure how to set it as a GraphPlot.

Here's my XML:

01.<telerik:RadCartesianChart Visibility="{Binding StdGraphVisibility}"
02.     x:Name="standardGraph"
03.     Height="500"
04.     Width="1000"
05.     MouseRightButtonDown="mouseRightButtonDown"
06.     MouseRightButtonUp="standardGraph_MouseRightButtonUp">
07.                                         
08.    <telerik:RadContextMenu.ContextMenu>
09.                                             
10.        <telerik:RadContextMenu x:Name="plotContextMenu"
11.            Visibility="Hidden">
12. 
13.            <telerik:RadMenuItem Header="Add note"
14.                x:Name="addNoteMenuItem"
15.                Click="addNoteMenuItem_Click" />
16. 
17.            </telerik:RadContextMenu>
18.        </telerik:RadContextMenu.ContextMenu>
19.           
20.        <telerik:RadCartesianChart.Behaviors>
21.         
22.            <telerik:ChartSelectionBehavior DataPointSelectionMode="Single" 
23.                SelectionChanged="ChartSelectionBehavior_SelectionChanged"/>
24. 
25.        </telerik:RadCartesianChart.Behaviors>
26.                             
27.        <telerik:RadCartesianChart.HorizontalAxis>
28.        </telerik:RadCartesianChart.HorizontalAxis>
29.         
30.        <telerik:RadCartesianChart.VerticalAxis>  
31.        </telerik:RadCartesianChart.VerticalAxis>
32.                             
33.        <telerik:RadCartesianChart.Grid>
34.         
35.            <chartView:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" />
36.             
37.        </telerik:RadCartesianChart.Grid>
38. 
39.        <telerik:RadCartesianChart.Series>
40.            <telerik:LineSeries Stroke="Orange"
41.                CategoryBinding="Category"
42.                ValueBinding="Value"
43.                ItemsSource="{Binding GraphValue}">
44.            </telerik:LineSeries>
45.             
46.        <telerik:PointSeries CategoryBinding="Category"
47.            ValueBinding="Value"
48.            ItemsSource="{Binding Notes}">
49.        </telerik:PointSeries>
50.    </telerik:RadCartesianChart.Series>
51.</telerik:RadCartesianChart>
 

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 16 Nov 2015, 11:18 AM
Hi Jennifer,

If the user has clicked on a data point visual, you should be able to retrieve the DataPoint from the DataContext of the OriginalSource. From the data point you should be able to get the underlying GraphPlots just as you did before via casting the DataItem property of the data point. Let us know if this information suffice.

Regards,
Petar Marchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Jennifer
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or