fix legend values when value is undefined
+ improve mechanism to find value
This commit is contained in:
@ -1940,10 +1940,15 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
||||
if (x === null) return;
|
||||
for(let i in chart.data.datasets){
|
||||
let y = null;
|
||||
for(let j = 0; j < chart.getDatasetMeta(i).data.length; j++){
|
||||
let dp = chart.getDatasetMeta(i).data[j];
|
||||
if (dp.x >= x) break; //_model does not exist anymore, properties are defined directly on elements
|
||||
y = chart.data.datasets[i].data[dp.$context.index].y; // $context not mentionned in ChartJS doc, seen with console.log
|
||||
let metadata = chart.getDatasetMeta(i).data;
|
||||
let dataset = chart.data.datasets[i];
|
||||
if (metadata.length != dataset.data.length) {
|
||||
console.log('length mismatch in dataset.data and metadata')
|
||||
}
|
||||
for(let j = 0; j < metadata.length; j++){
|
||||
let dp = metadata[j];
|
||||
if (dp.x >= x) break;
|
||||
y = dataset.data[j].y;
|
||||
}
|
||||
valueElm = legendvalues[chart.data.datasets[i].key];
|
||||
if (labelMinWidth == 0) {
|
||||
@ -1952,7 +1957,9 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
||||
labelMinWidth = valueElm.clientWidth;
|
||||
valueElm.style.minWidth = labelMinWidth + 'px';
|
||||
}
|
||||
if (y !== null) {
|
||||
if (y == null) {
|
||||
valueElm.innerHTML = '';
|
||||
} else {
|
||||
valueElm.innerHTML = strFormat(y, labelDigits);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user