コード例 #1
0
        private PlotModel genericColumnPlotModel(StreamViewModel viewModel, string yAxisTtitle, double scale = 1)
        {
            var plotModel = new PlotModel();

            plotModel.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Title          = yAxisTtitle,
                MaximumPadding = 0.05
            });

            var series = new ColumnSeries()
            {
                Background = OxyColor.FromRgb(33, 150, 243), // blue
                FillColor  = OxyColor.FromRgb(255, 165, 0)   // orange
            };

            List <Entry> entries      = viewModel.GetEntries();
            CategoryAxis categoryAxis = new CategoryAxis()
            {
                Position       = AxisPosition.Bottom,
                StringFormat   = DATE_FORMAT,
                Title          = "Date",
                MinimumPadding = 0.05,
                MaximumPadding = 0.05
            };

            if (entries != null)
            {
                foreach (var entry in entries)
                {
                    series.Items.Add(new ColumnItem((int)(entry.value / scale)));
                    categoryAxis.Labels.Add(entry.date.ToString(DATE_FORMAT, Culture));
                }
            }

            plotModel.Axes.Add(categoryAxis);
            plotModel.Series.Add(series);

            return(plotModel);
        }