Exemple #1
0
        public void DrawArea(
            string title,
            IEnumerable x1,
            IEnumerable y1,
            IEnumerable x2,
            IEnumerable y2,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour,
            bool showOnLegend)
        {
            AreaSeries series = new AreaSeries();

            series.Color = ConverterExtensions.ToOxyColor(colour);
            series.Fill  = ConverterExtensions.ToOxyColor(colour);
            List <DataPoint> points  = this.PopulateDataPointSeries(x1, y1, xAxisType, yAxisType);
            List <DataPoint> points2 = this.PopulateDataPointSeries(x2, y2, xAxisType, yAxisType);

            if (points != null && points2 != null)
            {
                foreach (DataPoint point in points)
                {
                    series.Points.Add(point);
                }

                foreach (DataPoint point in points2)
                {
                    series.Points2.Add(point);
                }
            }
            series.CanTrackerInterpolatePoints = false;

            this.plot1.Model.Series.Add(series);
        }
Exemple #2
0
        public void DrawLineAndMarkers(
            string title,
            IEnumerable x,
            IEnumerable y,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour,
            Models.Graph.Series.LineType lineType,
            Models.Graph.Series.MarkerType markerType,
            bool showOnLegend)
        {
            if (x != null && y != null)
            {
                Utility.LineSeriesWithTracker series = new Utility.LineSeriesWithTracker();
                series.OnHoverOverPoint += OnHoverOverPoint;
                if (showOnLegend)
                {
                    series.Title = title;
                }
                series.Color       = ConverterExtensions.ToOxyColor(colour);
                series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType);
                series.XAxisKey    = xAxisType.ToString();
                series.YAxisKey    = yAxisType.ToString();
                series.CanTrackerInterpolatePoints = false;

                bool   filled        = false;
                string oxyMarkerName = markerType.ToString();
                if (oxyMarkerName.StartsWith("Filled"))
                {
                    oxyMarkerName = oxyMarkerName.Remove(0, 6);
                    filled        = true;
                }

                // Line type.
                LineStyle oxyLineType;
                if (Enum.TryParse <LineStyle>(lineType.ToString(), out oxyLineType))
                {
                    series.LineStyle = oxyLineType;
                }

                // Marker type.
                MarkerType type;
                if (Enum.TryParse <MarkerType>(oxyMarkerName, out type))
                {
                    series.MarkerType = type;
                }

                series.MarkerSize   = 7.0;
                series.MarkerStroke = ConverterExtensions.ToOxyColor(colour);
                if (filled)
                {
                    series.MarkerFill   = ConverterExtensions.ToOxyColor(colour);
                    series.MarkerStroke = OxyColors.White;
                }

                this.plot1.Model.Series.Add(series);
            }
        }
Exemple #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    = ConverterExtensions.ToOxyColor(colour);
            annotation.Text        += "\r\n\r\n";
            this.plot1.Model.Annotations.Add(annotation);
        }
Exemple #4
0
        public void DrawText(
            string text,
            double x,
            double y,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour)
        {
            TextAnnotation annotation = new TextAnnotation();

            annotation.Text = text;
            annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left;
            annotation.TextVerticalAlignment   = VerticalAlignment.Top;
            annotation.Stroke       = OxyColors.White;
            annotation.TextPosition = new DataPoint(x, y);
            //annotation.XAxis = this.GetAxis(xAxisType);
            //annotation.YAxis = this.GetAxis(yAxisType);
            annotation.TextColor = ConverterExtensions.ToOxyColor(colour);
            annotation.FontSize  = FontSize - 1;
            this.plot1.Model.Annotations.Add(annotation);
        }
Exemple #5
0
        public void DrawBar(
            string title,
            IEnumerable x,
            IEnumerable y,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour,
            bool showOnLegend)
        {
            ColumnXYSeries series = new ColumnXYSeries();

            if (showOnLegend)
            {
                series.Title = title;
            }
            series.FillColor   = ConverterExtensions.ToOxyColor(colour);
            series.StrokeColor = ConverterExtensions.ToOxyColor(colour);
            series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType);
            series.XAxisKey    = xAxisType.ToString();
            series.YAxisKey    = yAxisType.ToString();
            this.plot1.Model.Series.Add(series);
        }
Exemple #6
0
        public void DrawLine(
            object x1,
            object y1,
            object x2,
            object y2,
            Models.Graph.LineType type,
            Models.Graph.LineThicknessType thickness,
            Color colour)
        {
            OxyPlot.Annotations.LineAnnotation annotation = new OxyPlot.Annotations.LineAnnotation();

            double x1Position = 0.0;

            if (x1 is DateTime)
            {
                x1Position = DateTimeAxis.ToDouble(x1);
            }
            else
            {
                x1Position = Convert.ToDouble(x1);
            }
            double y1Position = 0.0;

            if ((double)y1 == double.MinValue)
            {
                y1Position = AxisMinimum(Models.Graph.Axis.AxisType.Left);
            }
            else if ((double)y1 == double.MaxValue)
            {
                y1Position = AxisMaximum(Models.Graph.Axis.AxisType.Left);
            }
            else
            {
                y1Position = (double)y1;
            }
            double x2Position = 0.0;

            if (x2 is DateTime)
            {
                x2Position = DateTimeAxis.ToDouble(x2);
            }
            else
            {
                x2Position = Convert.ToDouble(x2);
            }
            double y2Position = 0.0;

            if ((double)y2 == double.MinValue)
            {
                y2Position = AxisMinimum(Models.Graph.Axis.AxisType.Left);
            }
            else if ((double)y2 == double.MaxValue)
            {
                y2Position = AxisMaximum(Models.Graph.Axis.AxisType.Left);
            }
            else
            {
                y2Position = (double)y2;
            }

            annotation.X        = x1Position;
            annotation.Y        = y1Position;
            annotation.MinimumX = x1Position;
            annotation.MinimumY = y1Position;
            annotation.MaximumX = x2Position;
            annotation.MaximumY = y2Position;
            annotation.Type     = LineAnnotationType.Vertical;
            annotation.Color    = ConverterExtensions.ToOxyColor(colour);

            // Line type.
            //LineStyle oxyLineType;
            //if (Enum.TryParse<LineStyle>(type.ToString(), out oxyLineType))
            //    annotation.LineStyle = oxyLineType;

            // Line thickness
            if (thickness == LineThicknessType.Thin)
            {
                annotation.StrokeThickness = 0.5;
            }
            this.plot1.Model.Annotations.Add(annotation);
        }