Pre loader

ScatterChartPerformanceDemo hit test

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

I wanted to experiment with adding a tooltip to the SciChart_ScatterChartPerformanceDemo.

I extended the xaml with

 <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <s:MouseWheelZoomModifier/>
                <s:TooltipModifier />
            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>

However, I have noticed that the tooltip doesn’t seem to react properly to the geometry under the cursor. The tooltip will often show up when the cursor is outside the geometry.

If you use a SquarePointMarker with a width and height of 25, the tooltip pops up even when you’re a fair distance away from the geometry.

The hit detection doesn’t appear to be working correctly?

Edit : Also, it appears I am unable to answer questions here, when I add an answer, it accepts it, but doesn’t show anything?

Version
7.0.1.27055
  • Andrew Burnett-Thompson
    To answer a question you need reputation, until then answers are manually approved. To get reputation, ask good questions & get voted up. This is to stop spammers https://www.scichart.com/changes-to-the-scichart-forum-permissions/ Hit-Test is controlled by a property: Hit-Test Radius. This can be set manually as well as adjusted automatically based on the series type. Would you like to share more about your requirements?
  • forl forl
    The requirement is to plot a scatterplot using squares as markers, and have a tooltip for each marker. Am I right in thinking that every marker is treated as a circle in regards to hit testing? No matter what shape of marker? If I have a square marker of width and height of 20, I should set the hit radius to about 10? Where do I set this value?
  • Andrew Burnett-Thompson
    That’s correct, HitTest is a radius on data. There are different rules for line, mountain, candles etc but for scatter it’s a simple radius. 25px scatter point + cube shpuld approximate as a 12.5pm radius circle when hit testing. It’s a public holiday today in the U.K. and I’m away from desk – but your question “how to control HitTest radius” – I’ve notified the team and will circle back shortly. Best regards, Andrew
  • You must to post comments
1
0

Here is something that kind of works, but still uses a radius.

I guess if I want proper rectangle hitchecking (not circles) I’ll have to implement it manually?

public class CustomXyScatterRenderableSeries : XyScatterRenderableSeries
{
    public class CustomScatterSeriesHitTestProvider : DefaultHitTestProvider<XyScatterRenderableSeries>
    {
        public CustomScatterSeriesHitTestProvider(XyScatterRenderableSeries renderSeries)
            : base(renderSeries)
        {
        }

        public override HitTestInfo HitTest(Point rawPoint, bool interpolate = false)
        {
            return base.HitTest(rawPoint, GetHitRadius(), interpolate);
        }

        protected override HitTestInfo HitTestInternal(Point rawPoint, double hitTestRadius, bool interpolate)
        {
            return base.HitTestInternal(rawPoint, GetHitRadius(), interpolate: false);
        }

        private double GetHitRadius()
        {
            IPointMarker pointMarker = RenderableSeries.PointMarker;
            if (pointMarker != null)
            {
                double side = Math.Max(Math.Max(pointMarker.Width, pointMarker.Height), DefaultHitTestRadius);
                side = Math.Sqrt(side * side + side * side);

                return side / 2;
            }

            return DefaultHitTestRadius;
        }
    }

    public CustomXyScatterRenderableSeries()
    {
        HitTestProvider = new CustomScatterSeriesHitTestProvider(this);
    }
}
  • Andrew Burnett-Thompson
    Nice solution, I did ask the team and you’re right – HitTestRadius is not exposed on the TooltipModifier (it should be!). It’s expanded based on marker width/height. It would not be difficult to have some code to hit-test approx geometry for different marker types, and I’ll add this to our backlog as a feature request.
  • forl forl
    Just a suggestion, but it would be good if you added some examples for how users can write their own : RenderSeries, HitTestProvider, ChartModifiers etc etc I did find some examples but the contents of the overridden methods are empty, and there is no information on how to deal with render passes, batches etc. You kind of just have to experiment and hope you can get enough info by the comments (usually the comments are not helpful) Would you consider making *just one* of each of the Render Series, Chart modifiers you provide open source so people can learn from it? perhaps put it in one of the example projects? I think it would be extremely helpful.
  • Joeri R
    Thanks for your suggestion, we’ve logged a task to create an article about HitTestProviders.
  • Joeri R
    Regarding custom ChartModifiers, there is an old Knowledgebase where you can find several examples of custom ChartModifiers implementation: https://support.scichart.com/index.php?/Knowledgebase/List/Index/32&_gl=1*lhne5z*_gcl_au*NjQwNTc0MTk4LjE2ODM2MDE3NTQ.
  • Joeri R
    As to custom RenderableSeries, it is very nuanced and can be quite complicated. So if a customization goes beyond of what is possible with the approach recommended in the docs we advise consulting with our Support Team.
  • You must to post comments
0
0

Hello,

I’m glad to inform you that the Hit-Test issue has been fixed, and the changes are available in the latest SciChart nightly build v7.0.2.27201.
Here is how to get it:
https://support.scichart.com/index.php?/Knowledgebase/Article/View/17232/37/getting-nightly-builds-with-nuget

Please try it out and let us know your feedback.

With best regards,
Lex
SciChart Technical Support Engineer

  • You must to post comments
Showing 2 results
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