Pre loader

DataPointSelectionModifier - can the hit test area be changed?

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 All,

I’ve got a class that derives from the DataPointSelectionModifier in order to access the OnValueChanged() functionality and everything is fine (Thank you Andrew).

However – When I have 2 series on the chart (scatter series) and 2 points are quite close together, a single selection of a point can result in the selection of two points. On playing around with it a bit I notice that a point can be selected when the mouse pointer is slightly outside the limits of the pointmarker (in this case a 10×10 EllipsePointMarker) so if you get 2 points only a few pixels apart it is possible to place the mouse between the two and get both points selected. You can also see the behaviour in the SciChart examples 2DCharts|Toltips and Hit Test| Pointmarkers Selection example if you play with the points in the top left corner.

The Question: Is there a way to reduce the area around the mouse pointer that a hit test is detected in? (e.g. 20 pixel radius down to say 5 pixel radius)

I’ve had a look at overriding GeometryHitTestResult HitTestCore but I don’t really know if this is even the right way to go. If somebody can confirm this is where I should be looking then I’ll find some time to persevere with it.

Thanks in advance
/Stuart

Version
5.1.0.11457
  • You must to post comments
1
1

Hi Stuart,

Short answer, no, the HitTest Radius is fixed for the DataPointSelectionModifier and dependent on series type.

You might be able to change it by overriding this method on DataPointSelectionModifier. Please note this code is untested

    public class DataPointSelectionModifierEx : DataPointSelectionModifier
    {
        protected override IEnumerable<SeriesInfo> GetSeriesInfoAt(Point point)
        {
            if (ParentSurface != null && !ParentSurface.RenderableSeries.IsNullOrEmpty())
            {
                foreach (var renderableSeries in ParentSurface.RenderableSeries)
                {
                    if (IsSeriesValid(renderableSeries))
                    {
                        const bool interpolate = false;
                        const double radius = 10;
                        var hitTestInfo = renderableSeries.HitTest(point, radius, interpolate);

                        if (IsHitPointValid(hitTestInfo))
                        {
                            var seriesInfo = renderableSeries.GetSeriesInfo(hitTestInfo);
                            yield return seriesInfo;
                        }
                    }
                }
            }
        }
    }

Best regards,
Andrew

  • Stuart McCullough
    Hi Andrew, As usual above and beyond – thank you very much for your response. I would never have though to try it this way and your “untested” code worked as is – wish mine did a bit more often lol Anyway – thanks again /Stuart
  • Andrew Burnett-Thompson
    Hah you get used to coding without a debugger when you handle as many support issues as I do :D Glad it did the trick and very happy to be of service!
  • 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