Пример #1
0
        /// <summary>
        /// Refresh the graph.
        /// </summary>
        public void Refresh()
        {
            this.plot1.Model.DefaultFontSize         = FontSize;
            this.plot1.Model.PlotAreaBorderThickness = new OxyThickness(0.0);
            this.plot1.Model.LegendBorder            = OxyColors.Transparent;
            this.plot1.Model.LegendBackground        = OxyColors.White;

            if (this.LeftRightPadding != 0)
            {
                this.plot1.Model.Padding = new OxyThickness(10, 10, this.LeftRightPadding, 10);
            }

            foreach (OxyPlot.Axes.Axis axis in this.plot1.Model.Axes)
            {
                this.FormatAxisTickLabels(axis);
            }

            this.plot1.Model.LegendFontSize = FontSize;

            foreach (OxyPlot.Annotations.Annotation annotation in this.plot1.Model.Annotations)
            {
                if (annotation is OxyPlot.Annotations.TextAnnotation)
                {
                    OxyPlot.Annotations.TextAnnotation textAnnotation = annotation as OxyPlot.Annotations.TextAnnotation;
                    if (textAnnotation != null)
                    {
                        textAnnotation.FontSize = FontSize;
                    }
                }
            }

            this.plot1.Model.InvalidatePlot(true);
        }
Пример #2
0
        public async Task <PlotModel> AddLineSeriesToPlot(PlotModel model, List <DataPoint> dataPoints, string lineColor, string textAnnotation = "")
        {
            return(await Task.Run(() =>
            {
                var color = Color.FromName(lineColor);

                var xAvg = dataPoints.Average(x => x.X);
                var yAvg = dataPoints.Average(x => x.Y);

                model.Series.Add(new LineSeries {
                    ItemsSource = dataPoints, Color = OxyColor.FromRgb(color.R, color.G, color.B)
                });

                if (string.IsNullOrEmpty(textAnnotation))
                {
                    return model;
                }

                var annotation = new TextAnnotation
                {
                    Background = OxyColor.FromRgb(255, 255, 255),
                    Text = textAnnotation,
                    TextColor = OxyColor.FromRgb(0, 0, 0),
                    TextPosition = new DataPoint(xAvg, yAvg),
                    Tag = TextTag
                };
                model.Annotations.Add(annotation);
                return model;
            }));
        }
Пример #3
0
        public void DrawText(
            string text,
            object x,
            object y,
            bool leftAlign,
            double textRotation,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour)
        {
            OxyPlot.Annotations.TextAnnotation annotation = new OxyPlot.Annotations.TextAnnotation();
            annotation.Text = text;
            if (leftAlign)
            {
                annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left;
            }
            else
            {
                annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center;
            }
            annotation.TextVerticalAlignment = VerticalAlignment.Top;
            annotation.Stroke       = OxyColors.White;
            annotation.Font         = Font;
            annotation.TextRotation = textRotation;

            double xPosition = 0.0;

            if (x is DateTime)
            {
                xPosition = DateTimeAxis.ToDouble(x);
            }
            else
            {
                xPosition = Convert.ToDouble(x);
            }
            double yPosition = 0.0;

            if ((double)y == double.MinValue)
            {
                yPosition = AxisMinimum(yAxisType);
                annotation.TextVerticalAlignment = VerticalAlignment.Bottom;
            }
            else if ((double)y == double.MaxValue)
            {
                yPosition = AxisMaximum(yAxisType);
            }
            else
            {
                yPosition = (double)y;
            }
            annotation.TextPosition = new DataPoint(xPosition, yPosition);
            annotation.TextColor    = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B);
            annotation.Text        += "\r\n\r\n";
            this.plot1.Model.Annotations.Add(annotation);
        }
Пример #4
0
        public void DrawText(
            string text,
            object x,
            object y,
            bool leftAlign,
            double textRotation,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour)
        {
            OxyPlot.Annotations.TextAnnotation annotation = new OxyPlot.Annotations.TextAnnotation();
            annotation.Text = text;
            if (leftAlign)
                annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left;
            else
                annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center;
            annotation.TextVerticalAlignment = VerticalAlignment.Top;
            annotation.Stroke = OxyColors.White;
            annotation.Font = Font;
            annotation.TextRotation = textRotation;

            double xPosition = 0.0;
            if (x is DateTime)
                xPosition = DateTimeAxis.ToDouble(x);
            else
                xPosition = Convert.ToDouble(x);
            double yPosition = 0.0;
            if ((double)y == double.MinValue)
            {
                yPosition = AxisMinimum(yAxisType);
                annotation.TextVerticalAlignment = VerticalAlignment.Bottom;
            }
            else if ((double)y == double.MaxValue)
                yPosition = AxisMaximum(yAxisType);
            else
                yPosition = (double)y;
            annotation.TextPosition = new DataPoint(xPosition, yPosition);
            annotation.TextColor = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B);
            this.plot1.Model.Annotations.Add(annotation);
        }