Esempio n. 1
0
        public ChartViewModel(IDataProvider dataProvider, string chartTitle, string mouseEventGroupId)
        {
            _dataProvider   = dataProvider;
            _chartTitle     = chartTitle;
            MouseEventGroup = mouseEventGroupId;

            CreateChartData();
            CreateChartSeries();
            CreateChartAxis();

            // Subscribe to future updates
            int i = 0;

            _dataProvider.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++;
            });
        }
Esempio n. 2
0
        public override void FilterAll()
        {
            _filteredDataSeries.Clear();

            int    index = 0;
            double animationStepMillisconds = 1;

            Action appendPoint = null;

            Action onAppendCallback = () =>
            {
                // 2.) Append the point
                _filteredDataSeries.Append(_originalDataSeries.XValues[index], _originalDataSeries.YValues[index]);
                _filteredDataSeries.InvalidateParentSurface(RangeMode.ZoomToFit);

                // 3.) Schedule another until complete
                if (++index < _originalDataSeries.Count)
                {
                    // Achieve some rudimentary easing
                    animationStepMillisconds *= 1.05;
                    animationStepMillisconds  = Math.Min(animationStepMillisconds, 10);

                    // Next point
                    appendPoint();
                }
            };

            appendPoint = () =>
            {
                TimedMethod.Invoke(onAppendCallback).After((int)animationStepMillisconds).Go();
            };

            // 1.) Schedule one point to be appended
            appendPoint();
        }
Esempio n. 3
0
        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);
            });
        }
Esempio n. 5
0
 private void UpdatePoint(Point mousePoint)
 {
     // On Mouse-move, update the latest point
     if (_dataSeries != null)
     {
         _dataSeries.XValues[_dataSeries.Count - 1] = (DateTime)XAxis.GetDataValue(mousePoint.X);
         _dataSeries.YValues[_dataSeries.Count - 1] = (double)YAxis.GetDataValue(mousePoint.Y);
         _dataSeries.InvalidateParentSurface(RangeMode.None);
     }
 }