Skip to content

Commit

Permalink
fix(zoom): fix throwing TypeError during zoom
Browse files Browse the repository at this point in the history
The call of tooltip.hide(), unexpad of circles & bars internal methods are called.
They're extended when line() or bar() modules are imported and called for esm env.

Fix #1760
  • Loading branch information
netil authored Nov 5, 2020
1 parent 38568c1 commit f2787fa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Chart/api/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ const tooltip = {

$$.hideTooltip(true);
$$.hideGridFocus();
$$.unexpandCircles();
$$.unexpandBars();

$$.unexpandCircles && $$.unexpandCircles();
$$.unexpandBars && $$.unexpandBars();
}
};

Expand Down
12 changes: 11 additions & 1 deletion test/esm/bar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* global describe, beforeEach, it, expect */
import {expect} from "chai";
import sinon from "sinon";
import bb, {bar} from "../../src/index.esm";
import bb, {bar, zoom} from "../../src/index.esm";

// for ESM test, import helper rather than util
import {getBBox, fireEvent} from "../assets/helper";
Expand Down Expand Up @@ -63,4 +63,14 @@ describe("ESM bar", function() {

expect(true).to.be.true;
});

it("set options zoom.enabled=true", () => {
args.zoom = {
enabled: zoom()
};
});

it("shouldn't throw error during zoom", () => {
expect(chart.zoom([0,1])).to.not.throw;
});
});
33 changes: 33 additions & 0 deletions test/esm/line-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
/* eslint-disable */
/* global describe, beforeEach, it, expect */
import {expect} from "chai";
import bb, {line, zoom} from "../../src/index.esm";

describe("ESM line", function() {
let chart;

const args: any = {
data: {
columns: [
["data1", 30, 350, 300, 0, 100],
["data2", 200, 100, 140, 200, 150]
],
type: line()
},
zoom: {
enabled: zoom()
}
};

beforeEach(() => {
chart = bb.generate(args);
});

it("shouldn't throw error during zoom", () => {
expect(chart.zoom([0,1])).to.not.throw;
});
});

0 comments on commit f2787fa

Please sign in to comment.