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
- EJansen asked 11 years ago
- You must login to post comments
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:
- You need SeriesSelection modifier only if you want to select series by mouse – and can add it either in Xaml or VM
- To select series from VM you need to set IsSelected=True
- 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
- 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
- Yuriy Zadereckiy answered 11 years ago
-
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 login to post comments
Hi,
Please try out attached solution. Is this what are you looking for?
Best regards,
Yuriy
- Yuriy Zadereckiy answered 11 years ago
-
Hi, Yes, with a little bit of tweaking I did get it working. Thanks...
- You must login to post comments
this example is a but dated. I have a button on my legend that is intended to allow the users to select all the series or deselect all the series. the button essentially goes through the renderable series view models and set the IsSelected to either true or false, this approach doesnt work. what is the best solution to accomplish this?
- Joseph McClean answered 6 years ago
-
Hi Joseph, Yes very out of date! A 6-yr old forum post. If you are using the new SeriesBinding Api available in SciChart v5 then you want to set BaseRenderableSeriesViewModel.IsSelected = true. You will have to iterate all series and set this value to true on all. If you are using series from code-behind then setting BaseRenderabieSeries.IsSelected = true.
-
hi Andrew thanks for the fast response this was actually a post that i looked at to try to solve my problem ,my question i posted is here: https://www.scichart.com/questions/question/toggle-select-deselect-all-legend-items. I will try what you suggested and see if that works! i am actually using V4.
-
Hi Andrew i reviewed my code and i am doing what you are suggesting but the View isn’t updating to show the selected/de-selected series. I have a code snippet below, is there anything that i am missing? XAML <s:SciChartSurface Name="sciChart" Grid.Row="1" Margin="5" RenderableSeries="{s:SeriesBinding RenderableSeriesViewModels, UpdateSourceTrigger=PropertyChanged}" behavior:AxesCollectionBehaviour.AxisSource="{Binding YAxisViewModels}" VM if (RenderableSeriesViewModels != null && RenderableSeriesViewModels.Any()) { foreach(var series in RenderableSeriesViewModels) { series.IsSelected = !series.IsSelected ; } } Thanks, Joseph
- You must login to post comments
Please login first to submit.