0

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 object 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.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=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.macromedia.com/go/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()" />


I would probably use an array to make the code less messy. Try something like this:

// UPDATE: change from String to int
int[] imageIds = new int[15] {
  R.id.card1, R.id.card2, R.id.card3,
  R.id.card4, R.id.card5, R.id.card6,
  R.id.card7, R.id.card8, R.id.card9,
  R.id.card10, R.id.card11, R.id.card12,
  R.id.card13, R.id.card14, R.id.card15
};

// load the source image only once
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.vraag);
Bitmap bScaled = Bitmap.createScaledBitmap(bMap, buttonSize, buttonSize, true);

// render them all
ImageButton[] imageButtons = new ImageButton[15];
for(int i = 0; i < imageButtons.size(); i++) {
  ImageButton button = imageButtons[i] = (ImageButton) findViewById(imageIds[i]);
  button.setImageBitmap(bMapScaled);
}

Good luck!

4

2 に答える 2

0

Fusion Chartsフォーラムでこれに対する答えを見つけました。グラフのブラウザーで埋め込みタグとオブジェクト タグの両方が使用されている場合、エクスポートに問題があるようです。

この回避策はここで説明さ れました

于 2010-12-30T01:28:22.693 に答える
0

以下の変更されたコードを見つけてください。

マイチャート

function ExportMyChart() { var cObject = document.getElementById('Column3D'); if( cObject.hasRendered && cObject.hasRendered()) cObject.exportChart({exportFormat: 'PDF'}); }

FusionCharts エクスポート ハンドラ コンポーネント var myExportComponent = new FusionChartsExportObject("fcExporter1", "../../FusionCharts/FCExporter.swf"); myExportComponent.Render("holderDiv");

お役に立てれば。

于 2011-01-06T05:35:48.083 に答える