A Faster HitTest?


https://www.nevron.com/Forum/Topic12085.aspx
Print Topic | Close Window

By Mark Malburg - 7 Years Ago
I'm working with a GridSurface chart with millions of points.  I want some double-click behaviors as follows:

1. Double-click the legend or the vertical axis... bring up a scaling dialog
2. Double-click the plot or the walls... restore the viewing angle (elevation, rotation, zoom, height)

My problem is that the hit test is very slow when I have a million or so points.  The use will double-click, and then double-click again thinking that the first one wasn't handled.

private void nChartControl1_MouseDoubleClick(object sender, MouseEventArgs e)
{
   // this handler is called immediately after the double click, but the HitTest function takes too much time. 
   NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
   // do something with "result"
}

Is there anyway I can do a hit test in a faster way?  Perhaps ignore the plot and just check for walls, legend and axes?

Thanks,
 
    - Mark





By Nevron Support - 7 Years Ago
Hi Mark,

You can workaround this by removing the surface series from the series collection before hit testing and then adding it again after you're done with the hit test. You can also freeze the axes ranges before you hit test to ensure that the chart hit tests a plot with exactly the same axis ranges - for example:

   // before hit test (fix the axis ranges as they were before you removed the grid surface
   StandardAxis[] axisIds = new StandardAxis[] { StandardAxis.PrimaryX, StandardAxis.PrimaryY, StandardAxis.Depth };

   foreach (StandardAxis axisId in axisIds)
   {
    NRange1DD rulerRange = chart.Axis(axisId).Scale.RulerRange;
    chart.Axis(axisId).View = new NRangeAxisView(rulerRange, true, true);
   }

   // after hit test - restore the default axis view
   foreach (StandardAxis axisId in axisIds)
   {
    chart.Axis(axisId).View = new NContentAxisView();
   }

Hope this helps - let us know if you meet any problems or have any questions.
By Mark Malburg - 7 Years Ago
I think I'm tracking with you... but how do I undo this after the hit test?

   - Mark
By Mark Malburg - 7 Years Ago
Since my data sets are huge... is there a quick way to remove it prior to the hit test and then quickly restore it after the hit test?
By Nevron Support - 7 Years Ago
Hi Mark,
You can set the Visible property of the surface series to false before hit testing and then to true again when hit testing is done. We may also consider to implement a hardware accelerated hit test for the new release.
By Kiran Varanasi - 6 Years Ago
I am using NChartControl in a winform application.  This have curve created from NPointSeries. 
Selecting the curve take multiple attempts as the selection has to be accurate. The HitTest method takes the location input to confirm if the chartelement selected is a data point. 
Is there a way to provide some kind of tolerance, so that user can pick the curve with slightly lesser accuracy of location?