damiencorpataux / jquery-smokeping-zoom

jQuery javascript plugin for zooming smokeping graphs, standalone.
0 stars 0 forks source link

Zooming on one graph affects another (not sync'ed graphs case) #4

Closed damiencorpataux closed 10 years ago

damiencorpataux commented 10 years ago

When using the plugin on multiple graphs, zooming on a graph messes up the others graph start/end.

Use case:

damiencorpataux commented 10 years ago

It seems that the plugin data is somehow shared. Which should not.

A fix would be not to store start/end values in the plugin data. But this solution is not acceptable, because plugin data should not be shared amongst elements.

Investigation needed.

damiencorpataux commented 10 years ago

Well, obviously the plugin data object is shared amongst the elements that where instanciated together, ie.

// These share the same data object
$($('img').splice(0,3)).zoomy({connector:'smokeping'});
// This (it's alone) share the object data with itself
$($('img').splice(-1)).zoomy({connector:'smokeping'});

Therefore, we cannot store start and end in the plugin data because it has to be different for each element (even if initialized together as shown above).

Edit: after a short test, it seems that the data object is not shared. There must be a typo or bug in code. Try to rewrite plugin base and track this issue along the way.

damiencorpataux commented 10 years ago

SIMPLY MOVE THE DATA OBJECT CREATION INSIDE THE RETURN EACH LOOP, sorry for screaming.

The data object is created once and then REFERENCED by the given dom elements. That's why they act as static property. Dumbly.

https://github.com/damiencorpataux/jquery-smokeping-zoom/blob/9dafe9b9530ba030934addd90d0ed8190cabefe0/zoomy.js#L63