Hi,
How can i create context menu for FastLineRenderableSeries ?
i tested ContextMenu property of FastLineRenderableSeries and it didn’t work.
As i understand – it is because FastLineRenderableSeries is not a control that visualized.
- Nikita asked 12 years ago
- You must login to post comments
Hi there,
You are right, the FastLineRenderableSeries is not in the visual tree, as these are rendered using bitmaps only. If you want to create a context menu that shows only when right-clicking on a chart, I suggest you handle the SciChartSurface MouseRightButtonUp event and decide whether to show a context menu based on a hit-test result.
You can find a demonstration of the hit-test API here:
http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/InspectDatapoints/HitTestDatapoints.xaml
and code to enact a hit test here:
private void SciChartSurfaceMouseRightButtonUp(object sender, MouseButtonEventArgs e) { // Hit tests are done per renderable series, so get a renderable series // or iterate over all RenderableSeries var renderableSeries = this.sciChartSurface.RenderableSeries[0]; // Perform the hit test relative to the GridLinesPanel Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement); var hitTest = renderableSeries.HitTest(mousePoint); // Output results string formattedString = string.Format("Mouse Coord: {0:0}, {1:0}\t\tNearest Datapoint Coord: {2}, {3}\tData Value: {4}, {5}\t\tIsHit? {6}", mousePoint.X, mousePoint.Y, hitTest.HitTestPoint.X, hitTest.HitTestPoint.Y, hitTest.XValue, hitTest.YValue, hitTest.IsHit); Debug.WriteLine(formattedString); }
Hope this helps!
- Andrew Burnett-Thompson answered 12 years ago
-
Thanks, Andrew. It works fine.
-
Hi folks, I tried attaching a handler for my sciChartSurface's MouseRightButtonUp event, but it only catches it when I click outside the actual plot area (i.e., near the plot title or below the X axis, but not anywhere inside the actual plot). How can I capture mouse events on the chart itself? Thanks, --George
- You must login to post comments
Please login first to submit.