Commit 01b1c8a9 authored by Karl Swedberg's avatar Karl Swedberg

Remove trailing white space.

parent 559a39ee
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
// for convenience // for convenience
/* Plugin for jQuery for working with colors. /* Plugin for jQuery for working with colors.
* *
* Version 1.1. * Version 1.1.
* *
* Inspiration from jQuery color animation plugin by John Resig. * Inspiration from jQuery color animation plugin by John Resig.
* *
* Released under the MIT license by Ole Laursen, October 2009. * Released under the MIT license by Ole Laursen, October 2009.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
// [ series1, series2 ... ] // [ series1, series2 ... ]
// where series is either just the data as [ [x1, y1], [x2, y2], ... ] // where series is either just the data as [ [x1, y1], [x2, y2], ... ]
// or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... } // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
var series = [], var series = [],
options = { options = {
// the color theme used for graphs // the color theme used for graphs
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
reserveSpace: null, // whether to reserve space even if axis isn't shown reserveSpace: null, // whether to reserve space even if axis isn't shown
tickLength: null, // size in pixels of ticks, or "full" for whole line tickLength: null, // size in pixels of ticks, or "full" for whole line
alignTicksWithAxis: null, // axis number or null for no sync alignTicksWithAxis: null, // axis number or null for no sync
// mode specific options // mode specific options
tickDecimals: null, // no. of decimals, null means auto tickDecimals: null, // no. of decimals, null means auto
tickSize: null, // number or [number, "unit"] tickSize: null, // number or [number, "unit"]
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
}, },
lines: { lines: {
// we don't put in show: false so we can see // we don't put in show: false so we can see
// whether lines were actively disabled // whether lines were actively disabled
lineWidth: 2, // in pixels lineWidth: 2, // in pixels
fill: false, fill: false,
fillColor: null, fillColor: null,
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
// public attributes // public attributes
plot.hooks = hooks; plot.hooks = hooks;
// initialize // initialize
initPlugins(plot); initPlugins(plot);
parseOptions(options_); parseOptions(options_);
...@@ -238,17 +238,17 @@ ...@@ -238,17 +238,17 @@
$.extend(true, options, p.options); $.extend(true, options, p.options);
} }
} }
function parseOptions(opts) { function parseOptions(opts) {
var i; var i;
$.extend(true, options, opts); $.extend(true, options, opts);
if (options.xaxis.color == null) if (options.xaxis.color == null)
options.xaxis.color = options.grid.color; options.xaxis.color = options.grid.color;
if (options.yaxis.color == null) if (options.yaxis.color == null)
options.yaxis.color = options.grid.color; options.yaxis.color = options.grid.color;
if (options.xaxis.tickColor == null) // backwards-compatibility if (options.xaxis.tickColor == null) // backwards-compatibility
options.xaxis.tickColor = options.grid.tickColor; options.xaxis.tickColor = options.grid.tickColor;
if (options.yaxis.tickColor == null) // backwards-compatibility if (options.yaxis.tickColor == null) // backwards-compatibility
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
options.grid.borderColor = options.grid.color; options.grid.borderColor = options.grid.color;
if (options.grid.tickColor == null) if (options.grid.tickColor == null)
options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString(); options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString();
// fill in defaults in axes, copy at least always the // fill in defaults in axes, copy at least always the
// first as the rest of the code assumes it'll be there // first as the rest of the code assumes it'll be there
for (i = 0; i < Math.max(1, options.xaxes.length); ++i) for (i = 0; i < Math.max(1, options.xaxes.length); ++i)
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
fillInSeriesOptions(); fillInSeriesOptions();
processData(); processData();
} }
function parseData(d) { function parseData(d) {
var res = []; var res = [];
for (var i = 0; i < d.length; ++i) { for (var i = 0; i < d.length; ++i) {
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
return res; return res;
} }
function axisNumber(obj, coord) { function axisNumber(obj, coord) {
var a = obj[coord + "axis"]; var a = obj[coord + "axis"];
if (typeof a == "object") // if we got a real axis, extract number if (typeof a == "object") // if we got a real axis, extract number
...@@ -348,9 +348,9 @@ ...@@ -348,9 +348,9 @@
// return flat array without annoying null entries // 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) { function canvasToAxisCoords(pos) {
// return an object with x/y corresponding to all used axes // return an object with x/y corresponding to all used axes
var res = {}, i, axis; var res = {}, i, axis;
for (i = 0; i < xaxes.length; ++i) { for (i = 0; i < xaxes.length; ++i) {
axis = xaxes[i]; axis = xaxes[i];
...@@ -363,7 +363,7 @@ ...@@ -363,7 +363,7 @@
if (axis && axis.used) if (axis && axis.used)
res["y" + axis.n] = axis.c2p(pos.top); res["y" + axis.n] = axis.c2p(pos.top);
} }
if (res.x1 !== undefined) if (res.x1 !== undefined)
res.x = res.x1; res.x = res.x1;
if (res.y1 !== undefined) if (res.y1 !== undefined)
...@@ -371,7 +371,7 @@ ...@@ -371,7 +371,7 @@
return res; return res;
} }
function axisToCanvasCoords(pos) { function axisToCanvasCoords(pos) {
// get canvas coords from the first pair of x/y found in pos // get canvas coords from the first pair of x/y found in pos
var res = {}, i, axis, key; var res = {}, i, axis, key;
...@@ -389,7 +389,7 @@ ...@@ -389,7 +389,7 @@
} }
} }
} }
for (i = 0; i < yaxes.length; ++i) { for (i = 0; i < yaxes.length; ++i) {
axis = yaxes[i]; axis = yaxes[i];
if (axis && axis.used) { if (axis && axis.used) {
...@@ -403,10 +403,10 @@ ...@@ -403,10 +403,10 @@
} }
} }
} }
return res; return res;
} }
function getOrCreateAxis(axes, number) { function getOrCreateAxis(axes, number) {
if (!axes[number - 1]) if (!axes[number - 1])
axes[number - 1] = { axes[number - 1] = {
...@@ -414,7 +414,7 @@ ...@@ -414,7 +414,7 @@
direction: axes == xaxes ? "x" : "y", direction: axes == xaxes ? "x" : "y",
options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis) options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis)
}; };
return axes[number - 1]; return axes[number - 1];
} }
...@@ -475,7 +475,7 @@ ...@@ -475,7 +475,7 @@
var colori = 0, s; var colori = 0, s;
for (i = 0; i < series.length; ++i) { for (i = 0; i < series.length; ++i) {
s = series[i]; s = series[i];
// assign colors // assign colors
if (s.color == null) { if (s.color == null) {
s.color = colors[colori].toString(); s.color = colors[colori].toString();
...@@ -501,7 +501,7 @@ ...@@ -501,7 +501,7 @@
s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y")); s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y"));
} }
} }
function processData() { function processData() {
var topSentry = Number.POSITIVE_INFINITY, var topSentry = Number.POSITIVE_INFINITY,
bottomSentry = Number.NEGATIVE_INFINITY, bottomSentry = Number.NEGATIVE_INFINITY,
...@@ -522,14 +522,14 @@ ...@@ -522,14 +522,14 @@
axis.datamax = bottomSentry; axis.datamax = bottomSentry;
axis.used = false; axis.used = false;
}); });
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 ]);
} }
// first pass: clean and copy data // first pass: clean and copy data
for (i = 0; i < series.length; ++i) { for (i = 0; i < series.length; ++i) {
s = series[i]; s = series[i];
...@@ -549,7 +549,7 @@ ...@@ -549,7 +549,7 @@
format[format.length - 1].x = true; format[format.length - 1].x = true;
} }
} }
s.datapoints.format = format; s.datapoints.format = format;
} }
...@@ -557,13 +557,13 @@ ...@@ -557,13 +557,13 @@
continue; // already filled in continue; // already filled in
s.datapoints.pointsize = format.length; s.datapoints.pointsize = format.length;
ps = s.datapoints.pointsize; ps = s.datapoints.pointsize;
points = s.datapoints.points; points = s.datapoints.points;
var insertSteps = s.lines.show && s.lines.steps; var insertSteps = s.lines.show && s.lines.steps;
s.xaxis.used = s.yaxis.used = true; s.xaxis.used = s.yaxis.used = true;
for (j = k = 0; j < data.length; ++j, k += ps) { for (j = k = 0; j < data.length; ++j, k += ps) {
p = data[j]; p = data[j];
...@@ -587,16 +587,16 @@ ...@@ -587,16 +587,16 @@
if (val == null) { if (val == null) {
if (f.required) if (f.required)
nullify = true; nullify = true;
if (f.defaultValue != null) if (f.defaultValue != null)
val = f.defaultValue; val = f.defaultValue;
} }
} }
points[k + m] = val; points[k + m] = val;
} }
} }
if (nullify) { if (nullify) {
for (m = 0; m < ps; ++m) { for (m = 0; m < ps; ++m) {
val = points[k + m]; val = points[k + m];
...@@ -636,7 +636,7 @@ ...@@ -636,7 +636,7 @@
// give the hooks a chance to run // give the hooks a chance to run
for (i = 0; i < series.length; ++i) { for (i = 0; i < series.length; ++i) {
s = series[i]; s = series[i];
executeHooks(hooks.processDatapoints, [ s, s.datapoints]); executeHooks(hooks.processDatapoints, [ s, s.datapoints]);
} }
...@@ -649,7 +649,7 @@ ...@@ -649,7 +649,7 @@
var xmin = topSentry, ymin = topSentry, var xmin = topSentry, ymin = topSentry,
xmax = bottomSentry, ymax = bottomSentry; xmax = bottomSentry, ymax = bottomSentry;
for (j = 0; j < points.length; j += ps) { for (j = 0; j < points.length; j += ps) {
if (points[j] == null) if (points[j] == null)
continue; continue;
...@@ -659,7 +659,7 @@ ...@@ -659,7 +659,7 @@
f = format[m]; f = format[m];
if (!f || val == fakeInfinity || val == -fakeInfinity) if (!f || val == fakeInfinity || val == -fakeInfinity)
continue; continue;
if (f.x) { if (f.x) {
if (val < xmin) if (val < xmin)
xmin = val; xmin = val;
...@@ -702,7 +702,7 @@ ...@@ -702,7 +702,7 @@
xmax += delta + s.bars.barWidth; xmax += delta + s.bars.barWidth;
} }
} }
updateAxis(s.xaxis, xmin, xmax); updateAxis(s.xaxis, xmin, xmax);
updateAxis(s.yaxis, ymin, ymax); updateAxis(s.yaxis, ymin, ymax);
} }
...@@ -725,11 +725,11 @@ ...@@ -725,11 +725,11 @@
function getPixelRatio(cctx) { function getPixelRatio(cctx) {
var devicePixelRatio = window.devicePixelRatio || 1; var devicePixelRatio = window.devicePixelRatio || 1;
var backingStoreRatio = var backingStoreRatio =
cctx.webkitBackingStorePixelRatio || cctx.webkitBackingStorePixelRatio ||
cctx.mozBackingStorePixelRatio || cctx.mozBackingStorePixelRatio ||
cctx.msBackingStorePixelRatio || cctx.msBackingStorePixelRatio ||
cctx.oBackingStorePixelRatio || cctx.oBackingStorePixelRatio ||
cctx.backingStorePixelRatio || 1; cctx.backingStorePixelRatio || 1;
return devicePixelRatio / backingStoreRatio; return devicePixelRatio / backingStoreRatio;
...@@ -778,21 +778,21 @@ ...@@ -778,21 +778,21 @@
// appear at the same size; the extra pixels will just make them crisper. // appear at the same size; the extra pixels will just make them crisper.
cctx.scale(pixelRatio, pixelRatio); cctx.scale(pixelRatio, pixelRatio);
return c; return c;
} }
function getCanvasDimensions() { function getCanvasDimensions() {
canvasWidth = placeholder.width(); canvasWidth = placeholder.width();
canvasHeight = placeholder.height(); canvasHeight = placeholder.height();
if (canvasWidth <= 0 || canvasHeight <= 0) if (canvasWidth <= 0 || canvasHeight <= 0)
throw new Error("Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight); throw new Error("Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight);
} }
function resizeCanvas(c) { function resizeCanvas(c) {
var cctx = c.getContext("2d"); var cctx = c.getContext("2d");
// Handle pixel ratios > 1 for retina displays, as explained in makeCanvas // Handle pixel ratios > 1 for retina displays, as explained in makeCanvas
...@@ -821,7 +821,7 @@ ...@@ -821,7 +821,7 @@
cctx.scale(pixelRatio, pixelRatio); cctx.scale(pixelRatio, pixelRatio);
} }
function setupCanvases() { function setupCanvases() {
var reused, var reused,
existingCanvas = placeholder.children("canvas.flot-base"), existingCanvas = placeholder.children("canvas.flot-base"),
...@@ -829,16 +829,16 @@ ...@@ -829,16 +829,16 @@
if (existingCanvas.length == 0 || existingOverlay == 0) { if (existingCanvas.length == 0 || existingOverlay == 0) {
// init everything // init everything
placeholder.html(""); // make sure placeholder is clear placeholder.html(""); // make sure placeholder is clear
placeholder.css({ padding: 0 }); // padding messes up the positioning placeholder.css({ padding: 0 }); // padding messes up the positioning
if (placeholder.css("position") == 'static') if (placeholder.css("position") == 'static')
placeholder.css("position", "relative"); // for positioning labels and overlay placeholder.css("position", "relative"); // for positioning labels and overlay
getCanvasDimensions(); getCanvasDimensions();
canvas = makeCanvas(true, "flot-base"); canvas = makeCanvas(true, "flot-base");
overlay = makeCanvas(false, "flot-overlay"); // overlay canvas for interactive features overlay = makeCanvas(false, "flot-overlay"); // overlay canvas for interactive features
...@@ -865,10 +865,10 @@ ...@@ -865,10 +865,10 @@
// reset reused canvases // reset reused canvases
plot.resize(); plot.resize();
// make sure overlay pixels are cleared (canvas is cleared when we redraw) // make sure overlay pixels are cleared (canvas is cleared when we redraw)
octx.clearRect(0, 0, canvasWidth, canvasHeight); octx.clearRect(0, 0, canvasWidth, canvasHeight);
// then whack any remaining obvious garbage left // then whack any remaining obvious garbage left
eventHolder.unbind(); eventHolder.unbind();
placeholder.children().not([canvas, overlay]).remove(); placeholder.children().not([canvas, overlay]).remove();
...@@ -894,23 +894,23 @@ ...@@ -894,23 +894,23 @@
function shutdown() { function shutdown() {
if (redrawTimeout) if (redrawTimeout)
clearTimeout(redrawTimeout); clearTimeout(redrawTimeout);
eventHolder.unbind("mousemove", onMouseMove); eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mouseleave", onMouseLeave); eventHolder.unbind("mouseleave", onMouseLeave);
eventHolder.unbind("click", onClick); eventHolder.unbind("click", onClick);
executeHooks(hooks.shutdown, [eventHolder]); executeHooks(hooks.shutdown, [eventHolder]);
} }
function setTransformationHelpers(axis) { function setTransformationHelpers(axis) {
// set helper functions on the axis, assumes plot area // set helper functions on the axis, assumes plot area
// has been computed already // has been computed already
function identity(x) { return x; } function identity(x) { return x; }
var s, m, t = axis.options.transform || identity, var s, m, t = axis.options.transform || identity,
it = axis.options.inverseTransform; it = axis.options.inverseTransform;
// precompute how much the axis is scaling a point // precompute how much the axis is scaling a point
// in canvas space // in canvas space
if (axis.direction == "x") { if (axis.direction == "x") {
...@@ -945,7 +945,7 @@ ...@@ -945,7 +945,7 @@
for (var i = 0; i < ticks.length; ++i) { for (var i = 0; i < ticks.length; ++i) {
var t = ticks[i]; var t = ticks[i];
t.lines = []; t.lines = [];
t.width = t.height = 0; t.width = t.height = 0;
...@@ -959,7 +959,7 @@ ...@@ -959,7 +959,7 @@
for (var j = 0; j < lines.length; ++j) { for (var j = 0; j < lines.length; ++j) {
var line = { text: lines[j] }, var line = { text: lines[j] },
m = ctx.measureText(line.text); m = ctx.measureText(line.text);
line.width = m.width; line.width = m.width;
// m.height might not be defined, not in the // m.height might not be defined, not in the
// standard yet // standard yet
...@@ -1016,21 +1016,21 @@ ...@@ -1016,21 +1016,21 @@
var sameDirection = $.grep(all, function (a) { var sameDirection = $.grep(all, function (a) {
return a && a.reserveSpace; return a && a.reserveSpace;
}); });
var innermost = $.inArray(axis, sameDirection) == 0; var innermost = $.inArray(axis, sameDirection) == 0;
if (innermost) if (innermost)
tickLength = "full"; tickLength = "full";
else else
tickLength = 5; tickLength = 5;
} }
if (!isNaN(+tickLength)) if (!isNaN(+tickLength))
padding += +tickLength; padding += +tickLength;
// compute box // compute box
if (axis.direction == "x") { if (axis.direction == "x") {
lh += padding; lh += padding;
if (pos == "bottom") { if (pos == "bottom") {
plotOffset.bottom += lh + axisMargin; plotOffset.bottom += lh + axisMargin;
axis.box = { top: canvasHeight - plotOffset.bottom, height: lh }; axis.box = { top: canvasHeight - plotOffset.bottom, height: lh };
...@@ -1042,7 +1042,7 @@ ...@@ -1042,7 +1042,7 @@
} }
else { else {
lw += padding; lw += padding;
if (pos == "left") { if (pos == "left") {
axis.box = { left: plotOffset.left + axisMargin, width: lw }; axis.box = { left: plotOffset.left + axisMargin, width: lw };
plotOffset.left += lw + axisMargin; plotOffset.left += lw + axisMargin;
...@@ -1076,7 +1076,7 @@ ...@@ -1076,7 +1076,7 @@
function adjustLayoutForThingsStickingOut() { function adjustLayoutForThingsStickingOut() {
// possibly adjust plot offset to ensure everything stays // possibly adjust plot offset to ensure everything stays
// inside the canvas and isn't clipped off // inside the canvas and isn't clipped off
var minMargin = options.grid.minBorderMargin, var minMargin = options.grid.minBorderMargin,
margins = { x: 0, y: 0 }, i, axis; margins = { x: 0, y: 0 }, i, axis;
...@@ -1090,7 +1090,7 @@ ...@@ -1090,7 +1090,7 @@
} }
margins.x = margins.y = Math.ceil(minMargin); margins.x = margins.y = Math.ceil(minMargin);
// check axis labels, note we don't check the actual // check axis labels, note we don't check the actual
// labels but instead use the overall width/height to not // labels but instead use the overall width/height to not
// jump as much around with replots // jump as much around with replots
...@@ -1105,7 +1105,7 @@ ...@@ -1105,7 +1105,7 @@
plotOffset.top = Math.max(margins.y, plotOffset.top); plotOffset.top = Math.max(margins.y, plotOffset.top);
plotOffset.bottom = Math.max(margins.y, plotOffset.bottom); plotOffset.bottom = Math.max(margins.y, plotOffset.bottom);
} }
function setupGrid() { function setupGrid() {
var i, axes = allAxes(), showGrid = options.grid.show; var i, axes = allAxes(), showGrid = options.grid.show;
...@@ -1134,7 +1134,7 @@ ...@@ -1134,7 +1134,7 @@
axis.show = axis.options.show; axis.show = axis.options.show;
if (axis.show == null) if (axis.show == null)
axis.show = axis.used; // by default an axis is visible if it's got data axis.show = axis.used; // by default an axis is visible if it's got data
axis.reserveSpace = axis.show || axis.options.reserveSpace; axis.reserveSpace = axis.show || axis.options.reserveSpace;
setRange(axis); setRange(axis);
...@@ -1177,7 +1177,7 @@ ...@@ -1177,7 +1177,7 @@
allocateAxisBoxSecondPhase(axis); allocateAxisBoxSecondPhase(axis);
}); });
} }
plotWidth = canvasWidth - plotOffset.left - plotOffset.right; plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top; plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
...@@ -1185,10 +1185,10 @@ ...@@ -1185,10 +1185,10 @@
$.each(axes, function (_, axis) { $.each(axes, function (_, axis) {
setTransformationHelpers(axis); setTransformationHelpers(axis);
}); });
insertLegend(); insertLegend();
} }
function setRange(axis) { function setRange(axis) {
var opts = axis.options, var opts = axis.options,
min = +(opts.min != null ? opts.min : axis.datamin), min = +(opts.min != null ? opts.min : axis.datamin),
...@@ -1230,7 +1230,7 @@ ...@@ -1230,7 +1230,7 @@
function setupTickGeneration(axis) { function setupTickGeneration(axis) {
var opts = axis.options; var opts = axis.options;
// estimate number of ticks // estimate number of ticks
var noTicks; var noTicks;
if (typeof opts.ticks == "number" && opts.ticks > 0) if (typeof opts.ticks == "number" && opts.ticks > 0)
...@@ -1331,7 +1331,7 @@ ...@@ -1331,7 +1331,7 @@
if (opts.max == null && niceTicks.length > 1) if (opts.max == null && niceTicks.length > 1)
axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]); axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]);
} }
axis.tickGenerator = function (axis) { axis.tickGenerator = function (axis) {
// copy ticks, scaled to this axis // copy ticks, scaled to this axis
var ticks = [], v, i; var ticks = [], v, i;
...@@ -1342,7 +1342,7 @@ ...@@ -1342,7 +1342,7 @@
} }
return ticks; return ticks;
}; };
// we might need an extra decimal since forced // we might need an extra decimal since forced
// ticks don't necessarily fit naturally // ticks don't necessarily fit naturally
if (!axis.mode && opts.tickDecimals == null) { if (!axis.mode && opts.tickDecimals == null) {
...@@ -1358,7 +1358,7 @@ ...@@ -1358,7 +1358,7 @@
} }
} }
} }
function setTicks(axis) { function setTicks(axis) {
var oticks = axis.options.ticks, ticks = []; var oticks = axis.options.ticks, ticks = [];
if (oticks == null || (typeof oticks == "number" && oticks > 0)) if (oticks == null || (typeof oticks == "number" && oticks > 0))
...@@ -1400,7 +1400,7 @@ ...@@ -1400,7 +1400,7 @@
axis.max = Math.max(axis.max, ticks[ticks.length - 1].v); axis.max = Math.max(axis.max, ticks[ticks.length - 1].v);
} }
} }
function draw() { function draw() {
ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.clearRect(0, 0, canvasWidth, canvasHeight);
...@@ -1411,7 +1411,7 @@ ...@@ -1411,7 +1411,7 @@
// draw background, if any // draw background, if any
if (grid.show && grid.backgroundColor) if (grid.show && grid.backgroundColor)
drawBackground(); drawBackground();
if (grid.show && !grid.aboveData) { if (grid.show && !grid.aboveData) {
drawGrid(); drawGrid();
drawAxisLabels(); drawAxisLabels();
...@@ -1423,7 +1423,7 @@ ...@@ -1423,7 +1423,7 @@
} }
executeHooks(hooks.draw, [ctx]); executeHooks(hooks.draw, [ctx]);
if (grid.show && grid.aboveData) { if (grid.show && grid.aboveData) {
drawGrid(); drawGrid();
drawAxisLabels(); drawAxisLabels();
...@@ -1460,10 +1460,10 @@ ...@@ -1460,10 +1460,10 @@
from = to; from = to;
to = tmp; to = tmp;
} }
return { from: from, to: to, axis: axis }; return { from: from, to: to, axis: axis };
} }
function drawBackground() { function drawBackground() {
ctx.save(); ctx.save();
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
...@@ -1475,7 +1475,7 @@ ...@@ -1475,7 +1475,7 @@
function drawGrid() { function drawGrid() {
var i; var i;
ctx.save(); ctx.save();
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
...@@ -1490,7 +1490,7 @@ ...@@ -1490,7 +1490,7 @@
axes.xmax = axes.xaxis.max; axes.xmax = axes.xaxis.max;
axes.ymin = axes.yaxis.min; axes.ymin = axes.yaxis.min;
axes.ymax = axes.yaxis.max; axes.ymax = axes.yaxis.max;
markings = markings(axes); markings = markings(axes);
} }
...@@ -1527,7 +1527,7 @@ ...@@ -1527,7 +1527,7 @@
xrange.to = xrange.axis.p2c(xrange.to); xrange.to = xrange.axis.p2c(xrange.to);
yrange.from = yrange.axis.p2c(yrange.from); yrange.from = yrange.axis.p2c(yrange.from);
yrange.to = yrange.axis.p2c(yrange.to); yrange.to = yrange.axis.p2c(yrange.to);
if (xrange.from == xrange.to || yrange.from == yrange.to) { if (xrange.from == xrange.to || yrange.from == yrange.to) {
// draw line // draw line
ctx.beginPath(); ctx.beginPath();
...@@ -1546,7 +1546,7 @@ ...@@ -1546,7 +1546,7 @@
} }
} }
} }
// draw the ticks // draw the ticks
var axes = allAxes(), bw = options.grid.borderWidth; var axes = allAxes(), bw = options.grid.borderWidth;
...@@ -1555,7 +1555,7 @@ ...@@ -1555,7 +1555,7 @@
t = axis.tickLength, x, y, xoff, yoff; t = axis.tickLength, x, y, xoff, yoff;
if (!axis.show || axis.ticks.length == 0) if (!axis.show || axis.ticks.length == 0)
continue; continue;
ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString(); ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString();
ctx.lineWidth = 1; ctx.lineWidth = 1;
...@@ -1574,7 +1574,7 @@ ...@@ -1574,7 +1574,7 @@
else else
x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0); x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0);
} }
// draw tick bar // draw tick bar
if (!axis.innermost) { if (!axis.innermost) {
ctx.beginPath(); ctx.beginPath();
...@@ -1583,7 +1583,7 @@ ...@@ -1583,7 +1583,7 @@
xoff = plotWidth; xoff = plotWidth;
else else
yoff = plotHeight; yoff = plotHeight;
if (ctx.lineWidth == 1) { if (ctx.lineWidth == 1) {
x = Math.floor(x) + 0.5; x = Math.floor(x) + 0.5;
y = Math.floor(y) + 0.5; y = Math.floor(y) + 0.5;
...@@ -1598,7 +1598,7 @@ ...@@ -1598,7 +1598,7 @@
ctx.beginPath(); ctx.beginPath();
for (i = 0; i < axis.ticks.length; ++i) { for (i = 0; i < axis.ticks.length; ++i) {
var v = axis.ticks[i].v; var v = axis.ticks[i].v;
xoff = yoff = 0; xoff = yoff = 0;
if (v < axis.min || v > axis.max if (v < axis.min || v > axis.max
...@@ -1611,14 +1611,14 @@ ...@@ -1611,14 +1611,14 @@
if (axis.direction == "x") { if (axis.direction == "x") {
x = axis.p2c(v); x = axis.p2c(v);
yoff = t == "full" ? -plotHeight : t; yoff = t == "full" ? -plotHeight : t;
if (axis.position == "top") if (axis.position == "top")
yoff = -yoff; yoff = -yoff;
} }
else { else {
y = axis.p2c(v); y = axis.p2c(v);
xoff = t == "full" ? -plotWidth : t; xoff = t == "full" ? -plotWidth : t;
if (axis.position == "left") if (axis.position == "left")
xoff = -xoff; xoff = -xoff;
} }
...@@ -1633,11 +1633,11 @@ ...@@ -1633,11 +1633,11 @@
ctx.moveTo(x, y); ctx.moveTo(x, y);
ctx.lineTo(x + xoff, y + yoff); ctx.lineTo(x + xoff, y + yoff);
} }
ctx.stroke(); ctx.stroke();
} }
// draw border // draw border
if (bw) { if (bw) {
// If either borderWidth or borderColor is an object, then draw the border // If either borderWidth or borderColor is an object, then draw the border
...@@ -1664,7 +1664,7 @@ ...@@ -1664,7 +1664,7 @@
ctx.moveTo(plotWidth + bw.right, plotHeight + bw.bottom / 2); ctx.moveTo(plotWidth + bw.right, plotHeight + bw.bottom / 2);
ctx.lineTo(0, plotHeight + bw.bottom / 2); ctx.lineTo(0, plotHeight + bw.bottom / 2);
ctx.stroke(); ctx.stroke();
ctx.beginPath(); ctx.beginPath();
ctx.strokeStyle = (typeof bc == "object" ? bc.left : bc); ctx.strokeStyle = (typeof bc == "object" ? bc.left : bc);
ctx.lineWidth = (typeof bw == "object" ? bw.left : bw); ctx.lineWidth = (typeof bw == "object" ? bw.left : bw);
...@@ -1688,12 +1688,12 @@ ...@@ -1688,12 +1688,12 @@
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function (_, axis) {
if (!axis.show || axis.ticks.length == 0) if (!axis.show || axis.ticks.length == 0)
return; return;
var box = axis.box, f = axis.font; var box = axis.box, f = axis.font;
// placeholder.append('<div style="position:absolute;opacity:0.10;background-color:red;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>') // debug // placeholder.append('<div style="position:absolute;opacity:0.10;background-color:red;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>') // debug
ctx.fillStyle = axis.options.color; ctx.fillStyle = axis.options.color;
// Important: Don't use quotes around axis.font.family! Just around single // Important: Don't use quotes around axis.font.family! Just around single
// font names like 'Times New Roman' that have a space or special character in it. // font names like 'Times New Roman' that have a space or special character in it.
ctx.font = f.style + " " + f.variant + " " + f.weight + " " + f.size + "px " + f.family; ctx.font = f.style + " " + f.variant + " " + f.weight + " " + f.size + "px " + f.family;
ctx.textAlign = "start"; ctx.textAlign = "start";
...@@ -1703,7 +1703,7 @@ ...@@ -1703,7 +1703,7 @@
// middle align to minimize variation between browsers // middle align to minimize variation between browsers
// and compensate when calculating the coordinates // and compensate when calculating the coordinates
ctx.textBaseline = "middle"; ctx.textBaseline = "middle";
for (var i = 0; i < axis.ticks.length; ++i) { for (var i = 0; i < axis.ticks.length; ++i) {
var tick = axis.ticks[i]; var tick = axis.ticks[i];
if (!tick.label || tick.v < axis.min || tick.v > axis.max) if (!tick.label || tick.v < axis.min || tick.v > axis.max)
...@@ -1712,7 +1712,7 @@ ...@@ -1712,7 +1712,7 @@
var x, y, offset = 0, line; var x, y, offset = 0, line;
for (var k = 0; k < tick.lines.length; ++k) { for (var k = 0; k < tick.lines.length; ++k) {
line = tick.lines[k]; line = tick.lines[k];
if (axis.direction == "x") { if (axis.direction == "x") {
x = plotOffset.left + axis.p2c(tick.v) - line.width/2; x = plotOffset.left + axis.p2c(tick.v) - line.width/2;
if (axis.position == "bottom") if (axis.position == "bottom")
...@@ -1759,18 +1759,18 @@ ...@@ -1759,18 +1759,18 @@
if (series.points.show) if (series.points.show)
drawSeriesPoints(series); drawSeriesPoints(series);
} }
function drawSeriesLines(series) { function drawSeriesLines(series) {
function plotLine(datapoints, xoffset, yoffset, axisx, axisy) { function plotLine(datapoints, xoffset, yoffset, axisx, axisy) {
var points = datapoints.points, var points = datapoints.points,
ps = datapoints.pointsize, ps = datapoints.pointsize,
prevx = null, prevy = null; prevx = null, prevy = null;
ctx.beginPath(); ctx.beginPath();
for (var i = ps; i < points.length; i += ps) { for (var i = ps; i < points.length; i += ps) {
var x1 = points[i - ps], y1 = points[i - ps + 1], var x1 = points[i - ps], y1 = points[i - ps + 1],
x2 = points[i], y2 = points[i + 1]; x2 = points[i], y2 = points[i + 1];
if (x1 == null || x2 == null) if (x1 == null || x2 == null)
continue; continue;
...@@ -1833,7 +1833,7 @@ ...@@ -1833,7 +1833,7 @@
if (x1 != prevx || y1 != prevy) if (x1 != prevx || y1 != prevy)
ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset); ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
prevx = x2; prevx = x2;
prevy = y2; prevy = y2;
ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset); ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset);
...@@ -1885,7 +1885,7 @@ ...@@ -1885,7 +1885,7 @@
continue; continue;
// clip x values // clip x values
// clip with xmin // clip with xmin
if (x1 <= x2 && x1 < axisx.min) { if (x1 <= x2 && x1 < axisx.min) {
if (x2 < axisx.min) if (x2 < axisx.min)
...@@ -1920,7 +1920,7 @@ ...@@ -1920,7 +1920,7 @@
ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom)); ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
areaOpen = true; areaOpen = true;
} }
// now first check the case where both is outside // now first check the case where both is outside
if (y1 >= axisy.max && y2 >= axisy.max) { if (y1 >= axisy.max && y2 >= axisy.max) {
ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max)); ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
...@@ -1932,7 +1932,7 @@ ...@@ -1932,7 +1932,7 @@
ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min)); ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
continue; continue;
} }
// else it's a bit more complicated, there might // else it's a bit more complicated, there might
// be a flat maxed out rectangle first, then a // be a flat maxed out rectangle first, then a
// triangular cutout or reverse; to find these // triangular cutout or reverse; to find these
...@@ -1941,7 +1941,7 @@ ...@@ -1941,7 +1941,7 @@
// clip the y values, without shortcutting, we // clip the y values, without shortcutting, we
// go through all cases in turn // go through all cases in turn
// clip with ymin // clip with ymin
if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) { if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
...@@ -1968,7 +1968,7 @@ ...@@ -1968,7 +1968,7 @@
ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1)); ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1));
// it goes to (x1, y1), but we fill that below // it goes to (x1, y1), but we fill that below
} }
// fill triangular section, this sometimes result // fill triangular section, this sometimes result
// in redundant points if (x1, y1) hasn't changed // in redundant points if (x1, y1) hasn't changed
// from previous line to, but we just ignore that // from previous line to, but we just ignore that
...@@ -2022,7 +2022,7 @@ ...@@ -2022,7 +2022,7 @@
var x = points[i], y = points[i + 1]; var x = points[i], y = points[i + 1];
if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
continue; continue;
ctx.beginPath(); ctx.beginPath();
x = axisx.p2c(x); x = axisx.p2c(x);
y = axisy.p2c(y) + offset; y = axisy.p2c(y) + offset;
...@@ -2031,7 +2031,7 @@ ...@@ -2031,7 +2031,7 @@
else else
symbol(ctx, x, y, radius, shadow); symbol(ctx, x, y, radius, shadow);
ctx.closePath(); ctx.closePath();
if (fillStyle) { if (fillStyle) {
ctx.fillStyle = fillStyle; ctx.fillStyle = fillStyle;
ctx.fill(); ctx.fill();
...@@ -2039,7 +2039,7 @@ ...@@ -2039,7 +2039,7 @@
ctx.stroke(); ctx.stroke();
} }
} }
ctx.save(); ctx.save();
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
...@@ -2110,12 +2110,12 @@ ...@@ -2110,12 +2110,12 @@
drawTop = false; drawTop = false;
} }
} }
// clip // clip
if (right < axisx.min || left > axisx.max || if (right < axisx.min || left > axisx.max ||
top < axisy.min || bottom > axisy.max) top < axisy.min || bottom > axisy.max)
return; return;
if (left < axisx.min) { if (left < axisx.min) {
left = axisx.min; left = axisx.min;
drawLeft = false; drawLeft = false;
...@@ -2130,7 +2130,7 @@ ...@@ -2130,7 +2130,7 @@
bottom = axisy.min; bottom = axisy.min;
drawBottom = false; drawBottom = false;
} }
if (top > axisy.max) { if (top > axisy.max) {
top = axisy.max; top = axisy.max;
drawTop = false; drawTop = false;
...@@ -2140,7 +2140,7 @@ ...@@ -2140,7 +2140,7 @@
bottom = axisy.p2c(bottom); bottom = axisy.p2c(bottom);
right = axisx.p2c(right); right = axisx.p2c(right);
top = axisy.p2c(top); top = axisy.p2c(top);
// fill the bar // fill the bar
if (fillStyleCallback) { if (fillStyleCallback) {
c.beginPath(); c.beginPath();
...@@ -2177,11 +2177,11 @@ ...@@ -2177,11 +2177,11 @@
c.stroke(); c.stroke();
} }
} }
function drawSeriesBars(series) { function drawSeriesBars(series) {
function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) { function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
var points = datapoints.points, ps = datapoints.pointsize; var points = datapoints.points, ps = datapoints.pointsize;
for (var i = 0; i < points.length; i += ps) { for (var i = 0; i < points.length; i += ps) {
if (points[i] == null) if (points[i] == null)
continue; continue;
...@@ -2224,7 +2224,7 @@ ...@@ -2224,7 +2224,7 @@
if (filloptions.fillColor) if (filloptions.fillColor)
return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor); return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
var c = $.color.parse(seriesColor); var c = $.color.parse(seriesColor);
c.a = typeof fill == "number" ? fill : 0.4; c.a = typeof fill == "number" ? fill : 0.4;
c.normalize(); c.normalize();
...@@ -2336,10 +2336,10 @@ ...@@ -2336,10 +2336,10 @@
// interactive features // interactive features
var highlights = [], var highlights = [],
redrawTimeout = null; redrawTimeout = null;
// returns the data item the mouse is over, or null if none is found // returns the data item the mouse is over, or null if none is found
function findNearbyItem(mouseX, mouseY, seriesFilter) { function findNearbyItem(mouseX, mouseY, seriesFilter) {
var maxDistance = options.grid.mouseActiveRadius, var maxDistance = options.grid.mouseActiveRadius,
...@@ -2349,7 +2349,7 @@ ...@@ -2349,7 +2349,7 @@
for (i = series.length - 1; i >= 0; --i) { for (i = series.length - 1; i >= 0; --i) {
if (!seriesFilter(series[i])) if (!seriesFilter(series[i]))
continue; continue;
var s = series[i], var s = series[i],
axisx = s.xaxis, axisx = s.xaxis,
axisy = s.yaxis, axisy = s.yaxis,
...@@ -2366,13 +2366,13 @@ ...@@ -2366,13 +2366,13 @@
maxx = Number.MAX_VALUE; maxx = Number.MAX_VALUE;
if (axisy.options.inverseTransform) if (axisy.options.inverseTransform)
maxy = Number.MAX_VALUE; maxy = Number.MAX_VALUE;
if (s.lines.show || s.points.show) { if (s.lines.show || s.points.show) {
for (j = 0; j < points.length; j += ps) { for (j = 0; j < points.length; j += ps) {
var x = points[j], y = points[j + 1]; var x = points[j], y = points[j + 1];
if (x == null) if (x == null)
continue; continue;
// For points and lines, the cursor must be within a // For points and lines, the cursor must be within a
// certain distance to the data point // certain distance to the data point
if (x - mx > maxx || x - mx < -maxx || if (x - mx > maxx || x - mx < -maxx ||
...@@ -2393,19 +2393,19 @@ ...@@ -2393,19 +2393,19 @@
} }
} }
} }
if (s.bars.show && !item) { // no other point can be nearby if (s.bars.show && !item) { // no other point can be nearby
var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2, var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
barRight = barLeft + s.bars.barWidth; barRight = barLeft + s.bars.barWidth;
for (j = 0; j < points.length; j += ps) { for (j = 0; j < points.length; j += ps) {
var x = points[j], y = points[j + 1], b = points[j + 2]; var x = points[j], y = points[j + 1], b = points[j + 2];
if (x == null) if (x == null)
continue; continue;
// for a bar graph, the cursor must be inside the bar // for a bar graph, the cursor must be inside the bar
if (series[i].bars.horizontal ? if (series[i].bars.horizontal ?
(mx <= Math.max(b, x) && mx >= Math.min(b, x) && (mx <= Math.max(b, x) && mx >= Math.min(b, x) &&
my >= y + barLeft && my <= y + barRight) : my >= y + barLeft && my <= y + barRight) :
(mx >= x + barLeft && mx <= x + barRight && (mx >= x + barLeft && mx <= x + barRight &&
my >= Math.min(b, y) && my <= Math.max(b, y))) my >= Math.min(b, y) && my <= Math.max(b, y)))
...@@ -2418,13 +2418,13 @@ ...@@ -2418,13 +2418,13 @@
i = item[0]; i = item[0];
j = item[1]; j = item[1];
ps = series[i].datapoints.pointsize; 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, dataIndex: j,
series: series[i], series: series[i],
seriesIndex: i }; seriesIndex: i };
} }
return null; return null;
} }
...@@ -2474,11 +2474,11 @@ ...@@ -2474,11 +2474,11 @@
h.point[1] == item.datapoint[1])) h.point[1] == item.datapoint[1]))
unhighlight(h.series, h.point); unhighlight(h.series, h.point);
} }
if (item) if (item)
highlight(item.series, item.datapoint, eventname); highlight(item.series, item.datapoint, eventname);
} }
placeholder.trigger(eventname, [ pos, item ]); placeholder.trigger(eventname, [ pos, item ]);
} }
...@@ -2488,7 +2488,7 @@ ...@@ -2488,7 +2488,7 @@
drawOverlay(); drawOverlay();
return; return;
} }
if (!redrawTimeout) if (!redrawTimeout)
redrawTimeout = setTimeout(drawOverlay, t); redrawTimeout = setTimeout(drawOverlay, t);
} }
...@@ -2500,7 +2500,7 @@ ...@@ -2500,7 +2500,7 @@
octx.save(); octx.save();
octx.clearRect(0, 0, canvasWidth, canvasHeight); octx.clearRect(0, 0, canvasWidth, canvasHeight);
octx.translate(plotOffset.left, plotOffset.top); octx.translate(plotOffset.left, plotOffset.top);
var i, hi; var i, hi;
for (i = 0; i < highlights.length; ++i) { for (i = 0; i < highlights.length; ++i) {
hi = highlights[i]; hi = highlights[i];
...@@ -2511,10 +2511,10 @@ ...@@ -2511,10 +2511,10 @@
drawPointHighlight(hi.series, hi.point); drawPointHighlight(hi.series, hi.point);
} }
octx.restore(); octx.restore();
executeHooks(hooks.drawOverlay, [octx]); executeHooks(hooks.drawOverlay, [octx]);
} }
function highlight(s, point, auto) { function highlight(s, point, auto) {
if (typeof s == "number") if (typeof s == "number")
s = series[s]; s = series[s];
...@@ -2533,13 +2533,13 @@ ...@@ -2533,13 +2533,13 @@
else if (!auto) else if (!auto)
highlights[i].auto = false; highlights[i].auto = false;
} }
function unhighlight(s, point) { function unhighlight(s, point) {
if (s == null && point == null) { if (s == null && point == null) {
highlights = []; highlights = [];
triggerRedrawOverlay(); triggerRedrawOverlay();
} }
if (typeof s == "number") if (typeof s == "number")
s = series[s]; s = series[s];
...@@ -2553,7 +2553,7 @@ ...@@ -2553,7 +2553,7 @@
triggerRedrawOverlay(); triggerRedrawOverlay();
} }
} }
function indexOfHighlight(s, p) { function indexOfHighlight(s, p) {
for (var i = 0; i < highlights.length; ++i) { for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i]; var h = highlights[i];
...@@ -2563,22 +2563,22 @@ ...@@ -2563,22 +2563,22 @@
} }
return -1; return -1;
} }
function drawPointHighlight(series, point) { function drawPointHighlight(series, point) {
var x = point[0], y = point[1], var x = point[0], y = point[1],
axisx = series.xaxis, axisy = series.yaxis; axisx = series.xaxis, axisy = series.yaxis;
highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(); highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString();
if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
return; return;
var pointRadius = series.points.radius + series.points.lineWidth / 2; var pointRadius = series.points.radius + series.points.lineWidth / 2;
octx.lineWidth = pointRadius; octx.lineWidth = pointRadius;
octx.strokeStyle = highlightColor; octx.strokeStyle = highlightColor;
var radius = 1.5 * pointRadius, var radius = 1.5 * pointRadius,
x = axisx.p2c(x), x = axisx.p2c(x),
y = axisy.p2c(y); y = axisy.p2c(y);
octx.beginPath(); octx.beginPath();
if (series.points.symbol == "circle") if (series.points.symbol == "circle")
octx.arc(x, y, radius, 0, 2 * Math.PI, false); octx.arc(x, y, radius, 0, 2 * Math.PI, false);
...@@ -2592,10 +2592,10 @@ ...@@ -2592,10 +2592,10 @@
var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(), var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(),
fillStyle = highlightColor, fillStyle = highlightColor,
barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
octx.lineWidth = series.bars.lineWidth; octx.lineWidth = series.bars.lineWidth;
octx.strokeStyle = highlightColor; octx.strokeStyle = highlightColor;
drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
} }
...@@ -2608,7 +2608,7 @@ ...@@ -2608,7 +2608,7 @@
// supports a simple vertical gradient properly, so that's // supports a simple vertical gradient properly, so that's
// what we support too // what we support too
var gradient = ctx.createLinearGradient(0, top, 0, bottom); var gradient = ctx.createLinearGradient(0, top, 0, bottom);
for (var i = 0, l = spec.colors.length; i < l; ++i) { for (var i = 0, l = spec.colors.length; i < l; ++i) {
var c = spec.colors[i]; var c = spec.colors[i];
if (typeof c != "string") { if (typeof c != "string") {
...@@ -2621,7 +2621,7 @@ ...@@ -2621,7 +2621,7 @@
} }
gradient.addColorStop(i / (l - 1), c); gradient.addColorStop(i / (l - 1), c);
} }
return gradient; return gradient;
} }
} }
...@@ -2635,12 +2635,12 @@ ...@@ -2635,12 +2635,12 @@
}; };
$.plot.version = "0.7"; $.plot.version = "0.7";
$.plot.plugins = []; $.plot.plugins = [];
// round to nearby lower multiple of base // round to nearby lower multiple of base
function floorInBase(n, base) { function floorInBase(n, base) {
return base * Math.floor(n / base); return base * Math.floor(n / base);
} }
})(jQuery); })(jQuery);
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