Sign in to follow this  
Shib

Issue With Example Code For Setchartattribute

Recommended Posts

Hi,

 

I am new to FC, I just downloaded latest trial version. While I am trying to follow an example to change chart attribute on the fly(http://www.fusioncharts.com/docs/JavaScript/JS_ChangeChartProperties.html), but it is not working for me.

 

Here is my html code(Only thing I change here is location of js and data.xml):

 

 

<html>

<head>

<title>Update Chart data</title>

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

</script>

</head>

<body>

<center>

<div id="chartContainer">FusionCharts will load here!</div>

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

 

var myChart = new FusionCharts( "FusionCharts/Column2D.swf",

"myChartId", "300", "240", "0", "1" );

myChart.setXMLUrl("Data.xml");

myChart.render("chartContainer");

 

function changeAttribute()

{

// get chart reference

var chartReference = FusionCharts( "myChartId" );

 

// change palette, palette colors and set glass effect to chart

chartReference.setChartAttribute( { "palette" : "2", paletteColors : "ACBF72", useRoundEdges : 1 } );

}

// -->

</script>

 

<input type="button" onClick="changeAttribute();" value="Change Chart Theme" >

</center>

</body>

</html>

 

 

 

And Data.xml:

 

 

<chart caption="Yearly Sales Summary" numberPrefix="$" xAxisName="Year" yAxisName="Amount">

<set label="2005" value="1735.08" />

<set label="2006" value="1335.08" />

<set label="2007" value="1582.08" />

<set label="2008" value="1555.08" />

</chart>

 

 

It renders the chart on first load, but nothing happens after clicking the change button. Please let me know what I am doing wrong.

Share this post


Link to post
Share on other sites

What I also found if replace myChart.setXMLUrl("Data.xml") with myChart.setXMLData(MY XML)..it works. Is there something with free version? Please advice.

thanks

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum! smile.gif

You seem to be using Data URL method (provide data to chart from files or streams) to provide chart data. Many browsers restrict JavaScript from accessing local file system owing to security reasons. When running locally, however, if you provide the data as string (using the Data String method), it works fine.

 

I am afraid, we are unable to replicate the issue, as the code is working fine from our end.

 

Please find the screenshot attached for your reference.

post-10517-0-03913500-1319001700_thumb.png

post-10517-0-84982900-1319001714_thumb.png

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