ChartDirector 5.1 (.NET Edition)

Creating Charts as Image Files


In many applications, it may be required to output ChartDirector charts as image files.

For example, if the charts are updated only slowly (eg. once per day), it may be more efficient to store a daily chart on disk, so that requests within the same day can get the chart from disk instead of re-generating the chart every time.

Other examples include applications that may create charts for embedding in other documents, or to be sent out by email.

The BaseChart.makeChart method can be used to output the chart directly an image file. For example:

[VB]
c.makeChart("c:/mychart.png")
[C#]
c.makeChart("c:/mychart.png");

For a web application, if the path to save the chart is relative to the web application directory, please remember to use "Server.MapPath" to translate it to a file system path.

In most systems, by default, the anonymous user cannot write to the web application directory or any of its subdirectory. You may need to modify the security settings. The recommended setting is to grant the "Everyone" group read, write and delete access to the "/tmp_chart" directory.

In most ASP.NET sample codes in this documentation, WebChartViewer controls are used to send chart images to browsers on the fly. WebChartViewer also supports chart images that are saved on disk. For example:

[VB]
c.makeChart(Server.MapPath("/charts/mychart.png"))
WebChartViewer1.ImageUrl="/charts/mychart.png"
[C#]
c.makeChart(Server.MapPath("/charts/mychart.png"));
WebChartViewer1.ImageUrl="/charts/mychart.png";