生成并保存ZedGraph图而不显示在表单上 [英] Generating and Saving ZedGraph plots without showing on forms
问题描述
是否可以将数据绘制到ZedGraph图表上并将其保存为文件而不显示/生成用户可见的图形?我正在寻找处理大量数据集并生成图形并将其保存到文件以供在应用程序之外查看的文件。
如果无法完成,是否可以在隐藏/最小化窗体上显示图形,保存图形,关闭窗口,然后重复每个图形
您可以创建并操作像往常一样使用ZedGraph控件,但不要将它添加到 Form.Controls
列表中,例如,在 InitializeComponent()
方法,注释掉如下所示的内容:
this.Controls.Add(this.zedGraphControl);
有几种方法可以保存图表
- 如果您想要显示SaveAs对话框,请在图形控件上调用
SaveAs()
。 -
如果您不想使用对话框,可以在MasterPane上使用
GetImage()
写出图像,然后保存:
zedGraphControl.MasterPane.GetImage()。Save(test.bmp);
Is it possible to plot data on to a ZedGraph graph and save it as a file without showing / generating a graph that is visible to the user? I'm looking to process a lot of datasets and generate a graph and saving it to a file for viewing outside of the application.
If this can't be done, would it be possible show the graph on a hidden/minimized form, save the graph, close the window, and repeat for each graph?
It is possible.
You create and manipulate the ZedGraph control as usual, but just don't add it to the Form.Controls
list, for example, in the InitializeComponent()
method, comment out something that looks like the below
this.Controls.Add(this.zedGraphControl);
There are a couple of ways to save the graph
- If you want a SaveAs dialog to appear, call
SaveAs()
on the graph control. If you don't want the dialog, you can write out the image using
GetImage()
on the MasterPane, and then save that:zedGraphControl.MasterPane.GetImage().Save("test.bmp");
这篇关于生成并保存ZedGraph图而不显示在表单上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!