Fix tooltip external handler and add null check

This commit is contained in:
mirivlad 2026-02-14 18:17:48 +00:00
parent 19d8bc4268
commit 3cf405c823
1 changed files with 6 additions and 2 deletions

View File

@ -517,8 +517,12 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
document.body.appendChild(tooltipEl);
}
var dataIndex = context[0].dataIndex;
var time = labels{{ metricName }}[dataIndex];
var dataIndex = context.tooltip && context.tooltip.dataPoints && context.tooltip.dataPoints[0] ? context.tooltip.dataPoints[0].dataIndex : null;
if (dataIndex === null) {
tooltipEl.style.opacity = 0;
return;
}
var time = labels{{ metricName }}[dataIndex];
// Fetch processes
fetch('/api/v1/agent/' + {{ server.id }} + '/processes?time=' + encodeURIComponent(time))