diff --git a/spec/internals/color-spec.js b/spec/internals/color-spec.js index 3676d9c99..8a596301c 100644 --- a/spec/internals/color-spec.js +++ b/spec/internals/color-spec.js @@ -231,6 +231,8 @@ describe("COLOR", () => { }); describe("color.onover", () => { + const barStrokeColor = "blue"; + before(() => { args = { data: { @@ -244,6 +246,12 @@ describe("COLOR", () => { }, color: { onover: "yellow" + }, + onafterinit: function(ctx) { + // set bar stroke color value manually + ctx.$.bar.bars + .style("stroke", barStrokeColor) + .style("stroke-width", 1) } } }); @@ -257,7 +265,8 @@ describe("COLOR", () => { shape.each(function() { originalColor.push({ - fill: this.style.fill + fill: this.style.fill, + stroke: this.style.stroke }); }); @@ -273,6 +282,10 @@ describe("COLOR", () => { } expect(this.style.fill).to.be.equal(color); + + if (this.tagName === "path") { + expect(this.style.stroke).to.be.equal(barStrokeColor); + } }); // check for restoration @@ -280,6 +293,7 @@ describe("COLOR", () => { shape.each(function(d, i) { expect(this.style.fill).to.be.equal(originalColor[i].fill); + expect(this.style.stroke).to.be.equal(originalColor[i].stroke); }); }; diff --git a/src/internals/color.js b/src/internals/color.js index 8455a852b..60c7a9de8 100644 --- a/src/internals/color.js +++ b/src/internals/color.js @@ -172,11 +172,7 @@ extend(ChartInternal.prototype, { let color = isOver ? onover : $$.color; if (isObject(color)) { - color = d => { - const id = d.id; - - return id in onover ? onover[id] : $$.color(id); - }; + color = ({id}) => (id in onover ? onover[id] : $$.color(id)); } else if (isString(color)) { color = () => onover; } @@ -187,12 +183,7 @@ extend(ChartInternal.prototype, { .style("fill", color(d)); } else { $$.main.selectAll(`.${CLASS.shape}-${d}`) - .each(function(d) { - const val = color(d); - - this.style.stroke = val; - this.style.fill = val; - }); + .style("fill", color); } } });