public DataMainViewModel() { HorizontalAxis = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IsAxisVisible = true, IsPanEnabled = false, IsZoomEnabled = false, TextColor = OxyColor.Parse("#FFF6F6F6"), Position = AxisPosition.Bottom }; VerticalAxis = new LinearAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Left }; Model.Axes.Add(HorizontalAxis); Model.Axes.Add(VerticalAxis); }
public TimeMainViewModel() { HorizontalAxis = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, StringFormat = "hh:mm:ss", MajorStep = 1, MinorStep = 0.1, TextColor = OxyColors.Black, Position = AxisPosition.Bottom }; VerticalAxis = new LinearAxis { Position = AxisPosition.Left, IsAxisVisible = false }; Model.Axes.Add(HorizontalAxis); Model.Axes.Add(VerticalAxis); }
public void InitPlot(string xAxis = "Time", string yAxis = "Viewers", string format = "HH:mm", bool relative = true) { if (PlotDataPoints == null) { PlotDataPoints = new List <KeyValuePair <string, KeyValuePair <double, double> > >(); } viewerChart = new PlotModel(); viewerChart.TextColor = OxyColor.FromRgb(175, 175, 175); viewerChart.PlotAreaBorderThickness = new OxyThickness(0); var valueAxisY = new OxyPlot.Axes.TimeSpanAxis { Position = OxyPlot.Axes.AxisPosition.Left, TicklineColor = OxyColor.FromRgb(125, 125, 155), Title = yAxis, FontSize = 26, TitleFontSize = 26, AxislineThickness = 3, MinorGridlineThickness = 5, MajorGridlineThickness = 5, MajorGridlineStyle = LineStyle.Solid, FontWeight = 700, TitleFontWeight = 700, AxislineStyle = LineStyle.Solid, AxislineColor = OxyColor.FromRgb(125, 125, 155) }; if (relative) { valueAxisY.Minimum = 0; } var valueAxisX = new OxyPlot.Axes.DateTimeAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, TicklineColor = OxyColor.FromRgb(125, 125, 155), Title = xAxis, FontSize = 26, TitleFontSize = 26, AxislineThickness = 3, MinorGridlineThickness = 5, MajorGridlineThickness = 5, MajorGridlineStyle = LineStyle.Solid, FontWeight = 700, TitleFontWeight = 700, AxislineStyle = LineStyle.Solid, AxislineColor = OxyColor.FromRgb(125, 125, 155), StringFormat = format }; viewerChart.Axes.Add(valueAxisY); viewerChart.Axes.Add(valueAxisX); viewerChart.LegendFontSize = 24; viewerChart.LegendPosition = LegendPosition.BottomCenter; viewerChart.LegendBorder = OxyColor.FromRgb(125, 125, 155); viewerChart.LegendBackground = OxyColor.FromArgb(200, 46, 49, 54); viewerChart.LegendTextColor = OxyColor.FromRgb(175, 175, 175); areaSeries = new List <OxyPlot.Series.AreaSeries>(); /*foreach (var plotPoint in PlotPoints) * { * AddValue(plotPoint.Key, plotPoint.Value, false); * }*/ if (PlotDataPoints.Count > 0) { PlotDataPoints = PlotDataPoints.Skip(Math.Max(0, PlotDataPoints.Count - 2000)).ToList(); StartTime = DateTimeAxis.ToDateTime(PlotDataPoints.First().Value.Key); foreach (var dataPoint in PlotDataPoints) { if (!MultipleLines) { AddValue(dataPoint.Key, dataPoint.Value.Value, DateTimeAxis.ToDateTime(dataPoint.Value.Key), false, relative); } else { AddValueSeperate(dataPoint.Key, dataPoint.Value.Value, DateTimeAxis.ToDateTime(dataPoint.Value.Key), false, relative); } } } }