0

I am creating a C# library without a User Interface, and as part of a unit test library, I would like to save these images of the graphs from the data produced in the Unit Tests. At the moment I writing the results to an excel file and producing the graphs manually, I would like the images to be saved automatically.

Jamie Mair
  • 306
  • 3
  • 12

1 Answers1

0

Found the answer - //Note must add a series and axis to input results...

            PlotModel model = new PlotModel() { Title = "Sample"};
            model.IsLegendVisible = true;
            model.LegendPosition = LegendPosition.RightMiddle;
            model.LegendPlacement = LegendPlacement.Outside;
            model.PlotType = PlotType.XY;     
            using (var stream = File.Create(Environment.CurrentDirectory + "/image.png"))
            {
                OxyPlot.Wpf.PngExporter exporter = new OxyPlot.Wpf.PngExporter() { Width = 2200, Height = 1400, Resolution = 200 };
                exporter.Export(model, stream);
            }
Jamie Mair
  • 306
  • 3
  • 12