Guest Rajroop

Exporting images server side

Recommended Posts

Hello, we are trying to export charts as images server side, because we need to insert theese images into a report.

 

 

 

I have read documentation pages "Returning the exported output as download" and "Saving exported output on server disk": no problem for the first mode (download of the user), but i need to use the second mode (parameter exportAction="save") and I have a little problem with it

 

 

 

I have not understand, how can I automatically get the image saved (server side) immediately after the chart has been loaded without pushing any button?

 

The parameter exportAction="save" is sufficient to instruct the chart to save the image immediately after loading, or I have to call any function or similar to start the saving process?

 

 

 

Thank you,

 

regards.

Share this post


Link to post
Share on other sites

Hi I am having the exact same issue. I have a thread ongoing and perhaps we could work together on this. I need to generate a PDF version of a long report, of which the Fusion Chart is only a part. So the pure PDF generation is not what I want. I am using FPDF to write the PDF with live data, and I need to generate a JPG of the FC and insert that into the PDF.

Is that what you are doing?

Cheers,

John Marno

RFN Software

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

 

 

 

By Default, you can get option to output to any of the 3 formats - JPG, PNG and PDF.

 

 

 

If you only need to export to JPEG and do not want any other option your XML attribute would be : exportFormats='JPEG=Save as JPEG'.

 

 

 

If you wish to export through JavaScript, you need to use:

 

 

 

chartId.exportChart({exportFormat:'jpg'});

 

 

 

Hope this helps. :)

Share this post


Link to post
Share on other sites

ok will try that.

Jeesh. Is this really the best you guys' support can do? I feel as though I have to wait 24 hours until any piece of information can be exchanged...

Really trying really trying really trying really trying really trying really trying

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

 

 

 

Do accept our apologies for the delay in the previous reply.

 

 

 

In case you have any queries, we're always here to help you. :)

Share this post


Link to post
Share on other sites

Method "chartId.exportChart({exportFormat:'jpg'});" is useful for both client-side and server-side export?

 

 

 

I have read bonjarno's problem described in the other thread and in effect I think that my problem is quite similar.

 

 

 

My specific case is the seguent: a web page shows a chart and a list of related data.

 

I want to print a report that shows exactly the same things, so I need to save the image SERVER-SIDE and embed it into the report.

 

 

 

I have read documentation but I have not understood HOW can I start the exporting process. Can I start it automatically when the chart has been loaded? Or instead, can I start it through a click on a button?

 

At this moment, I'm able to save the image on the server only through a right click on the chart->Save as PDF/JPG/PNG... but I don't want this.

 

My goal is to execute the exporting process and build the report with a single click of the user on a different button placed on the web page.

 

 

 

Thank you

Share this post


Link to post
Share on other sites

No, I have still had no success. I added the parameter for the JPG export as well.

One question I have is regarding the Waterfall2d chart - I notice that in the recently upgraded FC 3.1 there was no Waterfall in the download package - could this be the source of the trouble?

I guess I could change to a different chart for this test but was hoping I would not have to...

Do you have a simple PHP script to test with that you have verified works? Including the call back handler and everything? Surely you must somewhere - that way I can verify if the issue is on my server.

If I feel motivated I may try to produce a stripped down test case myself - but would hope that you have one already before I invest the time.

Thanks,

John Marno

Share this post


Link to post
Share on other sites
bookmark (7/17/2009)
Method "chartId.exportChart({exportFormat:'jpg'});" is useful for both client-side and server-side export?

 

 

 

I have read bonjarno's problem described in the other thread and in effect I think that my problem is quite similar.

 

 

 

My specific case is the seguent: a web page shows a chart and a list of related data.

 

I want to print a report that shows exactly the same things, so I need to save the image SERVER-SIDE and embed it into the report.

 

 

 

I have read documentation but I have not understood HOW can I start the exporting process. Can I start it automatically when the chart has been loaded? Or instead, can I start it through a click on a button?

 

At this moment, I'm able to save the image on the server only through a right click on the chart->Save as PDF/JPG/PNG... but I don't want this.

 

My goal is to execute the exporting process and build the report with a single click of the user on a different button placed on the web page.

 

 

 

Thank you

 

 

 

Up.

 

Sorry but this is an urgent question for us, our customer need this report in a short term..

 

I'd like to know if besides contextual men

Edited by Guest

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

 

 

 

Kindly accept our apologies for the delay in the reply.

 

 

 

Could you please visit the following links for an extensive and detailed explanation on how to implement the Export function on server side using just one click of a button?

 

 

 

http://www.fusioncharts.com/docs/Contents/ECJavaScript.html

 

http://www.fusioncharts.com/docs/Contents/ECServerOverview.html

 

http://www.fusioncharts.com/docs/Contents/ECServerDownload.html

 

 

 

I hope this helps. :)

Share this post


Link to post
Share on other sites

I think we have the same problem as mentioned above!

 

 

 

Create a chart with php

 

include .swf file into report

 

download report with chart.

 

 

 

is it possible to create a chart in php and download it via javascript (server-side) without any user action?

 

or is there an another way to do that?

 

 

 

 

 

 

JavaScript:

 

<script type="text/javascript">

 

function ExportMyChart() {

 

 

 

var chartObject = getChartFromId('myNext');

 

 

 

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

 

}

 

 

 

</script>

 

 

 

PHP

 

$chart = renderChartHTML("test/FusionCharts_Evaluation/Code/FusionCharts/Column3D.swf", "", $strXML, "myNext", 480, 200, false);

 

 

 

HTML:

 

 

 

<button onClick="ExportMyChart()">export</button>

 

 

ERROR:

 

chartObject.hasRendered is not a function

 

 

 

 

Thanks for your support

 

Boris

Share this post


Link to post
Share on other sites

Hi Boris,

John Marno here, aka Bonjarno. I have made some progress with some assistance from the support person named Sudipto - but I am stuck on having to click a button as well. I have made a workaround where the initial chart is a part of a rendered HTML page (PHP and MySQL initially), and already the user is supposed to click a link to generate a PDF version of the report. So I used the link to also serve as the button click that so far FC Exporting requires. I will keep you advised of progress and am pestering them with these same questions. FYI, you do have to have the v3.1 charts - and several of ours are not upgraded and do not work at all - but I have been able to generate JPGS to insert into the PDF with Pie3D, and others.

Cheers,

jm

Share this post


Link to post
Share on other sites

Hello Rajroop,

I have been trying to understand how server-side export of FC works. We have a requirement in our project to generate Batch Reports where user can create an SQL Query from a screen and submit the same for Excel-based Report Generation. The Excel Report which will be generated needs to have grid-data as well as FusionCharts, embedded as images on an excel sheet. Now, we are using server-side processes to generate the grid-data in the background (by querying SQlServer) and creating the Excel file (suing ASP.Net) and putting the grid data on a sheet. Problem is, we need to put the fusionchart as well on the sheet and I couldnt find a way to generate the bitmap (or chart image) from the chart in the background without rendering it on a page. The intention is to generate a Report which will have a Data grid on top and a Fusionchart at the bottom, and this report will be generated server-side (a backend process after user submits the query).

Is there a way to create the chart in memory based on the XML data and then call the export handlers to generate bitmap from it in the background, and then embed in Excel sheet?

Please advise.

Thanks,

Koushik Chakrabarti

Hartford,CT.

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello Koushik,

 

 

 

I'm afraid, while exporting server-side, the chart first needs to render in a browser, before the bitmap snapshot can be sent to server for processing.

 

You can not directly generate an image of chart on server, without actually rendering it in browser at least once.

 

(Ref: http://www.fusioncharts.com/docs/Contents/ECServerOverview.html)

 

 

 

:)

Share this post


Link to post
Share on other sites

I have partially solved my problems, now I can save chart images server side through JavaScript and embed them into reports.

 

Thanks to administrators for their replies.

 

 

 

But I still have a problem with Internet Explorer: after the image has been saved on the server (the file is present on the disk) the callback function is not invoked and nothing happens.

 

Instead, using Mozilla Firefox or Google Chrome, the callback function is normally invoked.

 

This function only contains an "alert".

 

 

 

I have already tried with IE7 and IE8, but the result is the same.

 

 

 

Which could be the reason of the problem? How can I solve it or how can I debug it?

 

Thank you.

Share this post


Link to post
Share on other sites

