Пример #1
0
 public ChartVM()
 {
     this.DisplayName = "Chart";
     _ChartSeries = new ChartSeries("Readings");
     LoadReadings();
     _RollingSeries = new RollingSeries(_ChartSeries, 1000, 60);
     _Series.Add(_RollingSeries.Rolled);
     MainVM.Instance.MainModel.Log.CollectionChanged += Log_CollectionChanged;
 }
Пример #2
0
 public RollingSeries(ChartSeries source, int max, int step)
 {
     _Source = source;
     Max = max;
     Step = step;
     Rolled = new ChartSeries(_Source.Name);
     _Source.Points.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Points_CollectionChanged);
     Roll();
 }
 ChartSeries CreateSeries(int count)
 {
     ChartSeries series = new ChartSeries("Test");
     for (int i = 0; i < count; i++)
     {
         series.AddPoint(i, i);
     }
     return series;
 }
 public void LineChartControlSeriesTest5()
 {
     LineChartControl target = new LineChartControl();
     ObservableCollection<ChartSeries> coll = new ObservableCollection<ChartSeries>();
     ChartSeries cs = new ChartSeries("La Palma");
     cs.AddPoint(555, 888);
     coll.Add(cs);
     cs = new ChartSeries("Lanzarote");
     cs.AddPoint(18, 4);
     cs.AddPoint(19, 3);
     coll.Add(cs);
     target.Series = coll;
     Assert.AreEqual(1, target.Chart.Series["La Palma"].Points.Count);
     Assert.AreEqual(2, target.Chart.Series["Lanzarote"].Points.Count);
     Assert.AreEqual(555, target.Chart.Series["La Palma"].Points[0].XValue);
     Assert.AreEqual(18, target.Chart.Series["Lanzarote"].Points[0].XValue);
     target.Dispose();
 }
 public void LineChartControlSeriesTest4()
 {
     LineChartControl target = new LineChartControl();
     ObservableCollection<ChartSeries> coll = new ObservableCollection<ChartSeries>();
     ChartSeries cs = new ChartSeries("La Palma");
     coll.Add(cs);
     cs.AddPoint(0.644, 2);
     cs.AddPoint(2, 4);
     cs.AddPoint(5, 10);
     cs.AddPoint(20, 42);
     target.Series = coll;
     Assert.AreEqual(4, target.Chart.Series["La Palma"].Points.Count);
     Assert.AreEqual(0.644, target.Chart.Series["La Palma"].Points[0].XValue);
     Assert.AreEqual(42, target.Chart.Series["La Palma"].Points[3].YValues[0]);
     target.Dispose();
 }
 public void LineChartControlBindingTest7()
 {
     LineChartControl target = new LineChartControl();
     ObservableCollection<ChartSeries> coll = new ObservableCollection<ChartSeries>();
     target.Series = coll;
     ChartSeries cs = new ChartSeries("Benidorm");
     coll.Add(cs);
     for (int i = 0; i < 100; i++)
     {
         cs.AddPoint(i, i * 2);
     }
     Assert.AreEqual(100, target.Chart.Series["Benidorm"].Points.Count);
     cs.Points.Clear();
     Assert.AreEqual(0, target.Chart.Series["Benidorm"].Points.Count);
     target.Dispose();
 }
 private void ResetPoints(ChartSeries chartSeries, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     this.Chart.Series[chartSeries.Name].Points.Clear();
     AddPoints(chartSeries);
 }
 private void RemovePoints(ChartSeries chartSeries, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     int startIndex = e.OldStartingIndex;
     int endIndex = startIndex + e.OldItems.Count - 1;
     for (; endIndex >= startIndex; endIndex--)
     {
         this.Chart.Series[chartSeries.Name].Points.RemoveAt(endIndex);
     }
 }
 private void RemoveChartSeries(ChartSeries chartSeries)
 {
     chartSeries.Points.CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Points_CollectionChanged);
     Series series = this.Chart.Series[chartSeries.Name];
     this.Chart.Series.Remove(series);
     series.Dispose();
 }
 private void AddPoints(ChartSeries chartSeries, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     foreach (var p in e.NewItems)
     {
         KeyValuePair<double, double> value = (KeyValuePair<double, double>)p;
         this.Chart.Series[chartSeries.Name].Points.AddXY(value.Key, value.Value);
     }
 }
 private void AddPoints(ChartSeries chartSeries)
 {
     foreach (var p in chartSeries.Points)
     {
         this.Chart.Series[chartSeries.Name].Points.AddXY(p.Key, p.Value);
     }
 }
 private void AddChartSeries(ChartSeries chartSeries)
 {
     AddSeries(chartSeries.Name);
     AddPoints(chartSeries);
     chartSeries.Points.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Points_CollectionChanged);
 }