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

Switch to === and !== for safer equality testing.

parent 49c312c3
......@@ -80,14 +80,14 @@
c = elem.css(css).toLowerCase();
// keep going until we find an element that has color, or
// we hit the body
if (c !== "" && c != "transparent") {
if (c !== "" && c !== "transparent") {
break;
}
elem = elem.parent();
} while (!$.nodeName(elem.get(0), "body"));
// catch Safari's way of signalling transparent
if (c == "rgba(0, 0, 0, 0)") {
if (c === "rgba(0, 0, 0, 0)") {
c = "transparent";
}
......@@ -138,7 +138,7 @@
// Otherwise, we're most likely dealing with a named color
var name = $.trim(str).toLowerCase();
if (name == "transparent") {
if (name === "transparent") {
return m(255, 255, 255, 0);
} else {
// default to black
......
......@@ -103,7 +103,7 @@ browser, but needs to redraw with canvas text when exporting as an image.
}
}
if (positions.length == 0) {
if (positions.length === 0) {
delete styleCache[key];
}
}
......@@ -280,9 +280,9 @@ browser, but needs to redraw with canvas text when exporting as an image.
// Tweak the initial y-position to match vertical alignment
if (valign == "middle") {
if (valign === "middle") {
y = Math.round(y - info.height / 2);
} else if (valign == "bottom") {
} else if (valign === "bottom") {
y = Math.round(y - info.height);
} else {
y = Math.round(y);
......@@ -302,7 +302,7 @@ browser, but needs to redraw with canvas text when exporting as an image.
// 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) {
if (position.x === x && position.y === y) {
position.active = true;
return;
}
......@@ -323,9 +323,9 @@ browser, but needs to redraw with canvas text when exporting as an image.
// individually for horizontal alignment.
for (var i = 0, line; line = lines[i]; i++) {
if (halign == "center") {
if (halign === "center") {
position.lines.push([Math.round(x - line.width / 2), y]);
} else if (halign == "right") {
} else if (halign === "right") {
position.lines.push([Math.round(x - line.width), y]);
} else {
position.lines.push([Math.round(x), y]);
......
......@@ -58,8 +58,8 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
// auto-transformation to numbers so the strings are intact
// for later processing
var xCategories = series.xaxis.options.mode == "categories",
yCategories = series.yaxis.options.mode == "categories";
var xCategories = series.xaxis.options.mode === "categories",
yCategories = series.yaxis.options.mode === "categories";
if (!(xCategories || yCategories)) {
return;
......@@ -124,7 +124,7 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
}
function setupCategoriesForAxis(series, axis, datapoints) {
if (series[axis].options.mode != "categories") {
if (series[axis].options.mode !== "categories") {
return;
}
......
......@@ -101,7 +101,7 @@ The plugin also adds four public methods:
return;
}
if (crosshair.x != -1) {
if (crosshair.x !== -1) {
crosshair.x = -1;
plot.triggerRedrawOverlay();
}
......@@ -143,7 +143,7 @@ The plugin also adds four public methods:
ctx.save();
ctx.translate(plotOffset.left, plotOffset.top);
if (crosshair.x != -1) {
if (crosshair.x !== -1) {
var adj = plot.getOptions().crosshair.lineWidth % 2 === 0 ? 0 : 0.5;
ctx.strokeStyle = c.color;
......@@ -151,12 +151,12 @@ The plugin also adds four public methods:
ctx.lineJoin = "round";
ctx.beginPath();
if (c.mode.indexOf("x") != -1) {
if (c.mode.indexOf("x") !== -1) {
var drawX = Math.round(crosshair.x) + adj;
ctx.moveTo(drawX, 0);
ctx.lineTo(drawX, plot.height());
}
if (c.mode.indexOf("y") != -1) {
if (c.mode.indexOf("y") !== -1) {
var drawY = Math.round(crosshair.y) + adj;
ctx.moveTo(0, drawY);
ctx.lineTo(plot.width(), drawY);
......
......@@ -86,7 +86,7 @@ shadowSize and lineWidth are derived as well from the points series.
var errors = series.points.errorbars;
// error bars - first X then Y
if (errors == "x" || errors == "xy") {
if (errors === "x" || errors === "xy") {
// lower / upper error
if (series.points.xerr.asymmetric) {
format.push({ x: true, number: true, required: true });
......@@ -95,7 +95,7 @@ shadowSize and lineWidth are derived as well from the points series.
format.push({ x: true, number: true, required: true });
}
}
if (errors == "y" || errors == "xy") {
if (errors === "y" || errors === "xy") {
// lower / upper error
if (series.points.yerr.asymmetric) {
format.push({ y: true, number: true, required: true });
......@@ -121,11 +121,11 @@ shadowSize and lineWidth are derived as well from the points series.
var eb = series.points.errorbars;
// error bars - first X
if (eb == "x" || eb == "xy") {
if (eb === "x" || eb === "xy") {
if (xerr.asymmetric) {
exl = points[i + 2];
exu = points[i + 3];
if (eb == "xy") {
if (eb === "xy") {
if (yerr.asymmetric){
eyl = points[i + 4];
eyu = points[i + 5];
......@@ -135,7 +135,7 @@ shadowSize and lineWidth are derived as well from the points series.
}
} else {
exl = points[i + 2];
if (eb == "xy") {
if (eb === "xy") {
if (yerr.asymmetric) {
eyl = points[i + 3];
eyu = points[i + 4];
......@@ -145,7 +145,7 @@ shadowSize and lineWidth are derived as well from the points series.
}
}
// only Y
} else if (eb == "y") {
} else if (eb === "y") {
if (yerr.asymmetric) {
eyl = points[i + 2];
eyu = points[i + 3];
......@@ -222,12 +222,12 @@ shadowSize and lineWidth are derived as well from the points series.
lower = [x, y][e] - errRanges[e * err.length];
//points outside of the canvas
if (err[e].err == "x") {
if (err[e].err === "x") {
if (y > ax[1].max || y < ax[1].min || upper < ax[0].min || lower > ax[0].max) {
continue;
}
}
if (err[e].err == "y") {
if (err[e].err === "y") {
if (x > ax[0].max || x < ax[0].min || upper < ax[1].min || lower > ax[1].max) {
continue;
}
......@@ -247,7 +247,7 @@ shadowSize and lineWidth are derived as well from the points series.
}
//sanity check, in case some inverted axis hack is applied to flot
if ((err[e].err == "x" && invertX) || (err[e].err == "y" && invertY)) {
if ((err[e].err === "x" && invertX) || (err[e].err === "y" && invertY)) {
//swap coordinates
var tmp = lower;
lower = upper;
......@@ -300,7 +300,7 @@ shadowSize and lineWidth are derived as well from the points series.
lower += offset;
// error bar - avoid plotting over circles
if (err.err == "x"){
if (err.err === "x"){
if (upper > x + radius) {
drawPath(ctx, [[upper,y],[Math.max(x + radius,minmax[0]),y]]);
} else {
......@@ -330,14 +330,14 @@ shadowSize and lineWidth are derived as well from the points series.
// upper cap
if (drawUpper) {
if (err.upperCap == "-"){
if (err.err=="x") {
if (err.upperCap === "-"){
if (err.err === "x") {
drawPath(ctx, [[upper,y - radius],[upper,y + radius]] );
} else {
drawPath(ctx, [[x - radius,upper],[x + radius,upper]] );
}
} else if ($.isFunction(err.upperCap)){
if (err.err=="x") {
if (err.err === "x") {
err.upperCap(ctx, upper, y, radius);
} else {
err.upperCap(ctx, x, upper, radius);
......@@ -346,14 +346,14 @@ shadowSize and lineWidth are derived as well from the points series.
}
// lower cap
if (drawLower) {
if (err.lowerCap == "-"){
if (err.err=="x") {
if (err.lowerCap === "-"){
if (err.err === "x") {
drawPath(ctx, [[lower,y - radius],[lower,y + radius]] );
} else {
drawPath(ctx, [[x - radius,lower],[x + radius,lower]] );
}
} else if ($.isFunction(err.lowerCap)){
if (err.err=="x") {
if (err.err === "x") {
err.lowerCap(ctx, lower, y, radius);
} else {
err.lowerCap(ctx, x, lower, radius);
......
......@@ -80,7 +80,7 @@ Google Maps).
}
$.each(s, function (i, p) {
if (typeof p[0] == "string") {
if (typeof p[0] === "string") {
urls.push(p[0]);
points.push(p);
}
......@@ -101,7 +101,7 @@ Google Maps).
$.plot.image.load = function (urls, callback) {
var missing = urls.length, loaded = {};
if (missing == 0) {
if (missing === 0) {
callback({});
}
......@@ -111,7 +111,7 @@ Google Maps).
loaded[url] = this;
if (missing == 0) {
if (missing === 0) {
callback(loaded);
}
};
......@@ -157,7 +157,7 @@ Google Maps).
// if the anchor is at the center of the pixel, expand the
// image by 1/2 pixel in each direction
if (series.images.anchor == "center") {
if (series.images.anchor === "center") {
tmp = 0.5 * (x2-x1) / (img.width - 1);
x1 -= tmp;
x2 += tmp;
......@@ -167,7 +167,7 @@ Google Maps).
}
// clip
if (x1 == x2 || y1 == y2 ||
if (x1 === x2 || y1 === y2 ||
x1 >= xaxis.max || x2 <= xaxis.min ||
y1 >= yaxis.max || y2 <= yaxis.min) {
continue;
......
This diff is collapsed.
......@@ -87,7 +87,7 @@ can set the default in the options.
jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
*/
//(function(a){function e(h){var k,j=this,l=h.data||{};if(l.elem)j=h.dragTarget=l.elem,h.dragProxy=d.proxy||j,h.cursorOffsetX=l.pageX-l.left,h.cursorOffsetY=l.pageY-l.top,h.offsetX=h.pageX-h.cursorOffsetX,h.offsetY=h.pageY-h.cursorOffsetY;else if(d.dragging||l.which>0&&h.which!=l.which||a(h.target).is(l.not))return;switch(h.type){case"mousedown":return a.extend(l,a(j).offset(),{elem:j,target:h.target,pageX:h.pageX,pageY:h.pageY}),b.add(document,"mousemove mouseup",e,l),i(j,!1),d.dragging=null,!1;case!d.dragging&&"mousemove":if(g(h.pageX-l.pageX)+g(h.pageY-l.pageY)<l.distance)break;h.target=l.target,k=f(h,"dragstart",j),k!==!1&&(d.dragging=j,d.proxy=h.dragProxy=a(k||j)[0]);case"mousemove":if(d.dragging){if(k=f(h,"drag",j),c.drop&&(c.drop.allowed=k!==!1,c.drop.handler(h)),k!==!1)break;h.type="mouseup"}case"mouseup":b.remove(document,"mousemove mouseup",e),d.dragging&&(c.drop&&c.drop.handler(h),f(h,"dragend",j)),i(j,!0),d.dragging=d.proxy=l.elem=!1}return!0}function f(b,c,d){b.type=c;var e=a.event.dispatch.call(d,b);return e===!1?!1:e||b.result}function g(a){return Math.pow(a,2)}function h(){return d.dragging===!1}function i(a,b){a&&(a.unselectable=b?"off":"on",a.onselectstart=function(){return b},a.style&&(a.style.MozUserSelect=b?"":"none"))}a.fn.drag=function(a,b,c){return b&&this.bind("dragstart",a),c&&this.bind("dragend",c),a?this.bind("drag",b?b:a):this.trigger("drag")};var b=a.event,c=b.special,d=c.drag={not:":input",distance:0,which:1,dragging:!1,setup:function(c){c=a.extend({distance:d.distance,which:d.which,not:d.not},c||{}),c.distance=g(c.distance),b.add(this,"mousedown",e,c),this.attachEvent&&this.attachEvent("ondragstart",h)},teardown:function(){b.remove(this,"mousedown",e),this===d.dragging&&(d.dragging=d.proxy=!1),i(this,!0),this.detachEvent&&this.detachEvent("ondragstart",h)}};c.dragstart=c.dragend={setup:function(){},teardown:function(){}}})(jQuery);
(function(a){function e(h){var k,j=this,l=h.data||{};if(l.elem)j=h.dragTarget=l.elem,h.dragProxy=d.proxy||j,h.cursorOffsetX=l.pageX-l.left,h.cursorOffsetY=l.pageY-l.top,h.offsetX=h.pageX-h.cursorOffsetX,h.offsetY=h.pageY-h.cursorOffsetY;else if(d.dragging||l.which>0&&h.which!=l.which||a(h.target).is(l.not))return;switch(h.type){case"mousedown":return a.extend(l,a(j).offset(),{elem:j,target:h.target,pageX:h.pageX,pageY:h.pageY}),b.add(document,"mousemove mouseup",e,l),i(j,!1),d.dragging=null,!1;case!d.dragging&&"mousemove":if(g(h.pageX-l.pageX)+g(h.pageY-l.pageY)<l.distance)break;h.target=l.target,k=f(h,"dragstart",j),k!==!1&&(d.dragging=j,d.proxy=h.dragProxy=a(k||j)[0]);case"mousemove":if(d.dragging){if(k=f(h,"drag",j),c.drop&&(c.drop.allowed=k!==!1,c.drop.handler(h)),k!==!1)break;h.type="mouseup"}case"mouseup":b.remove(document,"mousemove mouseup",e),d.dragging&&(c.drop&&c.drop.handler(h),f(h,"dragend",j)),i(j,!0),d.dragging=d.proxy=l.elem=!1}return!0}function f(b,c,d){b.type=c;var e=a.event.dispatch.call(d,b);return e===!1?!1:e||b.result}function g(a){return Math.pow(a,2)}function h(){return d.dragging===!1}function i(a,b){a&&(a.unselectable=b?"off":"on",a.onselectstart=function(){return b},a.style&&(a.style.MozUserSelect=b?"":"none"))}a.fn.drag=function(a,b,c){return b&&this.bind("dragstart",a),c&&this.bind("dragend",c),a?this.bind("drag",b?b:a):this.trigger("drag")};var b=a.event,c=b.special,d=c.drag={not:":input",distance:0,which:1,dragging:!1,setup:function(c){c=a.extend({distance:d.distance,which:d.which,not:d.not},c||{}),c.distance=g(c.distance),b.add(this,"mousedown",e,c),this.attachEvent&&this.attachEvent("ondragstart",h)},teardown:function(){b.remove(this,"mousedown",e),this===d.dragging&&(d.dragging=d.proxy=!1),i(this,!0),this.detachEvent&&this.detachEvent("ondragstart",h)}};c.dragstart=c.dragend={setup:function(){},teardown:function(){}}})(jQuery);
/* jquery.mousewheel.min.js
* Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
......@@ -142,7 +142,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
panTimeout = null;
function onDragStart(e) {
if (e.which != 1) { // only accept left-click
if (e.which !== 1) { // only accept left-click
return false;
}
var c = plot.getPlaceholder().css("cursor");
......
......@@ -88,7 +88,7 @@ More detail and specific examples can be found in the included HTML file.
// set labels.show
if (options.series.pie.label.show == "auto") {
if (options.series.pie.label.show === "auto") {
if (options.legend.show) {
options.series.pie.label.show = false;
} else {
......@@ -98,7 +98,7 @@ More detail and specific examples can be found in the included HTML file.
// set radius
if (options.series.pie.radius == "auto") {
if (options.series.pie.radius === "auto") {
if (options.series.pie.label.show) {
options.series.pie.radius = 3/4;
} else {
......@@ -180,7 +180,7 @@ More detail and specific examples can be found in the included HTML file.
// new one; this is more efficient and preserves any extra data
// that the user may have stored in higher indexes.
if ($.isArray(value) && value.length == 1) {
if ($.isArray(value) && value.length === 1) {
value = value[0];
}
......@@ -287,7 +287,7 @@ More detail and specific examples can be found in the included HTML file.
centerTop = canvasHeight / 2 + options.series.pie.offset.top;
centerLeft = canvasWidth / 2;
if (options.series.pie.offset.left == "auto") {
if (options.series.pie.offset.left === "auto") {
if (options.legend.position.match("w")) {
centerLeft += legendWidth / 2;
} else {
......@@ -469,7 +469,7 @@ More detail and specific examples can be found in the included HTML file.
function drawLabel(slice, startAngle, index) {
if (slice.data[0][1] == 0) {
if (slice.data[0][1] === 0) {
return true;
}
......@@ -507,7 +507,7 @@ More detail and specific examples can be found in the included HTML file.
return false;
}
if (options.series.pie.label.background.opacity != 0) {
if (options.series.pie.label.background.opacity !== 0) {
// put in the transparent background separately to avoid blended labels and label boxes
......@@ -665,7 +665,7 @@ More detail and specific examples can be found in the included HTML file.
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if (h.auto == eventname && !(item && h.series == item.series)) {
if (h.auto === eventname && !(item && h.series === item.series)) {
unhighlight(h.series);
}
}
......@@ -690,7 +690,7 @@ More detail and specific examples can be found in the included HTML file.
var i = indexOfHighlight(s);
if (i == -1) {
if (i === -1) {
highlights.push({ series: s, auto: auto });
plot.triggerRedrawOverlay();
} else if (!auto) {
......@@ -710,7 +710,7 @@ More detail and specific examples can be found in the included HTML file.
var i = indexOfHighlight(s);
if (i != -1) {
if (i !== -1) {
highlights.splice(i, 1);
plot.triggerRedrawOverlay();
}
......@@ -719,7 +719,7 @@ More detail and specific examples can be found in the included HTML file.
function indexOfHighlight(s) {
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if (h.series == s) {
if (h.series === s) {
return i;
}
}
......
......@@ -31,7 +31,7 @@ can just fix the size of their placeholders.
// somebody might have hidden us and we can't plot
// when we don't have the dimensions
if (placeholder.width() == 0 || placeholder.height() == 0) {
if (placeholder.width() === 0 || placeholder.height() === 0) {
return;
}
......
......@@ -104,7 +104,7 @@ The plugin allso adds the following methods to the plot object:
}
function onMouseDown(e) {
if (e.which != 1) { // only accept left-click
if (e.which !== 1) { // only accept left-click
return;
}
......@@ -199,12 +199,12 @@ The plugin allso adds the following methods to the plot object:
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
if (o.selection.mode == "y") {
pos.x = pos == selection.first ? 0 : plot.width();
if (o.selection.mode === "y") {
pos.x = pos === selection.first ? 0 : plot.width();
}
if (o.selection.mode == "x") {
pos.y = pos == selection.first ? 0 : plot.height();
if (o.selection.mode === "x") {
pos.y = pos === selection.first ? 0 : plot.height();
}
}
......@@ -238,9 +238,9 @@ The plugin allso adds the following methods to the plot object:
for (var k in axes) {
axis = axes[k];
if (axis.direction == coord) {
if (axis.direction === coord) {
key = coord + axis.n + "axis";
if (!ranges[key] && axis.n == 1) {
if (!ranges[key] && axis.n === 1) {
key = coord + "axis"; // support x1axis as xaxis
}
if (ranges[key]) {
......@@ -253,7 +253,7 @@ The plugin allso adds the following methods to the plot object:
// backwards-compat stuff - to be removed in future
if (!ranges[key]) {
axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
axis = coord === "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
from = ranges[coord + "1"];
to = ranges[coord + "2"];
}
......@@ -271,7 +271,7 @@ The plugin allso adds the following methods to the plot object:
function setSelection(ranges, preventEvent) {
var axis, range, o = plot.getOptions();
if (o.selection.mode == "y") {
if (o.selection.mode === "y") {
selection.first.x = 0;
selection.second.x = plot.width();
}
......@@ -282,7 +282,7 @@ The plugin allso adds the following methods to the plot object:
selection.second.x = range.axis.p2c(range.to);
}
if (o.selection.mode == "x") {
if (o.selection.mode === "x") {
selection.first.y = 0;
selection.second.y = plot.height();
}
......
......@@ -44,11 +44,11 @@ charts or filled areas).
function findMatchingSeries(s, allseries) {
var res = null;
for (var i = 0; i < allseries.length; ++i) {
if (s == allseries[i]) {
if (s === allseries[i]) {
break;
}
if (allseries[i].stack == s.stack) {
if (allseries[i].stack === s.stack) {
res = allseries[i];
}
}
......@@ -120,7 +120,7 @@ charts or filled areas).
qy = otherpoints[j + accumulateOffset];
bottom = 0;
if (px == qx) {
if (px === qx) {
for (m = 0; m < ps; ++m) {
newpoints.push(points[i + m]);
}
......@@ -170,16 +170,16 @@ charts or filled areas).
fromgap = false;
if (l != newpoints.length && withbottom) {
if (l !== newpoints.length && withbottom) {
newpoints[l + 2] += bottom;
}
}
// maintain the line steps invariant
if (withsteps && l != newpoints.length && l > 0 &&
if (withsteps && l !== newpoints.length && l > 0 &&
newpoints[l] != null &&
newpoints[l] != newpoints[l - ps] &&
newpoints[l + 1] != newpoints[l - ps + 1]) {
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];
}
......
......@@ -77,7 +77,7 @@ You may need to check for this in hover events.
p = newpoints;
}
if (addCrossingPoints && prevp != p && x != null && i > 0 && origpoints[i - ps] != null) {
if (addCrossingPoints && prevp !== p && x != null && i > 0 && origpoints[i - ps] != null) {
var interx = x + (below - y) * (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]);
prevp.push(interx);
prevp.push(below);
......
......@@ -30,14 +30,14 @@ API.txt for details.
function formatDate(d, fmt, monthNames, dayNames) {
if (typeof d.strftime == "function") {
if ($.isFunction(d.strftime)) {
return d.strftime(fmt);
}
var leftPad = function(n, pad) {
n = "" + n;
pad = "" + (pad == null ? "0" : pad);
return n.length == 1 ? pad + n : n;
return n.length === 1 ? pad + n : n;
};
var r = [];
......@@ -57,7 +57,7 @@ API.txt for details.
if (hours > 12) {
hours12 = hours - 12;
} else if (hours == 0) {
} else if (hours === 0) {
hours12 = 12;
} else {
hours12 = hours;
......@@ -92,7 +92,7 @@ API.txt for details.
r.push(c);
escape = false;
} else {
if (c == "%") {
if (c === "%") {
escape = true;
} else {
r.push(c);
......@@ -122,7 +122,7 @@ API.txt for details.
// support strftime, if found
if (d.strftime != undefined) {
if (d.strftime !== undefined) {
addProxyMethod(utc, "strftime", d, "strftime");
}
......@@ -143,11 +143,11 @@ API.txt for details.
// desired timezone
function dateGenerator(ts, opts) {
if (opts.timezone == "browser") {
if (opts.timezone === "browser") {
return new Date(ts);
} else if (!opts.timezone || opts.timezone == "utc") {
} else if (!opts.timezone || opts.timezone === "utc") {
return makeUtcWrapper(new Date(ts));
} else if (typeof timezoneJS != "undefined" && typeof timezoneJS.Date != "undefined") {
} else if (typeof timezoneJS !== "undefined" && typeof timezoneJS.Date !== "undefined") {
var d = new timezoneJS.Date();
// timezone-js is fickle, so be sure to set the time zone before
// setting the time.
......@@ -200,7 +200,7 @@ API.txt for details.
var opts = axis.options;
if (opts.mode == "time") {
if (opts.mode === "time") {
axis.tickGenerator = function(axis) {
var ticks = [];
......@@ -216,7 +216,7 @@ API.txt for details.
"quarter") ? specQuarters : specMonths;
if (opts.minTickSize != null) {
if (typeof opts.tickSize == "number") {
if (typeof opts.tickSize === "number") {
minSize = opts.tickSize;
} else {
minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]];
......@@ -236,12 +236,12 @@ API.txt for details.
// special-case the possibility of several years
if (unit == "year") {
if (unit === "year") {
// if given a minTickSize in years, just use it,
// ensuring that it's an integer
if (opts.minTickSize != null && opts.minTickSize[1] == "year") {
if (opts.minTickSize != null && opts.minTickSize[1] === "year") {
size = Math.floor(opts.minTickSize[0]);
} else {
......@@ -274,18 +274,18 @@ API.txt for details.
var step = tickSize * timeUnitSize[unit];
if (unit == "second") {
if (unit === "second") {
d.setSeconds(floorInBase(d.getSeconds(), tickSize));
} else if (unit == "minute") {
} else if (unit === "minute") {
d.setMinutes(floorInBase(d.getMinutes(), tickSize));
} else if (unit == "hour") {
} else if (unit === "hour") {
d.setHours(floorInBase(d.getHours(), tickSize));
} else if (unit == "month") {
} else if (unit === "month") {
d.setMonth(floorInBase(d.getMonth(), tickSize));
} else if (unit == "quarter") {
} else if (unit === "quarter") {
d.setMonth(3 * floorInBase(d.getMonth() / 3,
tickSize));
} else if (unit == "year") {
} else if (unit === "year") {
d.setFullYear(floorInBase(d.getFullYear(), tickSize));
}
......@@ -325,7 +325,7 @@ API.txt for details.
v = d.getTime();
ticks.push(v);
if (unit == "month" || unit == "quarter") {
if (unit === "month" || unit === "quarter") {
if (tickSize < 1) {
// a bit complicated - we'll divide the
......@@ -335,21 +335,21 @@ API.txt for details.
d.setDate(1);
var start = d.getTime();
d.setMonth(d.getMonth() + (unit == "quarter" ? 3 : 1));
d.setMonth(d.getMonth() + (unit === "quarter" ? 3 : 1));
var end = d.getTime();
d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
carry = d.getHours();
d.setHours(0);
} else {
d.setMonth(d.getMonth() +
tickSize * (unit == "quarter" ? 3 : 1));
tickSize * (unit === "quarter" ? 3 : 1));
}
} else if (unit == "year") {
} else if (unit === "year") {
d.setFullYear(d.getFullYear() + tickSize);
} else {
d.setTime(v + step);
}
} while (v < axis.max && v != prev);
} while (v < axis.max && v !== prev);
return ticks;
};
......@@ -368,9 +368,9 @@ API.txt for details.
// any of these places
var useQuarters = (axis.options.tickSize &&
axis.options.tickSize[1] == "quarter") ||
axis.options.tickSize[1] === "quarter") ||
(axis.options.minTickSize &&
axis.options.minTickSize[1] == "quarter");
axis.options.minTickSize[1] === "quarter");
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
var span = axis.max - axis.min;
......
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