Exemple #1
0
        /// <summary>
        /// process dec data
        /// </summary>
        /// <param name="entry"></param>
        private void ProcessValues2(MonitorEntry entry)
        {
            var date  = entry.Datetime.ToLocalTime();
            var point = new PointModel {
                DateTime = date, Value = 0, Set = ChartValueSet.Values2
            };
            var msg = entry.Message.Split(',');

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

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

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

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

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

            default:
                return;
            }

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

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

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

            if (item == null)
            {
                return;
            }
            item.Value = point.Value;
        }
Exemple #2
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 #3
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
        }