From caf1c7c9a5305e93f6889540cfdf4039eb485913 Mon Sep 17 00:00:00 2001 From: Cedric Le Roux Date: Sat, 15 Jun 2013 01:09:18 -0700 Subject: [PATCH 01/42] Fixing Issue 686: Tooltip bug --- examples/interacting/index.html | 38 +++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/examples/interacting/index.html b/examples/interacting/index.html index 15b2437..982aa2f 100644 --- a/examples/interacting/index.html +++ b/examples/interacting/index.html @@ -41,20 +41,15 @@ } }); - function showTooltip(x, y, contents) { - $("
" + contents + "
").css({ - position: "absolute", - display: "none", - top: y + 5, - left: x + 5, - border: "1px solid #fdd", - padding: "2px", - "background-color": "#fee", - opacity: 0.80 - }).appendTo("body").fadeIn(200); - } + $("
").css({ + position: "absolute", + display: "none", + border: "1px solid #fdd", + padding: "2px", + "background-color": "#fee", + opacity: 0.80 + }).appendTo("body"); - var previousPoint = null; $("#placeholder").bind("plothover", function (event, pos, item) { if ($("#enablePosition:checked").length > 0) { @@ -64,20 +59,14 @@ if ($("#enableTooltip:checked").length > 0) { if (item) { - if (previousPoint != item.dataIndex) { - - previousPoint = item.dataIndex; - - $("#tooltip").remove(); - var x = item.datapoint[0].toFixed(2), + var x = item.datapoint[0].toFixed(2), y = item.datapoint[1].toFixed(2); - showTooltip(item.pageX, item.pageY, - item.series.label + " of " + x + " = " + y); - } + $("#tooltip").html(item.series.label + " of " + x + " = " + y) + .css({top: item.pageY+5, left: item.pageX+5}) + .fadeIn(200); } else { - $("#tooltip").remove(); - previousPoint = null; + $("#tooltip").hide(); } } }); @@ -97,7 +86,6 @@ - From 13cedbc8970d2a32844b64cf044b8c500737005f Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Wed, 3 Jul 2013 13:57:20 +0200 Subject: [PATCH 02/42] Change [olson] to http link GitHub doesn't render ftp links for some reason ([security?][1]). [1]: https://github.com/mojombo/jekyll/issues/373#issuecomment-15025728 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4de7bde..a8f7064 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,4 @@ examples/axes-time-zones/index.html. [excanvas]: http://code.google.com/p/explorercanvas/ [flashcanvas]: http://code.google.com/p/flashcanvas/ [timezone-js]: https://github.com/mde/timezone-js -[olson]: ftp://ftp.iana.org/tz/ +[olson]: http://ftp.iana.org/time-zones From 488fbc8df57eb78208bf6e950d8593d6cf1e1370 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Wed, 3 Jul 2013 14:31:56 +0200 Subject: [PATCH 03/42] Fix typo in API.md --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index a9aaf17..415e84b 100644 --- a/API.md +++ b/API.md @@ -544,7 +544,7 @@ You can see a timestamp like this alert((new Date()).getTime()) ``` -There are different schools of thought when it comes to diplay of +There are different schools of thought when it comes to display of timestamps. Many will want the timestamps to be displayed according to a certain time zone, usually the time zone in which the data has been produced. Some want the localized experience, where the timestamps are From 5a0372159a3c9e17e134f2997799b03a37d9ed37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20C=C3=B4t=C3=A9?= Date: Thu, 18 Jul 2013 22:28:10 -0400 Subject: [PATCH 04/42] Always remove the tick text in drawAxisLabels() regardless of axis settings. Since a plot may be redrawn after removing ticks or hiding the axis, the tick text should always be removed before determining if there are ticks to draw. --- jquery.flot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 13455bd..52c2d31 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2100,9 +2100,6 @@ Licensed under the MIT license. function drawAxisLabels() { $.each(allAxes(), function (_, axis) { - if (!axis.show || axis.ticks.length == 0) - return; - var box = axis.box, legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis", layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles, @@ -2111,6 +2108,9 @@ Licensed under the MIT license. surface.removeText(layer); + if (!axis.show || axis.ticks.length == 0) + return; + for (var i = 0; i < axis.ticks.length; ++i) { tick = axis.ticks[i]; From df32626007bde06effd455ba2318b73896b49d82 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Fri, 19 Jul 2013 08:28:27 -0400 Subject: [PATCH 05/42] Added a comment for posterity. --- jquery.flot.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jquery.flot.js b/jquery.flot.js index 52c2d31..3bedcb5 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2106,6 +2106,10 @@ Licensed under the MIT license. font = axis.options.font || "flot-tick-label tickLabel", tick, x, y, halign, valign; + // Remove text before checking for axis.show and ticks.length; + // otherwise plugins, like flot-tickrotor, that draw their own + // tick labels will end up with both theirs and the defaults. + surface.removeText(layer); if (!axis.show || axis.ticks.length == 0) From d94c1b75bc330c1566bc82e9f463c230381e27b6 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Fri, 19 Jul 2013 08:33:26 -0400 Subject: [PATCH 06/42] Updated credits for the flot-tickrotor fix. --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 3c5407c..55be75c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,10 @@ when the grid had a left/right border width of zero. (reported by Teq1, fix researched by ryleyb, issue #1056) + - Fixed an unexpected change in behavior that resulted in duplicate tick + labels when using a plugin, like flot-tickrotor, that overrode tick labels. + (patch by Mark Cote, pull request #1091) + ## Flot 0.8.1 ## From 2ce1139cf7ac97c3804c32f30154541a606a19c9 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 11:40:43 -0400 Subject: [PATCH 07/42] Fix highlights for right-aligned bars. Support for right-aligned bars was never added to the hover or highlight code; only the actual bar drawing. We need to replicate that in the other two places as well. Resolves #1093. --- jquery.flot.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 3bedcb5..500e690 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2801,8 +2801,22 @@ Licensed under the MIT license. } if (s.bars.show && !item) { // no other point can be nearby - var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2, - barRight = barLeft + s.bars.barWidth; + + switch (s.bars.align) { + case "left": + barLeft = 0; + break; + case "right": + barLeft = -s.bars.barWidth; + break; + case "center": + barLeft = -s.bars.barWidth / 2; + break; + default: + throw new Error("Invalid bar alignment: " + s.bars.align); + } + + barRight = barLeft + s.bars.barWidth; for (j = 0; j < points.length; j += ps) { var x = points[j], y = points[j + 1], b = points[j + 2]; @@ -3000,7 +3014,21 @@ Licensed under the MIT license. function drawBarHighlight(series, point) { var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(), fillStyle = highlightColor, - barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; + barLeft; + + switch (series.bars.align) { + case "left": + barLeft = 0; + break; + case "right": + barLeft = -series.bars.barWidth; + break; + case "center": + barLeft = -series.bars.barWidth / 2; + break; + default: + throw new Error("Invalid bar alignment: " + series.bars.align); + } octx.lineWidth = series.bars.lineWidth; octx.strokeStyle = highlightColor; From 6a39c5ba11f5cf53a81b59a82b1ead381756fc48 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 11:41:13 -0400 Subject: [PATCH 08/42] Always simply default to center alignment. Throwing an exception was overkill for such a limited-use option; we should reserve those, and the file-size bytes they consume, for serious cases only. --- jquery.flot.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 500e690..a1c97f5 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1218,11 +1218,8 @@ Licensed under the MIT license. case "right": delta = -s.bars.barWidth; break; - case "center": - delta = -s.bars.barWidth / 2; - break; default: - throw new Error("Invalid bar alignment: " + s.bars.align); + delta = -s.bars.barWidth / 2; } if (s.bars.horizontal) { @@ -2609,11 +2606,8 @@ Licensed under the MIT license. case "right": barLeft = -series.bars.barWidth; break; - case "center": - barLeft = -series.bars.barWidth / 2; - break; default: - throw new Error("Invalid bar alignment: " + series.bars.align); + barLeft = -series.bars.barWidth / 2; } var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; @@ -2809,11 +2803,8 @@ Licensed under the MIT license. case "right": barLeft = -s.bars.barWidth; break; - case "center": - barLeft = -s.bars.barWidth / 2; - break; default: - throw new Error("Invalid bar alignment: " + s.bars.align); + barLeft = -s.bars.barWidth / 2; } barRight = barLeft + s.bars.barWidth; @@ -3023,11 +3014,8 @@ Licensed under the MIT license. case "right": barLeft = -series.bars.barWidth; break; - case "center": - barLeft = -series.bars.barWidth / 2; - break; default: - throw new Error("Invalid bar alignment: " + series.bars.align); + barLeft = -series.bars.barWidth / 2; } octx.lineWidth = series.bars.lineWidth; From ef23fd401a66e9870e49cd6a78c03905c98faaa5 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 11:44:58 -0400 Subject: [PATCH 09/42] Updated credits for right-aligned bar fix. --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 55be75c..375777f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,9 @@ labels when using a plugin, like flot-tickrotor, that overrode tick labels. (patch by Mark Cote, pull request #1091) + - Right-aligned bars no longer highlight as though they were center-aligned. + (reported by mihaisdm, issue #1093) + ## Flot 0.8.1 ## From 6dfc581d27b2afccebc73d64d3a662126908bf8f Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 12:19:40 -0400 Subject: [PATCH 10/42] Update inline jquery-resize to the latest version. Resolves #997 and #1081. --- jquery.flot.resize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.flot.resize.js b/jquery.flot.resize.js index 6b2c5d4..44e04f8 100644 --- a/jquery.flot.resize.js +++ b/jquery.flot.resize.js @@ -20,7 +20,7 @@ can just fix the size of their placeholders. * http://benalman.com/about/license/ */ -(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this); +(function($,t,n){function p(){for(var n=r.length-1;n>=0;n--){var o=$(r[n]);if(o[0]==t||o.is(":visible")){var h=o.width(),d=o.height(),v=o.data(a);!v||h===v.w&&d===v.h?i[f]=i[l]:(i[f]=i[c],o.trigger(u,[v.w=h,v.h=d]))}else v=o.data(a),v.w=0,v.h=0}s!==null&&(s=t.requestAnimationFrame(p))}var r=[],i=$.resize=$.extend($.resize,{}),s,o="setTimeout",u="resize",a=u+"-special-event",f="delay",l="pendingDelay",c="activeDelay",h="throttleWindow";i[l]=250,i[c]=20,i[f]=i[l],i[h]=!0,$.event.special[u]={setup:function(){if(!i[h]&&this[o])return!1;var t=$(this);r.push(this),t.data(a,{w:t.width(),h:t.height()}),r.length===1&&(s=n,p())},teardown:function(){if(!i[h]&&this[o])return!1;var t=$(this);for(var n=r.length-1;n>=0;n--)if(r[n]==this){r.splice(n,1);break}t.removeData(a),r.length||(cancelAnimationFrame(s),s=null)},add:function(t){function s(t,i,s){var o=$(this),u=o.data(a);u.w=i!==n?i:o.width(),u.h=s!==n?s:o.height(),r.apply(this,arguments)}if(!i[h]&&this[o])return!1;var r;if($.isFunction(t))return r=t,s;r=t.handler,t.handler=s}},t.requestAnimationFrame||(t.requestAnimationFrame=function(){return t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e,n){return t.setTimeout(e,i[f])}}()),t.cancelAnimationFrame||(t.cancelAnimationFrame=function(){return t.webkitCancelRequestAnimationFrame||t.mozCancelRequestAnimationFrame||t.oCancelRequestAnimationFrame||t.msCancelRequestAnimationFrame||clearTimeout}())})(jQuery,this); (function ($) { var options = { }; // no options From fca41ad5cd93b4f5be2339689bfa46cc823ffd3c Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 12:26:48 -0400 Subject: [PATCH 11/42] Added BeWiBu to credits for the right-aligned bar fix. --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 375777f..d62a2f1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,7 @@ (patch by Mark Cote, pull request #1091) - Right-aligned bars no longer highlight as though they were center-aligned. - (reported by mihaisdm, issue #1093) + (reported by BeWiBu and mihaisdm, issues #975 and #1093) ## Flot 0.8.1 ## From a286f044ef041523fb5df6b1ce9dd5b2b11690ca Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 13:50:18 -0400 Subject: [PATCH 12/42] Draw bars using fillRect instead of paths. This is up to 2x faster and appears to work around issues in Chrome's canvas implementation that sometimes result in bars not being filled. Resolves #915. --- jquery.flot.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index a1c97f5..63d9043 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2544,13 +2544,8 @@ Licensed under the MIT license. // fill the bar if (fillStyleCallback) { - c.beginPath(); - c.moveTo(left, bottom); - c.lineTo(left, top); - c.lineTo(right, top); - c.lineTo(right, bottom); c.fillStyle = fillStyleCallback(bottom, top); - c.fill(); + c.fillRect(left, top, right - left, bottom - top) } // draw outline From e2b9cf8ce06a85360541537b8182a5064a009172 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 22 Jul 2013 14:12:41 -0400 Subject: [PATCH 13/42] Remove the unused offset parameter. The drawBar method was always called with an offset of zero, and I see no other way in which it is currently used. Resolves #382. --- jquery.flot.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 63d9043..9abfda3 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2469,7 +2469,7 @@ Licensed under the MIT license. ctx.restore(); } - function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) { + function drawBar(x, y, b, barLeft, barRight, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) { var left, right, bottom, top, drawLeft, drawRight, drawTop, drawBottom, tmp; @@ -2553,35 +2553,35 @@ Licensed under the MIT license. c.beginPath(); // FIXME: inline moveTo is buggy with excanvas - c.moveTo(left, bottom + offset); + c.moveTo(left, bottom); if (drawLeft) - c.lineTo(left, top + offset); + c.lineTo(left, top); else - c.moveTo(left, top + offset); + c.moveTo(left, top); if (drawTop) - c.lineTo(right, top + offset); + c.lineTo(right, top); else - c.moveTo(right, top + offset); + c.moveTo(right, top); if (drawRight) - c.lineTo(right, bottom + offset); + c.lineTo(right, bottom); else - c.moveTo(right, bottom + offset); + c.moveTo(right, bottom); if (drawBottom) - c.lineTo(left, bottom + offset); + c.lineTo(left, bottom); else - c.moveTo(left, bottom + offset); + c.moveTo(left, bottom); c.stroke(); } } function drawSeriesBars(series) { - function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) { + function plotBars(datapoints, barLeft, barRight, fillStyleCallback, axisx, axisy) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) { if (points[i] == null) continue; - drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth); + drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth); } } @@ -2606,7 +2606,7 @@ Licensed under the MIT license. } var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; - plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis); + plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis); ctx.restore(); } @@ -3017,7 +3017,7 @@ Licensed under the MIT license. octx.strokeStyle = highlightColor; drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, - 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); + function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); } function getColorOrGradient(spec, bottom, top, defaultColor) { From ce3bdb0886b62890c3c1f697f901b263b73d49a6 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Fri, 9 Aug 2013 13:58:27 -0400 Subject: [PATCH 14/42] Fixed autoscale check when using null x/y values. The autoscale check was too broad; it included the case where autoscale was undefined. This resulted in axes not expanding correctly when coordinates at the end of a series had null x or y values. Fixed by narrowing the check to !== false; resolves #1095. --- jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 9abfda3..a545a6e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1131,7 +1131,7 @@ Licensed under the MIT license. if (val != null) { f = format[m]; // extract min/max info - if (f.autoscale) { + if (f.autoscale !== false) { if (f.x) { updateAxis(s.xaxis, val, val); } From bfc5d2ae7fa4487a63a2759d01e41700dff33d32 Mon Sep 17 00:00:00 2001 From: Eric Byers Date: Thu, 29 Aug 2013 14:36:00 -0400 Subject: [PATCH 15/42] Instantiating barLeft/barRight --- jquery.flot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.flot.js b/jquery.flot.js index a545a6e..2855d2e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2791,6 +2791,8 @@ Licensed under the MIT license. if (s.bars.show && !item) { // no other point can be nearby + var barLeft, barRight; + switch (s.bars.align) { case "left": barLeft = 0; From 4bfa801e31396c054d43edf0a028a71d421b9ba6 Mon Sep 17 00:00:00 2001 From: Brian Peiris Date: Wed, 4 Sep 2013 03:00:44 -0400 Subject: [PATCH 16/42] Link to PLUGINS.md --- API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 415e84b..874b439 100644 --- a/API.md +++ b/API.md @@ -1454,7 +1454,7 @@ hooks in the plugins bundled with Flot. case a plot is overwritten by a new plot. If you're writing a plugin that adds extra DOM elements or event handlers, you should add a callback to clean up after you. Take a look at the section in - PLUGINS.txt for more info. + the [PLUGINS](PLUGINS.md) document for more info. ## Plugins ## @@ -1476,7 +1476,7 @@ from the "option" attribute of the plugin. The init function gets a reference to the plot object created and uses this to register hooks and add new public methods if needed. -See the PLUGINS.txt file for details on how to write a plugin. As the +See the [PLUGINS](PLUGINS.md) document for details on how to write a plugin. As the above description hints, it's actually pretty easy. From 6f294cedf68354a86b63b9a0c9817329ea9f5041 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Mon, 9 Sep 2013 22:09:17 +0300 Subject: [PATCH 17/42] Added plot.destroy() method, to properly destruct and release memory of a plot. --- jquery.flot.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jquery.flot.js b/jquery.flot.js index 2855d2e..cbeeb02 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -658,6 +658,23 @@ Licensed under the MIT license. }; }; plot.shutdown = shutdown; + plot.destroy = function () { + shutdown(); + placeholder.removeData("plot").empty(); + + series = []; + options = null; + surface = null; + overlay = null; + eventHolder = null; + ctx = null; + octx = null; + xaxes = []; + yaxes = []; + hooks = null; + highlights = []; + plot = null; + }; plot.resize = function () { var width = placeholder.width(), height = placeholder.height(); From 593cbc5f193c86e6dc2b88e08eaf6b62f499642e Mon Sep 17 00:00:00 2001 From: Craig Oldford Date: Fri, 13 Sep 2013 13:53:40 -0300 Subject: [PATCH 18/42] Fixed a bug where plotting a chart crashes if the placeholder doesn't have a font size --- jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 2855d2e..684b207 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -737,7 +737,7 @@ Licensed under the MIT license. var i, axisOptions, axisCount, fontDefaults = { style: placeholder.css("font-style"), - size: Math.round(0.8 * (+placeholder.css("font-size").replace("px", "") || 13)), + size: Math.round(0.8 * (placeholder.css("font-size") ? +placeholder.css('font-size').replace("px", "") : 13)), variant: placeholder.css("font-variant"), weight: placeholder.css("font-weight"), family: placeholder.css("font-family") From 7deacc9ed16418c40f2d06260f1a8eb505923e05 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sat, 14 Sep 2013 17:44:18 -0700 Subject: [PATCH 19/42] Clip the pie center only when using offset auto. If an explicit numeric offset was provided, we should not override it. The clipping is only meant to apply to the case where the center is moved to make room for the legend in 'auto' mode, anyway. --- jquery.flot.pie.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index 6553c8e..a4b538a 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -293,16 +293,15 @@ More detail and specific examples can be found in the included HTML file. } else { centerLeft -= legendWidth / 2; } + if (centerLeft < maxRadius) { + centerLeft = maxRadius; + } else if (centerLeft > canvasWidth - maxRadius) { + centerLeft = canvasWidth - maxRadius; + } } else { centerLeft += options.series.pie.offset.left; } - if (centerLeft < maxRadius) { - centerLeft = maxRadius; - } else if (centerLeft > canvasWidth - maxRadius) { - centerLeft = canvasWidth - maxRadius; - } - var slices = plot.getData(), attempts = 0; From 6cd3cb9887668bdbe764719c789c9814f53a3aa2 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 15 Sep 2013 12:30:27 -0700 Subject: [PATCH 20/42] Prevent options from becoming global. The pie plugin was a little too clever in its use of closures. In processDatapoints it set canvas, target, and options for use in other functions. Since options was not declared this meant that it became global. Pages containing multiple pie plots therefore saw a range of weird effects resulting from earlier plots receiving some of the options set by later ones. Resolves #1128, resolves #1073, resolves #1055. --- jquery.flot.pie.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index a4b538a..9915863 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -69,6 +69,7 @@ More detail and specific examples can be found in the included HTML file. var canvas = null, target = null, + options = null, maxRadius = null, centerLeft = null, centerTop = null, From c8c67de8b7e0c27923975ce943231121e1ffb5f0 Mon Sep 17 00:00:00 2001 From: execjosh Date: Sat, 16 Jun 2012 02:44:00 +0900 Subject: [PATCH 21/42] Also stop at root when extracting CSS color This change adds an additional check for whether the parent element is `null` or `undefined` in `$.color.extract`. This can happen when working with elements that have not yet been added to the DOM under ``. Consider the following example pie chart. var elm = $("
") .css({ width: "240px" , height: "320px" }) var data = [ {label: "One", data: "33"} , {label: "Two", data: "33"} , {label: "Three", data: "33"} ] var opts = { legend: { show: true } , series: { pie: { show: true } } } $.plot(elm, data, opts) elm.appendTo($("body")) When flot inserts each legend row, it tries to use the same color as the corresponding graph part, unless it was explicitly specified in the options. However, in this example, `$.color.extract` runs into an unexpected `null` reference because `` is not an ancestor of `elm`. Specifically, a `TypeError: Cannot read property 'nodeName' of undefined` would be thrown. --- jquery.colorhelpers.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jquery.colorhelpers.js b/jquery.colorhelpers.js index d3524d7..61c6806 100644 --- a/jquery.colorhelpers.js +++ b/jquery.colorhelpers.js @@ -74,13 +74,18 @@ // if it's "transparent" $.color.extract = function (elem, css) { var c; + var parentElm; do { c = elem.css(css).toLowerCase(); // keep going until we find an element that has color, or - // we hit the body + // we hit the body or root (have no parent) if (c != '' && c != 'transparent') break; - elem = elem.parent(); + parentElm = elem.parent(); + if (null == parentElm.get(0)) { + break; + } + elem = parentElm; } while (!$.nodeName(elem.get(0), "body")); // catch Safari's way of signalling transparent From c4aa3cc764f359da0b51d2b3887cd80a8af55460 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 23 Sep 2013 06:48:16 -0700 Subject: [PATCH 22/42] Fix version branch name and clarify spaces v.s. tabs. --- CONTRIBUTING.md | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eef971b..2da732e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,19 +21,19 @@ love to hear them! Please submit each suggestion as a separate new issue. If you would like to work on an existing issue, please make sure it is not already assigned to someone else. If an issue is assigned to someone, that person has already started working on it. So, pick unassigned issues to prevent -duplicated efforts. +duplicated effort. ### Pull Requests ### To make merging as easy as possible, please keep these rules in mind: 1. Divide larger changes into a series of small, logical commits with - descriptive messages. + descriptive messages. 2. Format your code according to the style guidelines below. - 3. Submit new features or architectural changes to the -work branch - for the next major release. Submit bug fixes to the master branch. + 3. Submit new features or architectural changes to the *<version>-work* + branch for the next major release. Submit bug fixes to the master branch. 4. Rebase, if necessary, before submitting your pull request, to reduce the work we need to do to merge it. @@ -45,21 +45,21 @@ with the following updates and exceptions: #### Spacing #### -Do not add horizontal space around parameter lists, loop definitions, or -array/object indices. For example: +Use four-space indents, no tabs. Do not add horizontal space around parameter +lists, loop definitions, or array/object indices. For example: ```js - for ( var i = 0; i < data.length; i++ ) { // This block is wrong! - if ( data[ i ] > 1 ) { - data[ i ] = 2; - } - } - - for (var i = 0; i < data.length; i++) { // This block is correct! - if (data[i] > 1) { - data[i] = 2; - } - } + for ( var i = 0; i < data.length; i++ ) { // This block is wrong! + if ( data[ i ] > 1 ) { + data[ i ] = 2; + } + } + + for (var i = 0; i < data.length; i++) { // This block is correct! + if (data[i] > 1) { + data[i] = 2; + } + } ``` #### Comments #### @@ -71,12 +71,12 @@ All // comment blocks should have an empty line above *and* below them. For example: ```js - var a = 5; + var a = 5; - // We're going to loop here - // TODO: Make this loop faster, better, stronger! + // We're going to loop here + // TODO: Make this loop faster, better, stronger! - for (var x = 0; x < 10; x++) {} + for (var x = 0; x < 10; x++) {} ``` #### Wrapping #### @@ -91,9 +91,9 @@ Statements containing complex logic should not be wrapped arbitrarily if they do not exceed 80 characters. For example: ```js - if (a == 1 && // This block is wrong! - b == 2 && - c == 3) {} + if (a == 1 && // This block is wrong! + b == 2 && + c == 3) {} - if (a == 1 && b == 2 && c == 3) {} // This block is correct! + if (a == 1 && b == 2 && c == 3) {} // This block is correct! ``` From 836c9f15ff069ec7f9fcee328d789fb0f67df816 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 23 Sep 2013 06:50:33 -0700 Subject: [PATCH 23/42] Prioritize pull request instructions for clarity. --- CONTRIBUTING.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2da732e..4c11c14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,9 +8,8 @@ work for us, and a faster and better response. Issues are not a way to ask general questions about Flot. If you see unexpected behavior but are not 100% certain that it is a bug, please try posting to the [forum](http://groups.google.com/group/flot-graphs) first, and confirm that -what you see is really a Flot problem before creating a new issue for it. - -When reporting a bug, please include a working demonstration of the problem, if +what you see is really a Flot problem before creating a new issue for it. When +reporting a bug, please include a working demonstration of the problem, if possible, or at least a clear description of the options you're using and the environment (browser and version, jQuery version, other libraries) that you're running under. @@ -27,17 +26,17 @@ duplicated effort. To make merging as easy as possible, please keep these rules in mind: - 1. Divide larger changes into a series of small, logical commits with - descriptive messages. - - 2. Format your code according to the style guidelines below. - - 3. Submit new features or architectural changes to the *<version>-work* + 1. Submit new features or architectural changes to the *<version>-work* branch for the next major release. Submit bug fixes to the master branch. - 4. Rebase, if necessary, before submitting your pull request, to reduce the + 2. Divide larger changes into a series of small, logical commits with + descriptive messages. + + 3. Rebase, if necessary, before submitting your pull request, to reduce the work we need to do to merge it. + 4. Format your code according to the style guidelines below. + ### Flot Style Guidelines ### Flot follows the [jQuery Core Style Guidelines](http://docs.jquery.com/JQuery_Core_Style_Guidelines), From 3041b38d8daddc9ab72c83de42a41b7485452979 Mon Sep 17 00:00:00 2001 From: Luis Silva Date: Fri, 11 Oct 2013 23:48:47 +0930 Subject: [PATCH 24/42] Fixed Issue #1159 - Bug Redrawing Legend when using custom container --- jquery.flot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 2855d2e..4def83c 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2626,7 +2626,10 @@ Licensed under the MIT license. function insertLegend() { - placeholder.find(".legend").remove(); + if (options.legend.container!= null) + $(options.legend.container).html(""); + else + placeholder.find(".legend").remove(); if (!options.legend.show) return; From 91d254894d76a64de57a7ade75cb6a790d9ab34b Mon Sep 17 00:00:00 2001 From: Luis Silva Date: Mon, 14 Oct 2013 21:13:24 +0930 Subject: [PATCH 25/42] Added curly braces to match flot style guidelines --- jquery.flot.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 4def83c..a52c759 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2626,11 +2626,12 @@ Licensed under the MIT license. function insertLegend() { - if (options.legend.container!= null) + if (options.legend.container!= null) { $(options.legend.container).html(""); - else + } else { placeholder.find(".legend").remove(); - + } + if (!options.legend.show) return; From 0c2f6e30c288438961fd6ebc580fb998515603aa Mon Sep 17 00:00:00 2001 From: David Schnur Date: Mon, 14 Oct 2013 06:48:09 -0700 Subject: [PATCH 26/42] Slight cleanup / optimization for #1084. --- jquery.colorhelpers.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/jquery.colorhelpers.js b/jquery.colorhelpers.js index 61c6806..b2f6dc4 100644 --- a/jquery.colorhelpers.js +++ b/jquery.colorhelpers.js @@ -74,19 +74,15 @@ // if it's "transparent" $.color.extract = function (elem, css) { var c; - var parentElm; + do { c = elem.css(css).toLowerCase(); // keep going until we find an element that has color, or // we hit the body or root (have no parent) if (c != '' && c != 'transparent') break; - parentElm = elem.parent(); - if (null == parentElm.get(0)) { - break; - } - elem = parentElm; - } while (!$.nodeName(elem.get(0), "body")); + elem = elem.parent(); + } while (elem.length && !$.nodeName(elem.get(0), "body")); // catch Safari's way of signalling transparent if (c == "rgba(0, 0, 0, 0)") From 6a9f71f70ebe7748d4b15c9ec4decd66b21937bb Mon Sep 17 00:00:00 2001 From: Benjamin Gram Date: Tue, 29 Oct 2013 16:14:47 -0700 Subject: [PATCH 27/42] fix label's maxWidth calculation --- jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 2855d2e..67edfae 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1347,7 +1347,7 @@ Licensed under the MIT license. ticks = axis.ticks || [], labelWidth = opts.labelWidth || 0, labelHeight = opts.labelHeight || 0, - maxWidth = labelWidth || axis.direction == "x" ? Math.floor(surface.width / (ticks.length || 1)) : null, + maxWidth = labelWidth || (axis.direction == "x" ? Math.floor(surface.width / (ticks.length || 1)) : null), legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis", layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles, font = opts.font || "flot-tick-label tickLabel"; From 5d99034e246b939cc6170eec2fc2c5a05be391c7 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sat, 2 Nov 2013 08:24:53 -0700 Subject: [PATCH 28/42] Mandate jsDoc comments for file/function headers. --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c11c14..3e6e43a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,8 +63,8 @@ lists, loop definitions, or array/object indices. For example: #### Comments #### -Use // for all comments except the header at the top of a file or inline -include. +Use [jsDoc](http://usejsdoc.org) comments for all file and function headers. +Use // for all inline and block comments, regardless of length. All // comment blocks should have an empty line above *and* below them. For example: From 47017263028ddecd396640487dcf4fa546181c83 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 3 Nov 2013 08:07:24 -0800 Subject: [PATCH 29/42] Additional style fixes on code merged from #1160. --- jquery.flot.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index ef2cc77..df0acda 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2626,14 +2626,15 @@ Licensed under the MIT license. function insertLegend() { - if (options.legend.container!= null) { + if (options.legend.container != null) { $(options.legend.container).html(""); } else { placeholder.find(".legend").remove(); - } - - if (!options.legend.show) + } + + if (!options.legend.show) { return; + } var fragments = [], entries = [], rowStarted = false, lf = options.legend.labelFormatter, s, label; From c195e836fbdec83acdca6729dadd501c5c2b0e4e Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 3 Nov 2013 19:26:38 -0800 Subject: [PATCH 30/42] Minor cleanup / optimization of font-size defaulting. --- jquery.flot.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 32699c5..e26e325 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -735,9 +735,11 @@ Licensed under the MIT license. // since the rest of the code assumes that they exist. var i, axisOptions, axisCount, + fontSize = placeholder.css("font-size"), + fontSizeDefault = fontSize ? +fontSize.replace("px", "") : 13, fontDefaults = { style: placeholder.css("font-style"), - size: Math.round(0.8 * (placeholder.css("font-size") ? +placeholder.css('font-size').replace("px", "") : 13)), + size: Math.round(0.8 * fontSizeDefault), variant: placeholder.css("font-variant"), weight: placeholder.css("font-weight"), family: placeholder.css("font-family") From f79e106471359d6c1f60a4896909d7ebe8c3eeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Po=C5=82tyn?= Date: Mon, 4 Nov 2013 16:27:24 +0000 Subject: [PATCH 31/42] Add Ruby examples --- API.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/API.md b/API.md index 874b439..a9d8824 100644 --- a/API.md +++ b/API.md @@ -574,6 +574,17 @@ In Python you can get it with something like: ```python calendar.timegm(datetime_object.timetuple()) * 1000 ``` +In Ruby you can get it using `#to_i` method on [`Time`](http://apidock.com/ruby/Time/to_i) object. +If you're using `active_support` gem (default for Ruby on Rails application) `#to_i` is also available on `DateTime` and `ActiveSupport::TimeWithZone` objects. +After that multiply the result by 1000: + +```ruby +Time.now.to_i * 1000 # => 1383582043000 +# ActiveSupport examples: +DateTime.now.to_i * 1000 # => 1383582043000 +ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 100 +# => 1383582043000 +``` In .NET you can get it with something like: From 2cc2ab8975d7e14520300ee5c90a8562b7424671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Po=C5=82tyn?= Date: Mon, 4 Nov 2013 16:29:17 +0000 Subject: [PATCH 32/42] typo in ActiveSupport::TimeWithZone example --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index a9d8824..4bd3d6a 100644 --- a/API.md +++ b/API.md @@ -582,7 +582,7 @@ After that multiply the result by 1000: Time.now.to_i * 1000 # => 1383582043000 # ActiveSupport examples: DateTime.now.to_i * 1000 # => 1383582043000 -ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 100 +ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 1000 # => 1383582043000 ``` From 403b9532fbc39db89624b7e4d3461559f7efddeb Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 5 Nov 2013 05:59:21 -0800 Subject: [PATCH 33/42] Fix line wrapping and grammar. --- API.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index 4bd3d6a..e08b44c 100644 --- a/API.md +++ b/API.md @@ -574,9 +574,11 @@ In Python you can get it with something like: ```python calendar.timegm(datetime_object.timetuple()) * 1000 ``` -In Ruby you can get it using `#to_i` method on [`Time`](http://apidock.com/ruby/Time/to_i) object. -If you're using `active_support` gem (default for Ruby on Rails application) `#to_i` is also available on `DateTime` and `ActiveSupport::TimeWithZone` objects. -After that multiply the result by 1000: +In Ruby you can get it using the `#to_i` method on the +[`Time`](http://apidock.com/ruby/Time/to_i) object. If you're using the +`active_support` gem (default for Ruby on Rails applications) `#to_i` is also +available on the `DateTime` and `ActiveSupport::TimeWithZone` objects. You +simply need to multiply the result by 1000: ```ruby Time.now.to_i * 1000 # => 1383582043000 From eed38b8d4fe37521b3751bd6234d50226d8477f7 Mon Sep 17 00:00:00 2001 From: Anthony Ryan Date: Sun, 3 Nov 2013 23:15:13 -0500 Subject: [PATCH 34/42] :not(selector , selector) isn't actually a valid CSS selector jQuery's Sizzle is the only thing that this actually works in so jQuery will fail when it passes this directly to querySelectorAll() --- jquery.flot.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index e26e325..c2176aa 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1252,7 +1252,9 @@ Licensed under the MIT license. // from a previous plot in this container that we'll try to re-use. placeholder.css("padding", 0) // padding messes up the positioning - .children(":not(.flot-base,.flot-overlay)").remove(); + .children().filter(function(){ + return !$(this).hasClass("flot-overlay") && !$(this).hasClass('flot-base'); + }).remove(); if (placeholder.css("position") == 'static') placeholder.css("position", "relative"); // for positioning labels and overlay From 319f4dfe94449a65022d8c6bcb68832172f2dc28 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Wed, 13 Nov 2013 20:25:13 -0800 Subject: [PATCH 35/42] Apply fix from #1084 to the inline copy in jquery.flot.js. --- jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index c2176aa..c76fdc4 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -29,7 +29,7 @@ Licensed under the MIT license. * V. 1.1: Fix error handling so e.g. parsing an empty string does * produce a color rather than just crashing. */ -(function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return KI?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); +(function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return valuemax?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); // the actual Flot code (function($) { From edac9e0ed20a5fd710970c0e7a40909b42a12eec Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 24 Nov 2013 17:39:22 -0800 Subject: [PATCH 36/42] Distinguish between the first and innermost axis. The fix for #1056 caused a regression where grid lines were drawn for the innermost axes on both sides instead of just the first axis. Fixed by properly distinguishing the first axis in each direction from the innermost one on each side. Fixes #1075. --- jquery.flot.js | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 6ee9b9d..5a980e1 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1400,37 +1400,50 @@ Licensed under the MIT license. var lw = axis.labelWidth, lh = axis.labelHeight, pos = axis.options.position, + isXAxis = axis.direction === "x", tickLength = axis.options.tickLength, axisMargin = options.grid.axisMargin, padding = options.grid.labelMargin, - all = axis.direction == "x" ? xaxes : yaxes, - index, innermost; - - // determine axis margin - var samePosition = $.grep(all, function (a) { - return a && a.options.position == pos && a.reserveSpace; + innermost = true, + outermost = true, + first = true, + found = false; + + // Determine the axis's position in its direction and on its side + + $.each(isXAxis ? xaxes : yaxes, function(i, a) { + if (a && a.reserveSpace) { + if (a === axis) { + found = true; + } else if (a.options.position === pos) { + if (found) { + outermost = false; + } else { + innermost = false; + } + } + if (!found) { + first = false; + } + } }); - if ($.inArray(axis, samePosition) == samePosition.length - 1) - axisMargin = 0; // outermost - // Determine whether the axis is the first (innermost) on its side + // The outermost axis on each side has no margin - innermost = $.inArray(axis, samePosition) == 0; + if (outermost) { + axisMargin = 0; + } - // determine tick length - if we're innermost, we can use "full" + // The ticks for the first axis in each direction stretch across if (tickLength == null) { - if (innermost) - tickLength = "full"; - else - tickLength = 5; + tickLength = first ? "full" : 5; } if (!isNaN(+tickLength)) padding += +tickLength; - // compute box - if (axis.direction == "x") { + if (isXAxis) { lh += padding; if (pos == "bottom") { From 1650c184424c93468aae92a38fd18d852a84f522 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 24 Nov 2013 19:29:14 -0800 Subject: [PATCH 37/42] Don't add padding when there's no last tick. Flot 0.8 added logic to account for the size of axis tick labels and add padding around the edges of the plot, to prevent long labels from sticking out. But it padded both sides equally, which is incorrect if the right/top side has no last axis label. Fixed by allocating padding per-side, and checking whether the last label would be shown before padding the top or right. Fixes #1048. --- jquery.flot.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 6ee9b9d..491b57e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1480,7 +1480,7 @@ Licensed under the MIT license. // inside the canvas and isn't clipped off var minMargin = options.grid.minBorderMargin, - margins = { x: 0, y: 0 }, i, axis; + axis, i; // check stuff from the plot (FIXME: this should just read // a value from the series, otherwise it's impossible to @@ -1491,21 +1491,37 @@ Licensed under the MIT license. minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth/2)); } - margins.x = margins.y = Math.ceil(minMargin); + var margins = { + left: minMargin, + right: minMargin, + top: minMargin, + bottom: minMargin + }; // check axis labels, note we don't check the actual // labels but instead use the overall width/height to not // jump as much around with replots $.each(allAxes(), function (_, axis) { - var dir = axis.direction; - if (axis.reserveSpace) - margins[dir] = Math.ceil(Math.max(margins[dir], (dir == "x" ? axis.labelWidth : axis.labelHeight) / 2)); + var lastTick = axis.ticks[axis.ticks.length - 1]; + if (axis.reserveSpace && lastTick) { + if (axis.direction === "x") { + margins.left = Math.max(margins.left, axis.labelWidth / 2); + if (lastTick.v <= axis.max) { + margins.right = Math.max(margins.right, axis.labelWidth / 2); + } + } else { + margins.bottom = Math.max(margins.bottom, axis.labelHeight / 2); + if (lastTick.v <= axis.max) { + margins.top = Math.max(margins.top, axis.labelHeight / 2); + } + } + } }); - plotOffset.left = Math.max(margins.x, plotOffset.left); - plotOffset.right = Math.max(margins.x, plotOffset.right); - plotOffset.top = Math.max(margins.y, plotOffset.top); - plotOffset.bottom = Math.max(margins.y, plotOffset.bottom); + plotOffset.left = Math.ceil(Math.max(margins.left, plotOffset.left)); + plotOffset.right = Math.ceil(Math.max(margins.right, plotOffset.right)); + plotOffset.top = Math.ceil(Math.max(margins.top, plotOffset.top)); + plotOffset.bottom = Math.ceil(Math.max(margins.bottom, plotOffset.bottom)); } function setupGrid() { From 745d24cc7928e800b79684164b356db8c5070e0e Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 24 Nov 2013 20:02:53 -0800 Subject: [PATCH 38/42] Default lineHeight based on the font size. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flot 0.8.0 used the default font size, typically derived from the placeholder, as the basis for the default lineHeight. This produced incorrect results when a font.size was provided explicitly, and it differed from the placeholder’s CSS size. Fixed by waiting to default lineHeight until the actual font size has been resolved. Fixes #1131. --- jquery.flot.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 6ee9b9d..6a3799f 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -762,8 +762,6 @@ Licensed under the MIT license. family: placeholder.css("font-family") }; - fontDefaults.lineHeight = fontDefaults.size * 1.15; - axisCount = options.xaxes.length || 1; for (i = 0; i < axisCount; ++i) { @@ -780,6 +778,9 @@ Licensed under the MIT license. if (!axisOptions.font.color) { axisOptions.font.color = axisOptions.color; } + if (!axisOptions.font.lineHeight) { + axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15); + } } } @@ -799,6 +800,9 @@ Licensed under the MIT license. if (!axisOptions.font.color) { axisOptions.font.color = axisOptions.color; } + if (!axisOptions.font.lineHeight) { + axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15); + } } } From d436c04c863a7dd0511310112ab79370e2a3762c Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 26 Nov 2013 21:06:27 -0800 Subject: [PATCH 39/42] Updated NEWS for the 0.8.2 release. --- NEWS.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index d62a2f1..6eece14 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,11 +2,32 @@ ### Changes ### - - Added a table of contents to the API documentation. - (patch by Brian Peiris, pull request #1064) + - Added a plot.destroy method as a way to free memory when emptying the plot + placeholder and then re-using it for some other purpose. + (patch by Thodoris Greasidis, issue #1129, pull request #1130) + + - Added a table of contents and PLUGINS link to the API documentation. + (patches by Brian Peiris, pull requests #1064 and #1127) + + - Added Ruby code examples for time conversion. + (patch by Mike Połtyn, pull request #1182) + + - Minor improvements to API.md and README.md. + (patches by Patrik Ragnarsson, pull requests #1085 and #1086) + + - Updated inlined jQuery Resize to the latest version to fix errors. + (reported by Matthew Sabol and sloker, issues #997 ad #1081) ### Bug fixes ### + - Fixed an unexpected change in behavior that resulted in duplicate tick + labels when using a plugin, like flot-tickrotor, that overrode tick labels. + (patch by Mark Cote, pull request #1091) + + - Fixed a regression from 0.7 where axis labels were given the wrong width, + causing them to overlap at certain scales and ignore the labelWidth option. + (patch by Benjamin Gram, pull request #1177) + - Fixed a bug where the second axis in an xaxes/yaxes array incorrectly had its 'innermost' property set to false or undefined, even if it was on the other side of the plot from the first axis. This resulted in the axis bar @@ -14,13 +35,56 @@ when the grid had a left/right border width of zero. (reported by Teq1, fix researched by ryleyb, issue #1056) - - Fixed an unexpected change in behavior that resulted in duplicate tick - labels when using a plugin, like flot-tickrotor, that overrode tick labels. - (patch by Mark Cote, pull request #1091) + - Fixed an error when using a placeholder that has no font-size property. + (patch by Craig Oldford, pull request #1135) + + - Fixed a regression from 0.7 where nulls at the end of a series were ignored + for purposes of determing the range of the x-axis. + (reported by Munsifali Rashid, issue #1095) + + - If a font size is provided, base the default lineHeight on that size rather + that the font size of the plot placeholder, which may be very different. + (reported by Daniel Hoffmann Bernardes, issue #1131, pull request #1199) + + - Fix broken highlighting for right-aligned bars. + (reported by BeWiBu and Mihai Stanciu, issues #975 and #1093, with further + assistance by Eric Byers, pull request #1120) + + - Prevent white circles from sometimes showing up inside of pie charts. + (reported by Pierre Dubois and Jack Klink, issues #1128 and #1073) + + - Label formatting no longer breaks when a page contains multiple pie charts. + (reported by Brend Wanders, issue #1055) + + - When using multiple axes on opposite sides of the plot, the innermost axis + coming later in the list no longer has its bar drawn incorrectly. + (reported by ryleyb, issue #1056) + + - When removing series labels and redrawing the plot, the legend now updates + correctly even when using an external container. + (patch by Luis Silva, issue #1159, pull request #1160) - Right-aligned bars no longer highlight as though they were center-aligned. (reported by BeWiBu and mihaisdm, issues #975 and #1093) + - The pie plugin no longer ignores the value of the left offset option. + (reported by melanker, issue #1136) + + - Fixed a regression from 0.7, where extra padding was added unnecessarily to + sides of the plot where there was no last tick label. + (reported by sknob001, issue #1048, pull request #1200) + + - Fixed incorrect tooltip behavior in the interacting example. + (patch by cleroux, issue #686, pull request #1074) + + - Fixed an error in CSS color extraction with elements outside the DOM. + (patch by execjosh, pull request #1084) + + - Fixed :not selector error when using jQuery without Sizzle. + (patch by Anthony Ryan, pull request #1180) + + - Worked around a browser issue that caused bars to appear un-filled. + (reported by irbian, issue #915) ## Flot 0.8.1 ## From 00e93b6d466d253495273bae98eb9f6a09b517b0 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 26 Nov 2013 21:25:12 -0800 Subject: [PATCH 40/42] Update version numbers to 0.8.2 final. --- component.json | 2 +- flot.jquery.json | 2 +- jquery.flot.js | 4 ++-- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/component.json b/component.json index d211bcc..f3dabc5 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "Flot", - "version": "0.8.2-alpha", + "version": "0.8.2", "main": "jquery.flot.js", "dependencies": { "jquery": ">= 1.2.6" diff --git a/flot.jquery.json b/flot.jquery.json index 14d67e9..5cf7509 100644 --- a/flot.jquery.json +++ b/flot.jquery.json @@ -1,6 +1,6 @@ { "name": "flot", - "version": "0.8.2-alpha", + "version": "0.8.2", "title": "Flot", "author": { "name": "Ole Laursen", diff --git a/jquery.flot.js b/jquery.flot.js index 11cff2c..c410659 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1,4 +1,4 @@ -/* Javascript plotting library for jQuery, version 0.8.2-alpha. +/* Javascript plotting library for jQuery, version 0.8.2. Copyright (c) 2007-2013 IOLA and Ole Laursen. Licensed under the MIT license. @@ -3117,7 +3117,7 @@ Licensed under the MIT license. return plot; }; - $.plot.version = "0.8.2-alpha"; + $.plot.version = "0.8.2"; $.plot.plugins = []; diff --git a/package.json b/package.json index 1ee63f4..023af9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Flot", - "version": "0.8.2-alpha", + "version": "0.8.2", "main": "jquery.flot.js", "scripts": { "test": "make test" From 525d46ea8d7f5795bc5864468963709e564a83d7 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Thu, 28 Nov 2013 09:50:10 -0800 Subject: [PATCH 41/42] Removed duplicate NEWS entry. --- NEWS.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6eece14..a99b65e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -64,9 +64,6 @@ correctly even when using an external container. (patch by Luis Silva, issue #1159, pull request #1160) - - Right-aligned bars no longer highlight as though they were center-aligned. - (reported by BeWiBu and mihaisdm, issues #975 and #1093) - - The pie plugin no longer ignores the value of the left offset option. (reported by melanker, issue #1136) From 39bc058b211dd9645e3315c4dc93f0b606690544 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Thu, 28 Nov 2013 10:43:09 -0800 Subject: [PATCH 42/42] Fixed an error when plotting an empty dataset. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was accidentally introduced by #1200; we can’t assume that axis.ticks is an array. --- jquery.flot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index c410659..965e78e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1519,8 +1519,8 @@ Licensed under the MIT license. // labels but instead use the overall width/height to not // jump as much around with replots $.each(allAxes(), function (_, axis) { - var lastTick = axis.ticks[axis.ticks.length - 1]; - if (axis.reserveSpace && lastTick) { + if (axis.reserveSpace && axis.ticks && axis.ticks.length) { + var lastTick = axis.ticks[axis.ticks.length - 1]; if (axis.direction === "x") { margins.left = Math.max(margins.left, axis.labelWidth / 2); if (lastTick.v <= axis.max) {