Hi

I can think of two reasons why this problem could occur only in IE:

1. Flash Player 10 is not installed in IE. If so, please install it.

2. If there is a pop-up blocker in IE, it could be causing a problem.

  Either turn-off the  pop-up blocker or change the value of attribute exportTargetWindow='_self' instead of exportTargetWindow='_blank'.

Hope this helps! :)

Srividya

Share this post


Link to post
Share on other sites

Hi Srividya,

 

 

 

I tried to follow your advises but it seems that they don't work.

 

 

 

Popup filter is disabled, I have also forced the exportTargetWindow parameter to '_self'

 

 

 

Flash Player 10 was already installed but I tried to reinstall it again.

 

 

 

I also tried to use an other PC, but the problem is the same, with IE7 or IE8 the callback function is not invoked (the alert message does not appear)

 

 

 

Is there a way to debug? Any other suggestion?

 

Thank you.

Share this post


Link to post
Share on other sites

1) Debug Mode is not useful in this case because the callback function is not traced in it.

 

When the export process is completed I can see these messages

 

 

Export Capture Process Start: The chart has started capturing bitmap data for export.

 

Export Transmit Data Start: The chart has finished capture stage of bitmap export and is now initiating transfer of data to the module at 'http://localhost/BKM_FC/FCExporter.aspx'.

 

 

 

but the callback function is not mentioned

 

 

 

2) what do you intend for "server log"? How can I configure it?

 

 

 

Thank you.

Share this post


Link to post
Share on other sites

I've only recently begun working with FusionCharts, but I'm very enthusiastic with what I've personally be able to produce in my initial experimentation.

 

 

 

As many of you from reading this specific message thread, I too am trying to produce these reports in an automated batch process, and I'd like to do all of this without any button push. I just want to invoke the batch by hitting the page that contacts the JavaScript. Has anyone developed a functional process for this yet?

 

 

 

I am trying to produce many individually saved .PNG chart files using the Server Side option. I have an array that I will need to read from many separate external XML files for each chart. After the completion of the batch process I would expect to find all of my individual .PNG files in my predefined export directory.

 

 

 

Any assistance would be greatly appreciated.

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

Welcome to the FusionCharts Forum! :)

I've a similar sample in comparison to what your requirement is. Please check this sample attached below and comment on whether this gives you an idea how to implement/get to your exact requirement from it.

This sample is on batch export/sever-side where we use two charts and supply multiple number of datasets to them and all of the exported PNG images are saved in the pre-assigned place of choice. The first sample is based on the dataXML method and the next one is using dataURL method. However, in this sample the process is user intiated.

The third sample, however, is automated. The exported images are saved in the default 'JPEG' form. You can change the end-output image form of the exported image, by including the following lines of code:

 <---------------------For PDF------------------------------>

function FC_Rendered(DOMId)

{

  var chart = getChartFromId(DOMId);

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

}

<------------------------------------------------------------>

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

 function FC_Rendered(DOMId)

{

  var chart = getChartFromId(DOMId);

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

}

<------------------------------------------------------------>

I hope this helps. Looking forward to your feedback regarding this.

autoupdate_generate_dataXML.zip

autoupdate_generate_dataURL.zip

forum.zip

forum.zip

Share this post


Link to post
Share on other sites

Outstanding reply, thank you very much!

 

Just a clarification please...

 


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

function FC_Rendered(DOMId)

    {

     var chart = getChartFromId(DOMId);

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

    }  

<------------------------------------------------------------>

 

Where exactly is that located? What file?

 

 

 

And also you have (4) attachments. I assume that the forum.zip is just a duplication? Correct?

 

 

 

Thank you again for your replay and patience.

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello again,

You would need to add the line below in place of Line:34 in the index.php file in the attachment named forum.zip

chartObjects[DomID].exportChart({ exportFormat:'png' });

And also you have (4) attachments. I assume that the forum.zip is just a duplication? Correct?

You would assume correctly, this. :)

I hope this helps. :P

Share this post


Link to post
Share on other sites
Guest Rajroop

Hi,

 

 

 

Would you care to explain further by what you mean by this?

 

 

 

Looking forward to your post on this.

Share this post


Link to post
Share on other sites

