FusionCharts API-method: exportChart
Created using FusionCharts Suite XT - www.fusioncharts.com
HTML
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<div>
<select id="format" class="mb-20">
<option value="png">png</option>
<option value="jpg">jpg</option>
<option value="pdf">pdf</option>
</select>
<button id="export">Export Chart</button>
</div>
<div id="chart-container">FusionCharts will render here</div>
JavaScript
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Monthly revenue",
"subCaption": "Last Year",
"xAxisName": "Month",
"yAxisName": "Revenues",
//Making the chart export enabled in various formats
"exportEnabled": "1",
"exportFileName": "DemoExport",
"numberPrefix": "$",
"theme": "fint"
},
"data": [{
"label": "Jan",
"value": "420000"
}, {
"label": "Feb",
"value": "810000"
}, {
"label": "Mar",
"value": "720000"
}, {
"label": "Apr",
"value": "550000"
}, {
"label": "May",
"value": "910000"
}, {
"label": "Jun",
"value": "510000"
}, {
"label": "Jul",
"value": "680000"
}, {
"label": "Aug",
"value": "620000"
}, {
"label": "Sep",
"value": "610000"
}, {
"label": "Oct",
"value": "490000"
}, {
"label": "Nov",
"value": "900000"
}, {
"label": "Dec",
"value": "730000"
}]
}
});
revenueChart.render();
function myJS() {
revenueChart.setChartAttribute({
"animation": "0",
"caption": "Custom Caption"
});
setTimeout(function() {
export_chart();
}, 1000);
}
function export_chart() {
var format = document.getElementById("format").value;
revenueChart.exportChart({
"exportFormat": format
});
}
document.getElementById("export").addEventListener("click", myJS);
});