我可以获取Developer Express WebChartControl的图像输出吗?

时间:2020-03-05 18:48:26  来源:igfitidea点击:

我的网页上有一个WebChartControl。生成图表时,将生成图像并将其显示在页面上。

有没有一种方法可以在运行时获取并保存此图表作为图像输出?

解决方案

回答

当然。最终,图像来自某种URL。在网页上查看源代码,然后查看该URL的外观。通过一定程度的逆向工程,使用System.Web.UI.HtmlTextWriter(也许是HttpHandler等),我们应该能够得到想要的东西。

回答

使用ChartControl对象的ExportToImage方法。这是WinForm代码,但对于WebChartControl,应使用相同的概念:

Dim chart As ChartControl = ChartControl1.Clone()
    chart.Size = New Size(800, 600)
    chart.ExportToImage("file.png", System.Drawing.Imaging.ImageFormat.Png)

回答

从Developer Express图表控件(Web)导出图像的最佳解决方案是:

((IChartContainer)[Your web chart control]).Chart.ExportToImage([Your file name], ImageFormat.Png);