I'm trying to export a chart to PNG. It is embedded in an ASP.Net control. When the chart renders, the FC_Rendered event fires, but FusionCharts(DOMId) returns nothing and, therefore, I cannot export it. If I use document.getElementById to get the control, I get the control, but it is not recognized as a FusionChart so calling hasRendered() and exportChart({ exportFormat: 'PNG' }) both fail.
If I put the chart directly in the page, it all works ok.
The chart object is:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="700"
height="350"
name="ctl00_ContentPlaceHolder1__kpiVis_myBarChart2"
id="ctl00_ContentPlaceHolder1__myBarChart"
style="width:700; height:350" >
<param name="allowScriptAccess" value="always" />
<param name="movie" value="../flash/charts/Column2D.swf"/>
<param name="FlashVars" value="&chartWidth=700&chartHeight=350&debugMode=0®isterWithJS=1&DOMId=ctl00_ContentPlaceHolder1__myBarChart& dataXML=<chart caption='' useRoundEdges='1' labelDisplay='Rotate' slantLabels='1' yAxisName='' showValues='0' decimals='0' formatNumberScale='0' debugMode='1' exportEnabled='1' exportAction='save' exportHandler='../charts/FCExporter.aspx' exportShowMenuItem='1' exportFormats='PNG=Export as PNG' exportFileName='testchartsave' exportCallback='FC_ExportComplete' >
... (chart data removed) ...</chart>&scaleMode=noScale〈=EN" />
<param name="quality" value="high" />
</object>
The chart is wrapped in a <div> and the <div> control is added to the Controls collection of a custom control.
On the page side, I have:
<script type="text/javascript" src="../js/FusionCharts.js"></script>
<script type="text/javascript" src="../js/FusionChartsExportComponent.js"></script>
<script type="text/javascript">
function FC_Rendered(DOMId) {
if (FusionCharts(DOMId).exportChart) {
FusionCharts(DOMId).exportChart({ "exportFormat": 'PNG' });
}
</script>
I've also tried using:
var chart = document.getElementById(controlName);
if (chart.hasRendered()) {
chart.exportChart({ exportFormat: 'PNG' });
}
Any suggestion on how I can get this working?
Thanks in advance.