public MainViewModel() { CreateChartData(); CreateChartSeries(); CreateChartAxis(); // Subscribe to future updates int i = 0; _dummyDataProvider.SubscribeUpdates((newValues) => { // Append when new values arrive _lineData.Append(newValues.XValues, newValues.YValues); // Zoom the chart to fit _lineData.InvalidateParentSurface(RangeMode.ZoomToFit); // Every 100th datapoint, add an annotation if (i % 100 == 0) { Annotations.Add(new InfoAnnotationViewModel() { X1 = _lineData.XValues.Last(), Y1 = 0.0 }); } i++; }); }
public MainViewModel() { var dummyDataProvider = new DummyDataProvider(); var lineData = new XyDataSeries <double, double>() { SeriesName = "TestingSeries" }; _renderableSeries = new ObservableCollection <IRenderableSeriesViewModel>(); RenderableSeries.Add(new LineRenderableSeriesViewModel() { StrokeThickness = 2, Stroke = Colors.SteelBlue, DataSeries = lineData, StyleKey = "LineSeriesStyle" }); // Append the initial values to the chart var initialDataValues = dummyDataProvider.GetHistoricalData(); lineData.Append(initialDataValues.XValues, initialDataValues.YValues); // Subscribe to future updates dummyDataProvider.SubscribeUpdates((newValues) => { // Append when new values arrive lineData.Append(newValues.XValues, newValues.YValues); // Zoom the chart to fit lineData.InvalidateParentSurface(RangeMode.ZoomToFit); }); }