Question

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 version 3.3.1-sr2.19840 of FusionCharts.js

Was it helpful?

Solution

It seems that you are using the export handler that is designed for exporting Flash charts only. For exporting JavaScript charts, you would need to setup export separately.

The .NET export handler is not yet equipped to handle JavaScript charts. Having said that, you are not out of luck yet. There are two options you still have:

  1. Use pure server-side rendering to generate chart image - http://blog.fusioncharts.com/2013/03/how-to-save-charts-as-images-at-server-side/

  2. Use the CodePlex SVG rendering engine for .NET after sending the chart's SVG data to server - http://svg.codeplex.com (You can get a chart's SVG string, even on IE, using chartInstance.toSVGString())

Note that if you are using PHP export handler, it can handle both flash and javascript export using the same export handler as mentioned in the documentation article - http://docs.fusioncharts.com/charts/contents/exporting-image/ECPureJS.html

OTHER TIPS

Try adding following 2 attributes to your chart definition:

exportAtClient='0' exportAction='download'

This should make sure that export handler is being used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top