Skip to content

Commit

Permalink
fix(tooltip): Fix for dynamically loaded data adding column
Browse files Browse the repository at this point in the history
Correct getting nullable index value

Fix #660
Close #661
  • Loading branch information
netil committed Nov 19, 2018
1 parent d9dc75a commit 009d3b1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions spec/internals/tooltip-spec.js
Expand Up @@ -675,4 +675,37 @@ describe("TOOLTIP", function() {
expect(value).to.be.equal(200);
});
});

describe("tooltip for dynamic loaded data", () => {
before(() => {
args = {
data: {
columns: [
["data1", 30, 200, 100],
["data2", 130, 100, 140]
]
}
};
});

it("load data to be adding more columns", done => {
setTimeout(() => {
chart.load({
columns: [
["data2", 44, 134, 98, 170]
],
done: () => {
try {
chart.tooltip.show({index: 3});
} catch(e) {
expect(false).to.be.true;
}

expect(true).to.be.true;
done();
}
});
}, 500);
});
});
});
2 changes: 1 addition & 1 deletion src/internals/tooltip.js
Expand Up @@ -233,7 +233,7 @@ extend(ChartInternal.prototype, {
let height = (datum && datum.height) || 0;

if (!datum || datum.current !== dataStr) {
const index = selectedData[0].index;
const index = selectedData.concat().sort()[0].index;
const html = config.tooltip_contents.call(
$$,
selectedData,
Expand Down

0 comments on commit 009d3b1

Please sign in to comment.