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?
- Stephen Painchaud asked 9 years ago
- You must login to post comments
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.
- Stephen Painchaud answered 9 years ago
- You must login to post comments
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.
- Stephen Painchaud answered 9 years ago
- You must login to post comments
Please login first to submit.