Sign in to follow this  
abhishekm

problem in exporting javascript charts as Images on server side

Recommended Posts

Hi,

 

I am using FusionCharts version 3.3.1 and trying to export charts as images/pdfs using J2EE export handler. Everything works fine when I use Flash version of chart and export images. When I disable Flash in browser, JS chart is rendered and I am getting "Insufficient Data" error via FC_Exported(objRtn) javascript callback function.

 

Here are Tomcat server logs:

Aug 20, 2013 1:23:04 PM com.fusioncharts.exporter.error.ErrorHandler buildResponse
INFO: Miscellaneous Messages=&width=0&height=0&DOMId=Chart_ID_0.9248934648931026

 

Here is my config:

 

JSP/HTML code for chart

 

<chart bgAlpha='0,0' enableSmartLabels='1' pieRadius='120' formatNumberScale='0' debug='true' exportEnabled='1' registerWithJS='true' exportCallback='FC_Exported' exportHandler='/res/FCExporter' exportAtClient='0' exportAction='save'  bgColor='F7F7F7' showBorder='0' showShadow='0' use3DLighting='0'>

 

fusioncharts_export.properties under classes folder

SAVEPATH=/usr/sites/host101.com/htdocs/graphs
HTTP_URI=http://host101.com/graphs/
OVERWRITEFILE=false
INTELLIGENTFILENAMING=true
FILESUFFIXFORMAT=TIMESTAMP

 

Can anyone please help?

 

Thank you in advance.

 

 

Share this post


Link to post
Share on other sites

After further investigation and debugging, I came across the image is not being passed via strem.

 

I created a filter and in that put servletRequest.getParameter("stream"). It is coming fine for flash charts but it is Null in case of Javascript exports

 

Any clue?

 

Thank you,

Abhishek

Share this post


Link to post
Share on other sites

Using J2EE APi, is there a way to export (download) charts at client side rather than storing them at Server side? I know this works for Flash charts but does this work for Javascript charts, too?

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

Please note that the J2EE export handler which is provided by FusionCharts currently, will export only the Flash charts image/PDF to server.

 

However, if you are willing to export the JavaScript charts to server, you would need to either implement FusionCharts PHP export Handler or you could use our public server "http://export.api3.fusioncharts.com/" which will process the data and generate the required image/PDF and send back to you.

 

Also, please note that you could export the JavaScript charts at client side, without hitting the server. For more information on this, please visit the link: http://blog.fusioncharts.com/2013/06/export-chart-as-image-on-client-side/

 

For more information on "Exporting Pure JavaScript Charts", please visit the link: http://docs.fusioncharts.com/charts/contents/?exporting-image/ECPureJS.html

 

Hope this helps!

 

Looking forward to your valuable response.

Share this post


Link to post
Share on other sites

Thank you so much for your reply.

 

As per http://www.fusioncharts.com/products/suite/fusioncharts-xt/fusioncharts-version-history.html, "Exported JavaScript charts can now be saved to a server (using PHP and JAVA)".

I am using FusionCharts XT version 3.3.1. Shouldn't it work ?

 

As per your suggestion, I used http://export.api3.fusioncharts.com/ but I am getting "Chart could not be saved on sever There was an error. Descrption: undefined"

<chart bgAlpha='0,0' enableSmartLabels='1' pieRadius='120' formatNumberScale='0' exportEnabled='1'  exportCallback='FC_Exported' exportHandler='http://export.api3.fusioncharts.com/' exportAtClient='0' exportAction='save'  bgColor='F7F7F7' showBorder='0' showShadow='0' use3DLighting='0'>

 

What could be a problem here?

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

Please note that only setting exportEnabled='1' in the chart XML, will automatically call to the server "http://export.api3.fusioncharts.com/" and return the exported image/PDF to client as download. If you want to export the chart and save the image/PDF to your server, you need to setup your own server to process and export JavaScript charts.

 

As per the FusionCharts XT version history, to export the JavaScript charts to server, you could implement "Apache Batik SVG Rasterizer library" and set up your own server, for which you require PHP and Java running in your server.

 

Actually, the Batik library require JAVA to execute and the export handler is in PHP. So, the requirement is to run both PHP and JAVA in your server.

 

But, currently FusionCharts XT does not provide any JAVA export handler for JavaScript charts to export.

 

If feasible, you could configure "Batik" library on your server using PHP exportHander.

 

As an alternative, you could implement "wkhtmltoimage" shell utility in your JAVA application, which will export the entire webpage (along with the chart) offline to server.

 

For more information on this, please visit the link: http://blog.fusioncharts.com/2013/03/how-to-save-charts-as-images-at-server-side/

 

Hope I am able to clarify myself.

Share this post


Link to post
Share on other sites

Thank you for your prompt response. It looks like we do not have way to install php at our end. So, I do not think we can export the chart at server side. Also, we do not have flash 5 support as of now so we can not export at client side.

 

We use feature which automatically falls back to show JS chart when Flash is not available at client side. Flash client side export works fine. I just wanted to know if there is way to hide Download button when JS chart is rendered. I want download options in case of flash charts.

 

Are you considering to update J2EE export handler to support client/server side export of charts?

Share this post


Link to post
Share on other sites
Hi,

 

Please find the answers below:

 

1. We use feature which automatically falls back to show JS chart when Flash is not available at client side. Flash client side export works fine. I just wanted to know if there is way to hide Download button when JS chart is rendered. I want download options in case of flash charts.

>> There is no direct way to hide the download button when a JS chart is rendered. You will have to use your own mechanism to handle this. For instance,You may have two different XMLs (or JSON's)one with export and the other without it, and load it accordingly by detecting if Flash player is present or not.

 

2. Are you considering to update J2EE export handler to support client/server side export of charts?

>> The JS charts cannot be exported like the way Flash charts can be exported. For exporting JS charts to be saved on your server as an image or PDF, tools like Apache Batik, wkhtmltoimage etc need to be used.

 

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