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



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

Thank you for the additional information!

In that case you need our Hit-Test API

See the article link here:

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,

| 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

Best regards,

  • You must to post comments

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.