MT_MANC

Chart not saving as PDF on server Side: PHP Export Handler Issue ?

Recommended Posts

I adapted your SaveExample.html & SaveData.xml example (see both attached as .txt and .xml respectively) by changing paths and referencing my PHP Export Handler (see FCExporter.txt) to export Chart to PDF after rendering in browser (IE 6)

Chart renders OK in IE6 but javascript Callback handler doesnt display any alert and no .PDF appears

in the /AninGIF/GNU/ subdir on my linux server host (where CHMOD = 777)

When I view FCExporter.php directly in IE6 I get the following:

DOOMId=

height=0

width=0

fileName=

statusMessage= Insufficient data.

statusCode=0

This appears to be a FCExporter.php error in first instace but I can't see any obvious errors/ommisions in the php/other code; can anyone assist ?

FCExporter.txt

SaveExample_html.txt

SaveData.xml

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

Could you please make sure whether the  javascript Callback handler is called or not?

Looking forward to your reply. :)

Share this post


Link to post
Share on other sites

I'm assuming it is NOT CALLED, otherwise shouldn't I get an alert proclaiming either success or failure via

the function FC_Exported(objRtn)  ?

But, despite thorough examination of code, I cant spot where the error is occuring as I have just changed the server path in FCExporter.php from yours to mine and the path to FusionCharts.js

Is there a smart way to isolate if the non-calling is due to the XML file or the HTML code or the (edited) FCEporter.php ?

Share this post


Link to post
Share on other sites

...

Greetings,

I will try to solve your issue one by one. :)

First, you cannot call FCExporter.php directly. This is because, FCExporter.php mandatorily needs to be called by a FusionCharts chart as the chart sends the data that is required by the script to function properly. :)

Next, as you report that you can view Image on browser, we can safely assume that the chart is setup well and data is being sent and interpreted properly.

You are not getting any callback upon export. This can be due to various reason.

  1. There may be a JavaScript error on your deployment page.
  2. The FCExporter.php raises an unexpected error that is not well interpreted by your charts.

In either of the above case, we would require a scaled down implementation of your code before our debug team can work on it. We would aprpeciate if you could send us your sample implementation in a zip file. That zip file should also contain your modified FCExporter.php

Share this post


Link to post
Share on other sites

Thanks

I attached all these requested files in my original post - see top post

NB My editing of YOUR example template (SaveExample.html, SaveData.xml & FCExporter.php) has been minimal

Share this post


Link to post
Share on other sites

...

You are always welcome. :)

We have analyzed http://jcsweb.biz/mef/Export_Handler_FC/FCExporter.php, and have found that data is being saved on server perfectly. However, instead of returning a proper response that our charts can recognize, your server is doing a redirect to crossdomain.xml and that too is returning 404 Not Found. This is normal when data is posted to one domain from another (except the 404 part!)

While testing the situation in your original post, are you running SaveExample.html locally or from a different domain than jcsweb.biz? In any case, you can test this if you use IE Developer Toolbar on IE or FireBug on FireFox to analyze HTTP Requests of your page. In case you are unable to do this, send us a live URL of your implementation and we will analyze the same for you.

Edited by Guest

Share this post


Link to post
Share on other sites

Most Kind

What could be causing the "404 Not Found" error ?

I dont seem to have Developer Toolbar on IE6 ? I presume URLs below are all you need to analyse

Live version of your SaveExample chart is held at:

http://www.jcsweb.biz/mef/client/wd_scen_lev/SaveExample.html

with related XML file held at:

http://www.jcsweb.biz/mef/client/wd_scen_lev/SaveData.xml

 

Where exactly is the "data" saved to on my server ? (and do you mean a PDF file is saved or an XML ?)

Grateful for any insight/resolution

Share this post


Link to post
Share on other sites

...

Greetings,

From your live link we figured out the issue... you would be rolling in laughter if you see to it! :)

