diff --git a/src/ChartInternal/interactions/zoom.ts b/src/ChartInternal/interactions/zoom.ts index 04de57b17..467419448 100644 --- a/src/ChartInternal/interactions/zoom.ts +++ b/src/ChartInternal/interactions/zoom.ts @@ -298,8 +298,7 @@ export default { // Applying the workaround: https://github.com/d3/d3-zoom/issues/231#issuecomment-802305692 $$.$el.svg.on("wheel", () => {}); - eventRect - .call(behaviour) + eventRect?.call(behaviour) .on("dblclick.zoom", null); }, diff --git a/test/interactions/zoom-spec.ts b/test/interactions/zoom-spec.ts index 8050d2202..531fa7e06 100644 --- a/test/interactions/zoom-spec.ts +++ b/test/interactions/zoom-spec.ts @@ -49,9 +49,7 @@ describe("ZOOM", function() { expect(yDomain[0]).to.be.equal(expectedYDomain[0]); expect(yDomain[1]).to.be.equal(expectedYDomain[1]); }); - }); - describe("main chart domain", () => { it("should have original y domain in subchart", () => { const yDomain = chart.internal.scale.y.domain(); const subYDomain = chart.internal.scale.subY.domain(); @@ -59,9 +57,7 @@ describe("ZOOM", function() { expect(subYDomain[0]).to.be.equal(yDomain[0]); expect(subYDomain[1]).to.be.equal(yDomain[1]); }); - }); - describe("main chart domain", () => { it("should have specified brush extent", () => { const brushExtent = chart.internal.brush.extent()(); const expectedBrushExtent = [[1, 0], [2, 60]]; @@ -69,6 +65,21 @@ describe("ZOOM", function() { expect(brushExtent[0][1]).to.be.equal(expectedBrushExtent[0][1]); expect(brushExtent[1][1]).to.be.equal(expectedBrushExtent[1][1]); }); + + it("initialization with empty data", () => { + expect( + util.generate({ + data: { + x: "x", + columns: [], + type: "line" + }, + zoom: { + enabled: true + } + }) + ).to.not.throw; + }); }); });