Hi Boris,

 

 

 

John Marno here, aka Bonjarno. I have made some progress with some assistance from the support person named Sudipto - but I am stuck on having to click a button as well. I have made a workaround where the initial chart is a part of a rendered HTML page (PHP and MySQL initially), and already the user is supposed to click a link to generate a PDF version of the report. So I used the link to also serve as the button click that so far FC Exporting requires. I will keep you advised of progress and am pestering them with these same questions. FYI, you do have to have the v3.1 charts - and several of ours are not upgraded and do not work at all - but I have been able to generate JPGS to insert into the PDF with Pie3D, and others.

 

 

 

The above enquiry came from this post .

 

 

 

I wanted to know how this can be done.

Share this post


Link to post
Share on other sites
Guest Angie

Dear User,

 

We are delighted to announce that PowerCharts is now ready for your iPads and iPhones too. We have just released PowerCharts v3.2. Starting v3.2, PowerCharts has HighCharts embedded within it, and offers both Flash and JavaScript (HTML5) charting . The Flash charts are displayed on a majority of devices and the JavaScript charts on devices that do not support Flash, all of it without writing a line of code.

 

Automatic rendering of JavaScript charts on devices (like iPad and iPhone) where Flash player is not supported.

 

5 new chart types:

 

Heat Map Chart

 

Box and Whisker Chart

 

Step Line Chart

 

Error Line Chart

 

Error Scatter Chart

 

 

* Support for JSON data format.

 

* Support for LinkedCharts, where a single data source controls multiple charts.

 

* Interactive legends in charts allow selective showing/hiding of data series.

 

* Legends now support icons for each data series.

 

* Better management of labels on charts.

 

* Labels now have an auto rendering mode to prevent them from overlapping, the chart selects the best display mode depending on the length of the labels and the width of the chart.

 

* Long labels are truncated, with ellipses appended to the truncated end of each label, and a tooltip bearing the completed label text is displayed when the user hovers over a truncated label.

 

* Support for line breaks and wrapping in all text elements including: caption, sub caption, X-axis title, Y-axis title, Labels and tooltips.

 

* In Line charts, data values can now be positioned either above or below the dataplots. Automatic positioning of data values is also supported.

 

* In Step-line charts dataplots can be joined using vertical lines.

 

* Custom alignment of caption and sub caption using STYLES.

 

* Advanced print management using JavaScript.

 

* Additional options for efficient event handling using JavaScript.

 

* Support for dynamic update of chart properties using JavaScript(barring select scatter and drag charts).

 

* Charts now support % based sizes along with dynamic resizing (barring select scatter and drag charts).

 

 

Learn more about everything new in PowerCharts v3.2 at : http:/ www.fusioncharts.com/PowerCharts/

 

We would love to hear from you at: http://www.fusioncharts.com/contact/

Share this post


Link to post
Share on other sites

<SPAN id=_ctl1_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl2_lblFullMessage>Hello, </SPAN></P><P><SPAN>Welcome to the FusionCharts Forum! :)</P><P>I've a similar sample in comparison to what your requirement is. Please check this sample attached below and comment on whether this gives you an idea how to implement/get to your exact requirement from it.</P><P>This sample is on batch export/sever-side where we use two charts and supply multiple number of datasets to them and all of the exported PNG images are saved in the pre-assigned place of choice. The first sample is based on the dataXML method and the next one is using dataURL method. However, in this sample the process is user intiated.</P><P>The third sample, however, is automated. The exported images are saved in the default 'JPEG' form. You can change the end-output image form of the exported image, by including the following lines of code:</P><STRONG><P><STRONG> <---------------------For PDF------------------------------></STRONG></P><P>function FC_Rendered(DOMId)

{

  var chart = getChartFromId(DOMId);

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

}

<------------------------------------------------------------></P><P><----------------------For PNG------------------------------>

 function FC_Rendered(DOMId)

{

  var chart = getChartFromId(DOMId);

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

}

<------------------------------------------------------------></P><P></STRONG>I hope this helps. Looking forward to your feedback regarding this.</P></SPAN>

 

THANK YOU!!

 

I have been working on this all day trying to figure it out and finally stumbled upon this answer and it works as needed, an automatic page load and save the chart action.

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