The
WebChartViewer and
RazorChartViewer sends the chart image as <IMG> tags to the browser. In some case, the chart image is applied to other tags, such as <IFRAME>, <OBJECT> or <EMBED>, or to the CSS "background" property. For these cases, it is necessary to obtain the URL that can be used to load the chart image.
BaseChart.makeSession can be used to store chart images into session variables. A special utility script "getchart.aspx" can be used to load the chart images from session variables. The code is like:
[VB] | Dim url As String = "getchart.aspx?" & c.makeSession(Session, "chart1") |
[C#] | string url = "getchart.aspx?" + c.makeSession(Session, "chart1"); |
Note that in real code, depending on where is the "getchart.aspx", you may need to adjust the path to "getchart.aspx". Also note that for the above method to work, session variables must not be disabled.
ChartDirector has a special method
BaseChart.makeTmpFile that can store the charts as temporary files and automatically remove old temporary files. This is useful for ASP.NET systems with session variables disabled or with unreliable session variables. The code is like:
[VB] | Dim url As String = "/tmp_chart/" & c.makeTmpFile(Server.MapPath("/tmp_chart")) |
[C#] | string url = "/tmp_chart/" + c.makeTmpFile(Server.MapPath("/tmp_chart")); |
In the above code, the web application directory "/tmp_chart" is used to store the temporary files. Since
BaseChart.makeTmpFile expects a file system path, Server.MapPath is used to map the web application path to a file system path.
For the above to work, the "/tmp_chart" directory must exist and the web server must have write access to the directory. In many systems, the web server runs under a limited privilege account representing the anonymous user, and may not have write access to the web application directory or its subdirectories. You may need to grant the web server account read, write and delete access to the "/tmp_chart" directory. If you are not sure which account the web server is using, you may consider to grant these rights to the "Everyone" group for testing purpose.
© 2023 Advanced Software Engineering Limited. All rights reserved.