abbottmw

[idea] Plugin Thoughts (Binding One Chart To Another)

Recommended Posts

I was just thinking of something with the Jquery Plugin. Im not sure if this is doable, but I was thinking about maybe a way to bind a chart to another chart, so for example if chart A changes, it will also update the second chart that is bound it.

 

 

 

Currently there are events that are fired on the charts and you pass in the DOMId, and have to do a test on if the DOMId is "chartxxx" do something.

 

 

 

I just thought it may be possible to enhance the events and maybe bind two charts together...etc.

 

 

 

Hope that makes sense.

 

 

 

-Matthew

Share this post


Link to post
Share on other sites

Greetings Matthew,

 

 

 

Nice to hear from you again. :)

 

 

 

We are planning to fully integrate FusionCharts native events with jQuery events and in the process, this idea seems promising.

 

 

 

What if a code like this works:

 

jQuery('#myDiv:fusioncharts').bind('update', function($1) {

   jQuery('#myOtherDiv:fusioncharts').updateFusionCharts({

       data: 'myNewData.xml'

   });

});

 

 

 

Instead of the native events that FusionCharts generate FC_Rendered, etc... we want users to bind like:

 

jQuery('#myDiv:fusioncharts').bind('render', function() {

   // do stuffs here

});

 

 

 

And perhaps, will also have a way to raise global events... for earlier users of FC_Rendered. What is your take on global events? Should we do:

 

$(window).bind('fusioncharts.render', function() {

   // do stuffs here

});

 

or maybe do an aggregate alternative to work on events for ALL charts like:

 

$(':fusioncharts').bind('render', function() {

   // do stuffs here

});

Share this post


Link to post
Share on other sites

Im leaning towards the second option that you suggested for global events with the

$(':fusioncharts')....

I also do like what you have come up with with the update bindings. 

What about the real-time charts?  If the data hasnt changed, will the update event still fire?

-Matthew

Share this post


Link to post
Share on other sites

Now as you see, here stands one issue. FusionCharts, as of now, does not have a native event fired on update. The jQuery plugin will manually trigger the update when updateFusionCharts() function is used, hence we will try to standardise something. Perhaps, we will raise the event even when data is not changed and keep a "datachanged" flag as parameter to the event handler. But this may prove to be tough to implement.

 

 

 

The $(':fusioncharts') method will not require much of an implementation from our plugin perspective as ":fusioncharts" selector is already present and events will propagate through to the top.

 

 

 

But, we have tested that this method is not performance oriented and has a bad profile when used with significant number of charts. On the other hand, Manually triggering $(window).trigger() performs better. Nevertheless, if the loss is not that huge, we will opt for the one that is more usable!

 

 

 

 

 

PS: Yes... there is an undocumented updateFusionCharts function in our jQuery plugin which you can experiment with. It does NOT work with jQury 1.4.x (due to limitation in jQuery), but works with 1.3.2 and hence we do not recommend to use it as of now. The code updateFusionCharts({ type: 'Pie3D' }); will change only the chart type of an existing chart... similarly updateFusionCharts({ data: 'mynewdata.xml' }); will just update the chart with new data and without re-rendering!

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