Try calling http://jcsweb.biz/mef/client/wd_scen_lev/SaveExample.html (without www) and your exportcomponent will work just fine. This is because http://www.domain.com and http://domain.com are two different domains! :hehe:

Fix: Either call a relative URL in your XML exportHandler="/mef/Export_Handler_FC/FCExporter.php" or call the same domain for both the html and the xml (i.e. either both www or non www)

Edited by Guest

Share this post


Link to post
Share on other sites

Thanks

So calling:  http://jcsweb.biz/mef/client/wd_scen_lev/SaveExample.html

which references:  http://jcsweb.biz/mef/client/wd_scen_lev/SaveData.xml

should result in NEW.pdf appearing in my /AnimGIF/GNU/ directory on my server.

But no PDF (or JPG OR any chart) is appearing here automatically !!!  (Is the FCExporter.php actually being invoked )

But if I right click on rendered chart I CAN manually export via the menu to NEW.pdf ! and the 'SuccesfullySaved to server' js dialogue box appears. But why isnt this chart-saving happening automatically server-side after chart renders - I have removed "www" as you suggested ?!!!

Any ideas ?

Share this post


Link to post
Share on other sites

There was no *.html file in the zip ?! Not really sure how to extract what I need from this .zip?!

I have adpated your basic Javascript Export example again from the documentation at: http://www.fusioncharts.com/docs/Contents/ECJavaScript.html

so Data.html now includes js function ExportMyChart() http://www.jcsweb.biz/mef/client/wd_scen_lev/Data.html

which renders fine using the example XML file adapted for my server address: http://www.jcsweb.biz/mef/client/wd_scen_lev/Data.xml

but clicking button gives an error - "Object doesnt support this property or method"  - see attached DATA_HTML_ERROR.JPG

Your example had exportAction='download' in the .XML but shouldn't this be 

 exportAction='save' (the ExportMyChart() still doesnt work when I change this !!)

Functions still fails if I include  FusionChartsExportComponent.js in Data.html

(which I believe is NOT required) I have also uploaded "FCExporter.swf" in my charts dir on my server just in case; but do I need any other files uploaded to my server ?

QUESTIONS:

1. Why is ExportMyChart() failing ?

2. What is correct js code to get chart to AUTOMATICALLY save to server after rendering without needing to click button and to suppress any export dialogues (I have showExportDialogue='0' in Data.xml already) and callback dialogues?

To autoexport to server can I just add this line at bottom:  

if( chartObject.hasRendered() ) chartObject.exportChart();

to give:

var myChart = new FusionCharts("/mef/Charts/Column2D.swf", 'myChart', '900', '300', '0', '1');
myChart.setDataURL('Data.xml');
myChart.render('chartContainerDiv');
if( chartObject.hasRendered() ) chartObject.exportChart();

Couldnt really test this properly as chartExport() not working in first place !

Thanks again

post-4415-128441575403_thumb.jpg

Share this post


Link to post
Share on other sites

UPDATE - I have now figured out the functions in the attached index.php; I can now auto-export my chart after rendering to either .jpg or .pdf format. The only niggle is that the Chart logo is NOT appearing on the Chart saved on the Server - either jpg or pdf format - even though it DOES appear on the Rendered chart in the browser (and I have a Developer License)

XML Header code for Logo:

logoURL='/mef/Images/mef_pf5_tiny.jpg' 

Any ideas. Is it because Logo is a JPG itself ?

Thanks again

Share this post


Link to post
Share on other sites

Hi,

Name conflict:

var myChart = new FusionCharts("/mef/Charts/Column2D.swf", 'myChart', '900', '300', '0', '1');

 

Please try once changing any of the red texts.

Say,

var myChartJSObj = new FusionCharts("/mef/Charts/Column2D.swf", 'myChart', '900', '300', '0', '1');

 

Could you please send us the XML where you are loading the logo? If possible please send us a working live sample URL so that we can text. Our Test Lab confirms that the logo appears in exported image.

