private void Plotinit() { EnergyPlot.ItemsSource = EnergyPoints = new List <DataPoint>(); MagnetizationPlot.ItemsSource = MagnetizationPoints = new List <DataPoint>(); EnergyPlot.Color = Colors.Red; MagnetizationPlot.Color = Colors.DeepSkyBlue; line = new LineAnnotation() { Type = LineAnnotationType.Vertical, X = -10, StrokeThickness = 10, LineStyle = LineStyle.Solid, Color = lineColors[0] }; var mcol = MagnetizationPlot.Color.SetTransparency(120); mlineM = new LineAnnotation() { Intercept = -1, StrokeThickness = 1, Color = mcol }; mlineP = new LineAnnotation() { Intercept = 1, StrokeThickness = 1, Color = mcol }; var ecol = EnergyPlot.Color.SetTransparency(120); Plot.Annotations.Add(mlineP); Plot.Annotations.Add(mlineM); Plot.Annotations.Add(line); Plot.IsLegendVisible = true; EnergyPlot.TrackerFormatString = MagnetizationPlot.TrackerFormatString = "{0}: {4:0.00}"; //setup tick/background etc color (matching the dark theme) SwitchTheme(true); for (int i = 0; i < _plotDataMax; i++) { EnergyPoints.Add(new DataPoint(i, 0)); MagnetizationPoints.Add(new DataPoint(i, 0)); } }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel" /> class. /// </summary> public SpeedGraphModel() { // Create the plot model var tmp = new PlotModel { PlotMargins = new OxyThickness(0), //PlotAreaBorderColor = OxyColor.FromRgb(141, 141, 141), //PlotAreaBorderThickness = new OxyThickness(1), Padding = new OxyThickness(0, 0, 1, 1), IsLegendVisible = false }; speedLine = new OxyPlot.Wpf.LineAnnotation() { LineStyle = LineStyle.Solid, Color = Colors.White, TextColor = Colors.White, Y = -10, Type = LineAnnotationType.Horizontal, Text = "", TextVerticalAlignment = System.Windows.VerticalAlignment.Bottom, TextMargin = 5 }; xAxis = new LinearAxis() { TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Bottom, IsPanEnabled = false, IsZoomEnabled = false, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1, MajorStep = 10, MajorGridlineColor = OxyColor.FromRgb(205, 239, 211), Minimum = 1, Maximum = 100 }; yAxis = new LinearAxis() { TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Left, IsPanEnabled = false, IsZoomEnabled = false, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1, MajorGridlineColor = OxyColor.FromRgb(205, 239, 211), Minimum = 0, Maximum = 100, MajorStep = 20 }; progressOverlay = new RectangleAnnotation() { MaximumX = -1, Fill = OxyColor.FromArgb(96, 61, 229, 0) }; // Create two line series (markers are hidden by default) speedSeries = new AreaSeries { MarkerType = MarkerType.None, Fill = OxyColor.FromRgb(9, 175, 36) }; // Add the series to the plot model tmp.Series.Add(speedSeries); tmp.Axes.Add(xAxis); tmp.Axes.Add(yAxis); tmp.Annotations.Add(progressOverlay); tmp.Annotations.Add(speedLine.InternalAnnotation); // Axes are created automatically if they are not defined // Set the Model property, the INotifyPropertyChanged event will make the WPF Plot control update its content Model = tmp; }