Skip to content

Commit

Permalink
Fix: Sometimes index === -1
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emilsgulbis authored Oct 7, 2019
1 parent 39211a4 commit f85daa3
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/js/charts/AxisChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,19 @@ export default class AxisChart extends BaseChart {
if(!s.yExtremes) return;

let index = getClosestInArray(relX, s.xAxis.positions, true);
let dbi = this.dataByIndex[index];

this.tip.setValues(
dbi.xPos + this.tip.offset.x,
dbi.yExtreme + this.tip.offset.y,
{name: dbi.formattedLabel, value: ''},
dbi.values,
index
);

this.tip.showTip();
if (index >= 0) {
let dbi = this.dataByIndex[index];

this.tip.setValues(
dbi.xPos + this.tip.offset.x,
dbi.yExtreme + this.tip.offset.y,
{name: dbi.formattedLabel, value: ''},
dbi.values,
index
);

this.tip.showTip();
}
}

renderLegend() {
Expand Down

1 comment on commit f85daa3

@willjosefi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having the same issue... Every time I hover the chart container out of the axis :(
Do you guys have any news on when we should be able to see this fix?
Thanks

Please sign in to comment.