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

ChartView Context Menu

2 Answers 155 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Josh
Top achievements
Rank 1
Josh asked on 20 Apr 2012, 03:28 PM
I am trying to get a context menu to display when I right-click on a datapoint in a BarSeries.

I am able to add a context menu to the entire Cartesian Chart, but I want my context menu to be specific to the selected DataPoint.DataItem.

<telerik:BarSeries ItemsSource="{Binding DataView, ElementName=GroupsDataSource}" CombineMode="Cluster" ClipToPlotArea="False" AllowSelect="True" ShowLabels="True" MinWidth="30" Margin="5,0">
<telerik:RadContextMenu.ContextMenu>
     <telerik:RadContextMenu ItemClick="GroupContextMenu_ItemClicked" EventName="MouseRightButtonUp">
          <telerik:RadMenuItem x:Name="rmiCodeBar" Header="View Code Breakout (Bar)">
          </telerik:RadMenuItem>
          <telerik:RadMenuItem x:Name="rmiCodePie" Header="View Code Breakout (Pie)">
          </telerik:RadMenuItem>
     </telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>

I am also not sure how to get to the DataItem of the clicked point, as the below wont let me use DataPoint as the type.

private void GroupContextMenu_ItemClicked(object sender, RadRoutedEventArgs e)
{
       RadMenuItem item = e.OriginalSource as RadMenuItem;
       var actingOn = ((RadContextMenu)sender).GetClickedElement<DataPoint>();
       switch (item.Name)
       {
           // Create drill down charts based on what is selected
  
           default:
               break;
       }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 24 Apr 2012, 05:05 PM
Hello Josh,

We have attached a sample application that demonstrates how to achieve the desired functionality.

Note that the current version of RadCartesianChart has some limitations with regards to the support of context menu scenario (due to the current internal container structure of the control mouse input normally is not propagated to the series item visuals thus context menu cannot be properly notified to visualize itself). We have applied a workaround in the form of RadCartesianChart implicit style with custom template that addresses this problem but note that using this implicit style is only suggested if you want to use context-sensitive context menu items as it effectively disables the built-in interactive behaviors of the chart control like pan/zoom, trackball, selection, and tooltips.

Our developers are aware of the described limitation and will do their best to address it for the Q2 2012 release of the control.

Hope this helps.


All the best,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Josh
Top achievements
Rank 1
answered on 30 Apr 2012, 05:56 PM
Thanks for the reply. For this particular use, I value the Selection and Tooltip behaviors more than the Context menu, so I will make do with a static menu dynamically driven by the chart's selected data point until the control is updated.
Tags
ChartView
Asked by
Josh
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Josh
Top achievements
Rank 1
Share this question
or