Skip to content

Commit

Permalink
fix: Guide.Point, fix the bug caused by parsePoint() return null. Closed
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Dec 19, 2018
1 parent 5d1ac5e commit 2edbb03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/component/guide/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Point extends GuideBase {
render(coord, container) {
const position = this.parsePoint(coord, this.position);

if (!position) return null;

const shape = container.addShape('Circle', {
className: 'guide-point',
attrs: Util.mix({
Expand Down
17 changes: 16 additions & 1 deletion test/unit/component/guide/point-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,24 @@ describe('Guide.Point', function() {
expect(children[0].attr('x')).to.equal(60);
expect(children[0].attr('y')).to.equal(400);
expect(children[0].attr('r')).to.equal(3);
});

it('guide point, limitInPlot', function() {
group.clear();
const point = new Point({
xScale,
yScales: [ yScale ],
position: [ 0, -50 ], // 不在画布范围内
limitInPlot: true
});
const result = point.render(coord, group);
canvas.draw();

expect(result).to.be.null;
const children = group.get('children');
expect(children.length).to.equal(0);

canvas.destroy();
document.body.removeChild(canvas1);

});
});

0 comments on commit 2edbb03

Please sign in to comment.