Oxyplot可以在单元测试库(C#)中使用吗
本文关键字:单元测试 Oxyplot | 更新日期: 2023-09-27 18:25:05
我正在创建一个没有用户界面的C#库,作为单元测试库的一部分,我想保存单元测试中生成的数据中的这些图的图像。在我将结果写入excel文件并手动生成图形的那一刻,我希望图像能自动保存。
找到答案-//注意必须向输入结果添加序列和轴。。。
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);
}