Jump to content


Export Issue When Initiating Export Via Javascript


  • Please log in to reply
3 replies to this topic

#1 shereen

shereen

    Junior Member

  • Members
  • PipPip
  • 11 posts

Posted 28 December 2010 - 07:28 PM

I am trying to export a fusion chart created using 'Embedding Charts Using / Tags'.

Export works just perfect with the right click (on the chart) and chose a pdf to export. But I am not able to make this work via javascript. I have a button outside the chart which upon clicking calls the function below

function myexport()
{
var cObject = getChartFromId('Column3D');
if( cObject.hasRendered() ) cObject.exportChart({exportFormat: 'PDF'});
}
the cObject above returned is null and this fails on the next line

here is the full prototype

<html> <head> <title>My Chart</title> <script type="text/javascript" src="fusionCharts.debug.js"></script>
<script type="text/javascript" src="fusionChartsExportComponent.js"></script>
<script type="text/javascript">
function ExportMyChart()
{
var cObject = getChartFromId('Column3D');
if( cObject.hasRendered() ) cObject.exportChart({exportFormat: 'PDF'});
}
</script>
</head>
<body>
<object width="400" height="400" id="Column3D" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.ma...ersion=8,0,0,0" >
<param name="testname" value="Column3D.swf" />
<param name="FlashVars" value="&dataURL=testData.xml&chartWidth=400&chartHeight=300&DOMId=myChart1&registerWithJS=1&debugMode=0">
<param name="quality" value="high" />

<embed src="Column3D.swf" flashVars="&dataURL=testData.xml&chartWidth=400&chartHeight=300&DOMId=myChart1&registerWithJS=1&debugMode=0"
width="400" height="300" name="Column3D" quality="high" type="application/x-shockwave-flash"
pluginspage="http://www.macromedi...getflashplayer" />

</object>

<!-- We also create a DIV to contain the FusionCharts client-side exporter component -->
<div id="holderDiv" align="center">FusionCharts Export Handler Component</div>
<script type="text/javascript">
var myExportComponent = new FusionChartsExportObject("testExporter1", "FCExporter.swf");
//Render the exporter SWF in our DIV fcexpDiv
myExportComponent.Render("holderDiv"); </script>

<input type="button" value="Export My Chart" onclick="ExportMyChart()" />

Edited by shereen, 28 December 2010 - 07:33 PM.


#2 Guest_Angie_*

Guest_Angie_*
  • Guests

Posted 29 December 2010 - 05:57 AM

Hi,

Welcome to FusionCharts Forum!Posted Image

Please find the modified code below:


<html>
<head>
<title>My Chart</title>
<script type="text/javascript" src="../../FusionCharts/FusionCharts.js"></script>
<script type="text/javascript" src="../../FusionCharts/FusionChartsExportComponent.js"></script>
<script type="text/javascript">
function ExportMyChart()
{

var cObject = document.getElementById('Column3D');

if( cObject.hasRendered && cObject.hasRendered())
cObject.exportChart({exportFormat: 'PDF'});
}
</script>
</head>
<body>

<object lang="EN" width="400" height="500" type="application/x-shockwave-flash" data="../../FusionCharts/Column3D.swf" id="Column3D" ><param name="scaleMode" value="noScale"><param name="scale" value="noScale"><param name="wMode" value="opaque"><param name="allowScriptAccess" value="always"><param name="quality" value="best"><param name="flashvars" value="
&DOMId=Column3D&registerWithJS=1&chartWidth=400&chartHeight=500&dataURL=ExportClient.xmL&debugMode=0"></object>

<!-- We also create a DIV to contain the FusionCharts client-side exporter component -->
<div id="holderDiv" align="center">FusionCharts Export Handler Component</div>
<script type="text/javascript">
var myExportComponent = new FusionChartsExportObject("fcExporter1", "../../FusionCharts/FCExporter.swf");
//Render the exporter SWF in our DIV fcexpDiv
myExportComponent.Render("holderDiv");

</script>

<input type="button" value="Export My Chart" onClick="ExportMyChart()" />


Hope this helps.Posted Image

#3 shereen

shereen

    Junior Member

  • Members
  • PipPip
  • 11 posts

Posted 30 December 2010 - 01:19 AM

Thank you so much for your reply !

That worked like a charm, though I had to remove the embed tag from our chart implementations. Still testing it, but looks good for now.

Thanks again!

#4 Sanjukta

Sanjukta

    Supreme Being

  • L1 Moderators
  • 2112 posts

Posted 30 December 2010 - 07:37 AM

Hi,

You are always welcome! :)

Glad that your issue is resolved.

Happy FusionCharting! :)
Help us improve our documentation with your precious feedback at:
http://documentation...sioncharts.com/

Thanks,
Sanjukta

Follow us @Twitter!