Fix tooltip visibility logic
This commit is contained in:
parent
f10349af0d
commit
d2caa14766
|
|
@ -519,17 +519,20 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
|
||||||
tooltipEl.style.pointerEvents = 'none';
|
tooltipEl.style.pointerEvents = 'none';
|
||||||
document.body.appendChild(tooltipEl);
|
document.body.appendChild(tooltipEl);
|
||||||
|
|
||||||
// Hide tooltip on mouseleave
|
|
||||||
context.chart.canvas.addEventListener('mouseleave', function() {
|
|
||||||
tooltipEl.style.opacity = 0;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var dataIndex = context.tooltip && context.tooltip.dataPoints && context.tooltip.dataPoints[0] ? context.tooltip.dataPoints[0].dataIndex : null;
|
var dataIndex = context.tooltip && context.tooltip.dataPoints && context.tooltip.dataPoints[0] ? context.tooltip.dataPoints[0].dataIndex : null;
|
||||||
if (dataIndex === null) {
|
if (dataIndex === null) {
|
||||||
tooltipEl.style.opacity = 0;
|
tooltipEl.style.opacity = 0;
|
||||||
|
window.lastTooltipIndex = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Проверяем что курсор всё ещё над той же точкой
|
||||||
|
if (window.lastTooltipIndex && window.lastTooltipIndex !== dataIndex) {
|
||||||
|
tooltipEl.style.opacity = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.lastTooltipIndex = dataIndex;
|
||||||
var time = labels{{ metricName }}[dataIndex];
|
var time = labels{{ metricName }}[dataIndex];
|
||||||
|
|
||||||
// Fetch processes
|
// Fetch processes
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue