Pre loader

Hit Testing a RenderableSeriesViewModel?

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

I refactored from using custom RenderableSeries to a custom RenderableSeriesViewModel which has fixed a refresh bug in the chart:

  public class CustomExclusionRenderableSeriesViewModel : BaseRenderableSeriesViewModel
  {
     public override Type RenderSeriesType => typeof(CustomExclusionRenderableSeries);
  }

However I am invoking MouseLeftButtonUp in the chart code behind and performing a hit test. The HitTest method is not exposed on the BaseRenderableSeriesViewModel:

 private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {                          
    // Perform the hit test relative to the GridLinesPanel
    Point hitTestPoint = e.GetPosition(this.sciChart.GridLinesPanel as UIElement);

    // Get hit test the RenderableSeries using interpolation
    this.ViewModel.HitTestInfo = this.ViewModel.ExclusionSeries.HitTest(hitTestPoint, true);

Is there any way to get the series instance from the view model & hit test it?

Version
4
  • You must to post comments
0
0

Hi Thomas

Interesting requirement!

I would suggest to use our ChartModifierBase API to override OnModifierMouseDown for a start. Then perform the hit-test.

You can always then notify the ViewModel via a command binding, or, if you are not averse to slight hacks, direct call on a ViewModel.

e.g. simple case psuedocode becomes

public class HitTestModifierMvvm : ChartModifierBase
{
    public override void OnModifierMouseDown(ModifierMouseArgs e)
    {
        base.OnModifierMouseDown(e);

        foreach (var renderSeries in base.ParentSurface.RenderableSeries)
        {
            var hitTestInfo = renderSeries.HitTest(e.MousePoint);
            (renderSeries.DataContext as CustomExclusionRenderableSeriesViewModel).HitTest(hitTestInfo);
        }
    }
}

Obviously this can be improved, a lot. For example if you have an ICommand Dependency Property in your renderableseries, and bind it to a ViewModel ICommand you can invoke the command directly on the series, instead of doing a cast in your ChartModifier.

You can also choose to forward hit-tests where hitTestInfo.IsHit is true as opposed to all the hit-tests etc.. etc..

Does this help?

Best regards,
Andrew

  • Thomas Hutchinson
    Great, thanks. I have implemented a work around in which I get the series from the surface and match on SeriesName but I will try to implement hit testing as explained above
  • Andrew Burnett-Thompson
    I was thinking a better solution would be to have ICommand HitTestCommand on RenderableSeries bound to ICommand HitTestcommand in ViewModel. When the hit-test is invoked on the series it will call it on the ViewModel. Would be a nice addition to scichart MVVM
  • Andrew Burnett-Thompson
    Actually that won’t work … nevertheless I created a task for us to discuss internally https://abtsoftware.myjetbrains.com/youtrack/issue/SC-4036
  • Paul Frivold
    Being able to call hit test more easily with RenderableSeriesViewModels would be great!
  • 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