Sign in to follow this  
P51DAce

Jquery/js Animation

Recommended Posts

Is there a way to turn off animation from JQuery/JS? I noticed that I can turn it off in my json by adding

 

"animation":"0"

 

to chart. But, I'd like to turn animation from javascript or JQuery off before I do a refresh, so I'm trying something like:

function updateChart()
{
 $("#chartContainer").attrFusionCharts({"animation":"0"});
 $("#chartContainer").updateFusionCharts({dataSource: 'data.json', dataFormat: "jsonurl"});
}

 

but it still is animating. Any thoughts?

 

Thanks!

Edited by P51DAce

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,

 

Updating chart attributes without refreshing the chart is not possible.

 

You can explicitly apply "animation":"0" in the JSON.

Share this post


Link to post
Share on other sites

Is there a way to turn off animation from JQuery/JS? I noticed that I can turn it off in my json by adding

 

"animation":"0"

 

to chart. But, I'd like to turn animation from javascript or JQuery off before I do a refresh, so I'm trying something like:

function updateChart()
{
 $("#chartContainer").attrFusionCharts({"animation":"0"});
 $("#chartContainer").updateFusionCharts({dataSource: 'data.json', dataFormat: "jsonurl"});
}

 

but it still is animating. Any thoughts?

 

Thanks!

 

Hi,

 

I have just created a small code snippet for you to disable chart animation when a chart is updated.

 

/* 
INFO: Rendered event is raised only once when the chart is rendered for the first time
	and not when chart data is updated 

The statement below binds the "rendered" event 
and the code inside the event-listener binds "BeforeDataUpdate" event.

The "BeforeDataUpdate" even-listener disables animation for all subsequent updates.
This works in 2 steps:
	STEP 1 - It checks if the updated data contains any attribute to control animation. 
		If found, it changes the attribute's value to 0 i.e., disable animation.
	STEP 2 - If it does not find "animation" attribute in the data, it adds animation="0" .
*/
$("#chartContainer").bind( "fusionchartsrendered", function (e, args) { 
$("#chartContainer").bind( "fusionchartsbeforedataupdate", function (e, args) { 

       // stop on error
	if (args.error) {
		return;
	}

	// search for animation attribute and replace it's value with 0 (disabled)
	// Note: This statement force-disable animation even if the data contains settings to enable animation
	//       In case, one needs to stop this behaviour, comment this statement

	args.data = args.data.replace(/(\<chart[^>]+? animation[\s\r\n\t]*=[\s\r\n\t]*)(['"])[^'"]+?['"]/i, "$1$20$2");


	// when the "animation" attribute is not present in the data, add animation="0"

	if (args.data.search (/(\<chart[^>]+? animation[\s\r\n\t]*=[\s\r\n\t]*)(['"])/i) < 0) {
		args.data = args.data.replace(/(\<chart)/, '$1 animation="0"');
	}
}); 								

});

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