Exemple #1
0
 public GraphViewModel(ICollection <KeyValuePair <int, double> > values0, ICollection <KeyValuePair <int, double> > values1, Brush stroke0, Brush stroke1, string title, string decorate, double min, double max, string xtext)
 {
     if (values0 != null && values0.Count > 0)
     {
         this.Values0 = new DoubleCollection();
         foreach (var v0 in values0)
         {
             Values0.Add(v0.Value);
         }
     }
     if (values1 != null && values1.Count > 0)
     {
         this.Values1 = new DoubleCollection();
         foreach (var v1 in values1)
         {
             Values1.Add(v1.Value);
         }
     }
     Stroke0  = stroke0;
     Stroke1  = stroke1;
     Title    = title;
     Decorate = decorate;
     Minimum  = min;
     Maximum  = max;
     XText    = xtext;
 }
Exemple #2
0
        /// <summary>
        /// Process ra data
        /// </summary>
        /// <param name="entry"></param>
        private void ProcessValues1(MonitorEntry entry)
        {
            var date  = entry.Datetime.ToLocalTime();
            var point = new PointModel {
                DateTime = date, Value = 0, Set = ChartValueSet.Values1
            };
            var msg = entry.Message.Split(',');

            double.TryParse(msg[2], out var steps);

            if (IsZeroBased)
            {
                var zero = Conversions.Deg2ArcSec(90.0) * raStepsPerSecond;
                steps -= zero;
            }

            switch (Scale)
            {
            case ChartScale.Degrees:
                point.Value = Conversions.ArcSec2Deg(steps / raStepsPerSecond);
                break;

            case ChartScale.Arcsecs:
                point.Value = steps / raStepsPerSecond;
                break;

            case ChartScale.Steps:
                point.Value = steps;
                break;

            default:
                return;
            }
            if (IsLogging)
            {
                ChartLogging.LogPoint(BaseLogName, ChartType.Plot, point);
            }

            Values1.Add(point);
            if (Values1.Count > MaxPoints)
            {
                Values1.RemoveAt(0);
            }

            var item = TitleItems.FirstOrDefault(x => x.TitleName == Values1Title);

            if (item == null)
            {
                return;
            }
            item.Value = point.Value;
        }
Exemple #3
0
 public void DrawChart(int series_index, List <double> xvalues, List <double> yvalues)
 {
     if (series_index == 1)
     {
         for (int i = 0; i < xvalues.Count(); i++)
         {
             Values1.Add(new ObservablePoint {
                 X = xvalues[i], Y = yvalues[i]
             });
         }
     }
     if (series_index == 2)
     {
         for (int i = 0; i < xvalues.Count(); i++)
         {
             Values2.Add(new ObservablePoint {
                 X = xvalues[i], Y = yvalues[i]
             });
         }
     }
 }
Exemple #4
0
        public ChartsViewModel()
        {
            #region 趋势图
            var r = new Random();

            for (int i = 0; i < 20; i++)
            {
                Values1.Add(new ObservableValue(r.Next(0, 20)));
            }
            for (int i = 0; i < 20; i++)
            {
                Values2.Add(new ObservableValue(r.Next(0, 20)));
            }
            #endregion

            #region 饼图
            Func <ChartPoint, string> f = cp => { return($"值:{cp.Y},{cp.Participation.ToString("f2")}%"); };
            PieDataList = new SeriesCollection
            {
                new PieSeries
                {
                    Title  = "饼1",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(4)
                    },
                    DataLabels = true,
                    LabelPoint = f
                },
                new PieSeries
                {
                    Title  = "饼2",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(3)
                    },
                    DataLabels = true,
                    LabelPoint = f,
                    FontSize   = 18
                },
                new PieSeries
                {
                    Title  = "饼3",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(8)
                    },
                    DataLabels = true,
                    LabelPoint = f
                },
            };
            #endregion

            #region 柱状图
            SeriesCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title    = "2015",
                    FontSize = 33,
                    Values   = new ChartValues <double> {
                        10.1245, 50.1245, 39.1245, 50, 78, 99
                    },
                }
            };

            SeriesCollection.Add(new ColumnSeries
            {
                Title  = "2016",
                Values = new ChartValues <double> {
                    11.1245, 56, 42.1245
                },
            });

            SeriesCollection[1].Values.Add(48d);
            SeriesCollection[0].Values.Add(49d);
            Labels = new[] { "柱1", "柱2", "柱3", "柱4", "柱5", "柱6", "柱7", "柱8", };
            //y轴值转为整数
            Formatter = value => value.ToString("f0");

            #endregion
        }