Commit 355331fd authored by David Schnur's avatar David Schnur

Merge tag '0.8.1' into 0.9-work

parent 1720941f
...@@ -8,7 +8,7 @@ var plot = $.plot(placeholder, data, options) ...@@ -8,7 +8,7 @@ var plot = $.plot(placeholder, data, options)
The placeholder is a jQuery object or DOM element or jQuery expression The placeholder is a jQuery object or DOM element or jQuery expression
that the plot will be put into. This placeholder needs to have its that the plot will be put into. This placeholder needs to have its
width and height set as explained in the README (go read that now if width and height set as explained in the [README](README.md) (go read that now if
you haven't, it's short). The plot will modify some properties of the you haven't, it's short). The plot will modify some properties of the
placeholder so it's recommended you simply pass in a div that you placeholder so it's recommended you simply pass in a div that you
don't use for anything else. Make sure you check any fancy styling don't use for anything else. Make sure you check any fancy styling
...@@ -636,6 +636,10 @@ standard strftime specifiers are supported (plus the nonstandard %q): ...@@ -636,6 +636,10 @@ standard strftime specifiers are supported (plus the nonstandard %q):
%w: weekday as number (0-6, 0 being Sunday) %w: weekday as number (0-6, 0 being Sunday)
``` ```
Flot 0.8 switched from %h to the standard %H hours specifier. The %h specifier
is still available, for backwards-compatibility, but is deprecated and
scheduled to be removed permanently with the release of version 1.0.
You can customize the month names with the "monthNames" option. For You can customize the month names with the "monthNames" option. For
instance, for Danish you might specify: instance, for Danish you might specify:
......
...@@ -32,7 +32,11 @@ To make merging as easy as possible, please keep these rules in mind: ...@@ -32,7 +32,11 @@ To make merging as easy as possible, please keep these rules in mind:
2. Format your code according to the style guidelines below. 2. Format your code according to the style guidelines below.
3. Rebase against master, if necessary, before submitting your pull request. 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.
### Flot Style Guidelines ### ### Flot Style Guidelines ###
......
...@@ -5,6 +5,52 @@ ...@@ -5,6 +5,52 @@
- Added a strokeColor option to control the outline around point symbols. - Added a strokeColor option to control the outline around point symbols.
(patch by djamshed, pull request #1003) (patch by djamshed, pull request #1003)
## Flot 0.8.1 ##
### Bug fixes ###
- Fixed a regression in the time plugin, introduced in 0.8, that caused dates
to align to the minute rather than to the highest appropriate unit. This
caused many x-axes in 0.8 to have different ticks than they did in 0.7.
(reported by Tom Sheppard, patch by Daniel Shapiro, issue #1017, pull
request #1023)
- Fixed a regression in text rendering, introduced in 0.8, that caused axis
labels with the same text as another label on the same axis to disappear.
More generally, it's again possible to have the same text in two locations.
(issue #1032)
- Fixed a regression in text rendering, introduced in 0.8, where axis labels
were no longer assigned an explicit width, and their text could not wrap.
(reported by sabregreen, issue #1019)
- Fixed a regression in the pie plugin, introduced in 0.8, that prevented it
from accepting data in the format '[[x, y]]'.
(patch by Nicolas Morel, pull request #1024)
- The 'zero' series option and 'autoscale' format option are no longer
ignored when the series contains a null value.
(reported by Daniel Shapiro, issue #1033)
- Avoid triggering the time-mode plugin exception when there are zero series.
(reported by Daniel Rothig, patch by Mark Raymond, issue #1016)
- When a custom color palette has fewer colors than the default palette, Flot
no longer fills out the colors with the remainder of the default.
(patch by goorpy, issue #1031, pull request #1034)
- Fixed missing update for bar highlights after a zoom or other redraw.
(reported by Paolo Valleri, issue #1030)
- Fixed compatibility with jQuery versions earlier than 1.7.
(patch by Lee Willis, issue #1027, pull request #1027)
- The mouse wheel no longer scrolls the page when using the navigate plugin.
(patch by vird, pull request #1020)
- Fixed missing semicolons in the core library.
(reported by Michal Zglinski)
## Flot 0.8.0 ## ## Flot 0.8.0 ##
......
...@@ -71,9 +71,9 @@ $.plot($("#placeholder"), data, options); ...@@ -71,9 +71,9 @@ $.plot($("#placeholder"), data, options);
Here, data is an array of data series and options is an object with Here, data is an array of data series and options is an object with
settings if you want to customize the plot. Take a look at the settings if you want to customize the plot. Take a look at the
examples for some ideas of what to put in or look at the reference examples for some ideas of what to put in or look at the
in the file `API.txt`. Here's a quick example that'll draw a line from [API reference](API.md). Here's a quick example that'll draw a line
(0, 0) to (1, 1): from (0, 0) to (1, 1):
```js ```js
$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } }); $.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
......
...@@ -79,12 +79,9 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -79,12 +79,9 @@ browser, but needs to redraw with canvas text when exporting as an image.
for (var key in styleCache) { for (var key in styleCache) {
if (hasOwnProperty.call(styleCache, key)) { if (hasOwnProperty.call(styleCache, key)) {
var info = styleCache[key]; var info = styleCache[key],
positions = info.positions,
if (!info.active) { lines = info.lines;
delete styleCache[key];
continue;
}
// Since every element at this level of the cache have the // Since every element at this level of the cache have the
// same font and fill styles, we can just change them once // same font and fill styles, we can just change them once
...@@ -96,10 +93,18 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -96,10 +93,18 @@ browser, but needs to redraw with canvas text when exporting as an image.
updateStyles = false; updateStyles = false;
} }
var lines = info.lines; for (var i = 0, position; position = positions[i]; i++) {
for (var i = 0; i < lines.length; ++i) { if (position.active) {
var line = lines[i]; for (var j = 0, line; line = position.lines[j]; j++) {
context.fillText(line.text, line.x, line.y); context.fillText(lines[j].text, line[0], line[1]);
}
} else {
positions.splice(i--, 1);
}
}
if (positions.length == 0) {
delete styleCache[key];
} }
} }
} }
...@@ -116,11 +121,9 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -116,11 +121,9 @@ browser, but needs to redraw with canvas text when exporting as an image.
// When the canvas option is set, the object looks like this: // When the canvas option is set, the object looks like this:
// //
// { // {
// x: X coordinate at which the text is located.
// x: Y coordinate at which the text is located.
// width: Width of the text's bounding box. // width: Width of the text's bounding box.
// height: Height of the text's bounding box. // height: Height of the text's bounding box.
// active: Flag indicating whether the text should be visible. // positions: Array of positions at which this text is drawn.
// lines: [{ // lines: [{
// height: Height of this line. // height: Height of this line.
// widths: Width of this line. // widths: Width of this line.
...@@ -131,11 +134,20 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -131,11 +134,20 @@ browser, but needs to redraw with canvas text when exporting as an image.
// color: Color of the text. // color: Color of the text.
// }, // },
// } // }
//
// The positions array contains objects that look like this:
//
// {
// active: Flag indicating whether the text should be visible.
// lines: Array of [x, y] coordinates at which to draw the line.
// x: X coordinate at which to draw the text.
// y: Y coordinate at which to draw the text.
// }
Canvas.prototype.getTextInfo = function(layer, text, font, angle) { Canvas.prototype.getTextInfo = function(layer, text, font, angle, width) {
if (!plot.getOptions().canvas) { if (!plot.getOptions().canvas) {
return getTextInfo.call(this, layer, text, font, angle); return getTextInfo.call(this, layer, text, font, angle, width);
} }
var textStyle, layerCache, styleCache, info; var textStyle, layerCache, styleCache, info;
...@@ -210,7 +222,7 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -210,7 +222,7 @@ browser, but needs to redraw with canvas text when exporting as an image.
info = styleCache[text] = { info = styleCache[text] = {
width: 0, width: 0,
height: 0, height: 0,
active: false, positions: [],
lines: [], lines: [],
font: { font: {
definition: textStyle, definition: textStyle,
...@@ -251,19 +263,16 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -251,19 +263,16 @@ browser, but needs to redraw with canvas text when exporting as an image.
// Adds a text string to the canvas text overlay. // Adds a text string to the canvas text overlay.
Canvas.prototype.addText = function(layer, x, y, text, font, angle, halign, valign) { Canvas.prototype.addText = function(layer, x, y, text, font, angle, width, halign, valign) {
if (!plot.getOptions().canvas) { if (!plot.getOptions().canvas) {
return addText.call(this, layer, x, y, text, font, angle, halign, valign); return addText.call(this, layer, x, y, text, font, angle, width, halign, valign);
} }
var info = this.getTextInfo(layer, text, font, angle), var info = this.getTextInfo(layer, text, font, angle, width),
positions = info.positions,
lines = info.lines; lines = info.lines;
// Mark the text for inclusion in the next render pass
info.active = true;
// Text is drawn with baseline 'middle', which we need to account // Text is drawn with baseline 'middle', which we need to account
// for by adding half a line's height to the y position. // for by adding half a line's height to the y position.
...@@ -289,20 +298,39 @@ browser, but needs to redraw with canvas text when exporting as an image. ...@@ -289,20 +298,39 @@ browser, but needs to redraw with canvas text when exporting as an image.
y -= 2; y -= 2;
} }
// Determine whether this text already exists at this position.
// If so, mark it for inclusion in the next render pass.
for (var i = 0, position; position = positions[i]; i++) {
if (position.x == x && position.y == y) {
position.active = true;
return;
}
}
// If the text doesn't exist at this position, create a new entry
position = {
active: true,
lines: [],
x: x,
y: y
};
positions.push(position);
// Fill in the x & y positions of each line, adjusting them // Fill in the x & y positions of each line, adjusting them
// individually for horizontal alignment. // individually for horizontal alignment.
for (var i = 0; i < lines.length; ++i) { for (var i = 0, line; line = lines[i]; i++) {
var line = lines[i];
line.y = y;
y += line.height;
if (halign == "center") { if (halign == "center") {
line.x = Math.round(x - line.width / 2); position.lines.push([Math.round(x - line.width / 2), y]);
} else if (halign == "right") { } else if (halign == "right") {
line.x = Math.round(x - line.width); position.lines.push([Math.round(x - line.width), y]);
} else { } else {
line.x = Math.round(x); position.lines.push([Math.round(x), y]);
} }
y += line.height;
} }
}; };
} }
......
This diff is collapsed.
...@@ -135,6 +135,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L ...@@ -135,6 +135,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
} }
function onMouseWheel(e, delta) { function onMouseWheel(e, delta) {
e.preventDefault();
onZoomClick(e, delta < 0); onZoomClick(e, delta < 0);
return false; return false;
} }
......
...@@ -180,13 +180,18 @@ More detail and specific examples can be found in the included HTML file. ...@@ -180,13 +180,18 @@ More detail and specific examples can be found in the included HTML file.
// new one; this is more efficient and preserves any extra data // new one; this is more efficient and preserves any extra data
// that the user may have stored in higher indexes. // that the user may have stored in higher indexes.
if ($.isArray(value) && value.length == 1) {
value = value[0];
}
if ($.isArray(value)) { if ($.isArray(value)) {
if ($.isNumeric(value[1])) { // Equivalent to $.isNumeric() but compatible with jQuery < 1.7
if (!isNaN(parseFloat(value[1])) && isFinite(value[1])) {
value[1] = +value[1]; value[1] = +value[1];
} else { } else {
value[1] = 0; value[1] = 0;
} }
} else if ($.isNumeric(value)) { } else if (!isNaN(parseFloat(value)) && isFinite(value)) {
value = [1, +value]; value = [1, +value];
} else { } else {
value = [1, 0]; value = [1, 0];
......
...@@ -73,6 +73,7 @@ API.txt for details. ...@@ -73,6 +73,7 @@ API.txt for details.
case 'b': c = "" + monthNames[d.getMonth()]; break; case 'b': c = "" + monthNames[d.getMonth()]; break;
case 'd': c = leftPad(d.getDate()); break; case 'd': c = leftPad(d.getDate()); break;
case 'e': c = leftPad(d.getDate(), " "); break; case 'e': c = leftPad(d.getDate(), " "); break;
case 'h': // For back-compat with 0.7; remove in 1.0
case 'H': c = leftPad(hours); break; case 'H': c = leftPad(hours); break;
case 'I': c = leftPad(hours12); break; case 'I': c = leftPad(hours12); break;
case 'l': c = leftPad(hours12, " "); break; case 'l': c = leftPad(hours12, " "); break;
...@@ -194,7 +195,7 @@ API.txt for details. ...@@ -194,7 +195,7 @@ API.txt for details.
[1, "year"]]); [1, "year"]]);
function init(plot) { function init(plot) {
plot.hooks.processDatapoints.push(function (plot, series, datapoints) { plot.hooks.processOptions.push(function (plot, options) {
$.each(plot.getAxes(), function(axisName, axis) { $.each(plot.getAxes(), function(axisName, axis) {
var opts = axis.options; var opts = axis.options;
...@@ -294,17 +295,23 @@ API.txt for details. ...@@ -294,17 +295,23 @@ API.txt for details.
if (step >= timeUnitSize.minute) { if (step >= timeUnitSize.minute) {
d.setSeconds(0); d.setSeconds(0);
} else if (step >= timeUnitSize.hour) { }
if (step >= timeUnitSize.hour) {
d.setMinutes(0); d.setMinutes(0);
} else if (step >= timeUnitSize.day) { }
if (step >= timeUnitSize.day) {
d.setHours(0); d.setHours(0);
} else if (step >= timeUnitSize.day * 4) { }
if (step >= timeUnitSize.day * 4) {
d.setDate(1); d.setDate(1);
} else if (step >= timeUnitSize.month * 2) { }
if (step >= timeUnitSize.month * 2) {
d.setMonth(floorInBase(d.getMonth(), 3)); d.setMonth(floorInBase(d.getMonth(), 3));
} else if (step >= timeUnitSize.quarter * 2) { }
if (step >= timeUnitSize.quarter * 2) {
d.setMonth(floorInBase(d.getMonth(), 6)); d.setMonth(floorInBase(d.getMonth(), 6));
} else if (step >= timeUnitSize.year) { }
if (step >= timeUnitSize.year) {
d.setMonth(0); d.setMonth(0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment