diff --git a/jquery.colorhelpers.js b/jquery.colorhelpers.js
index 2ce381e..412aee7 100644
--- a/jquery.colorhelpers.js
+++ b/jquery.colorhelpers.js
@@ -32,14 +32,16 @@
o.a = a != null ? a : 1;
o.add = function (c, d) {
- for (var i = 0; i < c.length; ++i)
+ 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)
+ for (var i = 0; i < c.length; ++i) {
o[c.charAt(i)] *= f;
+ }
return o.normalize();
};
@@ -78,14 +80,16 @@
c = elem.css(css).toLowerCase();
// keep going until we find an element that has color, or
// we hit the body
- if (c !== "" && c != "transparent")
+ if (c !== "" && c != "transparent") {
break;
+ }
elem = elem.parent();
} while (!$.nodeName(elem.get(0), "body"));
// catch Safari's way of signalling transparent
- if (c == "rgba(0, 0, 0, 0)")
+ if (c == "rgba(0, 0, 0, 0)") {
c = "transparent";
+ }
return $.color.parse(c);
};
@@ -98,39 +102,45 @@
// Look for rgb(num,num,num)
res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str);
- if (res)
+ if (res) {
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10));
+ }
// Look for rgba(num,num,num,num)
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);
- if (res)
+ if (res) {
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4]));
+ }
// Look for rgb(num%,num%,num%)
res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str);
- if (res)
+ if (res) {
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55);
+ }
// Look for rgba(num%,num%,num%,num)
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);
- if (res)
+ if (res) {
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4]));
+ }
// Look for #a0b1c2
res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str);
- if (res)
+ if (res) {
return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16));
+ }
// Look for #fff
res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str);
- if (res)
+ if (res) {
return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16));
+ }
// Otherwise, we're most likely dealing with a named color
var name = $.trim(str).toLowerCase();
- if (name == "transparent")
+ if (name == "transparent") {
return m(255, 255, 255, 0);
- else {
+ } else {
// default to black
res = lookupColors[name] || [0, 0, 0];
return m(res[0], res[1], res[2]);
diff --git a/jquery.flot.categories.js b/jquery.flot.categories.js
index e31c241..24dcee2 100644
--- a/jquery.flot.categories.js
+++ b/jquery.flot.categories.js
@@ -61,8 +61,9 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
var xCategories = series.xaxis.options.mode == "categories",
yCategories = series.yaxis.options.mode == "categories";
- if (!(xCategories || yCategories))
+ if (!(xCategories || yCategories)) {
return;
+ }
var format = datapoints.format;
@@ -86,20 +87,24 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
}
for (var m = 0; m < format.length; ++m) {
- if (format[m].x && xCategories)
+ if (format[m].x && xCategories) {
format[m].number = false;
+ }
- if (format[m].y && yCategories)
+ if (format[m].y && yCategories) {
format[m].number = false;
+ }
}
}
function getNextIndex(categories) {
var index = -1;
- for (var v in categories)
- if (categories[v] > index)
+ for (var v in categories) {
+ if (categories[v] > index) {
index = categories[v];
+ }
+ }
return index + 1;
}
@@ -108,8 +113,9 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
var res = [];
for (var label in axis.categories) {
var v = axis.categories[label];
- if (v >= axis.min && v <= axis.max)
+ if (v >= axis.min && v <= axis.max) {
res.push([v, label]);
+ }
}
res.sort(function (a, b) { return a[0] - b[0]; });
@@ -118,27 +124,31 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
}
function setupCategoriesForAxis(series, axis, datapoints) {
- if (series[axis].options.mode != "categories")
+ if (series[axis].options.mode != "categories") {
return;
+ }
if (!series[axis].categories) {
// parse options
var c = {}, o = series[axis].options.categories || {};
if ($.isArray(o)) {
- for (var i = 0; i < o.length; ++i)
+ for (var i = 0; i < o.length; ++i) {
c[o[i]] = i;
+ }
}
else {
- for (var v in o)
+ for (var v in o) {
c[v] = o[v];
+ }
}
series[axis].categories = c;
}
// fix ticks
- if (!series[axis].options.ticks)
+ if (!series[axis].options.ticks) {
series[axis].options.ticks = categoriesTickGenerator;
+ }
transformPointsOnAxis(datapoints, axis, series[axis].categories);
}
@@ -152,14 +162,16 @@ as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
index = getNextIndex(categories);
for (var i = 0; i < points.length; i += ps) {
- if (points[i] == null)
+ if (points[i] == null) {
continue;
+ }
for (var m = 0; m < ps; ++m) {
var val = points[i + m];
- if (val == null || !format[m][formatColumn])
+ if (val == null || !format[m][formatColumn]) {
continue;
+ }
if (!(val in categories)) {
categories[val] = index;
diff --git a/jquery.flot.crosshair.js b/jquery.flot.crosshair.js
index 2a8d326..f09c133 100644
--- a/jquery.flot.crosshair.js
+++ b/jquery.flot.crosshair.js
@@ -72,9 +72,9 @@ The plugin also adds four public methods:
var crosshair = { x: -1, y: -1, locked: false };
plot.setCrosshair = function setCrosshair(pos) {
- if (!pos)
+ if (!pos) {
crosshair.x = -1;
- else {
+ } else {
var o = plot.p2c(pos);
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
@@ -86,8 +86,9 @@ The plugin also adds four public methods:
plot.clearCrosshair = plot.setCrosshair; // passes null for pos
plot.lockCrosshair = function lockCrosshair(pos) {
- if (pos)
+ if (pos) {
plot.setCrosshair(pos);
+ }
crosshair.locked = true;
};
@@ -96,8 +97,9 @@ The plugin also adds four public methods:
};
function onMouseOut(e) {
- if (crosshair.locked)
+ if (crosshair.locked) {
return;
+ }
if (crosshair.x != -1) {
crosshair.x = -1;
@@ -106,8 +108,9 @@ The plugin also adds four public methods:
}
function onMouseMove(e) {
- if (crosshair.locked)
+ if (crosshair.locked) {
return;
+ }
if (plot.getSelection && plot.getSelection()) {
crosshair.x = -1; // hide the crosshair while selecting
@@ -121,8 +124,9 @@ The plugin also adds four public methods:
}
plot.hooks.bindEvents.push(function (plot, eventHolder) {
- if (!plot.getOptions().crosshair.mode)
+ if (!plot.getOptions().crosshair.mode) {
return;
+ }
eventHolder.mouseout(onMouseOut);
eventHolder.mousemove(onMouseMove);
@@ -130,8 +134,9 @@ The plugin also adds four public methods:
plot.hooks.drawOverlay.push(function (plot, ctx) {
var c = plot.getOptions().crosshair;
- if (!c.mode)
+ if (!c.mode) {
return;
+ }
var plotOffset = plot.getPlotOffset();
diff --git a/jquery.flot.errorbars.js b/jquery.flot.errorbars.js
index 0e3af34..7ac49ee 100644
--- a/jquery.flot.errorbars.js
+++ b/jquery.flot.errorbars.js
@@ -74,8 +74,9 @@ shadowSize and lineWidth are derived as well from the points series.
};
function processRawData(plot, series, data, datapoints){
- if (!series.points.errorbars)
+ if (!series.points.errorbars) {
return;
+ }
// x,y values
var format = [
@@ -90,16 +91,18 @@ shadowSize and lineWidth are derived as well from the points series.
if (series.points.xerr.asymmetric) {
format.push({ x: true, number: true, required: true });
format.push({ x: true, number: true, required: true });
- } else
+ } else {
format.push({ x: true, number: true, required: true });
+ }
}
if (errors == "y" || errors == "xy") {
// lower / upper error
if (series.points.yerr.asymmetric) {
format.push({ y: true, number: true, required: true });
format.push({ y: true, number: true, required: true });
- } else
+ } else {
format.push({ y: true, number: true, required: true });
+ }
}
datapoints.format = format;
}
@@ -122,29 +125,42 @@ shadowSize and lineWidth are derived as well from the points series.
if (xerr.asymmetric) {
exl = points[i + 2];
exu = points[i + 3];
- if (eb == "xy")
+ if (eb == "xy") {
if (yerr.asymmetric){
eyl = points[i + 4];
eyu = points[i + 5];
- } else eyl = points[i + 4];
+ } else {
+ eyl = points[i + 4];
+ }
+ }
} else {
exl = points[i + 2];
- if (eb == "xy")
+ if (eb == "xy") {
if (yerr.asymmetric) {
eyl = points[i + 3];
eyu = points[i + 4];
- } else eyl = points[i + 3];
+ } else {
+ eyl = points[i + 3];
+ }
+ }
}
// only Y
- } else if (eb == "y")
+ } else if (eb == "y") {
if (yerr.asymmetric) {
eyl = points[i + 2];
eyu = points[i + 3];
- } else eyl = points[i + 2];
+ } else {
+ eyl = points[i + 2];
+ }
+ }
// symmetric errors?
- if (exu == null) exu = exl;
- if (eyu == null) eyu = eyl;
+ if (exu == null) {
+ exu = exl;
+ }
+ if (eyu == null) {
+ eyu = eyl;
+ }
var errRanges = [exl, exu, eyl, eyu];
// nullify if not showing
@@ -206,12 +222,16 @@ shadowSize and lineWidth are derived as well from the points series.
lower = [x, y][e] - errRanges[e * err.length];
//points outside of the canvas
- if (err[e].err == "x")
- if (y > ax[1].max || y < ax[1].min || upper < ax[0].min || lower > ax[0].max)
+ if (err[e].err == "x") {
+ if (y > ax[1].max || y < ax[1].min || upper < ax[0].min || lower > ax[0].max) {
continue;
- if (err[e].err == "y")
- if (x > ax[0].max || x < ax[0].min || upper < ax[1].min || lower > ax[1].max)
+ }
+ }
+ if (err[e].err == "y") {
+ if (x > ax[0].max || x < ax[0].min || upper < ax[1].min || lower > ax[1].max) {
continue;
+ }
+ }
// prevent errorbars getting out of the canvas
var drawUpper = true,
@@ -281,16 +301,27 @@ shadowSize and lineWidth are derived as well from the points series.
// error bar - avoid plotting over circles
if (err.err == "x"){
- if (upper > x + radius) drawPath(ctx, [[upper,y],[Math.max(x + radius,minmax[0]),y]]);
- else drawUpper = false;
- if (lower < x - radius) drawPath(ctx, [[Math.min(x - radius,minmax[1]),y],[lower,y]] );
- else drawLower = false;
- }
- else {
- if (upper < y - radius) drawPath(ctx, [[x,upper],[x,Math.min(y - radius,minmax[0])]] );
- else drawUpper = false;
- if (lower > y + radius) drawPath(ctx, [[x,Math.max(y + radius,minmax[1])],[x,lower]] );
- else drawLower = false;
+ if (upper > x + radius) {
+ drawPath(ctx, [[upper,y],[Math.max(x + radius,minmax[0]),y]]);
+ } else {
+ drawUpper = false;
+ }
+ if (lower < x - radius) {
+ drawPath(ctx, [[Math.min(x - radius,minmax[1]),y],[lower,y]] );
+ } else {
+ drawLower = false;
+ }
+ } else {
+ if (upper < y - radius) {
+ drawPath(ctx, [[x,upper],[x,Math.min(y - radius,minmax[0])]] );
+ } else {
+ drawUpper = false;
+ }
+ if (lower > y + radius) {
+ drawPath(ctx, [[x,Math.max(y + radius,minmax[1])],[x,lower]] );
+ } else {
+ drawLower = false;
+ }
}
//internal radius value in errorbar, allows to plot radius 0 points and still keep proper sized caps
@@ -300,21 +331,33 @@ shadowSize and lineWidth are derived as well from the points series.
// upper cap
if (drawUpper) {
if (err.upperCap == "-"){
- if (err.err=="x") drawPath(ctx, [[upper,y - radius],[upper,y + radius]] );
- else drawPath(ctx, [[x - radius,upper],[x + radius,upper]] );
+ if (err.err=="x") {
+ drawPath(ctx, [[upper,y - radius],[upper,y + radius]] );
+ } else {
+ drawPath(ctx, [[x - radius,upper],[x + radius,upper]] );
+ }
} else if ($.isFunction(err.upperCap)){
- if (err.err=="x") err.upperCap(ctx, upper, y, radius);
- else err.upperCap(ctx, x, upper, radius);
+ if (err.err=="x") {
+ err.upperCap(ctx, upper, y, radius);
+ } else {
+ err.upperCap(ctx, x, upper, radius);
+ }
}
}
// lower cap
if (drawLower) {
if (err.lowerCap == "-"){
- if (err.err=="x") drawPath(ctx, [[lower,y - radius],[lower,y + radius]] );
- else drawPath(ctx, [[x - radius,lower],[x + radius,lower]] );
+ if (err.err=="x") {
+ drawPath(ctx, [[lower,y - radius],[lower,y + radius]] );
+ } else {
+ drawPath(ctx, [[x - radius,lower],[x + radius,lower]] );
+ }
} else if ($.isFunction(err.lowerCap)){
- if (err.err=="x") err.lowerCap(ctx, lower, y, radius);
- else err.lowerCap(ctx, x, lower, radius);
+ if (err.err=="x") {
+ err.lowerCap(ctx, lower, y, radius);
+ } else {
+ err.lowerCap(ctx, x, lower, radius);
+ }
}
}
}
@@ -322,8 +365,9 @@ shadowSize and lineWidth are derived as well from the points series.
function drawPath(ctx, pts){
ctx.beginPath();
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.stroke();
}
@@ -333,8 +377,9 @@ shadowSize and lineWidth are derived as well from the points series.
ctx.save();
ctx.translate(plotOffset.left, plotOffset.top);
$.each(plot.getData(), function (i, s) {
- if (s.points.errorbars && (s.points.xerr.show || s.points.yerr.show))
+ if (s.points.errorbars && (s.points.xerr.show || s.points.yerr.show)) {
drawSeriesErrors(plot, ctx, s);
+ }
});
ctx.restore();
}
diff --git a/jquery.flot.image.js b/jquery.flot.image.js
index 3644841..91f39a0 100644
--- a/jquery.flot.image.js
+++ b/jquery.flot.image.js
@@ -71,11 +71,13 @@ Google Maps).
var defaultShow = options.series.images.show;
$.each(series, function (i, s) {
- if (!(defaultShow || s.images.show))
+ if (!(defaultShow || s.images.show)) {
return;
+ }
- if (s.data)
+ if (s.data) {
s = s.data;
+ }
$.each(s, function (i, p) {
if (typeof p[0] == "string") {
@@ -88,8 +90,9 @@ Google Maps).
$.plot.image.load(urls, function (loadedImages) {
$.each(points, function (i, p) {
var url = p[0];
- if (loadedImages[url])
+ if (loadedImages[url]) {
p[0] = loadedImages[url];
+ }
});
callback();
@@ -98,8 +101,9 @@ Google Maps).
$.plot.image.load = function (urls, callback) {
var missing = urls.length, loaded = {};
- if (missing == 0)
+ if (missing == 0) {
callback({});
+ }
$.each(urls, function (i, url) {
var handler = function () {
@@ -107,8 +111,9 @@ Google Maps).
loaded[url] = this;
- if (missing == 0)
+ if (missing == 0) {
callback(loaded);
+ }
};
$("").load(handler).error(handler).attr("src", url);
@@ -118,8 +123,9 @@ Google Maps).
function drawSeries(plot, ctx, series) {
var plotOffset = plot.getPlotOffset();
- if (!series.images || !series.images.show)
+ if (!series.images || !series.images.show) {
return;
+ }
var points = series.datapoints.points,
ps = series.datapoints.pointsize;
@@ -134,8 +140,9 @@ Google Maps).
// actually we should check img.complete, but it
// appears to be a somewhat unreliable indicator in
// IE6 (false even after load event)
- if (!img || img.width <= 0 || img.height <= 0)
+ if (!img || img.width <= 0 || img.height <= 0) {
continue;
+ }
if (x1 > x2) {
tmp = x2;
@@ -162,8 +169,9 @@ Google Maps).
// clip
if (x1 == x2 || y1 == y2 ||
x1 >= xaxis.max || x2 <= xaxis.min ||
- y1 >= yaxis.max || y2 <= yaxis.min)
+ y1 >= yaxis.max || y2 <= yaxis.min) {
continue;
+ }
var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;
if (x1 < xaxis.min) {
@@ -214,8 +222,9 @@ Google Maps).
}
function processRawData(plot, series, data, datapoints) {
- if (!series.images.show)
+ if (!series.images.show) {
return;
+ }
// format is Image, x1, y1, x2, y2 (opposite corners)
datapoints.format = [
diff --git a/jquery.flot.js b/jquery.flot.js
index b629638..5296cc3 100644
--- a/jquery.flot.js
+++ b/jquery.flot.js
@@ -638,8 +638,9 @@ Licensed under the MIT license.
plot.getAxes = function () {
var res = {}, i;
$.each(xaxes.concat(yaxes), function (_, axis) {
- if (axis)
+ if (axis) {
res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
+ }
});
return res;
};
@@ -680,8 +681,9 @@ Licensed under the MIT license.
function executeHooks(hook, args) {
args = [plot].concat(args);
- for (var i = 0; i < hook.length; ++i)
+ for (var i = 0; i < hook.length; ++i) {
hook[i].apply(this, args);
+ }
}
function initPlugins() {
@@ -695,8 +697,9 @@ Licensed under the MIT license.
for (var i = 0; i < plugins.length; ++i) {
var p = plugins[i];
p.init(plot, classes);
- if (p.options)
+ if (p.options) {
$.extend(true, options, p.options);
+ }
}
}
@@ -713,20 +716,26 @@ Licensed under the MIT license.
options.colors = opts.colors;
}
- if (options.xaxis.color == null)
+ if (options.xaxis.color == null) {
options.xaxis.color = $.color.parse(options.grid.color).scale("a", 0.22).toString();
- if (options.yaxis.color == null)
+ }
+ if (options.yaxis.color == null) {
options.yaxis.color = $.color.parse(options.grid.color).scale("a", 0.22).toString();
+ }
- if (options.xaxis.tickColor == null) // grid.tickColor for back-compatibility
+ if (options.xaxis.tickColor == null) { // grid.tickColor for back-compatibility
options.xaxis.tickColor = options.grid.tickColor || options.xaxis.color;
- if (options.yaxis.tickColor == null) // grid.tickColor for back-compatibility
+ }
+ if (options.yaxis.tickColor == null) { // grid.tickColor for back-compatibility
options.yaxis.tickColor = options.grid.tickColor || options.yaxis.color;
+ }
- if (options.grid.borderColor == null)
+ if (options.grid.borderColor == null) {
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();
+ }
// Fill in defaults for axis options, including any unspecified
// font-spec fields, if a font-spec was provided.
@@ -784,10 +793,12 @@ Licensed under the MIT license.
}
// backwards compatibility, to be removed in future
- if (options.xaxis.noTicks && options.xaxis.ticks == null)
+ if (options.xaxis.noTicks && options.xaxis.ticks == null) {
options.xaxis.ticks = options.xaxis.noTicks;
- if (options.yaxis.noTicks && options.yaxis.ticks == null)
+ }
+ if (options.yaxis.noTicks && options.yaxis.ticks == null) {
options.yaxis.ticks = options.yaxis.noTicks;
+ }
if (options.x2axis) {
options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis);
options.xaxes[1].position = "top";
@@ -796,31 +807,42 @@ Licensed under the MIT license.
options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis);
options.yaxes[1].position = "right";
}
- if (options.grid.coloredAreas)
+ if (options.grid.coloredAreas) {
options.grid.markings = options.grid.coloredAreas;
- if (options.grid.coloredAreasColor)
+ }
+ if (options.grid.coloredAreasColor) {
options.grid.markingsColor = options.grid.coloredAreasColor;
- if (options.lines)
+ }
+ if (options.lines) {
$.extend(true, options.series.lines, options.lines);
- if (options.points)
+ }
+ if (options.points) {
$.extend(true, options.series.points, options.points);
- if (options.bars)
+ }
+ if (options.bars) {
$.extend(true, options.series.bars, options.bars);
- if (options.shadowSize != null)
+ }
+ if (options.shadowSize != null) {
options.series.shadowSize = options.shadowSize;
- if (options.highlightColor != null)
+ }
+ if (options.highlightColor != null) {
options.series.highlightColor = options.highlightColor;
+ }
// save options on axes for future reference
- for (i = 0; i < options.xaxes.length; ++i)
+ for (i = 0; i < options.xaxes.length; ++i) {
getOrCreateAxis(xaxes, i + 1).options = options.xaxes[i];
- for (i = 0; i < options.yaxes.length; ++i)
+ }
+ for (i = 0; i < options.yaxes.length; ++i) {
getOrCreateAxis(yaxes, i + 1).options = options.yaxes[i];
+ }
// add hooks from options
- for (var n in hooks)
- if (options.hooks[n] && options.hooks[n].length)
+ for (var n in hooks) {
+ if (options.hooks[n] && options.hooks[n].length) {
hooks[n] = hooks[n].concat(options.hooks[n]);
+ }
+ }
executeHooks(hooks.processOptions, [options]);
}
@@ -843,9 +865,9 @@ Licensed under the MIT license.
$.extend(true, s, d[i]);
d[i].data = s.data;
- }
- else
+ } else {
s.data = d[i];
+ }
res.push(s);
}
@@ -854,10 +876,12 @@ Licensed under the MIT license.
function axisNumber(obj, coord) {
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
a = a.n;
- if (typeof a != "number")
+ }
+ if (typeof a != "number") {
a = 1; // default to first axis
+ }
return a;
}
@@ -871,20 +895,24 @@ Licensed under the MIT license.
var res = {}, i, axis;
for (i = 0; i < xaxes.length; ++i) {
axis = xaxes[i];
- if (axis && axis.used)
+ if (axis && axis.used) {
res["x" + axis.n] = axis.c2p(pos.left);
+ }
}
for (i = 0; i < yaxes.length; ++i) {
axis = yaxes[i];
- if (axis && axis.used)
+ if (axis && axis.used) {
res["y" + axis.n] = axis.c2p(pos.top);
+ }
}
- if (res.x1 !== undefined)
+ if (res.x1 !== undefined) {
res.x = res.x1;
- if (res.y1 !== undefined)
+ }
+ if (res.y1 !== undefined) {
res.y = res.y1;
+ }
return res;
}
@@ -897,8 +925,9 @@ Licensed under the MIT license.
axis = xaxes[i];
if (axis && axis.used) {
key = "x" + axis.n;
- if (pos[key] == null && axis.n == 1)
+ if (pos[key] == null && axis.n == 1) {
key = "x";
+ }
if (pos[key] != null) {
res.left = axis.p2c(pos[key]);
@@ -911,8 +940,9 @@ Licensed under the MIT license.
axis = yaxes[i];
if (axis && axis.used) {
key = "y" + axis.n;
- if (pos[key] == null && axis.n == 1)
+ if (pos[key] == null && axis.n == 1) {
key = "y";
+ }
if (pos[key] != null) {
res.top = axis.p2c(pos[key]);
@@ -925,12 +955,13 @@ Licensed under the MIT license.
}
function getOrCreateAxis(axes, number) {
- if (!axes[number - 1])
+ if (!axes[number - 1]) {
axes[number - 1] = {
n: number, // save the number for future reference
direction: axes == xaxes ? "x" : "y",
options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis)
};
+ }
return axes[number - 1];
}
@@ -981,8 +1012,12 @@ Licensed under the MIT license.
if (variation >= 0) {
if (variation < 0.5) {
variation = -variation - 0.2;
- } else variation = 0;
- } else variation = -variation;
+ } else {
+ variation = 0;
+ }
+ } else {
+ variation = -variation;
+ }
}
colors[i] = c.scale("rgb", 1 + variation);
@@ -999,19 +1034,22 @@ Licensed under the MIT license.
s.color = colors[colori].toString();
++colori;
}
- else if (typeof s.color == "number")
+ else if (typeof s.color == "number") {
s.color = colors[s.color].toString();
+ }
// turn on lines automatically in case nothing is set
if (s.lines.show == null) {
var v, show = true;
- for (v in s)
+ for (v in s) {
if (s[v] && s[v].show) {
show = false;
break;
}
- if (show)
+ }
+ if (show) {
s.lines.show = true;
+ }
}
// If nothing was provided for lines.zero, default it to match
@@ -1036,10 +1074,12 @@ Licensed under the MIT license.
data, format;
function updateAxis(axis, min, max) {
- if (min < axis.datamin && min != -fakeInfinity)
+ if (min < axis.datamin && min != -fakeInfinity) {
axis.datamin = min;
- if (max > axis.datamax && max != fakeInfinity)
+ }
+ if (max > axis.datamax && max != fakeInfinity) {
axis.datamax = max;
+ }
}
$.each(allAxes(), function (_, axis) {
@@ -1081,8 +1121,9 @@ Licensed under the MIT license.
s.datapoints.format = format;
}
- if (s.datapoints.pointsize != null)
+ if (s.datapoints.pointsize != null) {
continue; // already filled in
+ }
s.datapoints.pointsize = format.length;
@@ -1104,20 +1145,23 @@ Licensed under the MIT license.
if (f) {
if (f.number && val != null) {
val = +val; // convert to number
- if (isNaN(val))
+ if (isNaN(val)) {
val = null;
- else if (val == Infinity)
+ } else if (val == Infinity) {
val = fakeInfinity;
- else if (val == -Infinity)
+ } else if (val == -Infinity) {
val = -fakeInfinity;
+ }
}
if (val == null) {
- if (f.required)
+ if (f.required) {
nullify = true;
+ }
- if (f.defaultValue != null)
+ if (f.defaultValue != null) {
val = f.defaultValue;
+ }
}
}
@@ -1152,8 +1196,9 @@ Licensed under the MIT license.
&& points[k - ps] != points[k]
&& points[k - ps + 1] != points[k + 1]) {
// copy the point to make room for a middle point
- for (m = 0; m < ps; ++m)
+ for (m = 0; m < ps; ++m) {
points[k + ps + m] = points[k + m];
+ }
// middle point has same y
points[k + 1] = points[k - ps + 1];
@@ -1183,26 +1228,32 @@ Licensed under the MIT license.
xmax = bottomSentry, ymax = bottomSentry;
for (j = 0; j < points.length; j += ps) {
- if (points[j] == null)
+ if (points[j] == null) {
continue;
+ }
for (m = 0; m < ps; ++m) {
val = points[j + m];
f = format[m];
- if (!f || f.autoscale === false || val == fakeInfinity || val == -fakeInfinity)
+ if (!f || f.autoscale === false || val == fakeInfinity || val == -fakeInfinity) {
continue;
+ }
if (f.x) {
- if (val < xmin)
+ if (val < xmin) {
xmin = val;
- if (val > xmax)
+ }
+ if (val > xmax) {
xmax = val;
+ }
}
if (f.y) {
- if (val < ymin)
+ if (val < ymin) {
ymin = val;
- if (val > ymax)
+ }
+ if (val > ymax) {
ymax = val;
+ }
}
}
}
@@ -1228,8 +1279,7 @@ Licensed under the MIT license.
if (s.bars.horizontal) {
ymin += delta;
ymax += delta + s.bars.barWidth;
- }
- else {
+ } else {
xmin += delta;
xmax += delta + s.bars.barWidth;
}
@@ -1240,10 +1290,12 @@ Licensed under the MIT license.
}
$.each(allAxes(), function (_, axis) {
- if (axis.datamin == topSentry)
+ if (axis.datamin == topSentry) {
axis.datamin = null;
- if (axis.datamax == bottomSentry)
+ }
+ if (axis.datamax == bottomSentry) {
axis.datamax = null;
+ }
});
}
@@ -1255,8 +1307,9 @@ Licensed under the MIT license.
placeholder.css("padding", 0) // padding messes up the positioning
.children(":not(.flot-base,.flot-overlay)").remove();
- if (placeholder.css("position") == "static")
+ if (placeholder.css("position") == "static") {
placeholder.css("position", "relative"); // for positioning labels and overlay
+ }
surface = new Canvas("flot-base", placeholder);
overlay = new Canvas("flot-overlay", placeholder); // overlay canvas for interactive features
@@ -1294,15 +1347,17 @@ Licensed under the MIT license.
eventHolder.bind("mouseleave", onMouseLeave);
}
- if (options.grid.clickable)
+ if (options.grid.clickable) {
eventHolder.click(onClick);
+ }
executeHooks(hooks.bindEvents, [eventHolder]);
}
function shutdown() {
- if (redrawTimeout)
+ if (redrawTimeout) {
clearTimeout(redrawTimeout);
+ }
eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mouseleave", onMouseLeave);
@@ -1325,23 +1380,24 @@ Licensed under the MIT license.
if (axis.direction == "x") {
s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min));
m = Math.min(t(axis.max), t(axis.min));
- }
- else {
+ } else {
s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min));
s = -s;
m = Math.max(t(axis.max), t(axis.min));
}
// data point to canvas coordinate
- if (t == identity) // slight optimization
+ if (t == identity) { // slight optimization
axis.p2c = function (p) { return (p - m) * s; };
- else
+ } else {
axis.p2c = function (p) { return (t(p) - m) * s; };
+ }
// canvas coordinate to data point
- if (!it)
+ if (!it) {
axis.c2p = function (c) { return m + c / s; };
- else
+ } else {
axis.c2p = function (c) { return it(m + c / s); };
+ }
}
function measureTickLabels(axis) {
@@ -1359,8 +1415,9 @@ Licensed under the MIT license.
var t = ticks[i];
- if (!t.label)
+ if (!t.label) {
continue;
+ }
var info = surface.getTextInfo(layer, t.label, font, null, maxWidth);
@@ -1392,8 +1449,9 @@ Licensed under the MIT license.
var samePosition = $.grep(all, function (a) {
return a && a.options.position == pos && a.reserveSpace;
});
- if ($.inArray(axis, samePosition) == samePosition.length - 1)
+ if ($.inArray(axis, samePosition) == samePosition.length - 1) {
axisMargin = 0; // outermost
+ }
// Determine whether the axis is the first (innermost) on its side
@@ -1402,14 +1460,16 @@ Licensed under the MIT license.
// determine tick length - if we're innermost, we can use "full"
if (tickLength == null) {
- if (innermost)
+ if (innermost) {
tickLength = "full";
- else
+ } else {
tickLength = 5;
+ }
}
- if (!isNaN(+tickLength))
+ if (!isNaN(+tickLength)) {
padding += +tickLength;
+ }
// compute box
if (axis.direction == "x") {
@@ -1418,20 +1478,17 @@ Licensed under the MIT license.
if (pos == "bottom") {
plotOffset.bottom += lh + axisMargin;
axis.box = { top: surface.height - plotOffset.bottom, height: lh };
- }
- else {
+ } else {
axis.box = { top: plotOffset.top + axisMargin, height: lh };
plotOffset.top += lh + axisMargin;
}
- }
- else {
+ } else {
lw += padding;
if (pos == "left") {
axis.box = { left: plotOffset.left + axisMargin, width: lw };
plotOffset.left += lw + axisMargin;
- }
- else {
+ } else {
plotOffset.right += lw + axisMargin;
axis.box = { left: surface.width - plotOffset.right, width: lw };
}
@@ -1450,8 +1507,7 @@ Licensed under the MIT license.
if (axis.direction == "x") {
axis.box.left = plotOffset.left - axis.labelWidth / 2;
axis.box.width = surface.width - plotOffset.left - plotOffset.right + axis.labelWidth;
- }
- else {
+ } else {
axis.box.top = plotOffset.top - axis.labelHeight / 2;
axis.box.height = surface.height - plotOffset.bottom - plotOffset.top + axis.labelHeight;
}
@@ -1469,8 +1525,9 @@ Licensed under the MIT license.
// customize)
if (minMargin == null) {
minMargin = 0;
- for (i = 0; i < series.length; ++i)
+ for (i = 0; i < series.length; ++i) {
minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
+ }
}
margins.x = margins.y = Math.ceil(minMargin);
@@ -1480,8 +1537,9 @@ Licensed under the MIT license.
// jump as much around with replots
$.each(allAxes(), function (_, axis) {
var dir = axis.direction;
- if (axis.reserveSpace)
+ if (axis.reserveSpace) {
margins[dir] = Math.ceil(Math.max(margins[dir], (dir == "x" ? axis.labelWidth : axis.labelHeight) / 2));
+ }
});
plotOffset.left = Math.max(margins.x, plotOffset.left);
@@ -1507,8 +1565,7 @@ Licensed under the MIT license.
for (var a in plotOffset) {
if(typeof(options.grid.borderWidth) == "object") {
plotOffset[a] += showGrid ? options.grid.borderWidth[a] : 0;
- }
- else {
+ } else {
plotOffset[a] += showGrid ? options.grid.borderWidth : 0;
}
}
@@ -1516,8 +1573,9 @@ Licensed under the MIT license.
// init axes
$.each(axes, function (_, axis) {
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.reserveSpace = axis.show || axis.options.reserveSpace;
@@ -1540,8 +1598,9 @@ Licensed under the MIT license.
// with all dimensions calculated, we can compute the
// axis bounding boxes, start from the outside
// (reverse order)
- for (i = allocatedAxes.length - 1; i >= 0; --i)
+ for (i = allocatedAxes.length - 1; i >= 0; --i) {
allocateAxisBoxFirstPhase(allocatedAxes[i]);
+ }
// make sure we've got enough space for things that
// might stick out
@@ -1577,14 +1636,15 @@ Licensed under the MIT license.
// degenerate case
var widen = max == 0 ? 1 : 0.01;
- if (opts.min == null)
+ if (opts.min == null) {
min -= widen;
+ }
// always widen max if we couldn't widen min to ensure we
// don't fall into min == max which doesn't work
- if (opts.max == null || opts.min != null)
+ if (opts.max == null || opts.min != null) {
max += widen;
- }
- else {
+ }
+ } else {
// consider autoscaling
var margin = opts.autoscaleMargin;
if (margin != null) {
@@ -1592,13 +1652,15 @@ Licensed under the MIT license.
min -= delta * margin;
// make sure we don't go below zero if all values
// are positive
- if (min < 0 && axis.datamin != null && axis.datamin >= 0)
+ if (min < 0 && axis.datamin != null && axis.datamin >= 0) {
min = 0;
+ }
}
if (opts.max == null) {
max += delta * margin;
- if (max > 0 && axis.datamax != null && axis.datamax <= 0)
+ if (max > 0 && axis.datamax != null && axis.datamax <= 0) {
max = 0;
+ }
}
}
}
@@ -1611,12 +1673,13 @@ Licensed under the MIT license.
// estimate number of ticks
var noTicks;
- if (typeof opts.ticks == "number" && opts.ticks > 0)
+ if (typeof opts.ticks == "number" && opts.ticks > 0) {
noTicks = opts.ticks;
- else
+ } else {
// heuristic based on the model a*sqrt(x) fitted to
// some data points that seemed reasonable
noTicks = 0.3 * Math.sqrt(axis.direction == "x" ? surface.width : surface.height);
+ }
var delta = (axis.max - axis.min) / noTicks,
dec = -Math.floor(Math.log(delta) / Math.LN10),
@@ -1704,8 +1767,9 @@ Licensed under the MIT license.
};
}
- if ($.isFunction(opts.tickFormatter))
+ if ($.isFunction(opts.tickFormatter)) {
axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); };
+ }
if (opts.alignTicksWithAxis != null) {
var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1];
@@ -1713,10 +1777,12 @@ Licensed under the MIT license.
// consider snapping min/max to outermost nice ticks
var niceTicks = axis.tickGenerator(axis);
if (niceTicks.length > 0) {
- if (opts.min == null)
+ if (opts.min == null) {
axis.min = Math.min(axis.min, niceTicks[0]);
- 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.tickGenerator = function (axis) {
@@ -1739,8 +1805,9 @@ Licensed under the MIT license.
// only proceed if the tick interval rounded
// with an extra decimal doesn't give us a
// zero at end
- if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec))))
+ if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec)))) {
axis.tickDecimals = extraDec;
+ }
}
}
}
@@ -1748,14 +1815,15 @@ Licensed under the MIT license.
function setTicks(axis) {
var oticks = axis.options.ticks, ticks = [];
- if (oticks == null || (typeof oticks == "number" && oticks > 0))
+ if (oticks == null || (typeof oticks == "number" && oticks > 0)) {
ticks = axis.tickGenerator(axis);
- else if (oticks) {
- if ($.isFunction(oticks))
+ } else if (oticks) {
+ if ($.isFunction(oticks)) {
// generate the ticks
ticks = oticks(axis);
- else
+ } else {
ticks = oticks;
+ }
}
// clean up/labelify the supplied ticks, copy them over
@@ -1766,25 +1834,30 @@ Licensed under the MIT license.
var t = ticks[i];
if (typeof t == "object") {
v = +t[0];
- if (t.length > 1)
+ if (t.length > 1) {
label = t[1];
- }
- else
+ }
+ } else {
v = +t;
- if (label == null)
+ }
+ if (label == null) {
label = axis.tickFormatter(v, axis);
- if (!isNaN(v))
+ }
+ if (!isNaN(v)) {
axis.ticks.push({ v: v, label: label });
+ }
}
}
function snapRangeToTicks(axis, ticks) {
if (axis.options.autoscaleMargin && ticks.length > 0) {
// snap to ticks
- if (axis.options.min == null)
+ if (axis.options.min == null) {
axis.min = Math.min(axis.min, ticks[0].v);
- if (axis.options.max == null && ticks.length > 1)
+ }
+ if (axis.options.max == null && ticks.length > 1) {
axis.max = Math.max(axis.max, ticks[ticks.length - 1].v);
+ }
}
}
@@ -1797,8 +1870,9 @@ Licensed under the MIT license.
var grid = options.grid;
// draw background, if any
- if (grid.show && grid.backgroundColor)
+ if (grid.show && grid.backgroundColor) {
drawBackground();
+ }
if (grid.show && !grid.aboveData) {
drawGrid();
@@ -1830,8 +1904,9 @@ Licensed under the MIT license.
axis = axes[i];
if (axis.direction == coord) {
key = coord + axis.n + "axis";
- if (!ranges[key] && axis.n == 1)
+ if (!ranges[key] && axis.n == 1) {
key = coord + "axis"; // support x1axis as xaxis
+ }
if (ranges[key]) {
from = ranges[key].from;
to = ranges[key].to;
@@ -1893,27 +1968,33 @@ Licensed under the MIT license.
yrange = extractRange(m, "y");
// fill in missing
- if (xrange.from == null)
+ if (xrange.from == null) {
xrange.from = xrange.axis.min;
- if (xrange.to == null)
+ }
+ if (xrange.to == null) {
xrange.to = xrange.axis.max;
- if (yrange.from == null)
+ }
+ if (yrange.from == null) {
yrange.from = yrange.axis.min;
- if (yrange.to == null)
+ }
+ if (yrange.to == null) {
yrange.to = yrange.axis.max;
+ }
// clip
if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
- yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
+ yrange.to < yrange.axis.min || yrange.from > yrange.axis.max) {
continue;
+ }
xrange.from = Math.max(xrange.from, xrange.axis.min);
xrange.to = Math.min(xrange.to, xrange.axis.max);
yrange.from = Math.max(yrange.from, yrange.axis.min);
yrange.to = Math.min(yrange.to, yrange.axis.max);
- if (xrange.from == xrange.to && yrange.from == yrange.to)
+ if (xrange.from == xrange.to && yrange.from == yrange.to) {
continue;
+ }
// then draw
xrange.from = xrange.axis.p2c(xrange.from);
@@ -1929,8 +2010,7 @@ Licensed under the MIT license.
ctx.moveTo(xrange.from, yrange.from);
ctx.lineTo(xrange.to, yrange.to);
ctx.stroke();
- }
- else {
+ } else {
// fill area
ctx.fillStyle = m.color || options.grid.markingsColor;
ctx.fillRect(xrange.from, yrange.to,
@@ -1947,25 +2027,27 @@ Licensed under the MIT license.
for (var j = 0; j < axes.length; ++j) {
var axis = axes[j], box = axis.box,
t = axis.tickLength, x, y, xoff, yoff;
- if (!axis.show || axis.ticks.length == 0)
+ if (!axis.show || axis.ticks.length == 0) {
continue;
+ }
ctx.lineWidth = 1;
// find the edges
if (axis.direction == "x") {
x = 0;
- if (t == "full")
+ if (t == "full") {
y = (axis.position == "top" ? 0 : plotHeight);
- else
+ } else {
y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0);
- }
- else {
+ }
+ } else {
y = 0;
- if (t == "full")
+ if (t == "full") {
x = (axis.position == "left" ? 0 : plotWidth);
- else
+ } else {
x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0);
+ }
}
// draw tick bar
@@ -1973,10 +2055,11 @@ Licensed under the MIT license.
ctx.strokeStyle = axis.options.color;
ctx.beginPath();
xoff = yoff = 0;
- if (axis.direction == "x")
+ if (axis.direction == "x") {
xoff = plotWidth + 1;
- else
+ } else {
yoff = plotHeight + 1;
+ }
if (ctx.lineWidth == 1) {
if (axis.direction == "x") {
@@ -2005,29 +2088,32 @@ Licensed under the MIT license.
// skip those lying on the axes if we got a border
|| (t == "full"
&& ((typeof bw == "object" && bw[axis.position] > 0) || bw > 0)
- && (v == axis.min || v == axis.max)))
+ && (v == axis.min || v == axis.max))) {
continue;
+ }
if (axis.direction == "x") {
x = axis.p2c(v);
yoff = t == "full" ? -plotHeight : t;
- if (axis.position == "top")
+ if (axis.position == "top") {
yoff = -yoff;
- }
- else {
+ }
+ } else {
y = axis.p2c(v);
xoff = t == "full" ? -plotWidth : t;
- if (axis.position == "left")
+ if (axis.position == "left") {
xoff = -xoff;
+ }
}
if (ctx.lineWidth == 1) {
- if (axis.direction == "x")
+ if (axis.direction == "x") {
x = Math.floor(x) + 0.5;
- else
+ } else {
y = Math.floor(y) + 0.5;
+ }
}
ctx.moveTo(x, y);
@@ -2086,8 +2172,7 @@ Licensed under the MIT license.
ctx.lineTo(0- bw.left/2, 0);
ctx.stroke();
}
- }
- else {
+ } else {
ctx.lineWidth = bw;
ctx.strokeStyle = options.grid.borderColor;
ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw);
@@ -2100,8 +2185,9 @@ Licensed under the MIT license.
function drawAxisLabels() {
$.each(allAxes(), function (_, axis) {
- if (!axis.show || axis.ticks.length == 0)
+ if (!axis.show || axis.ticks.length == 0) {
return;
+ }
var box = axis.box,
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
@@ -2114,8 +2200,9 @@ Licensed under the MIT license.
for (var i = 0; i < axis.ticks.length; ++i) {
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) {
continue;
+ }
if (axis.direction == "x") {
halign = "center";
@@ -2143,12 +2230,15 @@ Licensed under the MIT license.
}
function drawSeries(series) {
- if (series.lines.show)
+ if (series.lines.show) {
drawSeriesLines(series);
- if (series.bars.show)
+ }
+ if (series.bars.show) {
drawSeriesBars(series);
- if (series.points.show)
+ }
+ if (series.points.show) {
drawSeriesPoints(series);
+ }
}
function drawSeriesLines(series) {
@@ -2162,68 +2252,74 @@ Licensed under the MIT license.
var x1 = points[i - ps], y1 = points[i - ps + 1],
x2 = points[i], y2 = points[i + 1];
- if (x1 == null || x2 == null)
+ if (x1 == null || x2 == null) {
continue;
+ }
// clip with ymin
if (y1 <= y2 && y1 < axisy.min) {
- if (y2 < axisy.min)
+ if (y2 < axisy.min) {
continue; // line segment is outside
+ }
// compute new intersection point
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
y1 = axisy.min;
- }
- else if (y2 <= y1 && y2 < axisy.min) {
- if (y1 < axisy.min)
+ } else if (y2 <= y1 && y2 < axisy.min) {
+ if (y1 < axisy.min) {
continue;
+ }
x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
y2 = axisy.min;
}
// clip with ymax
if (y1 >= y2 && y1 > axisy.max) {
- if (y2 > axisy.max)
+ if (y2 > axisy.max) {
continue;
+ }
x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
y1 = axisy.max;
- }
- else if (y2 >= y1 && y2 > axisy.max) {
- if (y1 > axisy.max)
+ } else if (y2 >= y1 && y2 > axisy.max) {
+ if (y1 > axisy.max) {
continue;
+ }
x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
y2 = axisy.max;
}
// clip with xmin
if (x1 <= x2 && x1 < axisx.min) {
- if (x2 < axisx.min)
+ if (x2 < axisx.min) {
continue;
+ }
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.min;
- }
- else if (x2 <= x1 && x2 < axisx.min) {
- if (x1 < axisx.min)
+ } else if (x2 <= x1 && x2 < axisx.min) {
+ if (x1 < axisx.min) {
continue;
+ }
y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
x2 = axisx.min;
}
// clip with xmax
if (x1 >= x2 && x1 > axisx.max) {
- if (x2 > axisx.max)
+ if (x2 > axisx.max) {
continue;
+ }
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.max;
- }
- else if (x2 >= x1 && x2 > axisx.max) {
- if (x1 > axisx.max)
+ } else if (x2 >= x1 && x2 > axisx.max) {
+ if (x1 > axisx.max) {
continue;
+ }
y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
x2 = axisx.max;
}
- if (x1 != prevx || y1 != prevy)
+ if (x1 != prevx || y1 != prevy) {
ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
+ }
prevx = x2;
prevy = y2;
@@ -2243,8 +2339,9 @@ Licensed under the MIT license.
// direction to sketch out top, then once we hit the
// end we go backwards to sketch the bottom
while (true) {
- if (ps > 0 && i > points.length + ps)
+ if (ps > 0 && i > points.length + ps) {
break;
+ }
i += ps; // ps is negative if going backwards
@@ -2272,35 +2369,40 @@ Licensed under the MIT license.
}
}
- if (x1 == null || x2 == null)
+ if (x1 == null || x2 == null) {
continue;
+ }
// clip x values
// clip with xmin
if (x1 <= x2 && x1 < axisx.min) {
- if (x2 < axisx.min)
+ if (x2 < axisx.min) {
continue;
+ }
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.min;
}
else if (x2 <= x1 && x2 < axisx.min) {
- if (x1 < axisx.min)
+ if (x1 < axisx.min) {
continue;
+ }
y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
x2 = axisx.min;
}
// clip with xmax
if (x1 >= x2 && x1 > axisx.max) {
- if (x2 > axisx.max)
+ if (x2 > axisx.max) {
continue;
+ }
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
x1 = axisx.max;
}
else if (x2 >= x1 && x2 > axisx.max) {
- if (x1 > axisx.max)
+ if (x1 > axisx.max) {
continue;
+ }
y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
x2 = axisx.max;
}
@@ -2317,8 +2419,7 @@ Licensed under the MIT license.
ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
continue;
- }
- else if (y1 <= axisy.min && y2 <= axisy.min) {
+ } else if (y1 <= axisy.min && y2 <= axisy.min) {
ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
continue;
@@ -2337,8 +2438,7 @@ Licensed under the MIT license.
if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
y1 = axisy.min;
- }
- else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
+ } else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
y2 = axisy.min;
}
@@ -2347,8 +2447,7 @@ Licensed under the MIT license.
if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
y1 = axisy.max;
- }
- else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
+ } else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
y2 = axisy.max;
}
@@ -2400,8 +2499,9 @@ Licensed under the MIT license.
plotLineArea(series.datapoints, series.xaxis, series.yaxis);
}
- if (lw > 0)
+ if (lw > 0) {
plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis);
+ }
ctx.restore();
}
@@ -2411,16 +2511,18 @@ Licensed under the MIT license.
for (var i = 0; i < points.length; i += ps) {
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;
+ }
ctx.beginPath();
x = axisx.p2c(x);
y = axisy.p2c(y) + offset;
- if (symbol == "circle")
+ if (symbol == "circle") {
ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false);
- else
+ } else {
symbol(ctx, x, y, radius, shadow);
+ }
ctx.closePath();
if (fillStyle) {
@@ -2444,8 +2546,9 @@ 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) {
// draw shadow in two steps
@@ -2492,8 +2595,7 @@ Licensed under the MIT license.
drawLeft = true;
drawRight = false;
}
- }
- else {
+ } else {
drawLeft = drawRight = drawTop = true;
drawBottom = false;
left = x + barLeft;
@@ -2513,8 +2615,9 @@ Licensed under the MIT license.
// clip
if (right < axisx.min || left > axisx.max ||
- top < axisy.min || bottom > axisy.max)
+ top < axisy.min || bottom > axisy.max) {
return;
+ }
if (left < axisx.min) {
left = axisx.min;
@@ -2558,22 +2661,26 @@ Licensed under the MIT license.
// FIXME: inline moveTo is buggy with excanvas
c.moveTo(left, bottom + offset);
- if (drawLeft)
+ if (drawLeft) {
c.lineTo(left, top + offset);
- else
+ } else {
c.moveTo(left, top + offset);
- if (drawTop)
+ }
+ if (drawTop) {
c.lineTo(right, top + offset);
- else
+ } else {
c.moveTo(right, top + offset);
- if (drawRight)
+ }
+ if (drawRight) {
c.lineTo(right, bottom + offset);
- else
+ } else {
c.moveTo(right, bottom + offset);
- if (drawBottom)
+ }
+ if (drawBottom) {
c.lineTo(left, bottom + offset);
- else
+ } else {
c.moveTo(left, bottom + offset);
+ }
c.stroke();
}
}
@@ -2583,8 +2690,9 @@ Licensed under the MIT license.
var points = datapoints.points, ps = datapoints.pointsize;
for (var i = 0; i < points.length; i += ps) {
- if (points[i] == null)
+ if (points[i] == null) {
continue;
+ }
drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
}
}
@@ -2619,11 +2727,13 @@ Licensed under the MIT license.
function getFillStyle(filloptions, seriesColor, bottom, top) {
var fill = filloptions.fill;
- if (!fill)
+ if (!fill) {
return null;
+ }
- if (filloptions.fillColor)
+ if (filloptions.fillColor) {
return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
+ }
var c = $.color.parse(seriesColor);
c.a = typeof fill == "number" ? fill : 0.4;
@@ -2635,8 +2745,9 @@ Licensed under the MIT license.
placeholder.find(".legend").remove();
- if (!options.legend.show)
+ if (!options.legend.show) {
return;
+ }
var fragments = [], entries = [], rowStarted = false,
lf = options.legend.labelFormatter, s, label;
@@ -2680,8 +2791,9 @@ Licensed under the MIT license.
var entry = entries[i];
if (i % options.legend.noColumns == 0) {
- if (rowStarted)
+ if (rowStarted) {
fragments.push("");
+ }
fragments.push("