Sign in to follow this  
Rahul Kumar

Problem with export chart to Pdf and Gif On Fusion Chart V3

Recommended Posts

i am getting data from database and creating XMLString, Please see the below code

//Aspx page

<%

@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Master/CSSMaster.master"

CodeFile="Snapshot.aspx.cs" Inherits="_Default" Theme="CSS" %>

<

asp:Content ID="MyHomeContent" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<script language="Javascript" src="../FusionCharts/FusionCharts.js" type="text/javascript"></script>

<script language="Javascript" src="../FusionCharts/FusionChartsExportComponent.js"

type="text/javascript"></script>

<

script type="text/javascript">

//Define a function, which will be invoked when user clicks the batch-export-initiate button

function initiateExport() {

myExportComponent.BeginExport();

}

</script>

<

asp:Panel ID="pnlDashBoard" runat="server" BackColor="#E8E8E8" CssClass="scrollSnapshot"

ScrollBars="Both">

<div style="padding: 5px; padding-left: 5px;">

<

input type='button' onclick="initiateExport();" value="Begin batch export" />

<div id="fcexpDiv" align="center">

FusionCharts Export Handler Component

</div>

</td>

<script type="text/javascript">

//Initialize Batch Exporter with DOM Id as fcBatchExporter

var myExportComponent = new FusionChartsExportObject("fcBatchExporter", "../FusionCharts/FCExporter.swf");

//Add the charts to queue. The charts are referred to by their DOM Id.

myExportComponent.sourceCharts = [

'myChartId1', 'myChartId2', 'myChartId3', 'myChartId4'];

//------ Export Component Attributes ------//

//Set the mode as full mode

myExportComponent.componentAttributes.fullMode =

'1';

//Set saving mode as both. This allows users to download individual charts/ as well as download all charts as a single file.

myExportComponent.componentAttributes.saveMode =

'both';

//Show allowed export format drop-down

myExportComponent.componentAttributes.showAllowedTypes =

'1';

//Cosmetics

//Width and height

myExportComponent.componentAttributes.width =

'350';

myExportComponent.componentAttributes.height =

'140';

//Message - caption of export component

myExportComponent.componentAttributes.showMessage =

'1';

myExportComponent.componentAttributes.message =

'Click on button above to begin export of charts. Then save from here.';

//Render the exporter SWF in our DIV fcexpDiv

myExportComponent.Render(

"fcexpDiv");

</script>

</tr>

</div>

<table id="tblDasdboard" runat="server">

<tr>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td>

<div id="dvColoumChart" class="graph">

<%

=CreateColoumChart()

%>

</div>

</td>

<td>

<div id="dvLineChart" class="graph">

<%

=CreateLineChart()

%>

</div>

</td>

</tr>

<tr>

<td>

<div id="dvLineColoumChart" class="graph">

<%

=CreateLineColoumChart()

%>

</div>

</td>

<td>

<div id="dvColoumdChart" class="graph">

<%

=CreateColoumdChart()

%>

</div>

</td>

</tr>

</table>

</asp:Panel>

</

asp:Content>

 

//Aspx.cs Page

I had pasted only the method to draw chart

public

string CreateColoumChart()

{

//Checking the Dataset is null or Not

if (dsGraph != null && dsGraph.Tables.Count > 0)

{

if (dsGraph.Tables[0].Rows.Count > 0)

{

//XML Data to draw Graph

strXML =

"<chart caption='Credit Line Vs WA CB Score' xAxisName='Credit Line' shadowAlpha='0'" +

" showValues='1' yAxisName='WA CB Score' showBorder='0' decimals='0' " +

" chartLeftMargin='2' chartRightMargin='2' chartTopMargin='2' chartBottomMargin='2' " +

" formatNumberScale='1' labelDisplay='Rotate' slantLabels='1' useRoundEdges='1' canvasBgColor='CCCCCC' " +

" exportEnabled='1' exportAtClient='1' exportHandler='fcBatchExporter' >";

//loop through each row of the dataset

foreach (DataRow drGroup in dsGraph.Tables[0].Rows)

{

strXML = strXML +

String.Format("<set label='{0}' value='{1}' />", drGroup["bucket_text"].ToString(), drGroup["WA_CB_SCR"].ToString());

}

strXML +=

"<styles><definition><style name='TFSCaptionFontStyle' type='font' face='Verdana' size='14' color='CE1A11' bold='1' letterSpacing='3' /><style name='TFSSubcaptionFontStyle' type='font' face='Verdana' size='12' color='CE1A11' bold='1' letterSpacing='2' /><style name='TFSXYAxisFontStyle' type='font' face='Verdana' size='12' color='CE1A11' bold='1' letterSpacing='1'/><style name='TFSXAnimationStyle' type='animation' param='_xScale' start='0' duration='1' shadowAlpha='0' /><style name='TFSYAnimationStyle' type='animation' param='_yScale' start='0' duration='1' shadowAlpha='0'/></definition><application><apply toObject='Caption' styles='TFSCaptionFontStyle' /><apply toObject='subcaption' styles='TFSSubcaptionFontStyle' /><apply toObject='Canvas' styles='TFSXAnimationStyle, TFSYAnimationStyle' /><apply toObject='yAxisName' styles='TFSXYAxisFontStyle' /><apply toObject='xAxisName' styles='TFSXYAxisFontStyle' /></application></styles>";

strXML +=

"</chart>";

strXML = strXML.Replace(

"%", "%25");

strXML = strXML.Replace(

"&", "%26");

strXML = strXML.Replace(

"#", "%23");

strXML = strXML.Replace(

"+", "%2B");

}

}

return FusionCharts.RenderChart("../FusionCharts/Column2D.swf", "", strXML, "myChartId1", "590", "320", false, false);

}

In the same way i am getting data for all the 4 charts.

all the swf and js file are placed properly, When i click on button nothing is happening.

I can able to draw the chart but Export is not working.

Please help me.

Share this post


Link to post
Share on other sites

Hi,

 
Could you please enable registerWithJS parameter and try again? To enable parameter please see the code below:
 

return FusionCharts.RenderChart("../FusionCharts/Column2D.swf", "", strXML, "myChartId1", "590", "320", false, true);

}

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