SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

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.