Kogie / flot

Automatically exported from code.google.com/p/flot
0 stars 0 forks source link

jQuery 1.8 compatibility #735

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
jquery.flot.pie works perfectly with jQuery 1.7.2, I had interactive hover 
enabled. After upgrading to jQuery 1.8, however, it shows a quarter of a pie. 
All the interactions were gone. I was able to replicate the issue on FF 14.0.1 
and the latest Chrome. No error in the console.

Original issue reported on code.google.com by ChinagoI...@gmail.com on 11 Aug 2012 at 3:07

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 13 Aug 2012 at 2:50

GoogleCodeExporter commented 8 years ago
Confirmed.  I see the same thing, haven't had a chance to see if I can figure 
it out.

Original comment by rob...@accettura.com on 17 Aug 2012 at 4:58

GoogleCodeExporter commented 8 years ago
I have found the issue and will post a fix shortly.  

In function setupPie() on line 187

 187   function setupPie()
 188               {
 189                       legendWidth = target.children().filter('.legend').children().width();

legendWidth is not being defined with the new jquery 1.8 library.

Original comment by andrew.theiss@gmail.com on 17 Aug 2012 at 5:16

GoogleCodeExporter commented 8 years ago
Its only a temporary fix but you can grab the legend width manually as the 
.width() does not properly go into the object context and return the width.

    legendWidth = target.children().filter('.legend').children();
    legendWidth = legendWidth.context.width;

This allows for most functionality except centering inside the container 
(however Im not using that so this work around is all I need)

Hope it helps for the time being even though a real solution is still needed.

Original comment by andrew.theiss@gmail.com on 17 Aug 2012 at 6:29

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
jquery.flot.js line 2265: $('<div style="position:absolute;width:' + 
div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + 
c + ';"> </div>').prependTo(legend).css('opacity', 
options.legend.backgroundOpacity);
Should be cleaner to call .width(div.width())

Original comment by ChinagoI...@gmail.com on 18 Aug 2012 at 3:30

GoogleCodeExporter commented 8 years ago
Has a bug been filed against jQuery?

Original comment by rob...@accettura.com on 20 Aug 2012 at 3:45

GoogleCodeExporter commented 8 years ago
jquery.flot.pie.js line 189: target.children().filter('.legend') returns an 
empty set on Chromium 18.

Original comment by ChinagoI...@gmail.com on 21 Aug 2012 at 8:44

GoogleCodeExporter commented 8 years ago
Hmm.  target.children = [canvas.base, canvas.overlay].

I don't see a .legend.  Looking at target itself, that returned array seems 
correct.  I'm guessing legend isn't being set.

Maybe a problem with flot's insertLegend vs. the flot.pie?

Original comment by rob...@accettura.com on 21 Aug 2012 at 2:20

GoogleCodeExporter commented 8 years ago
In jquery 1.7 the function for legendWidth returns null if no legend exists
This changed in jquery 1.8, now it returns undefined
From a theoretical standpoint, the new behaviour is more correct than the old 
one.
But in calculations handling of null is different to undefinded.
PIE plugin is based on null.

Simple workaround is to add a line after line 189 like this:
if(!legendWidth) legendWidth = null;

Original comment by juergenm...@googlemail.com on 22 Aug 2012 at 8:47

GoogleCodeExporter commented 8 years ago
This seems reasonable.  Can this be committed and made official.

(I hate to patch my code vs updating to latest).

Original comment by rob...@accettura.com on 24 Aug 2012 at 5:39

GoogleCodeExporter commented 8 years ago
Possibly related to:
http://bugs.jquery.com/ticket/12283

This appears to be fixed when using jQuery 1.8.1

Original comment by rob...@accettura.com on 5 Sep 2012 at 3:49

GoogleCodeExporter commented 8 years ago
I went crazy with this (I had jQuery 1.8.0).
I upgraded to 1.8.1 and the problem was gone! :D

Original comment by ilo...@gmail.com on 18 Sep 2012 at 9:42