Sign in to follow this  
abdfahim

Use variable in Javascript function for render

Recommended Posts

Hi,

 

How to use variables as params in core JS function for rendering chart?

 

FusionCharts.ready(function () {
var myChart = new FusionCharts({
 "type": "zoomline",
 "renderAt": "mydivid",
 "width": "600",
 "height": "400",
 "dataFormat": "xml",
 "dataSource": "xml_code"
});
myChart.render();
});

I want to use JS variable divid and strxml as "renderAt" and "dataSource" respectively. Some thing like below

var myblocks = document.getElementsByName("alldivs");
var myxml = "XML OUTPUT FROM AJAX REQUEST";
FusionCharts.ready(function () {
var myChart = new FusionCharts({
 "type": "zoomline",
 "renderAt": myblocks[0].id,
 "width": "600",
 "height": "400",
 "dataFormat": "xml",
 "dataSource": myxml
});
myChart.render();
});
Edited by abdfahim

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