Pre loader

ContextMenu for chart series

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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.

  • You must to post comments
0
0

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!

  • Nikita
    Thanks, Andrew. It works fine.
  • yefchak
    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 to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies