Sign in to follow this  
Bhushan

Problems exporting basic pure JavaScript charts using Asp.Net handler

Recommended Posts

I am having difficulty exporting a pure JavaScript chart from the basic examples provided in the C# solution (demo package from fusion charts). My sample is from the evaluation code provided on the FusionChart website.

I have added

exportenabled='1' exportHandler='http://localhost:64162/CS/Export_Handler/FCExporter.aspx'

to the existing Data.xml file in order to enable export using the local handler

Chart definition for the chart BasicExample/MultiChartsJS.aspx:

 

<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='0'
formatNumberScale='0' showBorder='1' exportenabled='1' exportHandler='http://localhost:64162/CS/Export_Handler/FCExporter.aspx'>
<set label='Jan' value='462' />
<set label='Feb' value='857' />
<set label='Mar' value='671' />
<set label='Apr' value='494' />
<set label='May' value='761' />
<set label='Jun' value='960' />
<set label='Jul' value='629' />
<set label='Aug' value='622' />
<set label='Sep' value='376' />
<set label='Oct' value='494' />
<set label='Nov' value='761' />
<set label='Dec' value='960' />
</chart>

 

I am pointing the exportHandler to the C# export handler (FCExporter) found in the same solution.

When invoking the export, the handler fires, but I am encountering two different runtime errors in the handler:

Failures inside FCExporter.cs

1)Jpeg conversion:

gr.Clear(ColorTranslator.FromHtml("#" + rawImageData["bgcolor"].ToString()));

is failing because rawImageData["bgcolor"] already contains a #

2)PDF conversion

int fRepeat = int.Parse(split_data[1]);

is failing with an out of range exception

It almost seems like the handler is out of sync with the charts that are being exported. It works if I point to the external fusion site for the export. Is there a new version of the handler available? I am using FusionCharts XT Version: 3.3.1.

 

Thanks,

Bhushan

Share this post


Link to post
Share on other sites

 

I am having difficulty exporting a pure JavaScript chart from the basic examples provided in the C# solution (demo package from fusion charts). My sample is from the evaluation code provided on the FusionChart website.

I have added

exportenabled='1' exportHandler='http://localhost:64162/CS/Export_Handler/FCExporter.aspx'

to the existing Data.xml file in order to enable export using the local handler

Chart definition for the chart BasicExample/MultiChartsJS.aspx:

 

<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='0'

formatNumberScale='0' showBorder='1' exportenabled='1' exportHandler='http://localhost:64162/CS/Export_Handler/FCExporter.aspx'>

<set label='Jan' value='462' />

<set label='Feb' value='857' />

<set label='Mar' value='671' />

<set label='Apr' value='494' />

<set label='May' value='761' />

<set label='Jun' value='960' />

<set label='Jul' value='629' />

<set label='Aug' value='622' />

<set label='Sep' value='376' />

<set label='Oct' value='494' />

<set label='Nov' value='761' />

<set label='Dec' value='960' />

</chart>

 

I am pointing the exportHandler to the C# export handler (FCExporter) found in the same solution.

When invoking the export, the handler fires, but I am encountering two different runtime errors in the handler:

Failures inside FCExporter.cs

1)Jpeg conversion:

gr.Clear(ColorTranslator.FromHtml("#" + rawImageData["bgcolor"].ToString()));

is failing because rawImageData["bgcolor"] already contains a #

2)PDF conversion

int fRepeat = int.Parse(split_data[1]);

is failing with an out of range exception

It almost seems like the handler is out of sync with the charts that are being exported. It works if I point to the external fusion site for the export. Is there a new version of the handler available? I am using FusionCharts XT Version: 3.3.1.

 

Thanks,

Bhushan

 

Hi,

 

Please note that FusionCharts supports only server-side export when exporting the JavaScript charts. But the "FCExporter.aspx" file from the Download package would not be able to assist you in this case as this exports only Flash charts. You would either need to export the JavaScript charts using our public server or set up Batik on your server.

Ref.- http://docs.fusioncharts.com/charts/contents/?exporting-image/ECPureJS.html

 
However, one of our developers internally developed a solution on .Net 4.0 and above & using SharpVectors and a few other assemblies, to export the latest version of FusionCharts XT (v3.3.0 and above), without using Batik library that require PHP server, that had helped us in exporting JavaScript & Flash charts simultaneously.
 
Also, technically this is just same as the native "FCExporter.aspx" component that we provide in the "ExportHandlers" folder of the Download Package, just a little modified, to fit in your requirement.
 
The system requirements to run this modified FCExporter.aspx are:
>> FusionCharts v3.3.0 and above
>> .Net 4.0 framework and above
 
Below, we provide you the detailed implementation with a ready sample for your better understanding.
 
You have a FusionCharts sample with the combination of multiple (Flash and/or JavaScript) charts on the same page, using ASP.Net that you want to export at once and save them on the server. Here we go for the easy solution:
>> Add the reference of all the SharpVectors, Windows.Base & PresentationCore assemblies besides the modified FCExporter.aspx component (as attached)
 
>> Modify "FCExporter.aspx.cs" file to save the exported images on the specified server location, as explained here
 
>> Modify in the Web.Config file (to prevent error while POST of SVG data string):
<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0"/>
</system.web>
</configuration>
 
>> Add the following attributes in all the XML files for the configurations:
<chart ... exportEnabled='1' exportAtClient='0' exportAction='save' exportHandler=’…/Path/FCExporter.aspx' exportFilename=’ImageFileName’>
 
>> Initiate export from JavaScript so that all the charts in the page are exported on button click, using this additional code snippet.
function exportCharts() {
initiateExport = true;
for (var chartRef in FusionCharts.items) {
//alert(chartRef);
if (FusionCharts.items[chartRef].exportChart) {
FusionCharts.items[chartRef].exportChart({ "exportFormat": "JPG" });
}
...
<input type="button" value="Export Charts" onclick="exportCharts()" />
 
Now, on button-click, you will find all the (JavaScript and/or Flash) charts rendered on a single page would be exported simultaneously as images and get saved on the specified server location with the desired Image file name, you had explicitly mentioned.
 
Please check with the sample implementation that can be downloaded from the following link containing the modified FCExporter.aspx component.
[Note: This is a modified file and is not the same which is included in the Download Package.]
 
Hope this helps. :)

Share this post


Link to post
Share on other sites

 

Hi,

 

Please note that FusionCharts supports only server-side export when exporting the JavaScript charts. But the "FCExporter.aspx" file from the Download package would not be able to assist you in this case as this exports only Flash charts. You would either need to export the JavaScript charts using our public server or set up Batik on your server.

Ref.- http://docs.fusioncharts.com/charts/contents/?exporting-image/ECPureJS.html

 
However, one of our developers internally developed a solution on .Net 4.0 and above & using SharpVectors and a few other assemblies, to export the latest version of FusionCharts XT (v3.3.0 and above), without using Batik library that require PHP server, that had helped us in exporting JavaScript & Flash charts simultaneously.
 
Also, technically this is just same as the native "FCExporter.aspx" component that we provide in the "ExportHandlers" folder of the Download Package, just a little modified, to fit in your requirement.
 
The system requirements to run this modified FCExporter.aspx are:
>> FusionCharts v3.3.0 and above
>> .Net 4.0 framework and above
 
Below, we provide you the detailed implementation with a ready sample for your better understanding.
 
You have a FusionCharts sample with the combination of multiple (Flash and/or JavaScript) charts on the same page, using ASP.Net that you want to export at once and save them on the server. Here we go for the easy solution:
>> Add the reference of all the SharpVectors, Windows.Base & PresentationCore assemblies besides the modified FCExporter.aspx component (as attached)
 
>> Modify "FCExporter.aspx.cs" file to save the exported images on the specified server location, as explained here
 
>> Modify in the Web.Config file (to prevent error while POST of SVG data string):
<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0"/>
</system.web>
</configuration>
 
>> Add the following attributes in all the XML files for the configurations:
<chart ... exportEnabled='1' exportAtClient='0' exportAction='save' exportHandler=’…/Path/FCExporter.aspx' exportFilename=’ImageFileName’>
 
>> Initiate export from JavaScript so that all the charts in the page are exported on button click, using this additional code snippet.
function exportCharts() {
initiateExport = true;
for (var chartRef in FusionCharts.items) {
//alert(chartRef);
if (FusionCharts.items[chartRef].exportChart) {
FusionCharts.items[chartRef].exportChart({ "exportFormat": "JPG" });
}
...
<input type="button" value="Export Charts" onclick="exportCharts()" />
 
Now, on button-click, you will find all the (JavaScript and/or Flash) charts rendered on a single page would be exported simultaneously as images and get saved on the specified server location with the desired Image file name, you had explicitly mentioned.
 
Please check with the sample implementation that can be downloaded from the following link containing the modified FCExporter.aspx component.
[Note: This is a modified file and is not the same which is included in the Download Package.]
 
Hope this helps. :)

 

 

Hi 

 

I am trying to export pure javascript charts too and the solution you have provided has been going very well form me, except for one detail.

 

When I export there seem to be problems with accents encoding in all export formats.

 

For example, I have the following pie 3d chart:

 

 

post-62880-0-93959700-1406835447_thumb.jpg

 

but when i export the chart it shows as follow:

 

post-62880-0-35085400-1406835458_thumb.jpg

 

 

 

It happens in all formats in which I export, as you can see in exported version a "?" symbol is shown instead of special characters We use in latin america like "á" or "ñ"

 

 

I hope you can help mw with this issue

 

Thanks,

 

Fernando

Edited by fespin5

Share this post


Link to post
Share on other sites

Hi 

 

I am trying to export pure javascript charts too and the solution you have provided has been going very well form me, except for one detail.

 

When I export there seem to be problems with accents encoding in all export formats.

 

For example, I have the following pie 3d chart:

 

 

attachicon.gifpiechart.JPG

 

but when i export the chart it shows as follow:

 

attachicon.gifpiechartexported.JPG

 

 

 

It happens in all formats in which I export, as you can see in exported version a "?" symbol is shown instead of special characters We use in latin america like "á" or "ñ"

 

 

I hope you can help mw with this issue

 

Thanks,

 

Fernando

Hi,

 

Could you please provide us with the relevant XML/JSON data so that we might test it?

 

Also, could you please remove the "exportHandler" attribute and export the chart via our public server and see if this helps?

 

Awaiting your response.

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