Skip to content

Commit

Permalink
fix(color): Correct to not set stroke
Browse files Browse the repository at this point in the history
Remove setting stroke value on  onover/onout interaction.

Ref #754
Ref #872
  • Loading branch information
netil authored Aug 7, 2019
1 parent 9beacfe commit f18aa35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
16 changes: 15 additions & 1 deletion spec/internals/color-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ describe("COLOR", () => {
});

describe("color.onover", () => {
const barStrokeColor = "blue";

before(() => {
args = {
data: {
Expand All @@ -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)
}
}
});
Expand All @@ -257,7 +265,8 @@ describe("COLOR", () => {

shape.each(function() {
originalColor.push({
fill: this.style.fill
fill: this.style.fill,
stroke: this.style.stroke
});
});

Expand All @@ -273,13 +282,18 @@ 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
util.fireEvent(eventRect, "mouseout");

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);
});
};

Expand Down
13 changes: 2 additions & 11 deletions src/internals/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
}
});

0 comments on commit f18aa35

Please sign in to comment.