diff --git a/jquery.flot.canvas.js b/jquery.flot.canvas.js
index 139d019..0f8c711 100644
--- a/jquery.flot.canvas.js
+++ b/jquery.flot.canvas.js
@@ -29,313 +29,313 @@ browser, but needs to redraw with canvas text when exporting as an image.
(function($) {
- var options = {
- canvas: true
- };
-
- var render, getTextInfo, addText;
-
- function init(plot, classes) {
-
- var Canvas = classes.Canvas;
-
- // We only want to replace the functions once; the second time around
- // we would just get our new function back. This whole replacing of
- // prototype functions is a disaster, and needs to be changed ASAP.
-
- if (render == null) {
- getTextInfo = Canvas.prototype.getTextInfo,
- addText = Canvas.prototype.addText,
- render = Canvas.prototype.render;
- }
-
- // Finishes rendering the canvas, including overlaid text
-
- Canvas.prototype.render = function() {
-
- if (!plot.getOptions().canvas) {
- return render.call(this);
- }
-
- var context = this.context,
- cache = this._textCache;
-
- // For each text layer, render elements marked as active
-
- context.save();
- context.textBaseline = "middle";
-
- for (var layerKey in cache) {
- if (Object.prototype.hasOwnProperty.call(cache, layerKey)) {
- var layerCache = cache[layerKey];
- for (var styleKey in layerCache) {
- if (Object.prototype.hasOwnProperty.call(layerCache, styleKey)) {
- var styleCache = layerCache[styleKey],
- updateStyles = true;
- for (var key in styleCache) {
- if (Object.prototype.hasOwnProperty.call(styleCache, key)) {
-
- var info = styleCache[key],
- positions = info.positions,
- lines = info.lines;
-
- // Since every element at this level of the cache have the
- // same font and fill styles, we can just change them once
- // using the values from the first element.
-
- if (updateStyles) {
- context.fillStyle = info.font.color;
- context.font = info.font.definition;
- updateStyles = false;
- }
-
- for (var i = 0, position; position = positions[i]; i++) {
- if (position.active) {
- for (var j = 0, line; line = position.lines[j]; j++) {
- context.fillText(lines[j].text, line[0], line[1]);
- }
- } else {
- positions.splice(i--, 1);
- }
- }
-
- if (positions.length === 0) {
- delete styleCache[key];
- }
- }
- }
- }
- }
- }
- }
-
- context.restore();
- };
-
- // Creates (if necessary) and returns a text info object.
- //
- // When the canvas option is set, the object looks like this:
- //
- // {
- // width: Width of the text's bounding box.
- // height: Height of the text's bounding box.
- // positions: Array of positions at which this text is drawn.
- // lines: [{
- // height: Height of this line.
- // widths: Width of this line.
- // text: Text on this line.
- // }],
- // font: {
- // definition: Canvas font property string.
- // 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, width) {
-
- if (!plot.getOptions().canvas) {
- return getTextInfo.call(this, layer, text, font, angle, width);
- }
-
- var textStyle, layerCache, styleCache, info;
-
- // Cast the value to a string, in case we were given a number
-
- text = "" + text;
-
- // If the font is a font-spec object, generate a CSS definition
-
- if (typeof font === "object") {
- textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px " + font.family;
- } else {
- textStyle = font;
- }
-
- // Retrieve (or create) the cache for the text's layer and styles
-
- layerCache = this._textCache[layer];
-
- if (layerCache == null) {
- layerCache = this._textCache[layer] = {};
- }
-
- styleCache = layerCache[textStyle];
-
- if (styleCache == null) {
- styleCache = layerCache[textStyle] = {};
- }
-
- info = styleCache[text];
-
- if (info == null) {
-
- var context = this.context;
-
- // If the font was provided as CSS, create a div with those
- // classes and examine it to generate a canvas font spec.
-
- if (typeof font !== "object") {
-
- var element = $("
")
- .css("position", "absolute")
- .addClass(typeof font === "string" ? font : null)
- .appendTo(this.getTextLayer(layer));
-
- font = {
- lineHeight: element.height(),
- style: element.css("font-style"),
- variant: element.css("font-variant"),
- weight: element.css("font-weight"),
- family: element.css("font-family"),
- color: element.css("color")
- };
+ var options = {
+ canvas: true
+ };
+
+ var render, getTextInfo, addText;
+
+ function init(plot, classes) {
+
+ var Canvas = classes.Canvas;
+
+ // We only want to replace the functions once; the second time around
+ // we would just get our new function back. This whole replacing of
+ // prototype functions is a disaster, and needs to be changed ASAP.
+
+ if (render == null) {
+ getTextInfo = Canvas.prototype.getTextInfo,
+ addText = Canvas.prototype.addText,
+ render = Canvas.prototype.render;
+ }
+
+ // Finishes rendering the canvas, including overlaid text
+
+ Canvas.prototype.render = function() {
+
+ if (!plot.getOptions().canvas) {
+ return render.call(this);
+ }
+
+ var context = this.context,
+ cache = this._textCache;
+
+ // For each text layer, render elements marked as active
+
+ context.save();
+ context.textBaseline = "middle";
+
+ for (var layerKey in cache) {
+ if (Object.prototype.hasOwnProperty.call(cache, layerKey)) {
+ var layerCache = cache[layerKey];
+ for (var styleKey in layerCache) {
+ if (Object.prototype.hasOwnProperty.call(layerCache, styleKey)) {
+ var styleCache = layerCache[styleKey],
+ updateStyles = true;
+ for (var key in styleCache) {
+ if (Object.prototype.hasOwnProperty.call(styleCache, key)) {
+
+ var info = styleCache[key],
+ positions = info.positions,
+ lines = info.lines;
+
+ // Since every element at this level of the cache have the
+ // same font and fill styles, we can just change them once
+ // using the values from the first element.
+
+ if (updateStyles) {
+ context.fillStyle = info.font.color;
+ context.font = info.font.definition;
+ updateStyles = false;
+ }
+
+ for (var i = 0, position; position = positions[i]; i++) {
+ if (position.active) {
+ for (var j = 0, line; line = position.lines[j]; j++) {
+ context.fillText(lines[j].text, line[0], line[1]);
+ }
+ } else {
+ positions.splice(i--, 1);
+ }
+ }
+
+ if (positions.length === 0) {
+ delete styleCache[key];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ context.restore();
+ };
+
+ // Creates (if necessary) and returns a text info object.
+ //
+ // When the canvas option is set, the object looks like this:
+ //
+ // {
+ // width: Width of the text's bounding box.
+ // height: Height of the text's bounding box.
+ // positions: Array of positions at which this text is drawn.
+ // lines: [{
+ // height: Height of this line.
+ // widths: Width of this line.
+ // text: Text on this line.
+ // }],
+ // font: {
+ // definition: Canvas font property string.
+ // 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, width) {
+
+ if (!plot.getOptions().canvas) {
+ return getTextInfo.call(this, layer, text, font, angle, width);
+ }
+
+ var textStyle, layerCache, styleCache, info;
+
+ // Cast the value to a string, in case we were given a number
+
+ text = "" + text;
+
+ // If the font is a font-spec object, generate a CSS definition
+
+ if (typeof font === "object") {
+ textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px " + font.family;
+ } else {
+ textStyle = font;
+ }
+
+ // Retrieve (or create) the cache for the text's layer and styles
+
+ layerCache = this._textCache[layer];
+
+ if (layerCache == null) {
+ layerCache = this._textCache[layer] = {};
+ }
+
+ styleCache = layerCache[textStyle];
+
+ if (styleCache == null) {
+ styleCache = layerCache[textStyle] = {};
+ }
+
+ info = styleCache[text];
+
+ if (info == null) {
+
+ var context = this.context;
+
+ // If the font was provided as CSS, create a div with those
+ // classes and examine it to generate a canvas font spec.
+
+ if (typeof font !== "object") {
+
+ var element = $("
")
+ .css("position", "absolute")
+ .addClass(typeof font === "string" ? font : null)
+ .appendTo(this.getTextLayer(layer));
+
+ font = {
+ lineHeight: element.height(),
+ style: element.css("font-style"),
+ variant: element.css("font-variant"),
+ weight: element.css("font-weight"),
+ family: element.css("font-family"),
+ color: element.css("color")
+ };
- // Setting line-height to 1, without units, sets it equal
- // to the font-size, even if the font-size is abstract,
- // like 'smaller'. This enables us to read the real size
- // via the element's height, working around browsers that
- // return the literal 'smaller' value.
+ // Setting line-height to 1, without units, sets it equal
+ // to the font-size, even if the font-size is abstract,
+ // like 'smaller'. This enables us to read the real size
+ // via the element's height, working around browsers that
+ // return the literal 'smaller' value.
- font.size = element.css("line-height", 1).height();
+ font.size = element.css("line-height", 1).height();
- element.remove();
- }
+ element.remove();
+ }
- textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px " + font.family;
+ textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px " + font.family;
- // Create a new info object, initializing the dimensions to
- // zero so we can count them up line-by-line.
+ // Create a new info object, initializing the dimensions to
+ // zero so we can count them up line-by-line.
- info = styleCache[text] = {
- width: 0,
- height: 0,
- positions: [],
- lines: [],
- font: {
- definition: textStyle,
- color: font.color
- }
- };
+ info = styleCache[text] = {
+ width: 0,
+ height: 0,
+ positions: [],
+ lines: [],
+ font: {
+ definition: textStyle,
+ color: font.color
+ }
+ };
- context.save();
- context.font = textStyle;
+ context.save();
+ context.font = textStyle;
- // Canvas can't handle multi-line strings; break on various
- // newlines, including HTML brs, to build a list of lines.
- // Note that we could split directly on regexps, but IE < 9 is
- // broken; revisit when we drop IE 7/8 support.
+ // Canvas can't handle multi-line strings; break on various
+ // newlines, including HTML brs, to build a list of lines.
+ // Note that we could split directly on regexps, but IE < 9 is
+ // broken; revisit when we drop IE 7/8 support.
- var lines = (text + "").replace(/
|\r\n|\r/g, "\n").split("\n");
+ var lines = (text + "").replace(/
|\r\n|\r/g, "\n").split("\n");
- for (var i = 0; i < lines.length; ++i) {
+ for (var i = 0; i < lines.length; ++i) {
- var lineText = lines[i],
- measured = context.measureText(lineText);
+ var lineText = lines[i],
+ measured = context.measureText(lineText);
- info.width = Math.max(measured.width, info.width);
- info.height += font.lineHeight;
+ info.width = Math.max(measured.width, info.width);
+ info.height += font.lineHeight;
- info.lines.push({
- text: lineText,
- width: measured.width,
- height: font.lineHeight
- });
- }
+ info.lines.push({
+ text: lineText,
+ width: measured.width,
+ height: font.lineHeight
+ });
+ }
- context.restore();
- }
+ context.restore();
+ }
- return info;
- };
+ return info;
+ };
- // 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, width, halign, valign) {
+ Canvas.prototype.addText = function(layer, x, y, text, font, angle, width, halign, valign) {
- if (!plot.getOptions().canvas) {
- return addText.call(this, layer, x, y, text, font, angle, width, halign, valign);
- }
+ if (!plot.getOptions().canvas) {
+ return addText.call(this, layer, x, y, text, font, angle, width, halign, valign);
+ }
- var info = this.getTextInfo(layer, text, font, angle, width),
- positions = info.positions,
- lines = info.lines;
+ var info = this.getTextInfo(layer, text, font, angle, width),
+ positions = info.positions,
+ lines = info.lines;
- // Text is drawn with baseline 'middle', which we need to account
- // for by adding half a line's height to the y position.
+ // Text is drawn with baseline 'middle', which we need to account
+ // for by adding half a line's height to the y position.
- y += info.height / lines.length / 2;
+ y += info.height / lines.length / 2;
- // Tweak the initial y-position to match vertical alignment
+ // Tweak the initial y-position to match vertical alignment
- if (valign === "middle") {
- y = Math.round(y - info.height / 2);
- } else if (valign === "bottom") {
- y = Math.round(y - info.height);
- } else {
- y = Math.round(y);
- }
-
- // FIXME: LEGACY BROWSER FIX
- // AFFECTS: Opera < 12.00
-
- // Offset the y coordinate, since Opera is off pretty
- // consistently compared to the other browsers.
-
- if (!!(window.opera && window.opera.version().split(".")[0] < 12)) {
- 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 (valign === "middle") {
+ y = Math.round(y - info.height / 2);
+ } else if (valign === "bottom") {
+ y = Math.round(y - info.height);
+ } else {
+ y = Math.round(y);
+ }
+
+ // FIXME: LEGACY BROWSER FIX
+ // AFFECTS: Opera < 12.00
+
+ // Offset the y coordinate, since Opera is off pretty
+ // consistently compared to the other browsers.
+
+ if (!!(window.opera && window.opera.version().split(".")[0] < 12)) {
+ 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
- // individually for horizontal alignment.
-
- for (var j = 0, line; line = lines[j]; j++) {
- if (halign === "center") {
- position.lines.push([Math.round(x - line.width / 2), y]);
- } else if (halign === "right") {
- position.lines.push([Math.round(x - line.width), y]);
- } else {
- position.lines.push([Math.round(x), y]);
- }
- y += line.height;
- }
- };
- }
+ // 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
+ // individually for horizontal alignment.
+
+ for (var j = 0, line; line = lines[j]; j++) {
+ if (halign === "center") {
+ position.lines.push([Math.round(x - line.width / 2), y]);
+ } else if (halign === "right") {
+ position.lines.push([Math.round(x - line.width), y]);
+ } else {
+ position.lines.push([Math.round(x), y]);
+ }
+ y += line.height;
+ }
+ };
+ }
- $.plot.plugins.push({
- init: init,
- options: options,
- name: "canvas",
- version: "1.0"
- });
+ $.plot.plugins.push({
+ init: init,
+ options: options,
+ name: "canvas",
+ version: "1.0"
+ });
})(jQuery);
diff --git a/jquery.flot.categories.js b/jquery.flot.categories.js
index c048cc5..7cc5253 100644
--- a/jquery.flot.categories.js
+++ b/jquery.flot.categories.js
@@ -9,24 +9,24 @@ allows you to plot such a dataset directly.
To enable it, you must specify mode: "categories" on the axis with the textual
labels, e.g.
- $.plot("#placeholder", data, { xaxis: { mode: "categories" } });
+ $.plot("#placeholder", data, { xaxis: { mode: "categories" } });
By default, the labels are ordered as they are met in the data series. If you
need a different ordering, you can specify "categories" on the axis options
and list the categories there:
- xaxis: {
- mode: "categories",
- categories: ["February", "March", "April"]
- }
+ xaxis: {
+ mode: "categories",
+ categories: ["February", "March", "April"]
+ }
If you need to customize the distances between the categories, you can specify
"categories" as an object mapping labels to values
- xaxis: {
- mode: "categories",
- categories: { "February": 1, "March": 3, "April": 4 }
- }
+ xaxis: {
+ mode: "categories",
+ categories: { "February": 1, "March": 3, "April": 4 }
+ }
If you don't specify all categories, the remaining categories will be numbered
from the max value plus 1 (with a spacing of 1 between each).
diff --git a/jquery.flot.crosshair.js b/jquery.flot.crosshair.js
index 4f3b6a6..3cfdb36 100644
--- a/jquery.flot.crosshair.js
+++ b/jquery.flot.crosshair.js
@@ -5,11 +5,11 @@ Licensed under the MIT license.
The plugin supports these options:
- crosshair: {
- mode: null or "x" or "y" or "xy"
- color: color
- lineWidth: number
- }
+ crosshair: {
+ mode: null or "x" or "y" or "xy"
+ color: color
+ lineWidth: number
+ }
Set the mode to one of "x", "y" or "xy". The "x" mode enables a vertical
crosshair that lets you trace the values on the x axis, "y" enables a
@@ -39,19 +39,19 @@ The plugin also adds four public methods:
Example usage:
- var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
- $("#graph").bind( "plothover", function ( evt, position, item ) {
- if ( item ) {
- // Lock the crosshair to the data point being hovered
- myFlot.lockCrosshair({
- x: item.datapoint[ 0 ],
- y: item.datapoint[ 1 ]
- });
- } else {
- // Return normal crosshair operation
- myFlot.unlockCrosshair();
- }
- });
+ var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
+ $("#graph").bind( "plothover", function ( evt, position, item ) {
+ if ( item ) {
+ // Lock the crosshair to the data point being hovered
+ myFlot.lockCrosshair({
+ x: item.datapoint[ 0 ],
+ y: item.datapoint[ 1 ]
+ });
+ } else {
+ // Return normal crosshair operation
+ myFlot.unlockCrosshair();
+ }
+ });
- unlockCrosshair()
diff --git a/jquery.flot.errorbars.js b/jquery.flot.errorbars.js
index 078db3f..4ac1084 100644
--- a/jquery.flot.errorbars.js
+++ b/jquery.flot.errorbars.js
@@ -15,44 +15,44 @@ your data array (*even* if you do not intend to plot them later, by setting
The plugin supports these options:
- series: {
- points: {
- errorbars: "x" or "y" or "xy",
- xerr: {
- show: null/false or true,
- asymmetric: null/false or true,
- upperCap: null or "-" or function,
- lowerCap: null or "-" or function,
- color: null or color,
- radius: null or number
- },
- yerr: { same options as xerr }
- }
- }
+ series: {
+ points: {
+ errorbars: "x" or "y" or "xy",
+ xerr: {
+ show: null/false or true,
+ asymmetric: null/false or true,
+ upperCap: null or "-" or function,
+ lowerCap: null or "-" or function,
+ color: null or color,
+ radius: null or number
+ },
+ yerr: { same options as xerr }
+ }
+ }
Each data point array is expected to be of the type:
- "x" [ x, y, xerr ]
- "y" [ x, y, yerr ]
- "xy" [ x, y, xerr, yerr ]
+ "x" [ x, y, xerr ]
+ "y" [ x, y, yerr ]
+ "xy" [ x, y, xerr, yerr ]
Where xerr becomes xerr_lower,xerr_upper for the asymmetric error case, and
equivalently for yerr. Eg., a datapoint for the "xy" case with symmetric
error-bars on X and asymmetric on Y would be:
- [ x, y, xerr, yerr_lower, yerr_upper ]
+ [ x, y, xerr, yerr_lower, yerr_upper ]
By default no end caps are drawn. Setting upperCap and/or lowerCap to "-" will
draw a small cap perpendicular to the error bar. They can also be set to a
user-defined drawing function, with (ctx, x, y, radius) as parameters, as eg.
- function drawSemiCircle( ctx, x, y, radius ) {
- ctx.beginPath();
- ctx.arc( x, y, radius, 0, Math.PI, false );
- ctx.moveTo( x - radius, y );
- ctx.lineTo( x + radius, y );
- ctx.stroke();
- }
+ function drawSemiCircle( ctx, x, y, radius ) {
+ ctx.beginPath();
+ ctx.arc( x, y, radius, 0, Math.PI, false );
+ ctx.moveTo( x - radius, y );
+ ctx.lineTo( x + radius, y );
+ ctx.stroke();
+ }
Color and radius both default to the same ones of the points series if not
set. The independent radius parameter on xerr/yerr is useful for the case when
diff --git a/jquery.flot.fillbetween.js b/jquery.flot.fillbetween.js
index be5466a..e1dd143 100644
--- a/jquery.flot.fillbetween.js
+++ b/jquery.flot.fillbetween.js
@@ -10,12 +10,12 @@ plugin to compute it for you.
In order to name the other series, you need to give it an id, like this:
- var dataset = [
- { data: [ ... ], id: "foo" } , // use default bottom
- { data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
- ];
+ var dataset = [
+ { data: [ ... ], id: "foo" } , // use default bottom
+ { data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
+ ];
- $.plot($("#placeholder"), dataset, { lines: { show: true, fill: true }});
+ $.plot($("#placeholder"), dataset, { lines: { show: true, fill: true }});
As a convenience, if the id given is a number that doesn't appear as an id in
the series, it is interpreted as the index in the array instead (so fillBetween:
@@ -31,196 +31,196 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
(function ($) {
- var options = {
- series: {
- fillBetween: null // or number
- }
- };
+ var options = {
+ series: {
+ fillBetween: null // or number
+ }
+ };
- function init(plot) {
+ function init(plot) {
- function findBottomSeries(s, allseries) {
+ function findBottomSeries(s, allseries) {
- var i;
+ var i;
- for (i = 0; i < allseries.length; ++i) {
- if (allseries[i].id === s.fillBetween) {
- return allseries[i];
- }
- }
+ for (i = 0; i < allseries.length; ++i) {
+ if (allseries[i].id === s.fillBetween) {
+ return allseries[i];
+ }
+ }
- if (typeof s.fillBetween === "number") {
- if (s.fillBetween < 0 || s.fillBetween >= allseries.length) {
- return null;
- }
- return allseries[s.fillBetween];
- }
+ if (typeof s.fillBetween === "number") {
+ if (s.fillBetween < 0 || s.fillBetween >= allseries.length) {
+ return null;
+ }
+ return allseries[s.fillBetween];
+ }
- return null;
- }
+ return null;
+ }
- function computeFillBottoms(plot, s, datapoints) {
+ function computeFillBottoms(plot, s, datapoints) {
- if (s.fillBetween == null) {
- return;
- }
+ if (s.fillBetween == null) {
+ return;
+ }
- var other = findBottomSeries(s, plot.getData());
+ var other = findBottomSeries(s, plot.getData());
- if (!other) {
- return;
- }
+ if (!other) {
+ return;
+ }
- var ps = datapoints.pointsize,
- points = datapoints.points,
- otherps = other.datapoints.pointsize,
- otherpoints = other.datapoints.points,
- newpoints = [],
- px, py, intery, qx, qy, bottom,
- withlines = s.lines.show,
- withbottom = ps > 2 && datapoints.format[2].y,
- withsteps = withlines && s.lines.steps,
- fromgap = true,
- i = 0,
- j = 0,
- l, m;
+ var ps = datapoints.pointsize,
+ points = datapoints.points,
+ otherps = other.datapoints.pointsize,
+ otherpoints = other.datapoints.points,
+ newpoints = [],
+ px, py, intery, qx, qy, bottom,
+ withlines = s.lines.show,
+ withbottom = ps > 2 && datapoints.format[2].y,
+ withsteps = withlines && s.lines.steps,
+ fromgap = true,
+ i = 0,
+ j = 0,
+ l, m;
- while (true) {
+ while (true) {
- if (i >= points.length) {
- break;
- }
+ if (i >= points.length) {
+ break;
+ }
- l = newpoints.length;
+ l = newpoints.length;
- if (points[i] == null) {
+ if (points[i] == null) {
- // copy gaps
+ // copy gaps
- for (m = 0; m < ps; ++m) {
- newpoints.push(points[i + m]);
- }
+ for (m = 0; m < ps; ++m) {
+ newpoints.push(points[i + m]);
+ }
- i += ps;
+ i += ps;
- } else if (j >= otherpoints.length) {
+ } else if (j >= otherpoints.length) {
- // for lines, we can't use the rest of the points
+ // for lines, we can't use the rest of the points
- if (!withlines) {
- for (m = 0; m < ps; ++m) {
- newpoints.push(points[i + m]);
- }
- }
+ if (!withlines) {
+ for (m = 0; m < ps; ++m) {
+ newpoints.push(points[i + m]);
+ }
+ }
- i += ps;
+ i += ps;
- } else if (otherpoints[j] == null) {
+ } else if (otherpoints[j] == null) {
- // oops, got a gap
+ // oops, got a gap
- for (m = 0; m < ps; ++m) {
- newpoints.push(null);
- }
+ for (m = 0; m < ps; ++m) {
+ newpoints.push(null);
+ }
- fromgap = true;
- j += otherps;
+ fromgap = true;
+ j += otherps;
- } else {
+ } else {
- // cases where we actually got two points
+ // cases where we actually got two points
- px = points[i];
- py = points[i + 1];
- qx = otherpoints[j];
- qy = otherpoints[j + 1];
- bottom = 0;
+ px = points[i];
+ py = points[i + 1];
+ qx = otherpoints[j];
+ qy = otherpoints[j + 1];
+ bottom = 0;
- if (px === qx) {
+ if (px === qx) {
- for (m = 0; m < ps; ++m) {
- newpoints.push(points[i + m]);
- }
+ for (m = 0; m < ps; ++m) {
+ newpoints.push(points[i + m]);
+ }
- //newpoints[l + 1] += qy;
- bottom = qy;
+ //newpoints[l + 1] += qy;
+ bottom = qy;
- i += ps;
- j += otherps;
+ i += ps;
+ j += otherps;
- } else if (px > qx) {
+ } else if (px > qx) {
- // we got past point below, might need to
- // insert interpolated extra point
+ // we got past point below, might need to
+ // insert interpolated extra point
- if (withlines && i > 0 && points[i - ps] != null) {
- intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
- newpoints.push(qx);
- newpoints.push(intery);
- for (m = 2; m < ps; ++m) {
- newpoints.push(points[i + m]);
- }
- bottom = qy;
- }
+ if (withlines && i > 0 && points[i - ps] != null) {
+ intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
+ newpoints.push(qx);
+ newpoints.push(intery);
+ for (m = 2; m < ps; ++m) {
+ newpoints.push(points[i + m]);
+ }
+ bottom = qy;
+ }
- j += otherps;
+ j += otherps;
- } else { // px < qx
+ } else { // px < qx
- // if we come from a gap, we just skip this point
+ // if we come from a gap, we just skip this point
- if (fromgap && withlines) {
- i += ps;
- continue;
- }
+ if (fromgap && withlines) {
+ i += ps;
+ continue;
+ }
- for (m = 0; m < ps; ++m) {
- newpoints.push(points[i + m]);
- }
+ for (m = 0; m < ps; ++m) {
+ newpoints.push(points[i + m]);
+ }
- // we might be able to interpolate a point below,
- // this can give us a better y
+ // we might be able to interpolate a point below,
+ // this can give us a better y
- if (withlines && j > 0 && otherpoints[j - otherps] != null) {
- bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
- }
+ if (withlines && j > 0 && otherpoints[j - otherps] != null) {
+ bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
+ }
- //newpoints[l + 1] += bottom;
+ //newpoints[l + 1] += bottom;
- i += ps;
- }
+ i += ps;
+ }
- fromgap = false;
+ fromgap = false;
- if (l !== newpoints.length && withbottom) {
- newpoints[l + 2] = bottom;
- }
- }
+ if (l !== newpoints.length && withbottom) {
+ newpoints[l + 2] = bottom;
+ }
+ }
- // maintain the line steps invariant
+ // maintain the line steps invariant
- if (withsteps && l !== newpoints.length && l > 0 &&
- newpoints[l] !== null &&
- newpoints[l] !== newpoints[ l - ps ] &&
- newpoints[l + 1] !== newpoints[l - ps + 1] ) {
- for (m = 0; m < ps; ++m) {
- newpoints[l + ps + m] = newpoints[l + m];
- }
- newpoints[l + 1] = newpoints[l - ps + 1];
- }
- }
+ if (withsteps && l !== newpoints.length && l > 0 &&
+ newpoints[l] !== null &&
+ newpoints[l] !== newpoints[ l - ps ] &&
+ newpoints[l + 1] !== newpoints[l - ps + 1] ) {
+ for (m = 0; m < ps; ++m) {
+ newpoints[l + ps + m] = newpoints[l + m];
+ }
+ newpoints[l + 1] = newpoints[l - ps + 1];
+ }
+ }
- datapoints.points = newpoints;
- }
+ datapoints.points = newpoints;
+ }
- plot.hooks.processDatapoints.push(computeFillBottoms);
- }
+ plot.hooks.processDatapoints.push(computeFillBottoms);
+ }
- $.plot.plugins.push({
- init: init,
- options: options,
- name: "fillbetween",
- version: "1.0"
- });
+ $.plot.plugins.push({
+ init: init,
+ options: options,
+ name: "fillbetween",
+ version: "1.0"
+ });
})(jQuery);
diff --git a/jquery.flot.image.js b/jquery.flot.image.js
index e6f03e3..95bee99 100644
--- a/jquery.flot.image.js
+++ b/jquery.flot.image.js
@@ -11,7 +11,7 @@ with new Image()). If the image is not complete, it's skipped when plotting.
There are two helpers included for retrieving images. The easiest work the way
that you put in URLs instead of images in the data, like this:
- [ "myimage.png", 0, 0, 10, 10 ]
+ [ "myimage.png", 0, 0, 10, 10 ]
Then call $.plot.image.loadData( data, options, callback ) where data and
options are the same as you pass in to $.plot. This loads the images, replaces
@@ -25,20 +25,20 @@ Image object when all images are loaded or have failed loading.
The plugin supports these options:
- series: {
- images: {
- show: boolean
- anchor: "corner" or "center"
- alpha: [ 0, 1 ]
- }
- }
+ series: {
+ images: {
+ show: boolean
+ anchor: "corner" or "center"
+ alpha: [ 0, 1 ]
+ }
+ }
They can be specified for a specific series:
- $.plot( $("#placeholder"), [{
- data: [ ... ],
- images: { ... }
- ])
+ $.plot( $("#placeholder"), [{
+ data: [ ... ],
+ images: { ... }
+ ])
Note that because the data format is different from usual data points, you
can't use images with anything else in a specific data series.
diff --git a/jquery.flot.js b/jquery.flot.js
index 8d27c30..0cb595f 100644
--- a/jquery.flot.js
+++ b/jquery.flot.js
@@ -7,150 +7,150 @@ Licensed under the MIT license.
(function($) {
- ///////////////////////////////////////////////////////////////////////////
- // The Canvas object is a wrapper around an HTML5