Pre loader

Binding on the dataSeries doesnot autoupdate scichart surface.

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

Requirements:

  • Main graph updates based on the data from the selected Item.
  • The data and styling is independent and the style is dynamic global style for all Items.
  • The data for the graphing that is Data Series is binded to DataSet which is of type XYDataSeries<DateTime, double>.
  • DataSeries data is obtained from the datacontext which implements INotifyPropertyChanged

Problem:

  • The databinding is not dynamic and the data series is not updated when the selection changes.
  • The initial data selection is reflected but any subsequent data changes are not reflected on the sci chart surface.
  • This behavior was only for the Dataseries binding and it was verified using a textbox which binds to the count of the DataSet and this updates as the selection changes but not the dataseries.

Please suggest a work around or an alternative solution so that I can predefine axes and series but swap out the data based on the selected Item. Please see the attached xaml code below.

        <Grid>
        <Grid DockPanel.Dock="Top">
            <chart:SciChartSurface x:Name="mainView"
                                   OnRenderException="MainView_OnRenderException"
                                   Loaded="MainView_Loaded">
                <chart:SciChartSurface.YAxes>
                    <chart:NumericAxis x:Name="AxisOne"
                                       Id="Id1"
                                       AxisAlignment="Left"/>

                    <chart:NumericAxis x:Name="AxisTwo"
                                       Id="Id2"
                                       AxisAlignment="Left"/>

                </chart:SciChartSurface.YAxes>
                <chart:SciChartSurface.XAxis>
                    <chart:DateTimeAxis x:Name="DateTimeAxis"/>
                </chart:SciChartSurface.XAxis>
                <chart:SciChartSurface.RenderableSeries>
                    <chart:FastLineRenderableSeries x:Name="DataSet1FS"
                                                    DataSeries="{Binding DataSet1}"
                                                    YAxisId="Id1"
                                                    Stroke="Yellow"/>
                </chart:SciChartSurface.RenderableSeries>
            </chart:SciChartSurface>
        </Grid>
        <TextBlock Text="{Binding Path=DataSet1.Count}"
                            Margin="0 -20 0 0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Top"
                            Height="20"
                            Width="200"
                            Background="White"
                            Foreground="Black"/>
    </Grid>
Version
6.6.0.26505
  • Andrew Burnett-Thompson
    Nice, well formatted question, +1 :) Are there any binding errors in the VS Output window? If you use Snoop WPF does it report any binding error for the property FastLineRenderableSeries.DataSeries? From what I can see, the code ‘should work’. We know you can bind from RenderableSeries.DataSeries to a DataSeries in viewmodel. So the first place I would look is binding errors (use Snoop WPF to inspect the property)
  • Arjun Sivaprasadam
    Hello Dr. Andrew, Thanks for responding asap. _________________________________________________________________________________________________________________ => Are there any binding errors in the VS Output window? # Nothing that is related or new after adding this! _________________________________________________________________________________________________________________ => If you use Snoop WPF does it report any binding error for the property FastLineRenderableSeries.DataSeries? # No Errors are reported on the snoop. It shows green on the DataSeries! _________________________________________________________________________________________________________________ => We know you can bind from RenderableSeries.DataSeries to a DataSeries in ViewModel! # Please note that in the example demoed here, there is no specific ViewModel of type (IRenderableSeriesViewModel) that is attached to the RenderableSeries. It is defined in Xaml here. I hope even then it should work. I’m getting the DataSet1 (of type XyDataSeries) from the DataContext. I was testing whether the binding is working or not using a textblock and there seems to be no problem for the text block to get the count of the selected DataSet1. _________________________________________________________________________________________________________________ Can you advise on how I can verify if this is an error on my side and not a potential bug on the SciChart library?
  • Arjun Sivaprasadam
    You’re right I was able to do data binding onto the series and it worked in an external example. I had to modify the given example so that the data source itself is swapped rather than adding or removing it from the same data source as given in the example. But I have confirmed that it works and I have to find out why the data binding is working for the text block and not for the scichart element in my other scenario. Arjun
  • Arjun Sivaprasadam
    I resolved the issue and successfully bound the data series. The binding issue was related to the XAxes binding. Declaring the XAxes in XAML did not work, but binding it using “s:AxesBinding” through the code did. On the other hand, declaring the YAxes in XAML worked without any problem. This was a strange bug, it may be worth investigating for you guys as it could be a potentially hard-to-replicate bug. Thanks, Dr. Andrew for all the quick responses. I was on vacation for a bit, hence the delay in communications.
  • Andrew Burnett-Thompson
    Hi Arjun, I’m glad you got the problem resolved! If you have any other issues please ask on a new question. Best regards, Andrew
1
0

Hi Arjun,

I had an idea for you to test. Our Bind SciChart to Data example has exactly the approach you are trying.

In the view:

        <s:SciChartSurface.RenderableSeries>
            <s:FastLineRenderableSeries DataSeries="{Binding ChartData}" Stroke="#279B27" />
        </s:SciChartSurface.RenderableSeries>

        <s:SciChartSurface.XAxis>
            <s:NumericAxis />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis GrowBy="0.1, 0.1" />
        </s:SciChartSurface.YAxis>

    </s:SciChartSurface>

In the viewmodel

    // Databound to via SciChartSurface in the view
    public IUniformXyDataSeries<double> ChartData
    {
        get => _dataSeries0;
        set
        {
            _dataSeries0 = value;
            OnPropertyChanged("ChartData");
        }
    }

What’s different about our example is we are forcing a zoom-to-fit after appending data.

You can do this one of three ways:

1/ Set Axis.AutoRange = AutoRange.Always. This will mean new data is always zoomed to fit on that axis. However, it will prevent zooming panning operations unless you do some clever tricks

2/ You can call _dataSeries.InvalidateParentSurface(). This has some options including telling SciChart if the data has changed, and whether to zoom to fit or not

3/ Or, you can use the ViewportManager. This is a way to control zooming, panning, even autorange from the Viewmodel. Note that immediate updates to data + Viewportmanager sometimes require a small time delay because of binding. See here for info

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.