MatB

Change Xml Data Source With Javascript

Recommended Posts

I've read through the examples showing how it is possible to update the data source URL using JavaScript, but it's not working for me. Instead, I get the following error in Firebug:

this.setAttribute is not a function

 

I have created the initial Gantt chart using the registerWithJS option and setting debugMode show that the correct chart is registered with external script. The initial chart loads perfectly.

 

The JavaScript I'm using is very simple at this stage. This is in the <HEAD>

function renderChart() {
	var chartObj = FusionCharts("Gantt1");
	chartObj.setDataURL("gantt_data.php?d=Civils");
}

 

This is in the body:

var Gantt = new FusionCharts("../lib/FusionWidgets/Charts/Gantt.swf", "Gantt1", "1000", "800", "1", "1");
Gantt.setDataURL("gantt_data.php?d=Rail");
Gantt.render("GanttDiv");

 

Currently, the renderChart function is called by clicking a button.

 

Any ideas why this isn't working?

 

Thanks

Share this post


Link to post
Share on other sites

Hi. Thanks for your help. I've now managed to get this working.

 

The problems was due to me using the FusionCharts.js that is supplied with the FusionWidgets package, rather than the FusionCharts.debug.js supplied with FusionCharts.

 

Are these supposed to be different?

 

Regards,

Mat

Share this post


Link to post
Share on other sites

Hi,

 

FusionCharts.js/FusionCharts.debug.js which is present in FusionCharts.v3.2.x or PowerCharts v3.2.1 pack is a newly built JavaScript class to load and add various functionality to charts in FusionCharts and PowerCharts 3.2.x packs.

 

However, since, FusionWidgets pack is not yet 3.2, it retains the old FusionCharts.js which was taken from FusionCharts v3.1.1.

 

Hence, the difference. However, FusionWidgets can be loaded using the latest js provided in FusionCharts/PowerCharts v3.2.1 without any issue. But, so far the use of JavaScript API is concerned, you need to stick to the API of FusionWidgets.

 

Could you please confirm, if the solution provided by Ayan has helped?

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

We are glad to know that you have managed to solve your problem.

 

Keep FusionCharting!biggrin.gif

Share this post


Link to post
Share on other sites

Hi Angshu,

I am getting the same problem.

setChartAttribute doesn't work with Fusioncharts.js which we got with fusionwidgets enterprise .

I need to dynamically change the color of chart based on a value .

Surprisingly it started working when i replaced it with FusionCharts.debug.js but then ,

with fusionwidgets i have to use realtimecharts, so FusionCharts.debug.js renders duplicate charts ( I seriously have no idea why, I am using a java wrapper though) and creates problem in using feedData method for realtime update.

 

Please help as in following area :

1. How do I change a chartAttribute like bgcolor, caption in fusionwidgets, using fusionchart.js .it has to be done dynamically not by providing xml again. (I get the error as this.setAttribute is not an attribute, i am using RealTimeArea.swf)

2.if I use fusioncharts.debug.js , it renders chart id as 'chartobject-1' not the id as i give. So i m unable to get ids , which i will be generating and keeping track of in my application.

 

Ultimate solution would be point #1. :rolleyes:

 

Thanks a lot in advance.

Share this post


Link to post
Share on other sites

Hi,

 

FusionCharts.js/FusionCharts.debug.js which is present in FusionCharts.v3.2.x or PowerCharts v3.2.1 pack is a newly built JavaScript class to load and add various functionality to charts in FusionCharts and PowerCharts 3.2.x packs.

 

However, since, FusionWidgets pack is not yet 3.2, it retains the old FusionCharts.js which was taken from FusionCharts v3.1.1.

 

Hence, the difference. However, FusionWidgets can be loaded using the latest js provided in FusionCharts/PowerCharts v3.2.1 without any issue. But, so far the use of JavaScript API is concerned, you need to stick to the API of FusionWidgets.

 

Hope this helps. :rolleyes:

Share this post


Link to post
Share on other sites

Many Thanks Sanjukta ,

That means , I can not use Fusionwidgets for something like http://www.fusioncharts.com/docs/JavaScript/JS_ChangeChartProperties.html ?

Because when I am doing so, I get an Error in JS saying that setChartAttribute is not a method.

can you please verify and let me know, if this is really a case.

I will have to look for other options of updating the chart, which totally negates the dynamic beaviour of fusionwidgets.

 

Your post above was a geat help in understanding things.. Thanks Again.

Share this post


Link to post
Share on other sites

Hi,

 

You are welcome. :)

 

But I am afraid, FusionWidgets does not support the "setChartAttribute" function, as of now. :)

 

However, glad to let you know that various new attributes, functions and features would be supported by the next upgraded version of FusionWidgets, i.e, FusionWidgets v3.2.

 

We are unable to commit any timeline for this as we are working on it. We shall keep you updated on the advancement.

 

Thank you for your continued patience and patronage.

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