|
|
|
|
@ -775,6 +775,23 @@ Licensed under the MIT license.
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
plot.shutdown = shutdown;
|
|
|
|
|
plot.destroy = function () {
|
|
|
|
|
shutdown();
|
|
|
|
|
placeholder.removeData("plot").empty();
|
|
|
|
|
|
|
|
|
|
series = [];
|
|
|
|
|
options = null;
|
|
|
|
|
surface = null;
|
|
|
|
|
overlay = null;
|
|
|
|
|
eventHolder = null;
|
|
|
|
|
ctx = null;
|
|
|
|
|
octx = null;
|
|
|
|
|
xaxes = [];
|
|
|
|
|
yaxes = [];
|
|
|
|
|
hooks = null;
|
|
|
|
|
highlights = [];
|
|
|
|
|
plot = null;
|
|
|
|
|
};
|
|
|
|
|
plot.resize = function (width, height) {
|
|
|
|
|
width = width || placeholder.width();
|
|
|
|
|
height = height || placeholder.height();
|
|
|
|
|
@ -860,17 +877,17 @@ Licensed under the MIT license.
|
|
|
|
|
// since the rest of the code assumes that they exist.
|
|
|
|
|
|
|
|
|
|
var i, axisOptions, axisCount,
|
|
|
|
|
fontSize = placeholder.css("font-size"),
|
|
|
|
|
fontSizeDefault = fontSize ? +fontSize.replace("px", "") : 13,
|
|
|
|
|
fontDefaults = {
|
|
|
|
|
style: placeholder.css("font-style"),
|
|
|
|
|
size: Math.round(0.8 * (+placeholder.css("font-size").replace("px", "") || 13)),
|
|
|
|
|
size: Math.round(0.8 * fontSizeDefault),
|
|
|
|
|
variant: placeholder.css("font-variant"),
|
|
|
|
|
weight: placeholder.css("font-weight"),
|
|
|
|
|
family: placeholder.css("font-family")
|
|
|
|
|
},
|
|
|
|
|
markings;
|
|
|
|
|
|
|
|
|
|
fontDefaults.lineHeight = fontDefaults.size * 1.15;
|
|
|
|
|
|
|
|
|
|
axisCount = options.xaxes.length || 1;
|
|
|
|
|
for (i = 0; i < axisCount; ++i) {
|
|
|
|
|
|
|
|
|
|
@ -893,15 +910,34 @@ Licensed under the MIT license.
|
|
|
|
|
axisOptions = $.extend(true, {}, options.xaxis, axisOptions);
|
|
|
|
|
options.xaxes[i] = axisOptions;
|
|
|
|
|
|
|
|
|
|
fontDefaults.color = axisOptions.color;
|
|
|
|
|
if (axisOptions.font) {
|
|
|
|
|
axisOptions.font = $.extend({}, fontDefaults, axisOptions.font);
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.tickFont || axisOptions.font) {
|
|
|
|
|
axisOptions.tickFont = $.extend({}, axisOptions.font || fontDefaults, axisOptions.tickFont);
|
|
|
|
|
if (!axisOptions.tickFont.color) {
|
|
|
|
|
axisOptions.tickFont.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.tickFont.lineHeight) {
|
|
|
|
|
axisOptions.tickFont.lineHeight = Math.round(axisOptions.tickFont.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.label && (axisOptions.labelFont || axisOptions.font)) {
|
|
|
|
|
axisOptions.labelFont = $.extend({}, axisOptions.font || fontDefaults, axisOptions.labelFont);
|
|
|
|
|
if (!axisOptions.labelFont.color) {
|
|
|
|
|
axisOptions.labelFont.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.labelFont.lineHeight) {
|
|
|
|
|
axisOptions.labelFont.lineHeight = Math.round(axisOptions.labelFont.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.font) {
|
|
|
|
|
if (!axisOptions.font.color) {
|
|
|
|
|
axisOptions.font.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.font.lineHeight) {
|
|
|
|
|
axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -927,15 +963,34 @@ Licensed under the MIT license.
|
|
|
|
|
axisOptions = $.extend(true, {}, options.yaxis, axisOptions);
|
|
|
|
|
options.yaxes[i] = axisOptions;
|
|
|
|
|
|
|
|
|
|
fontDefaults.color = axisOptions.color;
|
|
|
|
|
if (axisOptions.font) {
|
|
|
|
|
axisOptions.font = $.extend({}, fontDefaults, axisOptions.font);
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.tickFont || axisOptions.font) {
|
|
|
|
|
axisOptions.tickFont = $.extend({}, axisOptions.font || fontDefaults, axisOptions.tickFont);
|
|
|
|
|
if (!axisOptions.tickFont.color) {
|
|
|
|
|
axisOptions.tickFont.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.tickFont.lineHeight) {
|
|
|
|
|
axisOptions.tickFont.lineHeight = Math.round(axisOptions.tickFont.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.label && (axisOptions.labelFont || axisOptions.font)) {
|
|
|
|
|
axisOptions.labelFont = $.extend({}, axisOptions.font || fontDefaults, axisOptions.labelFont);
|
|
|
|
|
if (!axisOptions.labelFont.color) {
|
|
|
|
|
axisOptions.labelFont.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.labelFont.lineHeight) {
|
|
|
|
|
axisOptions.labelFont.lineHeight = Math.round(axisOptions.labelFont.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (axisOptions.font) {
|
|
|
|
|
if (!axisOptions.font.color) {
|
|
|
|
|
axisOptions.font.color = axisOptions.color;
|
|
|
|
|
}
|
|
|
|
|
if (!axisOptions.font.lineHeight) {
|
|
|
|
|
axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1327,7 +1382,7 @@ Licensed under the MIT license.
|
|
|
|
|
if (val != null) {
|
|
|
|
|
f = format[m];
|
|
|
|
|
// extract min/max info
|
|
|
|
|
if (f.autoscale) {
|
|
|
|
|
if (f.autoscale !== false) {
|
|
|
|
|
if (f.x) {
|
|
|
|
|
updateAxis(s.xaxis, val, val);
|
|
|
|
|
}
|
|
|
|
|
@ -1401,11 +1456,8 @@ Licensed under the MIT license.
|
|
|
|
|
case "right":
|
|
|
|
|
delta = -s.bars.barWidth;
|
|
|
|
|
break;
|
|
|
|
|
case "center":
|
|
|
|
|
delta = -s.bars.barWidth / 2;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new Error("Invalid bar alignment: " + s.bars.align);
|
|
|
|
|
delta = -s.bars.barWidth / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s.bars.horizontal) {
|
|
|
|
|
@ -1437,7 +1489,9 @@ Licensed under the MIT license.
|
|
|
|
|
// from a previous plot in this container that we'll try to re-use.
|
|
|
|
|
|
|
|
|
|
placeholder.css("padding", 0) // padding messes up the positioning
|
|
|
|
|
.children(":not(.flot-base,.flot-overlay)").remove();
|
|
|
|
|
.children().filter(function(){
|
|
|
|
|
return !$(this).hasClass("flot-overlay") && !$(this).hasClass('flot-base');
|
|
|
|
|
}).remove();
|
|
|
|
|
|
|
|
|
|
if (placeholder.css("position") === "static") {
|
|
|
|
|
placeholder.css("position", "relative"); // for positioning labels and overlay
|
|
|
|
|
@ -1540,7 +1594,8 @@ Licensed under the MIT license.
|
|
|
|
|
tickWidth = opts.tickWidth || opts.labelWidth || 0,
|
|
|
|
|
tickHeight = opts.tickHeight || opts.labelHeight || 0,
|
|
|
|
|
maxWidth = tickWidth || axis.direction === "x" ? Math.floor(surface.width / (ticks.length || 1)) : null,
|
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
|
|
|
|
|
font = opts.tickFont || "flot-tick-label tickLabel";
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < ticks.length; ++i) {
|
|
|
|
|
@ -1582,30 +1637,41 @@ Licensed under the MIT license.
|
|
|
|
|
axisPosition = axisOptions.position,
|
|
|
|
|
axisMargin = options.grid.axisMargin,
|
|
|
|
|
padding = options.grid.labelMargin,
|
|
|
|
|
all = axis.direction === "x" ? xaxes : yaxes,
|
|
|
|
|
innermost;
|
|
|
|
|
|
|
|
|
|
// Determine the margin around the axis
|
|
|
|
|
|
|
|
|
|
var samePosition = $.grep(all, function(axis) {
|
|
|
|
|
return axis && axis.options.position === axisPosition && axis.reserveSpace;
|
|
|
|
|
isXAxis = axis.direction === "x",
|
|
|
|
|
innermost = true,
|
|
|
|
|
outermost = true,
|
|
|
|
|
first = true,
|
|
|
|
|
found = false;
|
|
|
|
|
|
|
|
|
|
// Determine the axis's position in its direction and on its side
|
|
|
|
|
|
|
|
|
|
$.each(isXAxis ? xaxes : yaxes, function(i, a) {
|
|
|
|
|
if (a && a.reserveSpace) {
|
|
|
|
|
if (a === axis) {
|
|
|
|
|
found = true;
|
|
|
|
|
} else if (a.options.position === axisPosition) {
|
|
|
|
|
if (found) {
|
|
|
|
|
outermost = false;
|
|
|
|
|
} else {
|
|
|
|
|
innermost = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if ($.inArray(axis, samePosition) === samePosition.length - 1) {
|
|
|
|
|
axisMargin = 0; // outermost
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine whether the axis is the first (innermost) on its side
|
|
|
|
|
// The outermost axis on each side has no margin
|
|
|
|
|
|
|
|
|
|
innermost = $.inArray(axis, samePosition) === 0;
|
|
|
|
|
if (outermost) {
|
|
|
|
|
axisMargin = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine the length of the tick marks
|
|
|
|
|
// The ticks for the first axis in each direction stretch across
|
|
|
|
|
|
|
|
|
|
if (tickLength == null) {
|
|
|
|
|
if (innermost) {
|
|
|
|
|
tickLength = "full";
|
|
|
|
|
} else {
|
|
|
|
|
tickLength = 5;
|
|
|
|
|
}
|
|
|
|
|
tickLength = first ? "full" : 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isNaN(+tickLength)) {
|
|
|
|
|
@ -1615,9 +1681,10 @@ Licensed under the MIT license.
|
|
|
|
|
// Measure the dimensions of the axis label, if it has one
|
|
|
|
|
|
|
|
|
|
if (axisOptions.label) {
|
|
|
|
|
var layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
var legacyStyles = "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + axis.direction + legacyStyles,
|
|
|
|
|
font = axisOptions.labelFont || "flot-axis-label axisLabels " + axis.direction + axis.n + "axisLabel",
|
|
|
|
|
angle = axis.direction === "x" ? 0 : axisOptions.position === "right" ? 90 : -90,
|
|
|
|
|
angle = isXAxis ? 0 : axisOptions.position === "right" ? 90 : -90,
|
|
|
|
|
labelInfo = surface.getTextInfo(layer, axisOptions.label, font, angle);
|
|
|
|
|
contentWidth += labelInfo.width + axisOptions.labelPadding;
|
|
|
|
|
contentHeight += labelInfo.height + axisOptions.labelPadding;
|
|
|
|
|
@ -1625,7 +1692,7 @@ Licensed under the MIT license.
|
|
|
|
|
|
|
|
|
|
// Compute the axis bounding box and update the plot bounds
|
|
|
|
|
|
|
|
|
|
if (axis.direction === "x") {
|
|
|
|
|
if (isXAxis) {
|
|
|
|
|
contentHeight += padding;
|
|
|
|
|
if (axisPosition === "top") {
|
|
|
|
|
axis.box = { top: plotOffset.top + axisMargin, height: contentHeight };
|
|
|
|
|
@ -1667,35 +1734,49 @@ Licensed under the MIT license.
|
|
|
|
|
// possibly adjust plot offset to ensure everything stays
|
|
|
|
|
// inside the canvas and isn't clipped off
|
|
|
|
|
|
|
|
|
|
var minMargin = options.grid.minBorderMargin,
|
|
|
|
|
margins = { x: 0, y: 0 }, i;
|
|
|
|
|
var minMargin = options.grid.minBorderMargin;
|
|
|
|
|
|
|
|
|
|
// check stuff from the plot (FIXME: this should just read
|
|
|
|
|
// a value from the series, otherwise it's impossible to
|
|
|
|
|
// customize)
|
|
|
|
|
if (minMargin == null) {
|
|
|
|
|
minMargin = 0;
|
|
|
|
|
for (i = 0; i < series.length; ++i) {
|
|
|
|
|
for (var 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);
|
|
|
|
|
var margins = {
|
|
|
|
|
left: minMargin,
|
|
|
|
|
right: minMargin,
|
|
|
|
|
top: minMargin,
|
|
|
|
|
bottom: minMargin
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// check axis labels, note we don't check the actual
|
|
|
|
|
// labels but instead use the overall width/height to not
|
|
|
|
|
// jump as much around with replots
|
|
|
|
|
$.each(allAxes(), function (_, axis) {
|
|
|
|
|
var dir = axis.direction;
|
|
|
|
|
if (axis.reserveSpace) {
|
|
|
|
|
margins[dir] = Math.ceil(Math.max(margins[dir], (dir === "x" ? axis.tickWidth : axis.tickHeight) / 2));
|
|
|
|
|
if (axis.reserveSpace && axis.ticks && axis.ticks.length) {
|
|
|
|
|
var lastTick = axis.ticks[axis.ticks.length - 1];
|
|
|
|
|
if (axis.direction === "x") {
|
|
|
|
|
margins.left = Math.max(margins.left, axis.tickWidth / 2);
|
|
|
|
|
if (lastTick.v <= axis.max) {
|
|
|
|
|
margins.right = Math.max(margins.right, axis.tickWidth / 2);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
margins.bottom = Math.max(margins.bottom, axis.tickHeight / 2);
|
|
|
|
|
if (lastTick.v <= axis.max) {
|
|
|
|
|
margins.top = Math.max(margins.top, axis.tickHeight / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
plotOffset.left = Math.max(margins.x, plotOffset.left);
|
|
|
|
|
plotOffset.right = Math.max(margins.x, plotOffset.right);
|
|
|
|
|
plotOffset.top = Math.max(margins.y, plotOffset.top);
|
|
|
|
|
plotOffset.bottom = Math.max(margins.y, plotOffset.bottom);
|
|
|
|
|
plotOffset.left = Math.ceil(Math.max(margins.left, plotOffset.left));
|
|
|
|
|
plotOffset.right = Math.ceil(Math.max(margins.right, plotOffset.right));
|
|
|
|
|
plotOffset.top = Math.ceil(Math.max(margins.top, plotOffset.top));
|
|
|
|
|
plotOffset.bottom = Math.ceil(Math.max(margins.bottom, plotOffset.bottom));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupGrid() {
|
|
|
|
|
@ -2403,19 +2484,25 @@ Licensed under the MIT license.
|
|
|
|
|
function drawAxisLabels() {
|
|
|
|
|
|
|
|
|
|
$.each(allAxes(), function (_, axis) {
|
|
|
|
|
if (!axis.show || axis.ticks.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var box = axis.box,
|
|
|
|
|
axisOptions = axis.options,
|
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
|
|
|
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
|
|
|
|
|
labelFont = axisOptions.labelFont || "flot-axis-label axisLabels " + axis.direction + axis.n + "axisLabel",
|
|
|
|
|
tickFont = axisOptions.tickFont || "flot-tick-label tickLabel",
|
|
|
|
|
tick, x, y, halign, valign;
|
|
|
|
|
|
|
|
|
|
// Remove text before checking for axis.show and ticks.length;
|
|
|
|
|
// otherwise plugins, like flot-tickrotor, that draw their own
|
|
|
|
|
// tick labels will end up with both theirs and the defaults.
|
|
|
|
|
|
|
|
|
|
surface.removeText(layer);
|
|
|
|
|
|
|
|
|
|
if (!axis.show || axis.ticks.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (axisOptions.label) {
|
|
|
|
|
if (axis.direction === "x") {
|
|
|
|
|
if (axisOptions.position === "top") {
|
|
|
|
|
@ -2824,7 +2911,7 @@ Licensed under the MIT license.
|
|
|
|
|
ctx.restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
|
|
|
|
|
function drawBar(x, y, b, barLeft, barRight, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
|
|
|
|
|
var left, right, bottom, top,
|
|
|
|
|
drawLeft, drawRight, drawTop, drawBottom,
|
|
|
|
|
tmp;
|
|
|
|
|
@ -2899,13 +2986,8 @@ Licensed under the MIT license.
|
|
|
|
|
|
|
|
|
|
// fill the bar
|
|
|
|
|
if (fillStyleCallback) {
|
|
|
|
|
c.beginPath();
|
|
|
|
|
c.moveTo(left, bottom);
|
|
|
|
|
c.lineTo(left, top);
|
|
|
|
|
c.lineTo(right, top);
|
|
|
|
|
c.lineTo(right, bottom);
|
|
|
|
|
c.fillStyle = fillStyleCallback(bottom, top);
|
|
|
|
|
c.fill();
|
|
|
|
|
c.fillRect(left, top, right - left, bottom - top)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// draw outline
|
|
|
|
|
@ -2913,40 +2995,36 @@ Licensed under the MIT license.
|
|
|
|
|
c.beginPath();
|
|
|
|
|
|
|
|
|
|
// FIXME: inline moveTo is buggy with excanvas
|
|
|
|
|
c.moveTo(left, bottom + offset);
|
|
|
|
|
if (drawLeft) {
|
|
|
|
|
c.lineTo(left, top + offset);
|
|
|
|
|
} else {
|
|
|
|
|
c.moveTo(left, top + offset);
|
|
|
|
|
}
|
|
|
|
|
if (drawTop) {
|
|
|
|
|
c.lineTo(right, top + offset);
|
|
|
|
|
} else {
|
|
|
|
|
c.moveTo(right, top + offset);
|
|
|
|
|
}
|
|
|
|
|
if (drawRight) {
|
|
|
|
|
c.lineTo(right, bottom + offset);
|
|
|
|
|
} else {
|
|
|
|
|
c.moveTo(right, bottom + offset);
|
|
|
|
|
}
|
|
|
|
|
if (drawBottom) {
|
|
|
|
|
c.lineTo(left, bottom + offset);
|
|
|
|
|
} else {
|
|
|
|
|
c.moveTo(left, bottom + offset);
|
|
|
|
|
}
|
|
|
|
|
c.moveTo(left, bottom);
|
|
|
|
|
if (drawLeft)
|
|
|
|
|
c.lineTo(left, top);
|
|
|
|
|
else
|
|
|
|
|
c.moveTo(left, top);
|
|
|
|
|
if (drawTop)
|
|
|
|
|
c.lineTo(right, top);
|
|
|
|
|
else
|
|
|
|
|
c.moveTo(right, top);
|
|
|
|
|
if (drawRight)
|
|
|
|
|
c.lineTo(right, bottom);
|
|
|
|
|
else
|
|
|
|
|
c.moveTo(right, bottom);
|
|
|
|
|
if (drawBottom)
|
|
|
|
|
c.lineTo(left, bottom);
|
|
|
|
|
else
|
|
|
|
|
c.moveTo(left, bottom);
|
|
|
|
|
c.stroke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function drawSeriesBars(series) {
|
|
|
|
|
function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
|
|
|
|
|
function plotBars(datapoints, barLeft, barRight, fillStyleCallback, axisx, axisy) {
|
|
|
|
|
var points = datapoints.points, ps = datapoints.pointsize;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < points.length; i += ps) {
|
|
|
|
|
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);
|
|
|
|
|
drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2966,15 +3044,12 @@ Licensed under the MIT license.
|
|
|
|
|
case "right":
|
|
|
|
|
barLeft = -series.bars.barWidth;
|
|
|
|
|
break;
|
|
|
|
|
case "center":
|
|
|
|
|
barLeft = -series.bars.barWidth / 2;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new Error("Invalid bar alignment: " + series.bars.align);
|
|
|
|
|
barLeft = -series.bars.barWidth / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
|
|
|
|
|
plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
|
|
|
|
|
plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis);
|
|
|
|
|
ctx.restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2996,7 +3071,11 @@ Licensed under the MIT license.
|
|
|
|
|
|
|
|
|
|
function insertLegend() {
|
|
|
|
|
|
|
|
|
|
placeholder.find(".legend").remove();
|
|
|
|
|
if (options.legend.container != null) {
|
|
|
|
|
$(options.legend.container).html("");
|
|
|
|
|
} else {
|
|
|
|
|
placeholder.find(".legend").remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!options.legend.show) {
|
|
|
|
|
return;
|
|
|
|
|
@ -3198,8 +3277,21 @@ Licensed under the MIT license.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s.bars.show && !item) { // no other point can be nearby
|
|
|
|
|
var barLeft = s.bars.align === "left" ? 0 : -s.bars.barWidth/2,
|
|
|
|
|
barRight = barLeft + s.bars.barWidth;
|
|
|
|
|
|
|
|
|
|
var barLeft, barRight;
|
|
|
|
|
|
|
|
|
|
switch (s.bars.align) {
|
|
|
|
|
case "left":
|
|
|
|
|
barLeft = 0;
|
|
|
|
|
break;
|
|
|
|
|
case "right":
|
|
|
|
|
barLeft = -s.bars.barWidth;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
barLeft = -s.bars.barWidth / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
barRight = barLeft + s.bars.barWidth;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < points.length; j += ps) {
|
|
|
|
|
x = points[j];
|
|
|
|
|
@ -3417,13 +3509,24 @@ Licensed under the MIT license.
|
|
|
|
|
function drawBarHighlight(series, point) {
|
|
|
|
|
var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale("a", 0.5).toString(),
|
|
|
|
|
fillStyle = highlightColor,
|
|
|
|
|
barLeft = series.bars.align === "left" ? 0 : -series.bars.barWidth/2;
|
|
|
|
|
barLeft;
|
|
|
|
|
|
|
|
|
|
switch (series.bars.align) {
|
|
|
|
|
case "left":
|
|
|
|
|
barLeft = 0;
|
|
|
|
|
break;
|
|
|
|
|
case "right":
|
|
|
|
|
barLeft = -series.bars.barWidth;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
barLeft = -series.bars.barWidth / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
octx.lineWidth = series.bars.lineWidth;
|
|
|
|
|
octx.strokeStyle = highlightColor;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getColorOrGradient(spec, bottom, top, defaultColor) {
|
|
|
|
|
|