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

0
0

Hi,

I have 4 or 8 series on screen and I want to select 1 of them to display some info about it.

How can I use the SeriesSelectionModifier with MVVM and also change the color of the selected serie.
Is it also possible to get an event when the selection has been changed?

I started with:

SeriesSelectionModifier seriesSelectionModifier = new SeriesSelectionModifier();
this.ChartModifier.ChildModifiers.Add(seriesSelectionModifier);

But don’t know how to continue.

Thanks in advance,
Egbert

  • You must to post comments
0
0

Hello,

First of all, SeriesSelectionModifier is used for selecting series on chart by mouse. If you want select series from ViewModel, you just need to set IsSelected=True for this series(IsSelected is defined in IRenderableSeries). There is also SelectedSeriesStyle property, so you should set SeriesColor to color value you want to have when the series is selected there. Also IRenderableSeries has defined SelectionChanged event, and there is SelectedRenderableSeries property of type ObservableCollection defined in SciChartSurface, so you can subscribe to listen SelectionChanged event for each of the renderable series, or to CollectionChanged event of SelectedRenderableSeries (you need to have such a property in your ViewModel and bind it by One-way binding to surface’s property).

Therefore, what we have:

  1. You need SeriesSelection modifier only if you want to select series by mouse – and can add it either in Xaml or VM
  2. To select series from VM you need to set IsSelected=True
  3. Put all values which you want to have in selected series to Style and set it to SelectedSeriesStyle property – it is applied automatically when IsSelected=True
  4. you can subscribe to SelectionChanged event for each renderable series you have, either to CollectionChanged event of SelectedRenderableSeries property of SciChartSurface.

Please, don’t hesitate to ask if you have any questions!

Best regards,
Yuriy

  • EJansen
    Hi,We want to select the series by mouse and add them in the VM. At the moment I'm only using the following two lines of code:SeriesSelectionModifier seriesSelectionModifier = new SeriesSelectionModifier(); this.ChartModifier.ChildModifiers.Add(seriesSelectionModifier);What extra lines of code do I need to add this modifier to the RenderableSeries and set the selected serie style to a white line color?Thanks again...
  • You must to post comments
0
0

Hi,

Please try out attached solution. Is this what are you looking for?

Best regards,
Yuriy

  • EJansen
    Hi,Yes, with a little bit of tweaking I did get it working.Thanks...
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.