Share this post


Link to post
Share on other sites
shamasis (9/17/2009)
...

 

 

 

The chart does NOT get automatically exported server-side, unless you explicitly write JavaScript codes to do the same. I have attached a demo application that automatically starts exporting four charts upon page load.

 

 

 

Hope this is useful.

 

 

 

I was able to get your version working just fine with the same export file settings I'm using, yet my script will not render and save automatically like yours.

 

 

 

Do you have a simpler version of this for just 1 chart and not 4 at a time merging the files, etc. Just something stripped down and easy to understand?

 

 

 

Thank you!!

Share this post


Link to post
Share on other sites

Hi,

 

I am having trouble getting the save to server functionality working. I have set up and tested several examples, including the sample app as is that was included in this topic. In each case it looks like chart is trying to save but nothing happens on the server and the callback never gets called. In one of my tests, a javascript error occurs after the chart is captured. Any thoughts as to what my problem could be?

 

Thanks in advance for your help.

 

David Perry

Share this post


Link to post
Share on other sites

...

 

The chart does NOT get automatically exported server-side, unless you explicitly write JavaScript codes to do the same. I have attached a demo application that automatically starts exporting four charts upon page load.

 

Hope this is useful.

 

Thanks for your help.

 

i am working with your folder. i want to save fusion charts as pngs, but i am not getting. Please help me. Attaching folder here. please explain if you changed any code here.

 

Thanks

 

export.zip

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Thanks for your help.

 

i am working with your folder. i want to save fusion charts as pngs, but i am not getting. Please help me. Attaching folder here. please explain if you changed any code here.

 

Thanks

 

 

Hi,

 

From the "index.php" file of your sample, it seems you have used same chart ID multiple times while creating FusionCharts constructor in JavaScript.

 

So, could you please provide unique name to each chart IDs for all the charts in a page?

 

Ref. wrong Code:

var chart1 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");
....
var chart2 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");

 

Ref. Correct Code:

var chart1 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");
....
var chart2 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart2Id", "600", "400", "0", "1");

 

Also, it seems "G2.xml" is not present in the sample folder, which is used to render chart2, so commented the lines of code for creating chart2.

 

After making the above changes, we have tested your sample, and it is successfully exporting all the chart images to server successfully.

 

Please find the modified sample attached here, for your reference.

 

Hope this helps!

export_modified.zip

Share this post


Link to post
Share on other sites

Hi,

 

From the "index.php" file of your sample, it seems you have used same chart ID multiple times while creating FusionCharts constructor in JavaScript.

 

So, could you please provide unique name to each chart IDs for all the charts in a page?

 

Ref. wrong Code:

var chart1 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");
....
var chart2 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");

 

Ref. Correct Code:

var chart1 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart1Id", "600", "400", "0", "1");
....
var chart2 = new FusionCharts("FusionCharts/MSColumn3D.swf", "chart2Id", "600", "400", "0", "1");

 

Also, it seems "G2.xml" is not present in the sample folder, which is used to render chart2, so commented the lines of code for creating chart2.

 

After making the above changes, we have tested your sample, and it is successfully exporting all the chart images to server successfully.

 

Please find the modified sample attached here, for your reference.

 

Hope this helps!

 

thanks for your reply.

 

i am able to upload these images in jpeg format. but i need format like png.

please help me out.

thanks

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

We are glad to hear that the solution provided to you has been resolved your issue.

 

However, if you need to export the image in PNG format, you would need to pass "PNG" value to the export attribute "exportFormat" as parameter to the JavaScript function "exportChart()".

 

Ref. Code:

chartObject.exportChart( {exportFormat: 'PNG'} );

 

For more information on "Initiating from JavaScript > Providing Export Parameters (Overriding XML Export Attributes) using JavaScript", please follow the link below:

http://docs.fusioncharts.com/charts/contents/?exporting-image/javascript-ref/ECJavaScript.html

 

Hope this helps!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now