Commit ffcd71f4 authored by David Schnur's avatar David Schnur

Miscellaneous code cleanup.

parent 3de9c0e9
...@@ -138,8 +138,7 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories. ...@@ -138,8 +138,7 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
for (var i = 0; i < o.length; ++i) { for (var i = 0; i < o.length; ++i) {
c[o[i]] = i; c[o[i]] = i;
} }
} } else {
else {
for (var v in o) { for (var v in o) {
if (Object.prototype.hasOwnProperty.call(o, v)) { if (Object.prototype.hasOwnProperty.call(o, v)) {
c[v] = o[v]; c[v] = o[v];
......
...@@ -59,6 +59,7 @@ The plugin also adds four public methods: ...@@ -59,6 +59,7 @@ The plugin also adds four public methods:
*/ */
(function ($) { (function ($) {
var options = { var options = {
crosshair: { crosshair: {
mode: null, // one of null, "x", "y" or "xy", mode: null, // one of null, "x", "y" or "xy",
...@@ -178,4 +179,5 @@ The plugin also adds four public methods: ...@@ -178,4 +179,5 @@ The plugin also adds four public methods:
name: "crosshair", name: "crosshair",
version: "1.0" version: "1.0"
}); });
})(jQuery); })(jQuery);
...@@ -115,11 +115,11 @@ shadowSize and lineWidth are derived as well from the points series. ...@@ -115,11 +115,11 @@ shadowSize and lineWidth are derived as well from the points series.
var exl = null, var exl = null,
exu = null, exu = null,
eyl = null, eyl = null,
eyu = null; eyu = null,
var xerr = series.points.xerr, xerr = series.points.xerr,
yerr = series.points.yerr; yerr = series.points.yerr,
eb = series.points.errorbars;
var eb = series.points.errorbars;
// error bars - first X // error bars - first X
if (eb === "x" || eb === "xy") { if (eb === "x" || eb === "xy") {
if (xerr.asymmetric) { if (xerr.asymmetric) {
...@@ -204,7 +204,6 @@ shadowSize and lineWidth are derived as well from the points series. ...@@ -204,7 +204,6 @@ shadowSize and lineWidth are derived as well from the points series.
for (var i = 0; i < s.datapoints.points.length; i += ps) { for (var i = 0; i < s.datapoints.points.length; i += ps) {
//parse
var errRanges = parseErrors(s, i); var errRanges = parseErrors(s, i);
//cycle xerr & yerr //cycle xerr & yerr
...@@ -367,7 +366,7 @@ shadowSize and lineWidth are derived as well from the points series. ...@@ -367,7 +366,7 @@ shadowSize and lineWidth are derived as well from the points series.
function drawPath(ctx, pts){ function drawPath(ctx, pts){
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(pts[0][0], pts[0][1]); ctx.moveTo(pts[0][0], pts[0][1]);
for (var p=1; p < pts.length; p++) { for (var p = 1; p < pts.length; p++) {
ctx.lineTo(pts[p][0], pts[p][1]); ctx.lineTo(pts[p][0], pts[p][1]);
} }
ctx.stroke(); ctx.stroke();
...@@ -397,4 +396,5 @@ shadowSize and lineWidth are derived as well from the points series. ...@@ -397,4 +396,5 @@ shadowSize and lineWidth are derived as well from the points series.
name: "errorbars", name: "errorbars",
version: "1.0" version: "1.0"
}); });
})(jQuery); })(jQuery);
...@@ -29,7 +29,7 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -29,7 +29,7 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
*/ */
(function ( $ ) { (function ($) {
var options = { var options = {
series: { series: {
...@@ -37,37 +37,37 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -37,37 +37,37 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
} }
}; };
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 ) { for (i = 0; i < allseries.length; ++i) {
if ( allseries[ i ].id === s.fillBetween ) { if (allseries[i].id === s.fillBetween) {
return allseries[ i ]; return allseries[i];
} }
} }
if ( typeof s.fillBetween === "number" ) { if (typeof s.fillBetween === "number") {
if ( s.fillBetween < 0 || s.fillBetween >= allseries.length ) { if (s.fillBetween < 0 || s.fillBetween >= allseries.length) {
return null; return null;
} }
return allseries[ s.fillBetween ]; return allseries[s.fillBetween];
} }
return null; return null;
} }
function computeFillBottoms( plot, s, datapoints ) { function computeFillBottoms(plot, s, datapoints) {
if ( s.fillBetween == null ) { if (s.fillBetween == null) {
return; return;
} }
var other = findBottomSeries( s, plot.getData() ); var other = findBottomSeries(s, plot.getData());
if ( !other ) { if (!other) {
return; return;
} }
...@@ -85,42 +85,42 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -85,42 +85,42 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
j = 0, j = 0,
l, m; l, m;
while ( true ) { while (true) {
if ( i >= points.length ) { if (i >= points.length) {
break; 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 ) { for (m = 0; m < ps; ++m) {
newpoints.push( points[ i + 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 ) { if (!withlines) {
for ( m = 0; m < ps; ++m ) { for (m = 0; m < ps; ++m) {
newpoints.push( points[ i + 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 ) { for (m = 0; m < ps; ++m) {
newpoints.push( null ); newpoints.push(null);
} }
fromgap = true; fromgap = true;
...@@ -130,35 +130,35 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -130,35 +130,35 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
// cases where we actually got two points // cases where we actually got two points
px = points[ i ]; px = points[i];
py = points[ i + 1 ]; py = points[i + 1];
qx = otherpoints[ j ]; qx = otherpoints[j];
qy = otherpoints[ j + 1 ]; qy = otherpoints[j + 1];
bottom = 0; bottom = 0;
if ( px === qx ) { if (px === qx) {
for ( m = 0; m < ps; ++m ) { for (m = 0; m < ps; ++m) {
newpoints.push( points[ i + m ] ); newpoints.push(points[i + m]);
} }
//newpoints[ l + 1 ] += qy; //newpoints[l + 1] += qy;
bottom = qy; bottom = qy;
i += ps; i += ps;
j += otherps; j += otherps;
} else if ( px > qx ) { } else if (px > qx) {
// we got past point below, might need to // we got past point below, might need to
// insert interpolated extra point // insert interpolated extra point
if ( withlines && i > 0 && points[ i - ps ] != null ) { if (withlines && i > 0 && points[i - ps] != null) {
intery = py + ( points[ i - ps + 1 ] - py ) * ( qx - px ) / ( points[ i - ps ] - px ); intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
newpoints.push( qx ); newpoints.push(qx);
newpoints.push( intery ); newpoints.push(intery);
for ( m = 2; m < ps; ++m ) { for (m = 2; m < ps; ++m) {
newpoints.push( points[ i + m ] ); newpoints.push(points[i + m]);
} }
bottom = qy; bottom = qy;
} }
...@@ -169,20 +169,20 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -169,20 +169,20 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
// 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 ) { if (fromgap && withlines) {
i += ps; i += ps;
continue; continue;
} }
for ( m = 0; m < ps; ++m ) { for (m = 0; m < ps; ++m) {
newpoints.push( points[ i + m ] ); newpoints.push(points[i + m]);
} }
// we might be able to interpolate a point below, // we might be able to interpolate a point below,
// this can give us a better y // this can give us a better y
if ( withlines && j > 0 && otherpoints[ j - otherps ] != null ) { if (withlines && j > 0 && otherpoints[j - otherps] != null) {
bottom = qy + ( otherpoints[ j - otherps + 1 ] - qy ) * ( px - qx ) / ( otherpoints[ j - otherps ] - qx ); bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
} }
//newpoints[l + 1] += bottom; //newpoints[l + 1] += bottom;
...@@ -192,28 +192,28 @@ jquery.flot.stack.js plugin, possibly some code could be shared. ...@@ -192,28 +192,28 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
fromgap = false; fromgap = false;
if ( l !== newpoints.length && withbottom ) { if (l !== newpoints.length && withbottom) {
newpoints[ l + 2 ] = bottom; newpoints[l + 2] = bottom;
} }
} }
// maintain the line steps invariant // maintain the line steps invariant
if ( withsteps && l !== newpoints.length && l > 0 && if (withsteps && l !== newpoints.length && l > 0 &&
newpoints[ l ] !== null && newpoints[l] !== null &&
newpoints[ l ] !== newpoints[ l - ps ] && newpoints[l] !== newpoints[ l - ps ] &&
newpoints[ l + 1 ] !== newpoints[ l - ps + 1 ] ) { newpoints[l + 1] !== newpoints[l - ps + 1] ) {
for (m = 0; m < ps; ++m) { for (m = 0; m < ps; ++m) {
newpoints[ l + ps + m ] = newpoints[ l + m ]; newpoints[l + ps + m] = newpoints[l + m];
} }
newpoints[ l + 1 ] = newpoints[ l - ps + 1 ]; 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({ $.plot.plugins.push({
......
...@@ -1030,8 +1030,7 @@ Licensed under the MIT license. ...@@ -1030,8 +1030,7 @@ Licensed under the MIT license.
if (s.color == null) { if (s.color == null) {
s.color = colors[colori].toString(); s.color = colors[colori].toString();
++colori; ++colori;
} } else if (typeof s.color === "number") {
else if (typeof s.color === "number") {
s.color = colors[s.color].toString(); s.color = colors[s.color].toString();
} }
...@@ -1066,9 +1065,7 @@ Licensed under the MIT license. ...@@ -1066,9 +1065,7 @@ Licensed under the MIT license.
var topSentry = Number.POSITIVE_INFINITY, var topSentry = Number.POSITIVE_INFINITY,
bottomSentry = Number.NEGATIVE_INFINITY, bottomSentry = Number.NEGATIVE_INFINITY,
fakeInfinity = Number.MAX_VALUE, fakeInfinity = Number.MAX_VALUE,
i, j, k, m, i, j, k, m, s, points, ps, val, f, p, data, format;
s, points, ps, val, f, p,
data, format;
function updateAxis(axis, min, max) { function updateAxis(axis, min, max) {
if (min < axis.datamin && min !== -fakeInfinity) { if (min < axis.datamin && min !== -fakeInfinity) {
...@@ -1089,7 +1086,6 @@ Licensed under the MIT license. ...@@ -1089,7 +1086,6 @@ Licensed under the MIT license.
for (i = 0; i < series.length; ++i) { for (i = 0; i < series.length; ++i) {
s = series[i]; s = series[i];
s.datapoints = { points: [] }; s.datapoints = { points: [] };
executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]); executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]);
} }
...@@ -1183,8 +1179,7 @@ Licensed under the MIT license. ...@@ -1183,8 +1179,7 @@ Licensed under the MIT license.
} }
points[k + m] = null; points[k + m] = null;
} }
} } else {
else {
// a little bit of line specific stuff that // a little bit of line specific stuff that
// perhaps shouldn't be here, but lacking // perhaps shouldn't be here, but lacking
// better means... // better means...
...@@ -2383,8 +2378,7 @@ Licensed under the MIT license. ...@@ -2383,8 +2378,7 @@ Licensed under the MIT license.
} }
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.min; x1 = axisx.min;
} } else if (x2 <= x1 && x2 < axisx.min) {
else if (x2 <= x1 && x2 < axisx.min) {
if (x1 < axisx.min) { if (x1 < axisx.min) {
continue; continue;
} }
...@@ -2399,8 +2393,7 @@ Licensed under the MIT license. ...@@ -2399,8 +2393,7 @@ Licensed under the MIT license.
} }
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.max; x1 = axisx.max;
} } else if (x2 >= x1 && x2 > axisx.max) {
else if (x2 >= x1 && x2 > axisx.max) {
if (x1 > axisx.max) { if (x1 > axisx.max) {
continue; continue;
} }
......
...@@ -297,13 +297,13 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L ...@@ -297,13 +297,13 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
} }
$.each(plot.getAxes(), function (_, axis) { $.each(plot.getAxes(), function (_, axis) {
var opts = axis.options,
min, max, d = delta[axis.direction];
var opts = axis.options,
min = axis.c2p(axis.p2c(axis.min) + d), min = axis.c2p(axis.p2c(axis.min) + d),
max = axis.c2p(axis.p2c(axis.max) + d); max = axis.c2p(axis.p2c(axis.max) + d),
d = delta[axis.direction],
pr = opts.panRange;
var pr = opts.panRange;
if (pr === false) { // no panning on this axis if (pr === false) { // no panning on this axis
return; return;
} }
......
...@@ -80,8 +80,10 @@ The plugin allso adds the following methods to the plot object: ...@@ -80,8 +80,10 @@ The plugin allso adds the following methods to the plot object:
(function ($) { (function ($) {
function init(plot) { function init(plot) {
var selection = { var selection = {
first: { x: -1, y: -1}, second: { x: -1, y: -1}, first: { x: -1, y: -1},
second: { x: -1, y: -1},
show: false, show: false,
active: false active: false
}; };
...@@ -91,14 +93,13 @@ The plugin allso adds the following methods to the plot object: ...@@ -91,14 +93,13 @@ The plugin allso adds the following methods to the plot object:
// the navigation plugin, this should be massaged a bit to fit // the navigation plugin, this should be massaged a bit to fit
// the Flot cases here better and reused. Doing this would // the Flot cases here better and reused. Doing this would
// make this plugin much slimmer. // make this plugin much slimmer.
var savedhandlers = {};
var mouseUpHandler = null; var savedhandlers = {},
mouseUpHandler = null;
function onMouseMove(e) { function onMouseMove(e) {
if (selection.active) { if (selection.active) {
updateSelection(e); updateSelection(e);
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]); plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
} }
} }
...@@ -159,18 +160,19 @@ The plugin allso adds the following methods to the plot object: ...@@ -159,18 +160,19 @@ The plugin allso adds the following methods to the plot object:
} }
function getSelection() { function getSelection() {
if (!selectionIsSane()) {
return null;
}
if (!selection.show) { if (!selectionIsSane() || !selection.show) {
return null; return null;
} }
var r = {}, c1 = selection.first, c2 = selection.second; var r = {},
c1 = selection.first,
c2 = selection.second;
$.each(plot.getAxes(), function (name, axis) { $.each(plot.getAxes(), function (name, axis) {
if (axis.used) { if (axis.used) {
var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]); var p1 = axis.c2p(c1[axis.direction]),
p2 = axis.c2p(c2[axis.direction]);
r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) }; r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
} }
}); });
...@@ -193,9 +195,10 @@ The plugin allso adds the following methods to the plot object: ...@@ -193,9 +195,10 @@ The plugin allso adds the following methods to the plot object:
} }
function setSelectionPos(pos, e) { function setSelectionPos(pos, e) {
var o = plot.getOptions(); var o = plot.getOptions(),
var offset = plot.getPlaceholder().offset(); offset = plot.getPlaceholder().offset(),
var plotOffset = plot.getPlotOffset(); plotOffset = plot.getPlotOffset();
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width()); pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height()); pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
...@@ -227,7 +230,7 @@ The plugin allso adds the following methods to the plot object: ...@@ -227,7 +230,7 @@ The plugin allso adds the following methods to the plot object:
selection.show = false; selection.show = false;
plot.triggerRedrawOverlay(); plot.triggerRedrawOverlay();
if (!preventEvent) { if (!preventEvent) {
plot.getPlaceholder().trigger("plotunselected", [ ]); plot.getPlaceholder().trigger("plotunselected", []);
} }
} }
} }
...@@ -276,10 +279,8 @@ The plugin allso adds the following methods to the plot object: ...@@ -276,10 +279,8 @@ The plugin allso adds the following methods to the plot object:
if (o.selection.mode === "y") { if (o.selection.mode === "y") {
selection.first.x = 0; selection.first.x = 0;
selection.second.x = plot.width(); selection.second.x = plot.width();
} } else {
else {
range = extractRange(ranges, "x"); range = extractRange(ranges, "x");
selection.first.x = range.axis.p2c(range.from); selection.first.x = range.axis.p2c(range.from);
selection.second.x = range.axis.p2c(range.to); selection.second.x = range.axis.p2c(range.to);
} }
...@@ -287,10 +288,8 @@ The plugin allso adds the following methods to the plot object: ...@@ -287,10 +288,8 @@ The plugin allso adds the following methods to the plot object:
if (o.selection.mode === "x") { if (o.selection.mode === "x") {
selection.first.y = 0; selection.first.y = 0;
selection.second.y = plot.height(); selection.second.y = plot.height();
} } else {
else {
range = extractRange(ranges, "y"); range = extractRange(ranges, "y");
selection.first.y = range.axis.p2c(range.from); selection.first.y = range.axis.p2c(range.from);
selection.second.y = range.axis.p2c(range.to); selection.second.y = range.axis.p2c(range.to);
} }
...@@ -352,7 +351,6 @@ The plugin allso adds the following methods to the plot object: ...@@ -352,7 +351,6 @@ The plugin allso adds the following methods to the plot object:
plot.hooks.shutdown.push(function (plot, eventHolder) { plot.hooks.shutdown.push(function (plot, eventHolder) {
eventHolder.unbind("mousemove", onMouseMove); eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mousedown", onMouseDown); eventHolder.unbind("mousedown", onMouseDown);
if (mouseUpHandler) { if (mouseUpHandler) {
$(document).unbind("mouseup", mouseUpHandler); $(document).unbind("mouseup", mouseUpHandler);
} }
......
...@@ -94,8 +94,7 @@ charts or filled areas). ...@@ -94,8 +94,7 @@ charts or filled areas).
newpoints.push(points[i + 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) { if (!withlines) {
for (m = 0; m < ps; ++m) { for (m = 0; m < ps; ++m) {
...@@ -103,16 +102,14 @@ charts or filled areas). ...@@ -103,16 +102,14 @@ charts or filled areas).
} }
} }
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) { for (m = 0; m < ps; ++m) {
newpoints.push(null); newpoints.push(null);
} }
fromgap = true; fromgap = true;
j += otherps; j += otherps;
} } else {
else {
// cases where we actually got two points // cases where we actually got two points
px = points[i + keyOffset]; px = points[i + keyOffset];
py = points[i + accumulateOffset]; py = points[i + accumulateOffset];
...@@ -130,8 +127,7 @@ charts or filled areas). ...@@ -130,8 +127,7 @@ charts or filled areas).
i += ps; i += ps;
j += otherps; j += otherps;
} } else if (px > qx) {
else if (px > qx) {
// we got past point below, might need to // we got past point below, might need to
// insert interpolated extra point // insert interpolated extra point
if (withlines && i > 0 && points[i - ps] != null) { if (withlines && i > 0 && points[i - ps] != null) {
...@@ -145,8 +141,7 @@ charts or filled areas). ...@@ -145,8 +141,7 @@ charts or filled areas).
} }
j += otherps; j += otherps;
} } else { // px < qx
else { // px < qx
if (fromgap && withlines) { if (fromgap && withlines) {
// if we come from a gap, we just skip this point // if we come from a gap, we just skip this point
i += ps; i += ps;
......
...@@ -49,8 +49,14 @@ You may need to check for this in hover events. ...@@ -49,8 +49,14 @@ You may need to check for this in hover events.
function init(plot) { function init(plot) {
function thresholdData(plot, s, datapoints, below, color) { function thresholdData(plot, s, datapoints, below, color) {
var ps = datapoints.pointsize, i, x, y, p, prevp,
thresholded = $.extend({}, s); // note: shallow copy var origpoints = datapoints.points,
ps = datapoints.pointsize,
addCrossingPoints = s.lines.show,
thresholded = $.extend({}, s), // note: shallow copy
threspoints = [],
newpoints = [],
prevp, i, x, y, p, m;
thresholded.datapoints = { points: [], pointsize: ps, format: datapoints.format }; thresholded.datapoints = { points: [], pointsize: ps, format: datapoints.format };
thresholded.label = null; thresholded.label = null;
...@@ -59,13 +65,6 @@ You may need to check for this in hover events. ...@@ -59,13 +65,6 @@ You may need to check for this in hover events.
thresholded.originSeries = s; thresholded.originSeries = s;
thresholded.data = []; thresholded.data = [];
var origpoints = datapoints.points,
addCrossingPoints = s.lines.show;
var threspoints = [];
var newpoints = [];
var m;
for (i = 0; i < origpoints.length; i += ps) { for (i = 0; i < origpoints.length; i += ps) {
x = origpoints[i]; x = origpoints[i];
y = origpoints[i + 1]; y = origpoints[i + 1];
...@@ -129,8 +128,7 @@ You may need to check for this in hover events. ...@@ -129,8 +128,7 @@ You may need to check for this in hover events.
$(s.threshold).each(function(i, th) { $(s.threshold).each(function(i, th) {
thresholdData(plot, s, datapoints, th.below, th.color); thresholdData(plot, s, datapoints, th.below, th.color);
}); });
} } else {
else {
thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.color); thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.color);
} }
} }
......
...@@ -40,10 +40,10 @@ API.txt for details. ...@@ -40,10 +40,10 @@ API.txt for details.
return n.length === 1 ? pad + n : n; return n.length === 1 ? pad + n : n;
}; };
var r = []; var r = [],
var escape = false; escape = false,
var hours = d.getHours(); hours = d.getHours(),
var isAM = hours < 12; isAM = hours < 12;
if (monthNames == null) { if (monthNames == null) {
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
...@@ -203,9 +203,9 @@ API.txt for details. ...@@ -203,9 +203,9 @@ API.txt for details.
if (opts.mode === "time") { if (opts.mode === "time") {
axis.tickGenerator = function(axis) { axis.tickGenerator = function(axis) {
var ticks = []; var ticks = [],
var d = dateGenerator(axis.min, opts); d = dateGenerator(axis.min, opts),
var minSize = 0; minSize = 0;
// make quarter use a possibility if quarters are // make quarter use a possibility if quarters are
// mentioned in either of these options // mentioned in either of these options
...@@ -231,8 +231,8 @@ API.txt for details. ...@@ -231,8 +231,8 @@ API.txt for details.
} }
} }
var size = spec[i][0]; var size = spec[i][0],
var unit = spec[i][1]; unit = spec[i][1];
// special-case the possibility of several years // special-case the possibility of several years
...@@ -245,8 +245,8 @@ API.txt for details. ...@@ -245,8 +245,8 @@ API.txt for details.
size = Math.floor(opts.minTickSize[0]); size = Math.floor(opts.minTickSize[0]);
} else { } else {
var magn = Math.pow(10, Math.floor(Math.log(axis.delta / timeUnitSize.year) / Math.LN10)); var magn = Math.pow(10, Math.floor(Math.log(axis.delta / timeUnitSize.year) / Math.LN10)),
var norm = (axis.delta / timeUnitSize.year) / magn; norm = (axis.delta / timeUnitSize.year) / magn;
if (norm < 1.5) { if (norm < 1.5) {
size = 1; size = 1;
...@@ -315,9 +315,9 @@ API.txt for details. ...@@ -315,9 +315,9 @@ API.txt for details.
d.setMonth(0); d.setMonth(0);
} }
var carry = 0; var carry = 0,
var v = Number.NaN; v = Number.NaN,
var prev; prev;
do { do {
...@@ -370,13 +370,12 @@ API.txt for details. ...@@ -370,13 +370,12 @@ API.txt for details.
var useQuarters = (axis.options.tickSize && var useQuarters = (axis.options.tickSize &&
axis.options.tickSize[1] === "quarter") || axis.options.tickSize[1] === "quarter") ||
(axis.options.minTickSize && (axis.options.minTickSize &&
axis.options.minTickSize[1] === "quarter"); axis.options.minTickSize[1] === "quarter"),
t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]],
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]]; span = axis.max - axis.min,
var span = axis.max - axis.min; suffix = (opts.twelveHourClock) ? " %p" : "",
var suffix = (opts.twelveHourClock) ? " %p" : ""; hourCode = (opts.twelveHourClock) ? "%I" : "%H",
var hourCode = (opts.twelveHourClock) ? "%I" : "%H"; fmt;
var fmt;
if (t < timeUnitSize.minute) { if (t < timeUnitSize.minute) {
fmt = hourCode + ":%M:%S" + suffix; fmt = hourCode + ":%M:%S" + suffix;
......
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