Hi,
In the interface IRenderableSeriesViewModel an IncludeLegend property would be helpful (analogous to LegendModifier.IncludeSeriesProperty). Otherwise you have to override the LegendModifier.GetSeriesInfo method and implement the logic yourself.
regard
Tobias
- Tobias asked 1 year ago
- You must login to post comments
Hi Tobias
Good point, it is an attached property so strictly speaking not part of RenderableSeries.
You can set this via MVVM Series styles. See this guide:
Worked Example: Style Series in MVVM
Series can be styled in MVVM by registering a style in XAML and
referencing it from the ViewModel.To do this, you need to declare a Style
(TargetType=FastLineRenderableSeries, or, your chosen series type) in
XAML and give it a key. Next, set the
LineRenderableSeriesViewModel.StyleKey property equal to the key in
XAML. SciChart picks it up and applies the style automagically to the
series!
See the documentation page for code sample. I suggest creating a series style when you want to include/exclude a series explicitly from the legend.
If you want to update this property dynamically however, you will need to bind in the style to something. Perhaps a global registry somewhere with names of series + whether included in the legend or not?
Best regards
Andrew
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
Hi Andrew,
thank you for your answer. The disadvantage is that a separate style has to be created for each series type. A property in the IRenderableSeriesViewModel would be a quick and generic solution for the chart library (MVVM) user.
regards
Tobias
- Tobias answered 1 year ago
- last edited 1 year ago
- You must login to post comments
Hi Tobias
Of course, but adding a property then the delay of our release & test cycles means you won’t get a solution immediately.
How about this?
BaseRenderableSeriesViewModel has a Tag property which can be any object.
What about a style which binds to a custom object that you put on there with extra properties?
In view:
<Style x:Key="SeriesStyleKey" TargetType="{x:Type s:BaseRenderableSeries}">
<Setter Property="s:LegendModifier.IncludeSeries" Value="{Binding Tag.IsIncludedInLegend}"/>
</Style>
<s:SciChartSurface RenderableSeries="{s:SeriesBinding SeriesViewModels}">
</s:SciChartSurface>
In ViewModel
public class ExtraPropsViewModel
{
public bool IsIncludedInLegend { get; set; }
}
public class MyViewModel
{
public ObservableCollection<BaseRenderableSeriesViewModel> SeriesViewModels { get; set; }
void Foo()
{
SeriesViewModels.Add(new FastLineRenderableSeriesViewModel()
{
Tag = new ExtraPropsViewModel() { IsIncludedInLegend = true }
StyleKey = "SeriesStyleKey"
});
}
}
I’ve shortened that for brevity but shows the principle of the idea
Best regards
Andrew
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
Hi Andrew,
thank you for your support! That would also be a possible solution. However, I now had to override the LegendModifier.GetSeriesInfo. When the “IncludeLegend” property is added in a new SciChart release, we will refactor our code.
regards
Tobias
- Tobias answered 1 year ago
- last edited 1 year ago
- You must login to post comments
Please login first to submit.