【发布时间】:2015-11-30 10:29:16
【问题描述】:
我正在创建一个没有用户界面的 C# 库,并且作为单元测试库的一部分,我想从单元测试中生成的数据中保存这些图形图像。 在我将结果写入 excel 文件并手动生成图表的那一刻,我希望自动保存图像。
【问题讨论】:
标签: c# graph plot scientific-computing oxyplot
我正在创建一个没有用户界面的 C# 库,并且作为单元测试库的一部分,我想从单元测试中生成的数据中保存这些图形图像。 在我将结果写入 excel 文件并手动生成图表的那一刻,我希望自动保存图像。
【问题讨论】:
标签: c# graph plot scientific-computing oxyplot
找到答案 - //注意必须添加一个系列和轴输入结果...
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);
}
【讨论】: