public ScaledPlotModel(double dpiXscale, double dpiYscale)
        {
            PlotMargins = new OxyThickness(PlotMargins.Left * dpiXscale,
                                           PlotMargins.Top * dpiYscale,
                                           PlotMargins.Right * dpiXscale,
                                           PlotMargins.Bottom * dpiYscale);

            Padding = new OxyThickness(Padding.Left * dpiXscale,
                                       Padding.Top * dpiYscale,
                                       Padding.Right * dpiXscale,
                                       Padding.Bottom * dpiYscale);

            TitlePadding *= dpiXscale;

            Legend legend = new();

            legend.LegendSymbolLength  *= dpiXscale;
            legend.LegendSymbolMargin  *= dpiXscale;
            legend.LegendPadding       *= dpiXscale;
            legend.LegendColumnSpacing *= dpiXscale;
            legend.LegendItemSpacing   *= dpiXscale;
            legend.LegendMargin        *= dpiXscale;

            Legends.Add(legend);
        }
Пример #2
0
    public BasePlotModel()
    {
        TitleFontWeight         = 200;
        DefaultFontSize         = Settings.Instance.FontSize;
        DefaultFont             = Settings.Instance.Font;
        PlotAreaBorderThickness = new OxyThickness(Settings.Instance.BorderThickness);
        Padding = new OxyThickness(Settings.Instance.Padding, Settings.Instance.Padding, Settings.Instance.Padding, Settings.Instance.Padding);

        XAxis = new LinearAxis
        {
            Title                  = "X",
            Unit                   = "Å",
            Position               = AxisPosition.Bottom,
            Key                    = "X",
            FontWeight             = Settings.Instance.FontWeight,
            FontSize               = Settings.Instance.FontSize,
            Font                   = Settings.Instance.Font,
            AxislineThickness      = Settings.Instance.AxisThickness,
            MinorGridlineThickness = Settings.Instance.AxisThickness / 2,
            MajorGridlineThickness = Settings.Instance.AxisThickness,
            MajorTickSize          = Settings.Instance.AxisThickness * 3.5,
            MinorTickSize          = Settings.Instance.AxisThickness * 2,
            TitleFormatString      = Settings.Instance.AxisFormat
        };
        Axes.Add(XAxis);

        if (!PlotAreaBorderThickness.Equals(new OxyThickness(0)))
        {
            return;
        }
        XAxis.AxislineStyle = LineStyle.Solid;
    }
Пример #3
0
        /// <summary>
        /// Gets the coordinates of the (rotated) background rectangle.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="size">The size.</param>
        /// <param name="padding">The padding.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="horizontalAlignment">The horizontal alignment.</param>
        /// <param name="verticalAlignment">The vertical alignment.</param>
        /// <returns>The background rectangle coordinates.</returns>
        private static IList <ScreenPoint> GetTextBounds(
            ScreenPoint position,
            OxySize size,
            OxyThickness padding,
            double rotation,
            HorizontalAlignment horizontalAlignment,
            VerticalAlignment verticalAlignment)
        {
            double left, right, top, bottom;

            switch (horizontalAlignment)
            {
            case HorizontalAlignment.Center:
                left  = -size.Width * 0.5;
                right = -left;
                break;

            case HorizontalAlignment.Right:
                left  = -size.Width;
                right = 0;
                break;

            default:
                left  = 0;
                right = size.Width;
                break;
            }

            switch (verticalAlignment)
            {
            case VerticalAlignment.Middle:
                top    = -size.Height * 0.5;
                bottom = -top;
                break;

            case VerticalAlignment.Bottom:
                top    = -size.Height;
                bottom = 0;
                break;

            default:
                top    = 0;
                bottom = size.Height;
                break;
            }

            double cost    = Math.Cos(rotation / 180 * Math.PI);
            double sint    = Math.Sin(rotation / 180 * Math.PI);
            var    u       = new ScreenVector(cost, sint);
            var    v       = new ScreenVector(-sint, cost);
            var    polygon = new ScreenPoint[4];

            polygon[0] = position + (u * (left - padding.Left)) + (v * (top - padding.Top));
            polygon[1] = position + (u * (right + padding.Right)) + (v * (top - padding.Top));
            polygon[2] = position + (u * (right + padding.Right)) + (v * (bottom + padding.Bottom));
            polygon[3] = position + (u * (left - padding.Left)) + (v * (bottom + padding.Bottom));
            return(polygon);
        }
