Pre loader

How do I update my ViewModel when a dataseries changes.

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

0
0

I am directly editing my XyDataSeries on a chart by using my mouse. As the mouse moves I edit either the x or y value of a point using the methods

    public void SetPointYValueAt(IDataSeries series, int index, double newValue)
    {
        series.YValues[index] = newValue;
        series.InvalidateParentSurface(RangeMode.None);
    }

    public void SetPointXValueAt(IDataSeries series, int index, double newValue, double xMin, double xMax)
    {
        var xValue = newValue;

        // limit x values to keep them sorted
        if (xValue < xMin) xValue = xMin;
        if (xValue > xMax) xValue = xMax;
        series.XValues[index] = xValue;

        series.InvalidateParentSurface(RangeMode.None);
    }

With this code I am not getting an update at my ViewModel:

    public IDataSeries<double, double> MyDataSeries
    {
        get { return _myDataSeries; }
        set
        {
            _myDataSeries = value;
            OnPropertyChanged("MyDataSeries");
        }
    }

Here is my XAML:

            <sciChartExtensions:StepLineRenderableSeries x:Name="HResitivitySeries" IsDigitalLine="True" DataSeries="{Binding MyDataSeries, Mode=TwoWay}">

Where StepLineRenderableSeries is derived from FastLineRenderableSeries with IsDigitalLine = true and the HitTest method overridden.

How can I get MyDataSeries to update?

  • You must to post comments
0
0

I should have given more details. The methods SetPointXValueAt and SetPointYValueAt are located in a derived class

public class StepSeriesDataPointEditModifier : SeriesSelectionModifier

For this reason putting OnPropertyChanged in those methods will not help.

I will explain why I need to do this. I have a DigitaLine plot which is used to edit the data in the plot. The edited data has to be available in the viewmodel and model, where it will be used as input for numerical modeling.

I was hoping there would be some method in the dataseries that I could call to force the notification that it has changed.

  • You must to post comments
0
0

I am part way there. I can add a handler to my viewmodel with

        MyDataSeries.DataSeriesChanged += OnDataSeriesChanged;

but to invoke the DataSeriesChanged I have to modify my methods:

    public void SetPointYValueAt(IDataSeries series, int index, double newValue)
    {
        //series.YValues[index] = newValue;

        var xyDataSeries = series as XyDataSeries<double, double>;
        if (xyDataSeries != null)
        {
            var x = xyDataSeries.XValues[index];
            xyDataSeries.RemoveAt(index);
            xyDataSeries.Insert(index, x, newValue);
        }


        series.InvalidateParentSurface(RangeMode.None);
    }

Removing a data point and adding a new one triggers the DataSeriesChanged, but it is not as clean as just reseting the y value.

  • You must to post comments
Showing 2 results
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