These are chat archives for oxyplot/oxyplot

4th
Dec 2017
ShannonZ
@ShannonZ
Dec 04 2017 01:41
Cannot Convert ImageBrush to OxyColor @eoner
Anyone know how to insert an image in the PlotArea
eoner
@eoner
Dec 04 2017 20:59
you can set the plot's (PlotView) background with an ImageBrush
inside the PlotArea, an ImageAnnotation would work.
  var model=new OxyPlot.PlotModel();

            // image annotation
            var bmp = new BitmapImage(new Uri(@"path/to/some/image"));
            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(bmp));

            // image to byte[]
            byte[] data;
            using (var ms = new MemoryStream())
            {
                encoder.Save(ms);
                data = ms.ToArray();
            }

            var imgAnnotation = new ImageAnnotation();
            imgAnnotation.ImageSource = new OxyImage(data);
            imgAnnotation.Layer = AnnotationLayer.BelowAxes;
            model.Annotations.Add(imgAnnotation);

            // some data
            var series1 = new LineSeries { Title = "Series 1", MarkerType = MarkerType.Circle };
            series1.Points.Add(new DataPoint(0, 0));
            series1.Points.Add(new DataPoint(10, 18));
            series1.Points.Add(new DataPoint(20, 12));
            series1.Points.Add(new DataPoint(30, 8));
            series1.Points.Add(new DataPoint(40, 15));

             model.Series.Add(series1);

            plot.Model = model;