Пример #4
0
        public Matrix_Model
        (
            int plot_index,
            string[] op_tit,
            List <ScatterSeries> list_matrix_series,
            List <ScatterSeries> list_work_series,
            OxyPlot.Wpf.PlotView matrix2D_work_plot,
            Work_Model work_model
        )
        {
            Title = op_tit[plot_index];
            index = plot_index;

            IsLegendVisible         = false;
            PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);
            PlotMargins             = new OxyThickness(0, 0, 0, 0);
            Padding = new OxyThickness(5);

            Background     = OxyColors.White;
            SelectionColor = OxyColors.Crimson;

            Axes.Add(new LinearAxis
            {
                Position  = AxisPosition.Bottom,
                TickStyle = OxyPlot.Axes.TickStyle.None,
                //MajorGridlineStyle = LineStyle.Dash,
                //MinorGridlineStyle = LineStyle.Dash,
                MaximumPadding = 0.1,
                MinimumPadding = 0.1,
                IsPanEnabled   = false,
                IsZoomEnabled  = false,
                FontSize       = 0.1,
                SelectionMode  = OxyPlot.SelectionMode.Multiple
            });
            Axes.Add(new LinearAxis
            {
                Position  = AxisPosition.Left,
                TickStyle = OxyPlot.Axes.TickStyle.None,
                //MajorGridlineStyle = LineStyle.Dash,
                //MinorGridlineStyle = LineStyle.Dash,
                MaximumPadding = 0.1,
                MinimumPadding = 0.1,
                IsPanEnabled   = false,
                IsZoomEnabled  = false,
                FontSize       = 0.1,
                SelectionMode  = OxyPlot.SelectionMode.Multiple
            });

            Load_Mouse_Events(list_matrix_series, list_work_series, work_model, matrix2D_work_plot);
        }
Пример #5
0
        public Work_Model
        (
            int plot_index,
            string[] op_tit,
            string[] x_tit,
            string[] y_tit,
            List <ScatterSeries> list_work_series,
            List <ScatterSeries> list_matrix_series,
            List <Matrix_Model> list_matrix_models
        )
        {
            Title = op_tit[plot_index];
            index = plot_index;
            PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);
            PlotMargins             = new OxyThickness(30, 0, 0, 30);
            IsLegendVisible         = false;
            SelectionColor          = OxyColors.Crimson;

            Axes.Add(new LinearAxis
            {
                Position           = AxisPosition.Bottom,
                TickStyle          = OxyPlot.Axes.TickStyle.None,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dash,
                MaximumPadding     = 0,
                MinimumPadding     = 0,
                Title         = x_tit[plot_index],
                SelectionMode = OxyPlot.SelectionMode.Multiple
            });
            Axes.Add(new LinearAxis
            {
                Position           = AxisPosition.Left,
                TickStyle          = OxyPlot.Axes.TickStyle.None,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dash,
                MaximumPadding     = 0,
                MinimumPadding     = 0,
                Title         = y_tit[plot_index],
                SelectionMode = OxyPlot.SelectionMode.Multiple
            });

            Load_Mouse_Events
            (
                list_work_series,
                list_matrix_series,
                list_matrix_models
            );
        }
        private PlotModel createPlotModel()
        {
            OxyThickness thickness = new OxyThickness(25, 70, 15, 40);
            var          plotModel = new PlotModel {
                Title = "OxyPlot Demo", PlotMargins = thickness
            };

            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });


            var series1 = new LineSeries
            {
                Title                 = "Назва графіку",
                StrokeThickness       = 3,
                LineStyle             = LineStyle.Automatic,
                MarkerType            = MarkerType.Circle,
                MarkerSize            = 5,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Automatic,
                MarkerStrokeThickness = 1.5,
            };

            for (double y = 0; y < 10; y += 0.2)
            {
                double x = b0XonY + b1XonY * y;
                series1.Points.Add(new DataPoint(x, y));
            }

            series1.Points.Add(new DataPoint(0.0, 6.0));
            series1.Points.Add(new DataPoint(1.4, 2.1));
            series1.Points.Add(new DataPoint(2.0, 4.2));
            series1.Points.Add(new DataPoint(3.3, 2.3));
            series1.Points.Add(new DataPoint(4.7, 7.4));
            series1.Points.Add(new DataPoint(6.0, 6.2));
            series1.Points.Add(new DataPoint(8.9, 8.9));

            plotModel.Series.Add(series1);
            return(plotModel);
        }
