How To Enable Save As Image Option
Overview
AnyGantt Allows to save flash charts as PNG or JPG Images. This feature requires a small script to be placed on your server and chart xml should be configured to set your own page to be used.
By default AnyGantt uses a script that resides on http://www.anychart.com/
How it works?
When AnyGantt finishes rendering a chart it can create a PNG image and send it to server or application, PNG image data is sent in base64 encoding and server should decode it and output to response stream decoded.
For user it will look like that: user clicks on a chart with a right-mouse button and chooses "Save as Image" (than AnyGantt sends image to server and server sends image back to user AnyChart.) AntGantt launches browser default "Save As" dialog an user can choose where to store an image of chart.
To set your own Save Image Script Path set the following in chart XML File:
<settings>
<image_export url="http://localhost/saveasimage/AnyChartPNGSaver.php" />
</settings>
</anygantt>
We've created such scripts for PHP, J2EE, ASP (VBScript), VB.Net and C#, you can find them in export_image_scripts folder
File Name
You can set custom save as file name using file_name and use_title_as_file_name attributes, the last overrides file_name, if title is empty - file_name is used:
<settings>
<image_export url="http://localhost/saveasimage/AnyChartPNGSaver.php" file_name="weekly_report" use_title_as_file_name="true" />
</settings>
</anygantt>
Image Size
You can set the size of an exported image - this is not scaling, but actual chart resizing (as if you set width and height in JS), if these attributes are not set - image is exported exactly as chart is.
<settings>
<image_export url="http://localhost/saveasimage/AnyChartPNGSaver.php" width="1024" height="800" />
</settings>
</anygantt>
Gantt Fit Mode
<image_export> has special Gantt Related node: mode. If attribute is set to "FitContent" AnyGantt saves the image of the whole project, despite any zoom. "ActualZoom" lets you save exactly what you see, this value is useful when you want to save some part of the chart.
Getting Image: getPng function
getPng function of AnyChart returns base64 encoded strings with png image of a chart. Use it to get image and pass it to some script.
<script type="text/javascript" language="javascript">
//<![CDATA[
var chart = new AnyChart('./swf/AnyGantt.swf');
chart.width = 700;
chart.height = 300;
chart.setXMLFile('./anychart.xml');
chart.write();
function getPNGImage()
{
pngImage=chart.getPng();
}
//]]>
</script>
PHP Save As Script
Place AnyChartPNGSaver.php into the root folder of your web site and set in XML the following:
<settings>
<image_export url="http://localhost/AnyChartPNGSaver.php" />
</settings>
</anygantt>
ASP Save As Script
Place AnyChartPNGSaver.asp into the root folder of your web site and set in XML the following:
<settings>
<image_export url="http://localhost/AnyChartPNGSaver.asp" />
</settings>
</anygantt>
VB.NET Save As Script
Place AnyChartPNGSaver.aspx into the root folder of your web site and set in XML the following:
<settings>
<image_export url="http://localhost/AnyChartPNGSaver.aspx" />
</settings>
</anygantt>
C# Save As Script
Place AnyChartPNGSaver.aspx into the root folder of your web site and set in XML the following:
<settings>
<image_export url="http://localhost/AnyChartPNGSaver.aspx" />
</settings>
</anygantt>
J2EE Save As Script
Place AnyChartPNGSaver.war into the root folder of your web site and set in XML the following:
<settings>
<image_export url="http://localhost:8080/AnyChartPNGSaver/PNGSaver" />
</settings>
</anygantt>