To export a KoolPHP chart, you do:
<script type="text/javascript">
var chart = KoolChartJS.getChart('chart'); // 'chart' is in PHP code: $chart = new KoolChart('chart');
chart.exportToImage(imageType); // currently exporting supports 'jpeg', 'png' and 'webp'
</script>
<?php
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
require $KoolControlsFolder."/KoolChart/koolchart.php";
$chart = new KoolChart("chart");
$chart->scriptFolder=$KoolControlsFolder."/KoolChart";
$chart->Title->Text = "Sales report for 2012";
$chart->Width = 820;
$chart->Height = 500;
$chart->BackgroundColor = "#ffffee";
$chart->PlotArea->XAxis->Title = "Quarters";
$chart->PlotArea->XAxis->Set(array("Q1","Q2","Q3","Q4"));
$chart->PlotArea->YAxis->Title = "Sales ( .millions)";
$chart->PlotArea->YAxis->LabelsAppearance->DataFormatString = "$ {0}";
$series = new ColumnSeries();
$series->Name = "TVs";
$series->TooltipsAppearance->DataFormatString = "$ {0} millions";
$series->ArrayData(array(20,30,40,70));
$chart->PlotArea->AddSeries($series);
$series = new ColumnSeries();
$series->Name = "Computers";
$series->TooltipsAppearance->DataFormatString = "$ {0} millions";
$series->ArrayData(array(34,55,10,40));
$chart->PlotArea->AddSeries($series);
$series = new ColumnSeries();
$series->Name = "Tablets & e-readers";
$series->TooltipsAppearance->DataFormatString = "$ {0} millions";
$series->ArrayData(array(56,23,56,80));
$chart->PlotArea->AddSeries($series);
?>
<script type="text/javascript">
function exportChart(btn) {
var imgType = btn.value;
var chart = KoolChartJS.getChart('chart');
chart.exportToImage(imgType);
}
</script>
<div style="margin-bottom:10px;padding:10px;width:800px;background:#DFF3FF;border:solid 1px #C6E1F2;">
<button value="jpeg" onclick="exportChart(this)">Export to JPEG</button>
<button value="png" onclick="exportChart(this)">Export to PNG</button>
<button value="webp" onclick="exportChart(this)">Export to WEBP</button>
</div>
<form id="form1" method="post">
<?php echo $chart->Render();?>
<div><i>* <u>Note</u>:</i>Generate your own chart with <a style="color:#B8305E;" target="_blank" href="http://codegen.koolphp.net/chart/">Code Generator</a></div>
</form>