Skip to content

Commit

Permalink
fix(point): Fix custom point for nullish data
Browse files Browse the repository at this point in the history
Exclude position computation for nullish data

Fix #2107
  • Loading branch information
netil authored May 28, 2021
1 parent 8e2d2da commit 8c198f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ChartInternal/shape/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ export default {
withTransition, flow, selectedCircles) {
const {width, height} = element.node().getBBox();

const xPosFn2 = d => xPosFn(d) - width / 2;
const yPosFn2 = d => yPosFn(d) - height / 2;
const xPosFn2 = d => (isValue(d.value) ? xPosFn(d) - width / 2 : 0);
const yPosFn2 = d => (isValue(d.value) ? yPosFn(d) - height / 2 : 0);
let mainCircles = element;

if (withTransition) {
Expand Down
12 changes: 12 additions & 0 deletions test/shape/point-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ describe("SHAPE POINT", () => {
expect(scale).to.be.equal(1.75);
});
});

it("set option: nullish data", () => {
args.data.columns = [
["data1", 6, 4, null]
];

args.point.pattern = ['<circle cx="4" cy="4" r="4" />'];
});

it("custom point's position for null data shoudn't be set as NaN", () => {
expect(chart.$.circles.filter(":last-child").attr("y")).to.not.equal("NaN");
});
});

describe("point transition", () => {
Expand Down

0 comments on commit 8c198f2

Please sign in to comment.