Commit 90632172 authored by David Schnur's avatar David Schnur

Merge pull request #38 from eriwen/master

Allow custom highlight color
parents cc974bd0 46e1221f
...@@ -115,7 +115,8 @@ ...@@ -115,7 +115,8 @@
align: "left", // "left", "right", or "center" align: "left", // "left", "right", or "center"
horizontal: false horizontal: false
}, },
shadowSize: 3 shadowSize: 3,
highlightColor: null
}, },
grid: { grid: {
show: true, show: true,
...@@ -290,6 +291,8 @@ ...@@ -290,6 +291,8 @@
$.extend(true, options.series.bars, options.bars); $.extend(true, options.series.bars, options.bars);
if (options.shadowSize != null) if (options.shadowSize != null)
options.series.shadowSize = options.shadowSize; options.series.shadowSize = options.shadowSize;
if (options.highlightColor != null)
options.series.highlightColor = options.highlightColor;
// save options on axes for future reference // save options on axes for future reference
for (i = 0; i < options.xaxes.length; ++i) for (i = 0; i < options.xaxes.length; ++i)
...@@ -2441,13 +2444,14 @@ ...@@ -2441,13 +2444,14 @@
function drawPointHighlight(series, point) { function drawPointHighlight(series, point) {
var x = point[0], y = point[1], var x = point[0], y = point[1],
axisx = series.xaxis, axisy = series.yaxis; axisx = series.xaxis, axisy = series.yaxis;
highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString();
if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
return; return;
var pointRadius = series.points.radius + series.points.lineWidth / 2; var pointRadius = series.points.radius + series.points.lineWidth / 2;
octx.lineWidth = pointRadius; octx.lineWidth = pointRadius;
octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); octx.strokeStyle = highlightColor;
var radius = 1.5 * pointRadius, var radius = 1.5 * pointRadius,
x = axisx.p2c(x), x = axisx.p2c(x),
y = axisy.p2c(y); y = axisy.p2c(y);
...@@ -2462,10 +2466,13 @@ ...@@ -2462,10 +2466,13 @@
} }
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(),
fillStyle = highlightColor,
barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
octx.lineWidth = series.bars.lineWidth; octx.lineWidth = series.bars.lineWidth;
octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); octx.strokeStyle = highlightColor;
var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString();
var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, 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); 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
} }
......
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