* skip over points with missing yVals.
*/
DygraphCanvasRenderer._getIteratorPredicate = function(connectSeparatedPoints) {
- return connectSeparatedPoints
- ? DygraphCanvasRenderer._predicateThatSkipsEmptyPoints
- : null;
+ return connectSeparatedPoints ?
+ DygraphCanvasRenderer._predicateThatSkipsEmptyPoints :
+ null;
};
DygraphCanvasRenderer._predicateThatSkipsEmptyPoints =
if (point.canvasy === null || point.canvasy != point.canvasy) {
if (stepPlot && prevCanvasX !== null) {
// Draw a horizontal line to the start of the missing data
- ctx.moveTo(prevX, prevY);
- ctx.lineTo(point.canvasx, prevY);
+ ctx.moveTo(prevCanvasX, prevCanvasY);
+ ctx.lineTo(point.canvasx, prevCanvasY);
}
prevCanvasX = prevCanvasY = null;
} else {
e.dygraph, e.setName, ctx, cb[0], cb[1], color, pointSize);
ctx.restore();
}
-}
+};
/**
* Attaches canvas coordinates to the points array.
var sets = this.layout.points;
var setNames = this.layout.setNames;
var setCount = setNames.length;
+ var setName;
this.colors = this.dygraph_.colorsMap_;
var setPlotters = {}; // series name -> plotter fn.
for (i = 0; i < setNames.length; i++) {
- var setName = setNames[i];
+ setName = setNames[i];
var setPlotter = this.attr_("plotter", setName);
if (setPlotter == plotter_attr) continue; // not specialized.
var is_last = (i == plotters.length - 1);
for (var j = 0; j < sets.length; j++) {
- var setName = setNames[j];
+ setName = setNames[j];
if (opt_seriesName && setName != opt_seriesName) continue;
var points = sets[j];
drawPointCallback,
pointSize
);
-}
+};
/**
* Draws the shaded error bars/confidence intervals for each series.
prevX = point.canvasx;
}
ctx.fill();
-}
+};
/**
* Draws the shaded regions when "fillGraph" is set. Not to be confused with
* @private
*/
Dygraph.Interaction.endTouch = function(event, g, context) {
- if (event.touches.length != 0) {
+ if (event.touches.length !== 0) {
// this is effectively a "reset"
Dygraph.Interaction.startTouch(event, g, context);
}
// Assume it's a number or NaN. If it's something else, I'll be shocked.
return val;
-}
+};
DygraphLayout.prototype._evaluateLineTicks = function() {
var i, tick, label, pos;
}
Dygraph.cancelEvent(e);
var delX = e.screenX - xLast;
- if (Math.abs(delX) < 4 || e.screenX == 0) { // First iPad move event seems to have screenX = 0
+ if (Math.abs(delX) < 4 || e.screenX === 0) {
+ // First iPad move event seems to have screenX = 0
return true;
}
xLast = e.screenX;
this.end_ = Math.min(array.length, start + length);
this.nextIdx_ = start - 1; // use -1 so initial advance works.
this.next(); // ignoring result.
-}
+};
Dygraph.Iterator.prototype.next = function() {
if (!this.hasNext) {
this.peek = null;
}
return obj;
-}
+};
/**
* @private
}
ctx.fill();
ctx.stroke();
-}
+};
Dygraph.shapeFunction_ = function(sides, rotationRadians, delta) {
return function(g, name, ctx, cx, cy, color, radius) {
Dygraph.DrawPolygon_ = function(sides, rotationRadians, ctx, cx, cy, color, radius, delta) {
new Dygraph.RegularShape_(sides, rotationRadians, delta).draw(ctx, cx, cy, radius);
-}
+};
Dygraph.Circles = {
DEFAULT : function(g, name, ctx, canvasx, canvasy, color, radius) {
// Activate plugins.
this.plugins_ = [];
for (var i = 0; i < Dygraph.PLUGINS.length; i++) {
- var plugin = Dygraph.PLUGINS[i];
- var pluginInstance = new plugin();
+ var Plugin = Dygraph.PLUGINS[i];
+ var pluginInstance = new Plugin();
var pluginDict = {
plugin: pluginInstance,
events: {},
* @private
*/
Dygraph.prototype.cascadeEvents_ = function(name, extra_props) {
- if (!name in this.eventListeners_) return true;
+ if (!(name in this.eventListeners_)) return true;
// QUESTION: can we use objects & prototypes to speed this up?
var e = {
* Axis is an optional parameter. Can be set to 'x' or 'y'.
*
* The zoomed status for an axis is set whenever a user zooms using the mouse
- * or when the dateWindow or valueRange are updated (unless the isZoomedIgnoreProgrammaticZoom
- * option is also specified).
+ * or when the dateWindow or valueRange are updated (unless the
+ * isZoomedIgnoreProgrammaticZoom option is also specified).
*/
Dygraph.prototype.isZoomed = function(axis) {
- if (axis == null) return this.zoomed_x_ || this.zoomed_y_;
+ if (axis === null || axis === undefined) {
+ return this.zoomed_x_ || this.zoomed_y_;
+ }
if (axis === 'x') return this.zoomed_x_;
if (axis === 'y') return this.zoomed_y_;
throw "axis parameter is [" + axis + "] must be null, 'x' or 'y'.";
}
if (seriesName === this.highlightSet_ &&
this.user_attrs_.hasOwnProperty('highlightSeriesOpts')) {
- sources.push(this.user_attrs_['highlightSeriesOpts']);
+ sources.push(this.user_attrs_.highlightSeriesOpts);
}
}
}
newValueRanges = [];
for (i = 0; i < this.axes_.length; i++) {
var axis = this.axes_[i];
- newValueRanges.push(axis.valueRange != null ? axis.valueRange : axis.extremeRange);
+ newValueRanges.push(axis.valueRange !== null ?
+ axis.valueRange : axis.extremeRange);
}
}
}
}
// Stop if the point (domX, py) is above this series' upper edge
- if (setIdx == 0 || py < domY) {
+ if (setIdx === 0 || py < domY) {
closestPoint = p1;
closestSeries = setIdx;
}
point = this.layout_.unstackPointAtIndex(setIdx, row);
}
- if (!(point.yval === null)) this.selPoints_.push(point);
+ if (point.yval !== null) this.selPoints_.push(point);
}
}
} else {
num = Math.floor((num - 1) / 26);
}
return shortText;
- }
+ };
var cols = data.getNumberOfColumns();
var rows = data.getNumberOfRows();
#
# The zero-argument form lints everything.
-jsc_opts='maxerr:10000,devel:true,browser:true'
-rhino_opts='maxerr=10000,devel=true,browser=true'
+# See jshint/build/jshint-rhino.js for documentation on these parameters.
+# devel defines logging globals (i.e. "console.log")
+# browser defines standard web browser globals (i.e. "document")
+# shadow disables warnings on multiple var definitions in one scope (i.e. two
+# loops with "var i")
+jsc_opts='maxerr:10000,devel:true,browser:true,shadow:true'
+rhino_opts='maxerr=10000,devel=true,browser=true,shadow=true'
if [ $# -gt 1 ]; then
echo "Usage: $0 [file.js]"
files=$1
fi
+jshint_opts="shadow=false"
+
if [ -e /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc ]; then
# use JSC (Safari/JavaScriptCore) to run JSHint -- much faster than Rhino.
echo 'Running JSHint w/ JavaScriptCore (jsc)...'
// Early out in the (common) case of zero annotations.
var points = g.layout_.annotated_points;
- if (!points || points.length == 0) return;
+ if (!points || points.length === 0) return;
var containerDiv = e.canvas.parentNode;
var annotationStyle = {
axes.prototype.clearChart = function(e) {
var g = e.dygraph;
this.detachLabels();
-}
+};
axes.prototype.willDrawChart = function(e) {
var g = e.dygraph;
}
context.restore();
-}
+};
return axes;
})();
inner_div.appendChild(class_div);
div.appendChild(inner_div);
return div;
-}
+};
chart_labels.prototype.layout = function(e) {
this.detachLabels_();
};
chart_labels.prototype.destroy = function() {
- detachLabels();
+ this.detachLabels_();
};
}
ctx.restore();
}
-}
+};
grid.prototype.destroy = function() {
};
*/
+/*jshint globalstrict: true */
+/*global Dygraph:false */
"use strict";
return "Legend Plugin";
};
+// (defined below)
+var generateLegendHTML, generateLegendDashHTML;
+
/**
* This is called during the dygraph constructor, after options have been set
* but before the data is available.
legend.prototype.didDrawChart = function(e) {
this.deselect(e);
-}
+};
// Right edge should be flush with the right edge of the charting area (which
// may not be the same as the right edge of the div, if we have two y-axes.
var xOptView = g.optionsViewForAxis_('x');
var xvf = xOptView('valueFormatter');
html = xvf(x, xOptView, labels[0], g);
- if(html !== '') {
- html += ':';
+ if (html !== '') {
+ html += ':';
}
var yOptViews = [];