Sign in to follow this  
Mauricio

Server-Side: Saving On Server Disk Problem

Recommended Posts

I want to save a chart image on my server WITHOUT using the chart context menu.

According to the documentation in order to trigger the saving it can be done by chart context menu or Javascript API, I followed the example provided on the download pack (saveExample.html) under "ExportChartSamples/ServerSide",

but there's no example how to trigger the download, I want to use a mouserollover to trigger the action but HOW? the idea is to save the chart hidden from the user (without asking anything) so I can later use that image to generate a pdf report including text an other images.

 

Questions:

A) According to the example provided (see point 3) is not using a javascript api? how this supposed to work without a trigger?

 

B) Now to be sure the FCExporter since the relative path should be based on the location of FCexporter.php? or is where index.php is (application root)?

 

C) Can I be provided with an example how to trigger the saving NOT the DOWNLOAD, again I need the saving happens without asking the user to accept just on the server side.

 

 

This is the set up I have.

 

1) I set up the XML document: <chart maxLabelWidthPercent="50" plotBorderThickness="4" plotBorderColor="3794d1" anchorAlpha="100" caption="" showBorder="0" bgColor="FFFFFF" exportEnabled="1" exportAtClient="0" exportAction="save" exportHandler="http://my_domain/application_folder/tchart/PHP/FCExporter.php" exportFileName="test1" >

 

 

2) Modified the FCExporter.php file to point to the saving locations and already give 777 permision to the folders and subfolders this way:

define ( "SAVE_PATH", "/pdf/capturedimages/" );

define ( "HTTP_URI", "http://my_domain/application_folder/pdf/capturedimages/" );

 

 

3) in the HTML and added : FusionCharts.js & FusionChartsExportComponent.js on the header :

function FC_Exported(objRtn){

if (objRtn.statusCode=="1"){

alert("The chart with DOM Id " + objRtn.DOMId + " was successfully saved on server. The file can be accessed from " + objRtn.fileName);

}else{

alert("The chart with DOM Id " + objRtn.DOMId + " could not be saved on server. There was an error. Description : " + objRtn.statusMessage);

}

}

 

and the chart starter within body:

 

var myChart = new FusionCharts( "tchart/radar.swf","myChartId", "620", "400", "0", "1" );

myChart.setXMLUrl("the_xml.xml");

myChart.render("chartContainer");

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,

 

You can automatically start exporting as the chart gets rendered without the context menu. You would need to add event on JavaScript variable as the chart is rendered.

 

Ref.Code:

myChart.addEventListener("Rendered", function () { FusionCharts("myChartId").exportChart(); } );

 

exportChart() method is used for exporting a chart. exportChart() method is called upon the JavaScript variable which contains the chart instance.

 

For exporting chart directly into PDF format, you would need to set exportFormats attribute under the chart element.

 

Set exportFormats attribute as 'PDF' in the XML code.

 

Ref. Code:

<chart .. exportFormats='PDF'>

 

Please note, you would need to set proper path for the ExportHandlers (FCExporter.php) in the XML file.

 

Also, you would need to set following parameters in the (FCExporter.php) file.

> define ( "SAVE_PATH", "./" );

> define ( "HTTP_URI", "path of the folder which contains ExportHandler file" )

 

However, for implementing mouserollover to trigger, you would need to write your own logic.

 

For more information please refer the following link:

http://docs.fusioncharts.com/charts/contents/?exporting-image/server-side/ECServerSave.html

 

Please find attached demo for your reference.

 

Hope this helps.

Auto_ExportPHP.zip

Share this post


Link to post
Share on other sites

Hi Sumedh,

 

Thanks for your reply, it was very helpful, I tried a Flash version of a radio graphic and worked perfectly.

Now I want to replicate the same behavior on Javascript radio charts (in case the is accessed from non flash friendly browsers).

 

In order to test this I added : FusionCharts.setCurrentRenderer('javascript');

 

to the Chart constructor; now when I load the page, a download window opens asking permission to start downloading the chart.

Is there something else I need to add to the constructor?

 

Regards,

Mauricio

Share this post


Link to post
Share on other sites

Hi,

 

As of now, the export feature of JavaScript charts does not natively saving the exported image to server. It always returns back the image as download. However, you can setup your server to install the export handler and modify the code of the export handler to save the exported image in a server location.

Share this post


Link to post
Share on other sites

Hi,

 

As of now, the export feature of JavaScript charts does not natively saving the exported image to server. It always returns back the image as download. However, you can setup your server to install the export handler and modify the code of the export handler to save the exported image in a server location.

 

Hi There,

 

Does anybody know how to change the export handlers so the exported image is saved to the disk? At the moment the file is downloaded as Image.

I need to save the image and include in a PDF (I need some customizations for the generated PDF).

Also when the export process is initiated, a request is sent to export.highcharts.com. Is there a way to change it, so the graph is generated on my server and not to send some confidential data to another server?

 

Thanks in advance,

Andrei

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