Пример #7
0
        public LoadTestChart(List <Heartbeat> heartbeats)
        {
            Background = OxyColors.Transparent;
            PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);
            Padding         = new OxyThickness(15, 30, 30, 20);
            LegendPosition  = LegendPosition.LeftTop;
            LegendPlacement = LegendPlacement.Inside;

            Series.Add(new LineSeries
            {
                ItemsSource = heartbeats,
                DataFieldX  = "TotalRuntime",
                DataFieldY  = "TotalErrors",
                Color       = OxyColors.Red,
                Title       = "Errors",
                Smooth      = false
            });

            Series.Add(new LineSeries
            {
                ItemsSource = heartbeats,
                DataFieldX  = "TotalRuntime",
                DataFieldY  = "TotalThreads",
                Color       = OxyColors.Green,
                Title       = "Threads",
                Smooth      = false
            });

            Series.Add(new LineSeries
            {
                ItemsSource = heartbeats,
                DataFieldX  = "TotalRuntime",
                DataFieldY  = "Throughput",
                Color       = OxyColors.DodgerBlue,
                Title       = "Throughput",
                Smooth      = false
            });
        }
        /// <summary>
        /// Gets the coordinates of the (rotated) background rectangle.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <param name="padding">
        /// The padding.
        /// </param>
        /// <param name="rotation">
        /// The rotation.
        /// </param>
        /// <param name="horizontalAlignment">
        /// The horizontal alignment.
        /// </param>
        /// <param name="verticalAlignment">
        /// The vertical alignment.
        /// </param>
        /// <returns>
        /// The background rectangle coordinates.
        /// </returns>
        private static IList<ScreenPoint> GetTextBounds(
            ScreenPoint position,
            OxySize size,
            OxyThickness padding,
            double rotation,
            HorizontalAlignment horizontalAlignment,
            VerticalAlignment verticalAlignment)
        {
            double left, right, top, bottom;
            switch (horizontalAlignment)
            {
                case HorizontalAlignment.Center:
                    left = -size.Width * 0.5;
                    right = -left;
                    break;
                case HorizontalAlignment.Right:
                    left = -size.Width;
                    right = 0;
                    break;
                default:
                    left = 0;
                    right = size.Width;
                    break;
            }

            switch (verticalAlignment)
            {
                case VerticalAlignment.Middle:
                    top = -size.Height * 0.5;
                    bottom = -top;
                    break;
                case VerticalAlignment.Bottom:
                    top = -size.Height;
                    bottom = 0;
                    break;
                default:
                    top = 0;
                    bottom = size.Height;
                    break;
            }

            double cost = Math.Cos(rotation / 180 * Math.PI);
            double sint = Math.Sin(rotation / 180 * Math.PI);
            var u = new ScreenVector(cost, sint);
            var v = new ScreenVector(-sint, cost);
            var polygon = new ScreenPoint[4];
            polygon[0] = position + (u * (left - padding.Left)) + (v * (top - padding.Top));
            polygon[1] = position + (u * (right + padding.Right)) + (v * (top - padding.Top));
            polygon[2] = position + (u * (right + padding.Right)) + (v * (bottom + padding.Bottom));
            polygon[3] = position + (u * (left - padding.Left)) + (v * (bottom + padding.Bottom));
            return polygon;
        }
 /// <summary>
 /// Converts an OxyThickness to a Thickness.
 /// </summary>
 /// <param name="c">The thickness.</param>
 /// <returns>A <see cref="Thickness" /> instance.</returns>
 public static Thickness ToThickness(this OxyThickness c)
 {
     return(new Thickness(c.Left, c.Top, c.Right, c.Bottom));
 }
Пример #10
0
        private PlotModel createPlotModel()
        {
            OxyThickness thickness = new OxyThickness(35, 70, 15, 40);
            var          plotModel = new PlotModel {
                Title = "OxyPlot Demo", PlotMargins = thickness
            };

            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });

            var series1 = new LineSeries
            {
                Title                 = "Dots",
                StrokeThickness       = 3,
                LineStyle             = LineStyle.None,
                MarkerType            = MarkerType.Circle,
                MarkerSize            = 5,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Black,
                MarkerStrokeThickness = 1.5,
            };

            for (int i = 0; i < numbersX.Length; i++)
            {
                series1.Points.Add(new DataPoint(numbersX[i], numbersY[i]));
            }

            var series2 = new LineSeries
            {
                Title                 = "Linear",
                StrokeThickness       = 3,
                Color                 = OxyColors.Red,
                LineStyle             = LineStyle.Automatic,
                MarkerType            = MarkerType.None,
                MarkerSize            = 5,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Automatic,
                MarkerStrokeThickness = 1.5,
            };

            for (double x = minX - 0.2; x < maxX; x += 0.002)
            {
                double y = b0YonX + b1YonX * x;
                series2.Points.Add(new DataPoint(x, y));
            }

            var series3 = new LineSeries
            {
                Title                 = "Exponential",
                StrokeThickness       = 3,
                Color                 = OxyColors.Green,
                LineStyle             = LineStyle.Automatic,
                MarkerType            = MarkerType.None,
                MarkerSize            = 5,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Automatic,
                MarkerStrokeThickness = 1.5,
            };

            for (double x = minX - 0.2; x < maxX; x += 0.002)
            {
                double y = Math.Pow(10, expB1YonX * x + expB0YonX);
                series3.Points.Add(new DataPoint(x, y));
            }

            var series4 = new LineSeries
            {
                Title                 = "Power",
                StrokeThickness       = 3,
                Color                 = OxyColors.Blue,
                LineStyle             = LineStyle.Automatic,
                MarkerType            = MarkerType.None,
                MarkerSize            = 5,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Automatic,
                MarkerStrokeThickness = 1.5,
            };

            for (double x = minX - 0.2; x < maxX; x += 0.002)
            {
                double b = Math.Pow(10, powerB0YonX);  //b = a^x
                double y = b * Math.Pow(x, powerB1YonX);
                //double y = powerB0YonX * Math.Pow(x, powerB1YonX);
                series4.Points.Add(new DataPoint(x, y));
            }

            if (linearPlotEnabled)
            {
                plotModel.Series.Add(series2);
            }
            if (expPlotEnabled)
            {
                plotModel.Series.Add(series3);
            }
            if (powerPlotEnabled)
            {
                plotModel.Series.Add(series4);
            }
            plotModel.Series.Add(series1);
            return(plotModel);
        }