コード例 #1
1
        public static PlotModel TwoColorLineSeries()
        {
            var model = new PlotModel { Title = "TwoColorLineSeries", LegendSymbolLength = 24 };
            var s1 = new TwoColorLineSeries
                         {
                             Title = "Temperature at Eidesmoen, December 1986.",
                             Color = OxyColors.Red,
                             Color2 = OxyColors.LightBlue,
                             StrokeThickness = 3,
                             Limit = 0,
                             Smooth = true,
                             MarkerType = MarkerType.Circle,
                             MarkerSize = 4,
                             MarkerStroke = OxyColors.Black,
                             MarkerStrokeThickness = 1.5
                         };
            var temperatures = new[] { 5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0, -5 };

            for (int i = 0; i < temperatures.Length; i++)
            {
                s1.Points.Add(new DataPoint(i + 1, temperatures[i]));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, ExtraGridlines = new[] { 0.0 } });

            return model;
        }
コード例 #2
0
        public static PlotModel TwoColorLineSeries()
        {
            var model = new PlotModel("TwoColorLineSeries") { LegendSymbolLength = 24 };
            var s1 = new TwoColorLineSeries()
            {
                Title = "Temperature at Eidesmoen, December 1986.",
                Color = OxyColors.Red,
                Color2 = OxyColors.LightBlue,
                StrokeThickness = 3,
                Limit = 0,
                Smooth = true,
                MarkerType = MarkerType.Circle,
                MarkerSize = 4,
                MarkerStroke = OxyColors.Black,
                MarkerStrokeThickness = 1.5
            };
            var temperature = new[]
                {
                    5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0,
                    -5
                };

            for (int i = 0; i < temperature.Length; i++)
            {
                s1.Points.Add(new DataPoint(i + 1, temperature[i]));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis(AxisPosition.Left) { ExtraGridlines = new[] { 0.0 } });

            return model;
        }
コード例 #3
0
        private static TwoColorLineSeries CreateTwoColorLineSeries(string title, OxyColor color, OxyColor color2, IEnumerable <DateValue> dateValues)
        {
            var lineSeries = new TwoColorLineSeries {
                Title = title, Color = color, Color2 = color2
            };

            var dataPoints = dateValues.ToDataPoints();

            lineSeries.Points.AddRange(dataPoints);

            return(lineSeries);
        }
コード例 #4
0
        Task RenderTwoColorLine(Series plot)
        {
            var twoColorLineSeries = new TwoColorLineSeries
            {
                Color  = plot.Config.Color.ToOxyColor(),
                Color2 = plot.Config.Color2.ToOxyColor(),
                Limit  = plot.Config.Limit
            };

            foreach (var point in plot.Data)
            {
                twoColorLineSeries.Points.Add(new DataPoint(point.X, point.Y));
            }
            OxyplotModel.Series.Add(twoColorLineSeries);

            return(Task.CompletedTask);
        }
コード例 #5
0
 public static PlotModel TwoColorLineSeries()
 {
     var model = new PlotModel { Title = "TwoColorLineSeries" };
     var twoColorLineSeries = new TwoColorLineSeries
                                  {
                                      Color = OxyColors.Red,
                                      Color2 = OxyColors.Blue,
                                      LineStyle = LineStyle.Solid,
                                      LineStyle2 = LineStyle.Dot
                                  };
     twoColorLineSeries.Points.Add(new DataPoint(0, -6));
     twoColorLineSeries.Points.Add(new DataPoint(10, 4));
     twoColorLineSeries.Points.Add(new DataPoint(30, -2));
     twoColorLineSeries.Points.Add(new DataPoint(40, 8));
     model.Series.Add(twoColorLineSeries);
     return model;
 }
コード例 #6
0
        public static PlotModel TwoColorLineSeries()
        {
            var model = new PlotModel {
                Title = "TwoColorLineSeries"
            };
            var l = new Legend
            {
                LegendSymbolLength = 24
            };

            model.Legends.Add(l);

            var s1 = new TwoColorLineSeries
            {
                Title = "Temperature at Eidesmoen, December 1986.",
                TrackerFormatString = "December {2:0}: {4:0.0} °C",
                Color                  = OxyColors.Red,
                Color2                 = OxyColors.LightBlue,
                StrokeThickness        = 3,
                Limit                  = 0,
                InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline,
                MarkerType             = MarkerType.Circle,
                MarkerSize             = 4,
                MarkerStroke           = OxyColors.Black,
                MarkerStrokeThickness  = 1.5,
            };

            var temperatures = new[] { 5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0, -5 };

            for (int i = 0; i < temperatures.Length; i++)
            {
                s1.Points.Add(new DataPoint(i + 1, temperatures[i]));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Title = "Temperature", Unit = "°C", ExtraGridlines = new[] { 0.0 }
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Title = "Date"
            });

            return(model);
        }
コード例 #7
0
        public static PlotModel TwoColorLineSeries()
        {
            var model = new PlotModel {
                Title = "TwoColorLineSeries"
            };
            var twoColorLineSeries = new TwoColorLineSeries
            {
                Color      = OxyColors.Red,
                Color2     = OxyColors.Blue,
                LineStyle  = LineStyle.Solid,
                LineStyle2 = LineStyle.Dot
            };

            twoColorLineSeries.Points.Add(new DataPoint(0, -6));
            twoColorLineSeries.Points.Add(new DataPoint(10, 4));
            twoColorLineSeries.Points.Add(new DataPoint(30, -2));
            twoColorLineSeries.Points.Add(new DataPoint(40, 8));
            model.Series.Add(twoColorLineSeries);
            return(model);
        }
