Pre loader

Custom renderable series

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

I’m migrating from v3.1 to 6.5 but unsure how to deal with a custom renderable series that contains dependency props used by its overridden Draw() method. This is the class:

public class CustomXyScatterRenderableSeries : CustomRenderableSeries
{
     // An example dependency prop:
    public static readonly DependencyProperty RejectionLimitProperty = DependencyProperty.Register(
        "RejectionLimit",
        typeof(double?),
        typeof(NuXyScatterRenderableSeries),
        new PropertyMetadata(null, OnPropertyChangedGeneric));

    protected override void Draw(...) ...
}

I have now created a renderable series view model to go with the custom renderable series:

public class CustomXyScatterRenderableSeriesViewModel : BaseRenderableSeriesViewModel
{
    public override Type ViewType => typeof(CustomXyScatterRenderableSeries);
}

And in my window VM I have something like this, to programmatically create the chart series:

public ObservableCollection<IRenderableSeriesViewModel> SeriesCollection {get;} // Bound to the chart's 'RenderableSeries'

...

var vm = new CustomXyScatterRenderableSeriesViewModel()
         {
             StyleKey = "customSeriesStyle",
             StrokeThickness = 1,
             AntiAliasing = False,
             ...,
             RejectionLimit = 123  // Obviously won't work!
         }

SeriesCollection.Add(vm);

As per the above comment, how do I assign values to the RejectionLimit (and other dependency props)? I’m guessing that I’ll have to create a “RejectionLimit” property on my window VM, set this to 123 (or whatever), then bind this property to the custom renderable series dependency prop via the XAML style (created as per this article), e.g.:

  <Style TargetType="CustomXyScatterRenderableSeries" x:Key="customSeriesStyle"
           BasedOn="{StaticResource MvvmDefaultRenderableSeriesStyle}">
     <Setter Property="RejectionLimit" Value="{Binding RejectionLimit}"/>
     ...
  </Style>

Seems a bit convoluted when all I want to do is programmatically create a custom renderable series, so wanted to check that there isn’t a more straightforward approach.

Version
6.5
  • Andrew Stephens
    I can’t edit my question, but I’ve since noticed that CustomRenderableSeries inherits from FrameworkElement, so does this mean that my CustomXyScatterRenderableSeries can access the CustomXyScatterRenderableSeriesViewModel instance via the DataContext property? If so then I guess it makes more sense to add a “RejectionLimit” property to the latter VM, rather than my convoluted suggestion above of using the style.
  • You must to post comments
0
0

Hi Andrew,

This is the approach for creating custom series with the MVVM SeriesBinding API. We have a worked example here showing the steps.

Worked Example – CustomRenderableSeries in MVVM

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies