Pre loader

IRenderableSeriesViewModel IncludeLegend property is missing

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

1
0

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

Version
7.0.2
  • You must to post comments
0
0

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

  • You must to post comments
0
0

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

  • You must to post comments
0
0

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

  • You must to post comments
0
0

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

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.