Right-click on a RadCartesianChart

2 posts, 0 answers
  1. Jennifer
    Jennifer avatar
    1 posts
    Member since:
    Oct 2015

    Posted 11 Nov 2015 Link to this post

    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>
     

  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 16 Nov 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top