コード例 #8
0
        //bool showXAxis = true, showYAxix = true, isZoomable = true, isMovable = true;
        //IPlotType chart;
        //public bool ShowXAxis
        //{
        //    get => showXAxis;
        //    set
        //    {
        //        if (showXAxis == value) return;
        //        showXAxis = value;
        //    }
        //}
        //public bool ShowYAxix
        //{
        //    get => showYAxix;
        //    set
        //    {
        //        if (showYAxix == value) return;
        //        showYAxix = value;
        //    }
        //}
        //public bool IsZoomable
        //{
        //    get => isZoomable;
        //    set
        //    {
        //        if (isZoomable == value) return;
        //        isZoomable = value;
        //    }
        //}
        //public bool IsMovable
        //{
        //    get => isMovable;
        //    set
        //    {
        //        if (isMovable == value) return;
        //        isMovable = value;
        //    }
        //}

        public async Task Add(PlotModel plotModel)
        {
            this.oxyplotModel       = new OxyPlot.PlotModel();
            this.oxyplotModel.Title = plotModel.Title;
            foreach (var chart in plotModel.Series)
            {
                if (chart is TwoColorArea) //it should be placed before Area if clause
                {
                    var twoColorAreaSeries = new TwoColorAreaSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color2),
                        Limit  = ((TwoColorArea)chart).Limit
                    };
                    foreach (var item in ((TwoColorArea)chart).Data)
                    {
                        twoColorAreaSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorAreaSeries);
                }
                else if (chart is Area)
                {
                    var areaSeries = new AreaSeries();
                    foreach (var point in ((Area)chart).Data)
                    {
                        areaSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(areaSeries);
                }
                else if (chart is TwoColorLine)//it should be placed before line if clause
                {
                    var twoColorLineSeries = new TwoColorLineSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color2),
                        Limit  = ((TwoColorLine)chart).Limit
                    };
                    foreach (var item in ((TwoColorLine)chart).Data)
                    {
                        twoColorLineSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorLineSeries);
                }
                else if (chart is Line)
                {
                    var lineSeries = new LineSeries
                    {
                        MarkerType   = MarkerType.Circle,
                        MarkerSize   = 4,
                        MarkerStroke = OxyColors.White
                    };

                    foreach (var point in ((Line)chart).Data)
                    {
                        lineSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(lineSeries);
                }
                else if (chart is Pie)
                {
                    var pieSeries = new PieSeries();
                    foreach (var slice in ((Pie)chart).Data)
                    {
                        pieSeries.Slices.Add(slice);
                    }
                    this.oxyplotModel.Series.Add(pieSeries);
                }
                else if (chart is Bar)
                {
                    var barSeries = new BarSeries();
                    foreach (var item in ((Bar)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is ErrorColumn)
                {
                    var errorColumn = new ErrorColumnSeries();
                    foreach (ErrorColumnItem item in ((ErrorColumn)chart).Data)
                    {
                        errorColumn.Items.Add((OxyPlot.Series.ErrorColumnItem)item);
                    }
                    this.oxyplotModel.Series.Add(errorColumn);
                }
                else if (chart is Column)
                {
                    var barSeries = new ColumnSeries();
                    foreach (var item in ((Column)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is Box)
                {
                    var boxSeries = new BoxPlotSeries();
                    foreach (var item in ((Box)chart).Data)
                    {
                        boxSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(boxSeries);
                }
                else if (chart is Contour)
                {
                    var contourSeries = new ContourSeries
                    {
                        Data = ((Contour)chart).Data,
                        ColumnCoordinates = ((Contour)chart).ColumnCoordinates,
                        RowCoordinates    = ((Contour)chart).RowCoordinates
                    };
                    this.oxyplotModel.Series.Add(contourSeries);
                }
                else if (chart is RectangleBar)
                {
                    var rectangleBarSeries = new RectangleBarSeries
                    {
                        Title = ((RectangleBar)chart).Title
                    };
                    foreach (var item in ((RectangleBar)chart).Data)
                    {
                        rectangleBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(rectangleBarSeries);
                }
                else if (chart is CandleStick)
                {
                    var candleStickSeries = new CandleStickSeries();
                    foreach (var item in ((CandleStick)chart).Data)
                    {
                        candleStickSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(candleStickSeries);
                }
                else if (chart is HeatMap)
                {
                    var heatMapSeries = new HeatMapSeries()
                    {
                        Data         = ((HeatMap)chart).Data,
                        X0           = ((HeatMap)chart).X0,
                        X1           = ((HeatMap)chart).X1,
                        Y0           = ((HeatMap)chart).Y0,
                        Y1           = ((HeatMap)chart).Y1,
                        Interpolate  = ((HeatMap)chart).Interpolate,
                        RenderMethod = ((HeatMap)chart).RenderMethod
                    };
                    this.oxyplotModel.Series.Add(heatMapSeries);
                }
                else if (chart is HighLow)
                {
                    var highLowSeries = new HighLowSeries();
                    foreach (var item in ((HighLow)chart).Data)
                    {
                        highLowSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(highLowSeries);
                }
                else if (chart is IntervalBar)
                {
                    var intervalBarSeries = new IntervalBarSeries();
                    foreach (var item in ((IntervalBar)chart).Data)
                    {
                        intervalBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(intervalBarSeries);
                }
                else if (chart is Scatter)
                {
                    var scatterSeries = new ScatterSeries();
                    foreach (var item in ((Scatter)chart).Data)
                    {
                        scatterSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(scatterSeries);
                }
            }
            foreach (var axis in plotModel.Axes)
            {
                this.oxyplotModel.Axes.Add(axis);
            }
        }