Sign in to follow this  
maria

saving chart to PDF or JPEG

Recommended Posts

Hi,

 

 

 

I followed the instructions for server-side saving of charts to PDF and JPEG. I can successfully right-click and see the "save as" options, the the progress bar appears. However, the download dialog box never appears so I can't really save the chart. Instead the webpage loads the contents of FusionCharts/ExportHandlers/PHP/

 

 

 

I must be going wrong somewhere. The code snippet looks like this:

 

 

 

< ... exportAtClient='0'

 

exportAction='download' exportEnabled='1'

 

exportHandler='http://powernet.stanford.edu/FusionCharts/ExportHandlers/PHP' ...>

 

 

 

 

 

Thank you.

 

M

Share this post


Link to post
Share on other sites
Guest Madhumita

Hi,

Could you please try using Flash Player 10 for this.

Looking forward to your feedback on this. :P

Share this post


Link to post
Share on other sites

Maria,

 

 

 

You need to render the chart at least once at the client end (in a browser) before you can export it at the server side. You cannot directly export the chart at the server side without rendering it at the client end first.

 

 

 

If you are already doing that the there are a couple of things you need to check:

 

 

 

1) Whether you are using the latest version 3.1.1 of the SWFs and FusionChartsExportComponent.js (you can enable the debug mode to check your version)

 

2) Whether you have the Flash Player Global settings enabled as Madhumita has already pointed out.

 

 

 

If none of these help, just send us the code you are using and we will try to see what could be causing the problem.

Share this post


Link to post
Share on other sites

Hi, thanks for the suggestions.

 

 

 

I double checked my Flash Player settings and the version (3.1.1) of the files.

 

As far as the FusionChartsExportComponent.js is concerned, I am not sure what that is. I never saw anything about it in the documentation. I traced it in the source code and added it to my code but that didn't change anything.

 

 

 

I am attaching three files:

 

energy-watts2 contains some data

 

plot-monitor.php reads the data file and generates the XML string

 

monitor.php renders the chart (note that i had trouble opening this file in TexEdit but vim or cat works just fine)

 

 

 

The two php files are attached as .txt so they need to be renamed. The datafile needs to have the .txt extension completely removed.

 

 

 

It must be something silly but I just don't see it.

 

 

 

Many thanks.

energy-watts2.txt

monitor.txt

plot-monitor.txt

Share this post


Link to post
Share on other sites

Would anyone be kind enough to at least ACK or NACK whether they can successfully export charts give the code attached in the earlier post?

 

 

 

I will really appreciate it.

 

 

 

Best,

 

Maria

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello Maria,

I apologize for the delay in the reply. :crying:

Could you please use the following attachment in place of plot-monitor.txt that you have attached to one of your earlies posts, and try again?

After testing in our Labs, we found out that the change that was needed to make it work was in the following line of code:

exportHandler='FusionCharts/ExportHandlers/PHP/FCExporter.php'";

Please comment on whether this was helpful or otherwise. I do really hope this helps.

Sample1.txt

Share this post


Link to post
Share on other sites

Hi,

 

 

 

Thanks for helping out.

 

Making the suggested changes allows me to export the chart to PDF successfully. Yay!

 

 

 

Exporting to JPEG or PNG fails with the following error:

 

Fatal error: Call to undefined function imagecreatetruecolor() in /var/www/FusionCharts/ExportHandlers/PHP/Resources/FCExporter_IMG.php on line 261

 

 

 

Maria

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

 

 

 

Could you please add the following lines of code in your JS code and try again?

 

 

<-------------------------JPEG----------------------------->

 

function FC_Rendered(DOMId)

 

{

 

var chart = getChartFromId(DOMId);

 

chart.exportChart({ exportFormat:'jpeg' });

 

}

 

 

 

<------------------------PNG-------------------------------->

 

function FC_Rendered(DOMId)

 

{

 

var chart = getChartFromId(DOMId);

 

chart.exportChart({ exportFormat:'png' });

 

}

 

 

 

I hope this helps.

Share this post


Link to post
Share on other sites

Hi, Thanks for the reply.

 

Does this go in my custom code or in one of the support files provided by the Fusion Charts library?

 

 

 

Best,

 

Maria

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
Sign in to follow this