生成并保存 ZedGraph 绘图而不在表单上显示
是否可以将数据绘制到 ZedGraph 图表上并将其保存为文件,而不显示/生成用户可见的图表?我希望处理大量数据集并生成图表并将其保存到文件中以便在应用程序外部查看。
如果无法做到这一点,是否可以在隐藏/最小化表单上显示图形,保存图形,关闭窗口,然后对每个图形重复?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是可能的。
您像往常一样创建和操作 ZedGraph 控件,但只是不要将其添加到
Form.Controls
列表中,例如,在InitializeComponent()
方法中,注释掉如下所示有多种方法可以保存图形
SaveAs()
。如果您不需要该对话框,可以在 MasterPane 上使用
GetImage()
写出图像,然后保存:zedGraphControl.MasterPane.GetImage().Save("test.bmp");
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 theInitializeComponent()
method, comment out something that looks like the belowThere are a couple of ways to save the graph
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");
下面是一个代码片段,用于创建和保存位图,无需任何 WinForms 基础设施:
这甚至应该能够在没有任何桌面的情况下作为服务运行。唯一的缺点是您需要引用 System.Windows.Forms 和 System.Drawing 才能使用它。
Here is a code snippet to create and save the Bitmaps without any WinForms infrastructure necessary:
This should even be able to run as service without any desktop. The only downside is that you need to reference
System.Windows.Forms
andSystem.Drawing
to use it.