Pre loader

rollover events

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

1
0

Hello,

Is there an event that is triggered by the rollover modifier, or some other modifier for that matter?
Basically, I am trying to get the X/Y values of the point that the mouse is currently over through code.

Any help is appreciated.

  • You must to post comments
1
0

Thank you for the additional information!

In that case you need our Hit-Test API

See the article link here: http://support.scichart.com/index.php?/Knowledgebase/Article/View/17186/28/hit-test-api

Using BaseRenderableSeries.HitTest

The Hit-Test API is set of virtual methods defined on
BaseRenderableSeries, and overridden by some of the series types. This
API is used by the RolloverModifier, SeriesSelectionModifier and
TooltipModifier to transform mouse-clicks into data-points, and
determine if a mouse-point is over a point or over a series.

To call the Hit-Test method, use the following code:

// Subscribed using this code: 
  // sciChartSurface.MouseLeftButtonUp += SciChartSurfaceMouseLeftButtonUp;
  private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  {
      // Perform the hit test relative to the GridLinesPanel
      Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement); 
      double datapointRadius = 8;
      bool useInterpolation = false;
      HitTestInfo result = sciChartSurface.RenderableSeries[0].HitTest(mousePoint, datapointRadius, useInterpolation);
   
      // Output results 
      string formattedString =
          string.Format("{6}:\tMouse Coord: {0:0}, {1:0}\t\tNearest Datapoint Coord: {2:0.0}, {3:0.0}\tData Value:{4:0.0}, {5:0.0}",
              mousePoint.X, mousePoint.Y,
              result.HitTestPoint.X, result.HitTestPoint.Y,
              result.XValue, result.YValue,
              result.DataSeriesName);
   
      Console.WriteLine(formattedString);
  }
  

| Note: You must transform any mouse-points into the coordinate space
of the main chart area. Above we use the GridLinesPanel, which is a
canvas in the centre of the chart viewport (inside the axes). Without
this, all hit-test results will be inaccurate.

Live Example of Hit-Test API

Also we have a demo of using the Hit-Test API in the example called Hit Test Datapoints.

Take a look at the code in the example which outputs results to a ListBox

    private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        const string formatString = "{6}:\tMouse Coord: {0:0}, {1:0}\t\tNearest Datapoint Coord: {2:0.0}, {3:0.0}\tData Value: {4:0.0}, {5:0.0}";

        // Perform the hit test relative to the GridLinesPanel
        var hitTestPoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement);

        // Show info for series, which HitTest operation was successful for only
        foreach(var renderableSeries in sciChartSurface.RenderableSeries)
        {
            // Get hit-test the RenderableSeries using interpolation
            var hitTestInfo = renderableSeries.HitTest(hitTestPoint, true);

            if (hitTestInfo.IsHit)
            {
                // Convert the result of hit-test operation to SeriesInfo
                var seriesInfo = renderableSeries.GetSeriesInfo(hitTestInfo);

                // Output result
                var formattedString = SeriesInfoToFormattedString(seriesInfo, hitTestPoint, formatString);

                // Show result
                Console.WriteLine(formattedString);
                AddOnView(formattedString);
            }
        }
    }

Best regards,
Andrew

  • You must to post comments
0
0

Hi Andrew,

I really just need to get the details of whatever point is currently under the mouse.
Essentially when a user mouses over a point I need to query some additional information from a dataset in memory based on the x value of the point.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.