Pre loader

The HitTest is shifted

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,
I use HitTest in the “OnModifierMouseDown(ModifierMouseArgs e)”in the MyCustomClass.
This Class inherits SeriesSelectionModifier.
The result of HitTest is shifted by the width of Y axis when the AxisAlignment of Y axis is Left.
So, the HitTestInfo of XValue or IsHit or anymore are not correct.
For Avoiding this ploblem, I need to write the following code before HitTest.
var point = new Point(e.MousePoint.X, e.MousePoint.Y);
if (base.YAxis.AxisAlignment == SciChart.Charting.Visuals.Axes.AxisAlignment.Left)
{
point.X = point.X – base.YAxis.Width;
}

Is this a specification or a bug?

Thanks.

Version
V5.1.1 BUILD 11473
  • You must to post comments
0
0

Hi there,

I think you need to shift the Hit-Test point to the GridLinesPanel in the centre of the chart as mentioned here:

https://www.scichart.com/documentation/v5.x/webframe.html#RenderableSeries%20Hit-Test%20API.html

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.

// 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);
    // THIS LINE ABOVE IS IMPORTANT
    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);
}

Also further background and related question here:
https://www.scichart.com/questions/question/modifiermouseargs-bug-report

Can you try it?

Best regards,
Andrew

  • Kiyotaka Kubo
    Hi Andrew, Thank you for reply and GetPointRelativeTo works correctly. Best Regard.
  • 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