Pre loader

Keeping a series selected on mouse up over a point quirk

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

Maybe this isn’t a quirk, but I wanted to point this out. (No pun intended on points.)

So, I was in search of a way to keep a series selected after the user drags a point or double-clicks on a point in that series.

I found a way, but it doesn’t really make sense to me why it works.

Before, I was using the following code and it would keep the series selected, but it would also select another series with the index of hitTestPoint.DataSeriesIndex. (Which makes sense.) But I wasn’t sure why the series with the point was staying selected too.

    private void _sciChart_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (SelectedSeries == null) { return; }

        HitTestInfo hitTestPoint = SelectedSeries.HitTest(rawPoint: MousePosition, hitTestRadius: 10);

        if (hitTestPoint.IsHit)
        {
            RenderableSeries[hitTestPoint.DataSeriesIndex].IsSelected = true;
        }
    }

However, by adding the IsSelected = false part right after setting it to true works like a charm. And I get why the series with the same index as DataSeriesIndex becomes selected/unselected, but I don’t get why the series with the point also stays selected.

Here’s my “hack” to make it work as I want:

    private void _sciChart_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (SelectedSeries == null) { return; }

        HitTestInfo hitTestPoint = SelectedSeries.HitTest(rawPoint: MousePosition, hitTestRadius: 10);

        if (hitTestPoint.IsHit)
        {
            RenderableSeries[hitTestPoint.DataSeriesIndex].IsSelected = true;
            RenderableSeries[hitTestPoint.DataSeriesIndex].IsSelected = false;
        }
    }

Anyway, it works so that’s great. But I just wanted to let you know about this and maybe give me some insight into why this works or if there’s a “cleaner” way.

Thanks!

Version
5.3.0.11954
  • You must to post comments
0
0

Hi Greg,

Thanks for sharing the problem & proposed workaround. It’s difficult for us to advise on the problem as we dont have a full code sample. For example, you may have modifiers in the chart which perform things like selection, or custom modifiers or other parts of the code that deal with selection.

In SciChart by default, Selection is not enabled. You have to explicitly enable it with the SeriesSelectionModifier, the DataPointSelectionModifier, a custom modifier or by setting PointMetadata.IsSelected in code as you have done.

So I would guess that some interaction between the above is causing the effect you see, and cannot diagnose without further info. However, if you have a workaround, and it works, then I’d say — great! Stick with it!

If you get problems in the future, and need our help, try to demonstrate the problem in a complete but minimal code sample, and we will be glad to help.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.