SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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
    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
    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.