Ste*_*bbi 10 c# zedgraph graph
是否可以将数据绘制到ZedGraph图形并将其保存为文件而不显示/生成用户可见的图形?我正在寻找处理大量数据集并生成图表并将其保存到文件中以便在应用程序之外查看.
如果无法做到这一点,是否可以在隐藏/最小化的表单上显示图表,保存图表,关闭窗口,并重复每个图表?
有可能的.
您像往常一样创建和操作ZedGraph控件,但只是不要将它添加到Form.Controls列表中,例如,在InitializeComponent()方法中,注释掉如下所示的内容
this.Controls.Add(this.zedGraphControl);
Run Code Online (Sandbox Code Playgroud)
有几种方法可以保存图表
SaveAs()图形控件.如果您不想使用该对话框,可以GetImage()在MasterPane上使用它来写出图像,然后保存:
.zedGraphControl.MasterPane.GetImage()保存( "TEST.BMP");
这是一个代码片段,用于创建和保存位图,而无需任何WinForms基础结构:
var zedGraph = new ZedGraphControl();
// configure ZedGraphControl here
using (var g = zedGraph.CreateGraphics())
{
zedGraph.MasterPane.ReSize(g, new RectangleF(0, 0, widthPx, heightPx));
}
zedGraph.MasterPane.GetImage().Save(Path.Combine(destinationDir, "test.bmp"));
Run Code Online (Sandbox Code Playgroud)
这甚至可以在没有任何桌面的情况下作为服务运行.唯一的缺点是你需要参考System.Windows.Forms和System.Drawing使用它.