Skip to content

Commit

Permalink
fix(arc): Fix handling spaced data name
Browse files Browse the repository at this point in the history
Replace arc data names having space(or special chars).

Fix #1168
  • Loading branch information
netil authored Dec 20, 2019
1 parent da7b81c commit 4824a47
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions spec/interactions/interaction-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,4 +1012,32 @@ describe("INTERACTION", () => {
expect(main.selectAll(`.${CLASS.EXPANDED}`).size()).to.be.equal(0);
});
});

describe("check for arc data name", () => {
before(() => {
args = {
data: {
columns: [
["catégorie 1", 20],
["catégorie 2 2", 80]
],
type: "pie"
}
};
});

it("should not throw error", () => {
try {
chart.internal.setOverOut(true, {
id: "catégorie 1"
});

chart.internal.setOverOut(true, {
id: "catégorie 2 2"
});

expect(true).to.be.ok;
} catch(e) {}
})
});
});
2 changes: 1 addition & 1 deletion src/interactions/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ extend(ChartInternal.prototype, {
config.color_onover && $$.setOverColor(isOver, d, isArc);

if (isArc) {
callback(d, $$.main.select(`.${CLASS.arc}-${d.id}`).node());
callback(d, $$.main.select(`.${CLASS.arc}${$$.getTargetSelectorSuffix(d.id)}`).node());
} else if (!config.tooltip_grouped) {
const callee = $$.setOverOut;
let last = callee.last || [];
Expand Down
2 changes: 1 addition & 1 deletion src/internals/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extend(ChartInternal.prototype, {

// when is Arc type
if (isObject(d)) {
$$.main.selectAll(`.${CLASS.arc}-${d.id}`)
$$.main.selectAll(`.${CLASS.arc}${$$.getTargetSelectorSuffix(d.id)}`)
.style("fill", color(d));
} else {
$$.main.selectAll(`.${CLASS.shape}-${d}`)
Expand Down

0 comments on commit 4824a47

Please sign in to comment.