Parcourir la source

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
tags/v1.3.1
Emīls Gulbis il y a 5 ans
committed by GitHub
Parent
révision
f85daa3d6e
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
1 fichiers modifiés avec 13 ajouts et 11 suppressions
  1. +13
    -11
      src/js/charts/AxisChart.js

+ 13
- 11
src/js/charts/AxisChart.js Voir le fichier

@@ -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];

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() { renderLegend() {


Chargement…
Annuler
Enregistrer