Fix highlights for right-aligned bars.

Support for right-aligned bars was never added to the hover or highlight
code; only the actual bar drawing. We need to replicate that in the
other two places as well.

Resolves #1093.
master
David Schnur 13 years ago
parent d94c1b75bc
commit 2ce1139cf7

@ -2801,8 +2801,22 @@ 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;
switch (s.bars.align) {
case "left":
barLeft = 0;
break;
case "right":
barLeft = -s.bars.barWidth;
break;
case "center":
barLeft = -s.bars.barWidth / 2;
break;
default:
throw new Error("Invalid bar alignment: " + s.bars.align);
}
barRight = barLeft + s.bars.barWidth;
for (j = 0; j < points.length; j += ps) {
var x = points[j], y = points[j + 1], b = points[j + 2];
@ -3000,7 +3014,21 @@ 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;
case "center":
barLeft = -series.bars.barWidth / 2;
break;
default:
throw new Error("Invalid bar alignment: " + series.bars.align);
}
octx.lineWidth = series.bars.lineWidth;
octx.strokeStyle = highlightColor;

Loading…
Cancel
Save