|
|
|
@ -73,7 +73,8 @@
|
|
|
|
barWidth: 1, // in units of the x axis
|
|
|
|
barWidth: 1, // in units of the x axis
|
|
|
|
fill: true,
|
|
|
|
fill: true,
|
|
|
|
fillColor: null,
|
|
|
|
fillColor: null,
|
|
|
|
align: "left" // or "center"
|
|
|
|
align: "left", // or "center"
|
|
|
|
|
|
|
|
horizontal: false // when horizontal, left is now top
|
|
|
|
},
|
|
|
|
},
|
|
|
|
threshold: null, // or { below: number, color: color spec}
|
|
|
|
threshold: null, // or { below: number, color: color spec}
|
|
|
|
grid: {
|
|
|
|
grid: {
|
|
|
|
@ -344,10 +345,16 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (s.bars.show) {
|
|
|
|
if (s.bars.show) {
|
|
|
|
// make sure we got room for the bar
|
|
|
|
// make sure we got room for the bar on the dancing floor
|
|
|
|
var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
|
|
|
|
var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
|
|
|
|
xmin += delta;
|
|
|
|
if(s.bars.horizontal) {
|
|
|
|
xmax += delta + s.bars.barWidth;
|
|
|
|
ymin += delta;
|
|
|
|
|
|
|
|
ymax += delta + s.bars.barWidth;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
xmin += delta;
|
|
|
|
|
|
|
|
xmax += delta + s.bars.barWidth;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
axisx.datamin = Math.min(axisx.datamin, xmin);
|
|
|
|
axisx.datamin = Math.min(axisx.datamin, xmin);
|
|
|
|
@ -1458,20 +1465,43 @@
|
|
|
|
ctx.restore();
|
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function drawBar(x, y, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c) {
|
|
|
|
function drawBar(x, y, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal) {
|
|
|
|
var drawLeft = true, drawRight = true,
|
|
|
|
var left, right, bottom, top,
|
|
|
|
drawTop = true, drawBottom = false,
|
|
|
|
drawLeft, drawRight, drawTop, drawBottom;
|
|
|
|
left = x + barLeft, right = x + barRight,
|
|
|
|
|
|
|
|
bottom = 0, top = y;
|
|
|
|
if (horizontal) {
|
|
|
|
|
|
|
|
drawBottom = drawRight = drawTop = true;
|
|
|
|
// account for negative bars
|
|
|
|
drawLeft = false;
|
|
|
|
if (top < bottom) {
|
|
|
|
left = 0;
|
|
|
|
top = 0;
|
|
|
|
right = x;
|
|
|
|
bottom = y;
|
|
|
|
top = y + barLeft;
|
|
|
|
drawBottom = true;
|
|
|
|
bottom = y + barRight;
|
|
|
|
drawTop = false;
|
|
|
|
|
|
|
|
|
|
|
|
// account for negative bars
|
|
|
|
|
|
|
|
if (right < left) {
|
|
|
|
|
|
|
|
right = 0;
|
|
|
|
|
|
|
|
left = x;
|
|
|
|
|
|
|
|
drawLeft = true;
|
|
|
|
|
|
|
|
drawRight = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
drawLeft = drawRight = drawTop = true;
|
|
|
|
|
|
|
|
drawBottom = false;
|
|
|
|
|
|
|
|
left = x + barLeft;
|
|
|
|
|
|
|
|
right = x + barRight;
|
|
|
|
|
|
|
|
bottom = 0;
|
|
|
|
|
|
|
|
top = y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// account for negative bars
|
|
|
|
|
|
|
|
if (top < bottom) {
|
|
|
|
|
|
|
|
top = 0;
|
|
|
|
|
|
|
|
bottom = y;
|
|
|
|
|
|
|
|
drawBottom = true;
|
|
|
|
|
|
|
|
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)
|
|
|
|
@ -1546,7 +1576,7 @@
|
|
|
|
for (var i = 0; i < points.length; i += incr) {
|
|
|
|
for (var i = 0; i < points.length; i += incr) {
|
|
|
|
if (points[i] == null)
|
|
|
|
if (points[i] == null)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
drawBar(points[i], points[i + 1], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx);
|
|
|
|
drawBar(points[i], points[i + 1], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1714,10 +1744,13 @@
|
|
|
|
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 (mx >= x + barLeft && mx <= x + barRight &&
|
|
|
|
if (series[i].bars.horizontal ?
|
|
|
|
my >= Math.min(0, y) && my <= Math.max(0, y))
|
|
|
|
(mx <= Math.max(0, x) && mx >= Math.min(0, x) &&
|
|
|
|
item = [i, j / incr];
|
|
|
|
my >= y + barLeft && my <= y + barRight) :
|
|
|
|
|
|
|
|
(mx >= x + barLeft && mx <= x + barRight &&
|
|
|
|
|
|
|
|
my >= Math.min(0, y) && my <= Math.max(0, y)))
|
|
|
|
|
|
|
|
item = [i, j / incr];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1988,7 +2021,7 @@
|
|
|
|
var fillStyle = parseColor(series.color).scale(1, 1, 1, 0.5).toString();
|
|
|
|
var fillStyle = parseColor(series.color).scale(1, 1, 1, 0.5).toString();
|
|
|
|
var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
|
|
|
|
var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
|
|
|
|
drawBar(point[0], point[1], barLeft, barLeft + series.bars.barWidth,
|
|
|
|
drawBar(point[0], point[1], barLeft, barLeft + series.bars.barWidth,
|
|
|
|
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx);
|
|
|
|
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setPositionFromEvent(pos, e) {
|
|
|
|
function setPositionFromEvent(pos, e) {
|
|
|
|
|