|
|
|
|
@ -29,7 +29,7 @@ Licensed under the MIT license. |
|
|
|
|
* V. 1.1: Fix error handling so e.g. parsing an empty string does |
|
|
|
|
* produce a color rather than just crashing. |
|
|
|
|
*/ |
|
|
|
|
(function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); |
|
|
|
|
(function($) { $.color = {}; $.color.make = function(r, g, b, a) { var o = {}; o.r = r || 0; o.g = g || 0; o.b = b || 0; o.a = a != null ? a : 1; o.add = function(c, d) { for (var i = 0; i < c.length; ++i)o[c.charAt(i)] += d; return o.normalize() }; o.scale = function(c, f) { for (var i = 0; i < c.length; ++i)o[c.charAt(i)] *= f; return o.normalize() }; o.toString = function() { if (o.a >= 1) { return "rgb(" + [o.r, o.g, o.b].join(",") + ")" } else { return "rgba(" + [o.r, o.g, o.b, o.a].join(",") + ")" } }; o.normalize = function() { function clamp(min, value, max) { return value < min ? min : value > max ? max : value } o.r = clamp(0, parseInt(o.r), 255); o.g = clamp(0, parseInt(o.g), 255); o.b = clamp(0, parseInt(o.b), 255); o.a = clamp(0, o.a, 1); return o }; o.clone = function() { return $.color.make(o.r, o.b, o.g, o.a) }; return o.normalize() }; $.color.extract = function(elem, css) { var c; do { c = elem.css(css).toLowerCase(); if (c != "" && c != "transparent") break; elem = elem.parent() } while (elem.length && !$.nodeName(elem.get(0), "body")); if (c == "rgba(0, 0, 0, 0)") c = "transparent"; return $.color.parse(c) }; $.color.parse = function(str) { var res, m = $.color.make; if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str)) return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10)); if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4])); if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str)) return m(parseFloat(res[1]) * 2.55, parseFloat(res[2]) * 2.55, parseFloat(res[3]) * 2.55); if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) return m(parseFloat(res[1]) * 2.55, parseFloat(res[2]) * 2.55, parseFloat(res[3]) * 2.55, parseFloat(res[4])); if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str)) return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16)); if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str)) return m(parseInt(res[1] + res[1], 16), parseInt(res[2] + res[2], 16), parseInt(res[3] + res[3], 16)); var name = $.trim(str).toLowerCase(); if (name == "transparent") return m(255, 255, 255, 0); else { res = lookupColors[name] || [0, 0, 0]; return m(res[0], res[1], res[2]) } }; var lookupColors = { aqua: [0, 255, 255], azure: [240, 255, 255], beige: [245, 245, 220], black: [0, 0, 0], blue: [0, 0, 255], brown: [165, 42, 42], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgrey: [169, 169, 169], darkgreen: [0, 100, 0], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkviolet: [148, 0, 211], fuchsia: [255, 0, 255], gold: [255, 215, 0], green: [0, 128, 0], indigo: [75, 0, 130], khaki: [240, 230, 140], lightblue: [173, 216, 230], lightcyan: [224, 255, 255], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightyellow: [255, 255, 224], lime: [0, 255, 0], magenta: [255, 0, 255], maroon: [128, 0, 0], navy: [0, 0, 128], olive: [128, 128, 0], orange: [255, 165, 0], pink: [255, 192, 203], purple: [128, 0, 128], violet: [128, 0, 128], red: [255, 0, 0], silver: [192, 192, 192], white: [255, 255, 255], yellow: [255, 255, 0] } })(jQuery); |
|
|
|
|
|
|
|
|
|
// the actual Flot code
|
|
|
|
|
(function($) { |
|
|
|
|
@ -48,7 +48,7 @@ Licensed under the MIT license. |
|
|
|
|
$.fn.detach = function() { |
|
|
|
|
return this.each(function() { |
|
|
|
|
if (this.parentNode) { |
|
|
|
|
this.parentNode.removeChild( this ); |
|
|
|
|
this.parentNode.removeChild(this); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
@ -616,7 +616,7 @@ Licensed under the MIT license. |
|
|
|
|
mouseActiveRadius: 10 // how far the mouse can be away to activate an item
|
|
|
|
|
}, |
|
|
|
|
interaction: { |
|
|
|
|
redrawOverlayInterval: 1000/60 // time between updates, -1 means in same flow
|
|
|
|
|
redrawOverlayInterval: 1000 / 60 // time between updates, -1 means in same flow
|
|
|
|
|
}, |
|
|
|
|
hooks: {} |
|
|
|
|
}, |
|
|
|
|
@ -625,7 +625,7 @@ Licensed under the MIT license. |
|
|
|
|
eventHolder = null, // jQuery object that events should be bound to
|
|
|
|
|
ctx = null, octx = null, |
|
|
|
|
xaxes = [], yaxes = [], |
|
|
|
|
plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, |
|
|
|
|
plotOffset = { left: 0, right: 0, top: 0, bottom: 0 }, |
|
|
|
|
plotWidth = 0, plotHeight = 0, |
|
|
|
|
hooks = { |
|
|
|
|
processOptions: [], |
|
|
|
|
@ -649,28 +649,28 @@ Licensed under the MIT license. |
|
|
|
|
plot.getPlaceholder = function() { return placeholder; }; |
|
|
|
|
plot.getCanvas = function() { return surface.element; }; |
|
|
|
|
plot.getPlotOffset = function() { return plotOffset; }; |
|
|
|
|
plot.width = function () { return plotWidth; }; |
|
|
|
|
plot.height = function () { return plotHeight; }; |
|
|
|
|
plot.offset = function () { |
|
|
|
|
plot.width = function() { return plotWidth; }; |
|
|
|
|
plot.height = function() { return plotHeight; }; |
|
|
|
|
plot.offset = function() { |
|
|
|
|
var o = eventHolder.offset(); |
|
|
|
|
o.left += plotOffset.left; |
|
|
|
|
o.top += plotOffset.top; |
|
|
|
|
return o; |
|
|
|
|
}; |
|
|
|
|
plot.getData = function () { return series; }; |
|
|
|
|
plot.getAxes = function () { |
|
|
|
|
plot.getData = function() { return series; }; |
|
|
|
|
plot.getAxes = function() { |
|
|
|
|
var res = {}, i; |
|
|
|
|
$.each(xaxes.concat(yaxes), function (_, axis) { |
|
|
|
|
$.each(xaxes.concat(yaxes), function(_, axis) { |
|
|
|
|
if (axis) |
|
|
|
|
res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis; |
|
|
|
|
}); |
|
|
|
|
return res; |
|
|
|
|
}; |
|
|
|
|
plot.getXAxes = function () { return xaxes; }; |
|
|
|
|
plot.getYAxes = function () { return yaxes; }; |
|
|
|
|
plot.getXAxes = function() { return xaxes; }; |
|
|
|
|
plot.getYAxes = function() { return yaxes; }; |
|
|
|
|
plot.c2p = canvasToAxisCoords; |
|
|
|
|
plot.p2c = axisToCanvasCoords; |
|
|
|
|
plot.getOptions = function () { return options; }; |
|
|
|
|
plot.getOptions = function() { return options; }; |
|
|
|
|
plot.highlight = highlight; |
|
|
|
|
plot.unhighlight = unhighlight; |
|
|
|
|
plot.triggerRedrawOverlay = triggerRedrawOverlay; |
|
|
|
|
@ -681,7 +681,7 @@ Licensed under the MIT license. |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
plot.shutdown = shutdown; |
|
|
|
|
plot.destroy = function () { |
|
|
|
|
plot.destroy = function() { |
|
|
|
|
shutdown(); |
|
|
|
|
placeholder.removeData("plot").empty(); |
|
|
|
|
|
|
|
|
|
@ -698,7 +698,7 @@ Licensed under the MIT license. |
|
|
|
|
highlights = []; |
|
|
|
|
plot = null; |
|
|
|
|
}; |
|
|
|
|
plot.resize = function () { |
|
|
|
|
plot.resize = function() { |
|
|
|
|
var width = placeholder.width(), |
|
|
|
|
height = placeholder.height(); |
|
|
|
|
surface.resize(width, height); |
|
|
|
|
@ -923,7 +923,7 @@ Licensed under the MIT license. |
|
|
|
|
|
|
|
|
|
function allAxes() { |
|
|
|
|
// return flat array without annoying null entries
|
|
|
|
|
return $.grep(xaxes.concat(yaxes), function (a) { return a; }); |
|
|
|
|
return $.grep(xaxes.concat(yaxes), function(a) { return a; }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function canvasToAxisCoords(pos) { |
|
|
|
|
@ -1102,7 +1102,7 @@ Licensed under the MIT license. |
|
|
|
|
axis.datamax = max; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.each(allAxes(), function (_, axis) { |
|
|
|
|
$.each(allAxes(), function(_, axis) { |
|
|
|
|
// init axis
|
|
|
|
|
axis.datamin = topSentry; |
|
|
|
|
axis.datamax = bottomSentry; |
|
|
|
|
@ -1113,7 +1113,7 @@ Licensed under the MIT license. |
|
|
|
|
s = series[i]; |
|
|
|
|
s.datapoints = { points: [] }; |
|
|
|
|
|
|
|
|
|
executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]); |
|
|
|
|
executeHooks(hooks.processRawData, [s, s.data, s.datapoints]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// first pass: clean and copy data
|
|
|
|
|
@ -1213,7 +1213,7 @@ Licensed under the MIT license. |
|
|
|
|
points[k + 1] = points[k - ps + 1] || 0; |
|
|
|
|
|
|
|
|
|
// if series has null values, let's give the last !null value a nice step
|
|
|
|
|
if(nullify) |
|
|
|
|
if (nullify) |
|
|
|
|
points[k] = p[0]; |
|
|
|
|
|
|
|
|
|
// we've added a point, better reflect that
|
|
|
|
|
@ -1239,7 +1239,7 @@ Licensed under the MIT license. |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
executeHooks(hooks.processDatapoints, [ s, s.datapoints]); |
|
|
|
|
executeHooks(hooks.processDatapoints, [s, s.datapoints]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// second pass: find datamax/datamin for auto-scaling
|
|
|
|
|
@ -1306,7 +1306,7 @@ Licensed under the MIT license. |
|
|
|
|
updateAxis(s.yaxis, ymin, ymax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.each(allAxes(), function (_, axis) { |
|
|
|
|
$.each(allAxes(), function(_, axis) { |
|
|
|
|
if (axis.datamin == topSentry) |
|
|
|
|
axis.datamin = null; |
|
|
|
|
if (axis.datamax == bottomSentry) |
|
|
|
|
@ -1401,14 +1401,14 @@ Licensed under the MIT license. |
|
|
|
|
|
|
|
|
|
// data point to canvas coordinate
|
|
|
|
|
if (t == identity) // slight optimization
|
|
|
|
|
axis.p2c = function (p) { return (p - m) * s; }; |
|
|
|
|
axis.p2c = function(p) { return (p - m) * s; }; |
|
|
|
|
else |
|
|
|
|
axis.p2c = function (p) { return (t(p) - m) * s; }; |
|
|
|
|
axis.p2c = function(p) { return (t(p) - m) * s; }; |
|
|
|
|
// canvas coordinate to data point
|
|
|
|
|
if (!it) |
|
|
|
|
axis.c2p = function (c) { return m + c / s; }; |
|
|
|
|
axis.c2p = function(c) { return m + c / s; }; |
|
|
|
|
else |
|
|
|
|
axis.c2p = function (c) { return it(m + c / s); }; |
|
|
|
|
axis.c2p = function(c) { return it(m + c / s); }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function measureTickLabels(axis) { |
|
|
|
|
@ -1555,7 +1555,7 @@ Licensed under the MIT license. |
|
|
|
|
if (minMargin == null) { |
|
|
|
|
minMargin = 0; |
|
|
|
|
for (i = 0; i < series.length; ++i) |
|
|
|
|
minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth/2)); |
|
|
|
|
minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth / 2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var margins = { |
|
|
|
|
@ -1568,7 +1568,7 @@ Licensed under the MIT license. |
|
|
|
|
// check axis labels, note we don't check the actual
|
|
|
|
|
// labels but instead use the overall width/height to not
|
|
|
|
|
// jump as much around with replots
|
|
|
|
|
$.each(allAxes(), function (_, axis) { |
|
|
|
|
$.each(allAxes(), function(_, axis) { |
|
|
|
|
if (axis.reserveSpace && axis.ticks && axis.ticks.length) { |
|
|
|
|
if (axis.direction === "x") { |
|
|
|
|
margins.left = Math.max(margins.left, axis.labelWidth / 2); |
|
|
|
|
@ -1601,7 +1601,7 @@ Licensed under the MIT license. |
|
|
|
|
// If the grid is visible, add its border width to the offset
|
|
|
|
|
|
|
|
|
|
for (var a in plotOffset) { |
|
|
|
|
if(typeof(options.grid.borderWidth) == "object") { |
|
|
|
|
if (typeof (options.grid.borderWidth) == "object") { |
|
|
|
|
plotOffset[a] += showGrid ? options.grid.borderWidth[a] : 0; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
@ -1609,7 +1609,7 @@ Licensed under the MIT license. |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.each(axes, function (_, axis) { |
|
|
|
|
$.each(axes, function(_, axis) { |
|
|
|
|
var axisOpts = axis.options; |
|
|
|
|
axis.show = axisOpts.show == null ? axis.used : axisOpts.show; |
|
|
|
|
axis.reserveSpace = axisOpts.reserveSpace == null ? axis.show : axisOpts.reserveSpace; |
|
|
|
|
@ -1620,13 +1620,13 @@ Licensed under the MIT license. |
|
|
|
|
|
|
|
|
|
if (showGrid) { |
|
|
|
|
|
|
|
|
|
var allocatedAxes = $.grep(axes, function (axis) { |
|
|
|
|
var allocatedAxes = $.grep(axes, function(axis) { |
|
|
|
|
return axis.show || axis.reserveSpace; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var snaped = false; |
|
|
|
|
for (var i = 0; i < 2; i++) { |
|
|
|
|
$.each(allocatedAxes, function (_, axis) { |
|
|
|
|
$.each(allocatedAxes, function(_, axis) { |
|
|
|
|
// make the ticks
|
|
|
|
|
setupTickGeneration(axis); |
|
|
|
|
setTicks(axis); |
|
|
|
|
@ -1653,7 +1653,7 @@ Licensed under the MIT license. |
|
|
|
|
// might stick out
|
|
|
|
|
adjustLayoutForThingsStickingOut(); |
|
|
|
|
|
|
|
|
|
$.each(allocatedAxes, function (_, axis) { |
|
|
|
|
$.each(allocatedAxes, function(_, axis) { |
|
|
|
|
allocateAxisBoxSecondPhase(axis); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
@ -1663,7 +1663,7 @@ Licensed under the MIT license. |
|
|
|
|
plotHeight = surface.height - plotOffset.bottom - plotOffset.top; |
|
|
|
|
|
|
|
|
|
// now we got the proper plot dimensions, we can compute the scaling
|
|
|
|
|
$.each(axes, function (_, axis) { |
|
|
|
|
$.each(axes, function(_, axis) { |
|
|
|
|
setTransformationHelpers(axis); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -1795,7 +1795,7 @@ Licensed under the MIT license. |
|
|
|
|
|
|
|
|
|
if (!axis.tickGenerator) { |
|
|
|
|
|
|
|
|
|
axis.tickGenerator = function (axis) { |
|
|
|
|
axis.tickGenerator = function(axis) { |
|
|
|
|
|
|
|
|
|
var ticks = [], |
|
|
|
|
start = floorInBase(axis.min, axis.tickSize), |
|
|
|
|
@ -1812,7 +1812,7 @@ Licensed under the MIT license. |
|
|
|
|
return ticks; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
axis.tickFormatter = function (value, axis) { |
|
|
|
|
axis.tickFormatter = function(value, axis) { |
|
|
|
|
|
|
|
|
|
var factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1; |
|
|
|
|
var formatted = "" + Math.round(value * factor) / factor; |
|
|
|
|
@ -1833,7 +1833,7 @@ Licensed under the MIT license. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($.isFunction(opts.tickFormatter)) |
|
|
|
|
axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); }; |
|
|
|
|
axis.tickFormatter = function(v, axis) { return "" + opts.tickFormatter(v, axis); }; |
|
|
|
|
|
|
|
|
|
if (opts.alignTicksWithAxis != null) { |
|
|
|
|
var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1]; |
|
|
|
|
@ -1847,7 +1847,7 @@ Licensed under the MIT license. |
|
|
|
|
axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
axis.tickGenerator = function (axis) { |
|
|
|
|
axis.tickGenerator = function(axis) { |
|
|
|
|
// copy ticks, scaled to this axis
|
|
|
|
|
var ticks = [], v, i; |
|
|
|
|
for (i = 0; i < otherAxis.ticks.length; ++i) { |
|
|
|
|
@ -2185,20 +2185,20 @@ Licensed under the MIT license. |
|
|
|
|
// If either borderWidth or borderColor is an object, then draw the border
|
|
|
|
|
// line by line instead of as one rectangle
|
|
|
|
|
bc = options.grid.borderColor; |
|
|
|
|
if(typeof bw == "object" || typeof bc == "object") { |
|
|
|
|
if (typeof bw == "object" || typeof bc == "object") { |
|
|
|
|
if (typeof bw !== "object") { |
|
|
|
|
bw = {top: bw, right: bw, bottom: bw, left: bw}; |
|
|
|
|
bw = { top: bw, right: bw, bottom: bw, left: bw }; |
|
|
|
|
} |
|
|
|
|
if (typeof bc !== "object") { |
|
|
|
|
bc = {top: bc, right: bc, bottom: bc, left: bc}; |
|
|
|
|
bc = { top: bc, right: bc, bottom: bc, left: bc }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (bw.top > 0) { |
|
|
|
|
ctx.strokeStyle = bc.top; |
|
|
|
|
ctx.lineWidth = bw.top; |
|
|
|
|
ctx.beginPath(); |
|
|
|
|
ctx.moveTo(0 - bw.left, 0 - bw.top/2); |
|
|
|
|
ctx.lineTo(plotWidth, 0 - bw.top/2); |
|
|
|
|
ctx.moveTo(0 - bw.left, 0 - bw.top / 2); |
|
|
|
|
ctx.lineTo(plotWidth, 0 - bw.top / 2); |
|
|
|
|
ctx.stroke(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -2224,15 +2224,15 @@ Licensed under the MIT license. |
|
|
|
|
ctx.strokeStyle = bc.left; |
|
|
|
|
ctx.lineWidth = bw.left; |
|
|
|
|
ctx.beginPath(); |
|
|
|
|
ctx.moveTo(0 - bw.left/2, plotHeight + bw.bottom); |
|
|
|
|
ctx.lineTo(0- bw.left/2, 0); |
|
|
|
|
ctx.moveTo(0 - bw.left / 2, plotHeight + bw.bottom); |
|
|
|
|
ctx.lineTo(0 - bw.left / 2, 0); |
|
|
|
|
ctx.stroke(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
ctx.lineWidth = bw; |
|
|
|
|
ctx.strokeStyle = options.grid.borderColor; |
|
|
|
|
ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw); |
|
|
|
|
ctx.strokeRect(-bw / 2, -bw / 2, plotWidth + bw, plotHeight + bw); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -2241,7 +2241,7 @@ Licensed under the MIT license. |
|
|
|
|
|
|
|
|
|
function drawAxisLabels() { |
|
|
|
|
|
|
|
|
|
$.each(allAxes(), function (_, axis) { |
|
|
|
|
$.each(allAxes(), function(_, axis) { |
|
|
|
|
var box = axis.box, |
|
|
|
|
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis", |
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles, |
|
|
|
|
@ -2319,7 +2319,7 @@ Licensed under the MIT license. |
|
|
|
|
var olddatapoints = datapoints.points |
|
|
|
|
datapoints.points = abandonedPoints; |
|
|
|
|
|
|
|
|
|
series.points.radius = series.lines.lineWidth/2; |
|
|
|
|
series.points.radius = series.lines.lineWidth / 2; |
|
|
|
|
// plot the orphan points with a radius of lineWidth/2
|
|
|
|
|
drawSeriesPoints(series); |
|
|
|
|
// reset old info
|
|
|
|
|
@ -2575,10 +2575,10 @@ Licensed under the MIT license. |
|
|
|
|
ctx.lineWidth = sw; |
|
|
|
|
ctx.strokeStyle = "rgba(0,0,0,0.1)"; |
|
|
|
|
// position shadow at angle from the mid of line
|
|
|
|
|
var angle = Math.PI/18; |
|
|
|
|
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis); |
|
|
|
|
ctx.lineWidth = sw/2; |
|
|
|
|
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis); |
|
|
|
|
var angle = Math.PI / 18; |
|
|
|
|
plotLine(series.datapoints, Math.sin(angle) * (lw / 2 + sw / 2), Math.cos(angle) * (lw / 2 + sw / 2), series.xaxis, series.yaxis); |
|
|
|
|
ctx.lineWidth = sw / 2; |
|
|
|
|
plotLine(series.datapoints, Math.sin(angle) * (lw / 2 + sw / 4), Math.cos(angle) * (lw / 2 + sw / 4), series.xaxis, series.yaxis); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.lineWidth = lw; |
|
|
|
|
@ -2633,7 +2633,7 @@ Licensed under the MIT license. |
|
|
|
|
// Doing the conditional here allows the shadow setting to still be
|
|
|
|
|
// optional even with a lineWidth of 0.
|
|
|
|
|
|
|
|
|
|
if( lw == 0 ) |
|
|
|
|
if (lw == 0) |
|
|
|
|
lw = 0.0001; |
|
|
|
|
|
|
|
|
|
if (lw > 0 && sw > 0) { |
|
|
|
|
@ -2641,11 +2641,11 @@ Licensed under the MIT license. |
|
|
|
|
var w = sw / 2; |
|
|
|
|
ctx.lineWidth = w; |
|
|
|
|
ctx.strokeStyle = "rgba(0,0,0,0.1)"; |
|
|
|
|
plotPoints(series.datapoints, radius, null, w + w/2, true, |
|
|
|
|
plotPoints(series.datapoints, radius, null, w + w / 2, true, |
|
|
|
|
series.xaxis, series.yaxis, symbol); |
|
|
|
|
|
|
|
|
|
ctx.strokeStyle = "rgba(0,0,0,0.2)"; |
|
|
|
|
plotPoints(series.datapoints, radius, null, w/2, true, |
|
|
|
|
plotPoints(series.datapoints, radius, null, w / 2, true, |
|
|
|
|
series.xaxis, series.yaxis, symbol); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -2793,7 +2793,7 @@ Licensed under the MIT license. |
|
|
|
|
barLeft = -series.bars.barWidth / 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; |
|
|
|
|
var fillStyleCallback = series.bars.fill ? function(bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; |
|
|
|
|
plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis); |
|
|
|
|
ctx.restore(); |
|
|
|
|
} |
|
|
|
|
@ -2815,7 +2815,7 @@ Licensed under the MIT license. |
|
|
|
|
function insertLegend() { |
|
|
|
|
|
|
|
|
|
if (options.legend.container != null) { |
|
|
|
|
$(options.legend.container).html(""); |
|
|
|
|
$.find(options.legend.container).html(""); |
|
|
|
|
} else { |
|
|
|
|
placeholder.find(".legend").remove(); |
|
|
|
|
} |
|
|
|
|
@ -2901,7 +2901,7 @@ Licensed under the MIT license. |
|
|
|
|
pos += 'right:' + (m[0] + plotOffset.right) + 'px;'; |
|
|
|
|
else if (p.charAt(1) == "w") |
|
|
|
|
pos += 'left:' + (m[0] + plotOffset.left) + 'px;'; |
|
|
|
|
var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder); |
|
|
|
|
var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos + ';') + '</div>').appendTo(placeholder); |
|
|
|
|
if (options.legend.backgroundOpacity != 0.0) { |
|
|
|
|
// put in the transparent background
|
|
|
|
|
// separately to avoid blended labels and
|
|
|
|
|
@ -2917,7 +2917,7 @@ Licensed under the MIT license. |
|
|
|
|
c = c.toString(); |
|
|
|
|
} |
|
|
|
|
var div = legend.children(); |
|
|
|
|
$('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity); |
|
|
|
|
$('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos + 'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -3020,10 +3020,12 @@ Licensed under the MIT license. |
|
|
|
|
j = item[1]; |
|
|
|
|
ps = series[i].datapoints.pointsize; |
|
|
|
|
|
|
|
|
|
return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps), |
|
|
|
|
return { |
|
|
|
|
datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps), |
|
|
|
|
dataIndex: j, |
|
|
|
|
series: series[i], |
|
|
|
|
seriesIndex: i }; |
|
|
|
|
seriesIndex: i |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
@ -3032,13 +3034,13 @@ Licensed under the MIT license. |
|
|
|
|
function onMouseMove(e) { |
|
|
|
|
if (options.grid.hoverable) |
|
|
|
|
triggerClickHoverEvent("plothover", e, |
|
|
|
|
function (s) { return s["hoverable"] != false; }); |
|
|
|
|
function(s) { return s["hoverable"] != false; }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onMouseLeave(e) { |
|
|
|
|
if (options.grid.hoverable) |
|
|
|
|
triggerClickHoverEvent("plothover", e, |
|
|
|
|
function (s) { return false; }); |
|
|
|
|
function(s) { return false; }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onClick(e) { |
|
|
|
|
@ -3046,7 +3048,7 @@ Licensed under the MIT license. |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
triggerClickHoverEvent("plotclick", e, function (s) { return s["clickable"] != false; }); |
|
|
|
|
triggerClickHoverEvent("plotclick", e, function(s) { return s["clickable"] != false; }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// grafana addon - added to support mobile devices click in plot
|
|
|
|
|
@ -3056,7 +3058,7 @@ Licensed under the MIT license. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!eventHolder.is(e.target) && eventHolder.has(e.target).length === 0) { |
|
|
|
|
triggerClickHoverEvent("plotleave", e, function (s) { false; }); |
|
|
|
|
triggerClickHoverEvent("plotleave", e, function(s) { false; }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -3125,7 +3127,7 @@ Licensed under the MIT license. |
|
|
|
|
highlight(item.series, item.datapoint, eventname); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
placeholder.trigger(eventname, [ pos, item ]); |
|
|
|
|
placeholder.trigger(eventname, [pos, item]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function triggerRedrawOverlay() { |
|
|
|
|
@ -3257,7 +3259,7 @@ Licensed under the MIT license. |
|
|
|
|
octx.strokeStyle = highlightColor; |
|
|
|
|
|
|
|
|
|
drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, |
|
|
|
|
function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); |
|
|
|
|
function() { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getColorOrGradient(spec, bottom, top, defaultColor) { |
|
|
|
|
|