diff --git a/src/ChartInternal/shape/point.ts b/src/ChartInternal/shape/point.ts index ed8b4a6dc..fa557afe3 100644 --- a/src/ChartInternal/shape/point.ts +++ b/src/ChartInternal/shape/point.ts @@ -378,7 +378,7 @@ export default { const mouse = getPointer(state.event, node); const element = d3Select(node); const prefix = this.isCirclePoint(node) ? "c" : ""; - const pointSensitivity = this.getPointSensitivity(node); + const pointSensitivity = this.getPointSensitivity(element?.datum()); let cx = +element.attr(`${prefix}x`); let cy = +element.attr(`${prefix}y`); diff --git a/test/shape/point-spec.ts b/test/shape/point-spec.ts index b92116d29..f92396963 100644 --- a/test/shape/point-spec.ts +++ b/test/shape/point-spec.ts @@ -416,7 +416,7 @@ describe("SHAPE POINT", () => { }); it("set options: poinst.sensitivity=function(){}", () => { - args.point.sensitivity = ({r}) => r + args.point.sensitivity = sinon.spy(({r}) => r); }); it("should data.onclick callback called.", () => { @@ -429,7 +429,10 @@ describe("SHAPE POINT", () => { clientY: rect.top + 3 }, chart); + const spy = args.point.sensitivity.args[0][0]; + expect(args.data.onclick.called).to.be.true; + expect(spy.r > 0).to.be.true; }); it("set options", () => { @@ -444,9 +447,9 @@ describe("SHAPE POINT", () => { type: "line" }, point: { - sensitivity: function(r) { - return 10; - }, + sensitivity: sinon.spy(function(r) { + return 10; + }), r: 10, focus: { expand: { @@ -466,8 +469,11 @@ describe("SHAPE POINT", () => { clientX: 300, clientY: 40 }, chart); + + const spy = args.point.sensitivity.args[0][0]; expect(args.data.onclick.called).to.be.true; + expect(spy.r > 0).to.be.true; }); });