Fix: Sometimes index === -1
Sometimes when mouse-overing container, i got `vendors.app.js:8427 Uncaught TypeError: Cannot read property 'xPos' of undefined` that is caused by `-1` index
This commit is contained in:
parent
39211a406d
commit
f85daa3d6e
@ -405,17 +405,19 @@ export default class AxisChart extends BaseChart {
|
|||||||
if(!s.yExtremes) return;
|
if(!s.yExtremes) return;
|
||||||
|
|
||||||
let index = getClosestInArray(relX, s.xAxis.positions, true);
|
let index = getClosestInArray(relX, s.xAxis.positions, true);
|
||||||
let dbi = this.dataByIndex[index];
|
if (index >= 0) {
|
||||||
|
let dbi = this.dataByIndex[index];
|
||||||
|
|
||||||
this.tip.setValues(
|
this.tip.setValues(
|
||||||
dbi.xPos + this.tip.offset.x,
|
dbi.xPos + this.tip.offset.x,
|
||||||
dbi.yExtreme + this.tip.offset.y,
|
dbi.yExtreme + this.tip.offset.y,
|
||||||
{name: dbi.formattedLabel, value: ''},
|
{name: dbi.formattedLabel, value: ''},
|
||||||
dbi.values,
|
dbi.values,
|
||||||
index
|
index
|
||||||
);
|
);
|
||||||
|
|
||||||
this.tip.showTip();
|
this.tip.showTip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLegend() {
|
renderLegend() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user