Commit 9bb52ea5 authored by David Schnur's avatar David Schnur

Merge branch '0.9-jsDoc-fix' of https://github.com/ameyms/flot into ameyms-0.9-jsDoc-fix

Conflicts:
	jquery.flot.js
parents 6e76ffff 61fb96d7
...@@ -13,16 +13,16 @@ Licensed under the MIT license. ...@@ -13,16 +13,16 @@ Licensed under the MIT license.
return obj - parseFloat( obj ) >= 0; return obj - parseFloat( obj ) >= 0;
}; };
/////////////////////////////////////////////////////////////////////////// /**
// The Canvas object is a wrapper around an HTML5 <canvas> tag. * The Canvas object is a wrapper around an HTML5 <canvas> tag.
// *
// @constructor * @constructor
// @param {string} cls List of classes to apply to the canvas. * @param {string} cls List of classes to apply to the canvas.
// @param {element} container Element onto which to append the canvas. * @param {element} container Element onto which to append the canvas.
// *
// Requiring a container is a little iffy, but unfortunately canvas * Requiring a container is a little iffy, but unfortunately canvas
// operations don't work unless the canvas is attached to the DOM. * operations don't work unless the canvas is attached to the DOM.
*/
function Canvas(cls, container) { function Canvas(cls, container) {
var element = container.children("." + cls)[0]; var element = container.children("." + cls)[0];
...@@ -83,11 +83,12 @@ Licensed under the MIT license. ...@@ -83,11 +83,12 @@ Licensed under the MIT license.
this._textCache = {}; this._textCache = {};
} }
// Resizes the canvas to the given dimensions. /**
// * Resizes the canvas to the given dimensions.
// @param {number} width New width of the canvas, in pixels. *
// @param {number} width New height of the canvas, in pixels. * @param {number} width New width of the canvas, in pixels.
* @param {number} width New height of the canvas, in pixels.
*/
Canvas.prototype.resize = function(width, height) { Canvas.prototype.resize = function(width, height) {
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
...@@ -131,14 +132,16 @@ Licensed under the MIT license. ...@@ -131,14 +132,16 @@ Licensed under the MIT license.
context.scale(pixelRatio, pixelRatio); context.scale(pixelRatio, pixelRatio);
}; };
// Clears the entire canvas area, not including any overlaid HTML text /**
* Clears the entire canvas area, not including any overlaid HTML text
*/
Canvas.prototype.clear = function() { Canvas.prototype.clear = function() {
this.context.clearRect(0, 0, this.width, this.height); this.context.clearRect(0, 0, this.width, this.height);
}; };
// Finishes rendering the canvas, including managing the text overlay. /**
* Finishes rendering the canvas, including managing the text overlay.
*/
Canvas.prototype.render = function() { Canvas.prototype.render = function() {
var cache = this._textCache; var cache = this._textCache;
...@@ -194,12 +197,13 @@ Licensed under the MIT license. ...@@ -194,12 +197,13 @@ Licensed under the MIT license.
} }
}; };
// Creates (if necessary) and returns the text overlay container. /**
// * Creates (if necessary) and returns the text overlay container.
// @param {string} classes String of space-separated CSS classes used to *
// uniquely identify the text layer. * @param {string} classes String of space-separated CSS classes used to
// @return {object} The jQuery-wrapped text-layer div. * uniquely identify the text layer.
* @return {object} The jQuery-wrapped text-layer div.
*/
Canvas.prototype.getTextLayer = function(classes) { Canvas.prototype.getTextLayer = function(classes) {
var layer = this.text[classes]; var layer = this.text[classes];
...@@ -239,45 +243,46 @@ Licensed under the MIT license. ...@@ -239,45 +243,46 @@ Licensed under the MIT license.
return layer; return layer;
}; };
// Creates (if necessary) and returns a text info object. /**
// * Creates (if necessary) and returns a text info object.
// The object looks like this: *
// * The object looks like this:
// { *
// width: Width of the text's wrapper div. * {
// height: Height of the text's wrapper div. * width: Width of the text's wrapper div.
// element: The jQuery-wrapped HTML div containing the text. * height: Height of the text's wrapper div.
// positions: Array of positions at which this text is drawn. * element: The jQuery-wrapped HTML div containing the text.
// } * positions: Array of positions at which this text is drawn.
// * }
// The positions array contains objects that look like this: *
// * The positions array contains objects that look like this:
// { *
// active: Flag indicating whether the text should be visible. * {
// rendered: Flag indicating whether the text is currently visible. * active: Flag indicating whether the text should be visible.
// element: The jQuery-wrapped HTML div containing the text. * rendered: Flag indicating whether the text is currently visible.
// x: X coordinate at which to draw the text. * element: The jQuery-wrapped HTML div containing the text.
// y: Y coordinate at which to draw the text. * x: X coordinate at which to draw the text.
// } * y: Y coordinate at which to draw the text.
// * }
// Each position after the first receives a clone of the original element. *
// * Each position after the first receives a clone of the original element.
// The idea is that that the width, height, and general 'identity' of the *
// text is constant no matter where it is placed; the placements are a * The idea is that that the width, height, and general 'identity' of the
// secondary property. * text is constant no matter where it is placed; the placements are a
// * secondary property.
// Canvas maintains a cache of recently-used text info objects; getTextInfo *
// either returns the cached element or creates a new entry. * Canvas maintains a cache of recently-used text info objects; getTextInfo
// * either returns the cached element or creates a new entry.
// @param {string} layer A string of space-separated CSS classes uniquely *
// identifying the layer containing this text. * @param {string} layer A string of space-separated CSS classes uniquely
// @param {string} text Text string to retrieve info for. * identifying the layer containing this text.
// @param {(string|object)=} font Either a string of space-separated CSS * @param {string} text Text string to retrieve info for.
// classes or a font-spec object, defining the text's font and style. * @param {(string|object)=} font Either a string of space-separated CSS
// @param {number=} angle Angle at which to rotate the text, in degrees. * classes or a font-spec object, defining the text's font and style.
// @param {number=} width Maximum width of the text before it wraps. * @param {number=} angle Angle at which to rotate the text, in degrees.
// @return {object} a text info object. * @param {number=} width Maximum width of the text before it wraps.
* @return {object} a text info object.
*/
Canvas.prototype.getTextInfo = function(layer, text, font, angle, width) { Canvas.prototype.getTextInfo = function(layer, text, font, angle, width) {
var textStyle, layerCache, styleCache, angleCache, info; var textStyle, layerCache, styleCache, angleCache, info;
...@@ -454,25 +459,26 @@ Licensed under the MIT license. ...@@ -454,25 +459,26 @@ Licensed under the MIT license.
return info; return info;
}; };
// Adds a text string to the canvas text overlay. /**
// * Adds a text string to the canvas text overlay.
// The text isn't drawn immediately; it is marked as rendering, which will *
// result in its addition to the canvas on the next render pass. * The text isn't drawn immediately; it is marked as rendering, which will
// * result in its addition to the canvas on the next render pass.
// @param {string} layer A string of space-separated CSS classes uniquely *
// identifying the layer containing this text. * @param {string} layer A string of space-separated CSS classes uniquely
// @param {number} x X coordinate at which to draw the text. * identifying the layer containing this text.
// @param {number} y Y coordinate at which to draw the text. * @param {number} x X coordinate at which to draw the text.
// @param {string} text Text string to draw. * @param {number} y Y coordinate at which to draw the text.
// @param {(string|object)=} font Either a string of space-separated CSS * @param {string} text Text string to draw.
// classes or a font-spec object, defining the text's font and style. * @param {(string|object)=} font Either a string of space-separated CSS
// @param {number=} angle Angle at which to rotate the text, in degrees. * classes or a font-spec object, defining the text's font and style.
// @param {number=} width Maximum width of the text before it wraps. * @param {number=} angle Angle at which to rotate the text, in degrees.
// @param {string=} halign Horizontal alignment of the text; either "left", * @param {number=} width Maximum width of the text before it wraps.
// "center" or "right". * @param {string=} halign Horizontal alignment of the text; either "left",
// @param {string=} valign Vertical alignment of the text; either "top", * "center" or "right".
// "middle" or "bottom". * @param {string=} valign Vertical alignment of the text; either "top",
* "middle" or "bottom".
*/
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) {
var info = this.getTextInfo(layer, text, font, angle, width), var info = this.getTextInfo(layer, text, font, angle, width),
...@@ -526,26 +532,27 @@ Licensed under the MIT license. ...@@ -526,26 +532,27 @@ Licensed under the MIT license.
}); });
}; };
// Removes one or more text strings from the canvas text overlay. /**
// * Removes one or more text strings from the canvas text overlay.
// If no parameters are given, all text within the layer is removed. *
// * If no parameters are given, all text within the layer is removed.
// Note that the text is not immediately removed; it is simply marked as *
// inactive, which will result in its removal on the next render pass. * Note that the text is not immediately removed; it is simply marked as
// This avoids the performance penalty for 'clear and redraw' behavior, * inactive, which will result in its removal on the next render pass.
// where we potentially get rid of all text on a layer, but will likely * This avoids the performance penalty for 'clear and redraw' behavior,
// add back most or all of it later, as when redrawing axes, for example. * where we potentially get rid of all text on a layer, but will likely
// * add back most or all of it later, as when redrawing axes, for example.
// @param {string} layer A string of space-separated CSS classes uniquely *
// identifying the layer containing this text. * @param {string} layer A string of space-separated CSS classes uniquely
// @param {number=} x X coordinate of the text. * identifying the layer containing this text.
// @param {number=} y Y coordinate of the text. * @param {number=} x X coordinate of the text.
// @param {string=} text Text string to remove. * @param {number=} y Y coordinate of the text.
// @param {(string|object)=} font Either a string of space-separated CSS * @param {string=} text Text string to remove.
// classes or a font-spec object, defining the text's font and style. * @param {(string|object)=} font Either a string of space-separated CSS
// @param {number=} angle Angle at which the text is rotated, in degrees. * classes or a font-spec object, defining the text's font and style.
// Angle is currently unused, it will be implemented in the future. * @param {number=} angle Angle at which the text is rotated, in degrees.
* Angle is currently unused, it will be implemented in the future.
*/
Canvas.prototype.removeText = function(layer, x, y, text, font, angle) { Canvas.prototype.removeText = function(layer, x, y, text, font, angle) {
var i, positions, position; var i, positions, position;
if (text == null) { if (text == null) {
...@@ -580,9 +587,9 @@ Licensed under the MIT license. ...@@ -580,9 +587,9 @@ Licensed under the MIT license.
} }
}; };
/////////////////////////////////////////////////////////////////////////// /**
// The top-level container for the entire plot. * The top-level container for the entire plot.
*/
function Plot(placeholder, data_, options_, plugins) { function Plot(placeholder, data_, options_, plugins) {
// data is on the form: // data is on the form:
// [ series1, series2 ... ] // [ series1, series2 ... ]
......
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