public ChartViewModel() { ViewportManager = new DefaultViewportManager(); var dataSeries = new XyDataSeries <float, float>(); var x = new float[] { 1, 2, 4, 5, 6, 7 }; var y = new float[] { 4, 2, 3, 1, 2, 3 }; dataSeries.SeriesName = "Series 1"; dataSeries.Append(x, y); var viewModel = new LineRenderableSeriesViewModel { DataSeries = dataSeries, StyleKey = "LineStyle" }; RenderableSeriesViewModels.Add(viewModel); var annotation = new ExHorizontalLineAnnotation { Caption = "Annotation", Y1 = 2 }; Annotations.Add(annotation); ViewportManager.ZoomExtents(); }
public ManipulateSeriesMvvmViewModel() { _renderableSeriesViewModels = new ObservableCollection <IRenderableSeriesViewModel>(); _addCommand = new ActionCommand(() => { RenderableSeriesViewModels.Add(ViewModelsFactory.New(SelectedSeriesType.Type, 0)); ZoomExtents(); ClearCommand.RaiseCanExecuteChanged(); }, () => SelectedSeriesType != null); _removeCommand = new ActionCommand(() => { RenderableSeriesViewModels.RemoveWhere(s => s.IsSelected); ClearCommand.RaiseCanExecuteChanged(); }, () => RenderableSeriesViewModels.Any(s => s.IsSelected)); _clearCommand = new ActionCommand(() => { RenderableSeriesViewModels.Clear(); ClearCommand.RaiseCanExecuteChanged(); }, () => RenderableSeriesViewModels.Count > 0); _selectionChangedCommand = new ActionCommand(() => { var rSeriesVm = RenderableSeriesViewModels.FirstOrDefault(s => s.IsSelected); if (rSeriesVm != null) { SelectedSeriesType = SeriesTypes.FirstOrDefault(x => x.Type == rSeriesVm.GetType()); } RemoveCommand.RaiseCanExecuteChanged(); }); var data = DataManager.Instance.GetSinewave(1.0, 0.5, 100, 5); var lineDataSeries = new XyDataSeries <double, double>(); lineDataSeries.Append(data.XData.Select(d => d * 5), data.YData); FillSeriesTypes(); SelectedSeriesType = SeriesTypes[3]; _addCommand.Execute(null); AddCommand.RaiseCanExecuteChanged(); RemoveCommand.RaiseCanExecuteChanged(); }