public MainWindowModel()
        {
            Values = new ChartValues <DateTimePoint>();

            var trend    = 50d;
            var random   = new Random();
            var timeStep = DateTime.Now;

            for (var i = 0; i < 500; i++)
            {
                timeStep = timeStep.AddHours(1);
                Values.Add(new DateTimePoint(timeStep.AddDays(i * 10), trend));

                if (random.NextDouble() > 0.4)
                {
                    trend += random.NextDouble() * 10;
                }
                else
                {
                    trend -= random.NextDouble() * 10;
                }
            }

            Formatter = x => new DateTime((long)x).ToString("yyyy");
            From      = Values.Min(x => x.DateTime).Ticks;
            To        = DateTime.Now.AddHours(90000).Ticks;
        }
Пример #2
0
        private void BuildHistogram()
        {
            var max     = Math.Ceiling(ChartValues.Max(p => p.TotDouble));
            var min     = Math.Floor(ChartValues.Min(p => p.TotDouble));
            var binSize = max / 100;

            var histValues = new Dictionary <string, int>();

            for (var i = min; i < max; i += binSize)
            {
                histValues.Add(i + " - " + (i + binSize), ChartValues.Count(v => v.TotDouble > i && v.TotDouble <= i + binSize));
            }

            sizeChart.Series.Clear();
            sizeChart.AxisY.Clear();
            sizeChart.Series = new SeriesCollection
            {
                new RowSeries
                {
                    Values = new ChartValues <int>(histValues.Values)
                }
            };
            sizeChart.AxisY.Add(new Axis
            {
                Labels = histValues.Keys.ToList()
            });
        }
Пример #3
0
        public GoldGraph()
        {
            InitializeComponent();

            Timer.Interval = TimeSpan.FromMinutes(2);
            Timer.Tick    += TimerTick;

            Values = new ChartValues <double> {
                0, 0.5, 2, 0.8, 4, 3.6, 1, -2, 2, 1.4, -2.3, -4, -6, -7.5, -10.8
            };

            GoldDifference.Labels = new[] { $"{Values.Min()}", "0", $"{Values.Max()}" };

            Minutes.Labels = new[] { "0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24", "26", "28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50" };

            DataContext = this;

            //Timer.Start();
            //TimerTick(null, null);
        }