Commit 2ce1139c authored by David Schnur's avatar David Schnur

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.
parent d94c1b75
...@@ -2801,7 +2801,21 @@ Licensed under the MIT license. ...@@ -2801,7 +2801,21 @@ Licensed under the MIT license.
} }
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,
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; barRight = barLeft + s.bars.barWidth;
for (j = 0; j < points.length; j += ps) { for (j = 0; j < points.length; j += ps) {
...@@ -3000,7 +3014,21 @@ Licensed under the MIT license. ...@@ -3000,7 +3014,21 @@ Licensed under the MIT license.
function drawBarHighlight(series, point) { function drawBarHighlight(series, point) {
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;
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.lineWidth = series.bars.lineWidth;
octx.strokeStyle = highlightColor; octx.strokeStyle = highlightColor;
......
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