Simplify tooltip logic - hide on mouseleave
This commit is contained in:
parent
d2caa14766
commit
75499e07e7
|
|
@ -518,21 +518,15 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
|
||||||
tooltipEl.style.fontSize = '12px';
|
tooltipEl.style.fontSize = '12px';
|
||||||
tooltipEl.style.pointerEvents = 'none';
|
tooltipEl.style.pointerEvents = 'none';
|
||||||
document.body.appendChild(tooltipEl);
|
document.body.appendChild(tooltipEl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var dataIndex = context.tooltip && context.tooltip.dataPoints && context.tooltip.dataPoints[0] ? context.tooltip.dataPoints[0].dataIndex : null;
|
// Прячем если курсор ушел с графика
|
||||||
if (dataIndex === null) {
|
if (!context.tooltip._active || context.tooltip._active.length === 0) {
|
||||||
tooltipEl.style.opacity = 0;
|
|
||||||
window.lastTooltipIndex = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Проверяем что курсор всё ещё над той же точкой
|
|
||||||
if (window.lastTooltipIndex && window.lastTooltipIndex !== dataIndex) {
|
|
||||||
tooltipEl.style.opacity = 0;
|
tooltipEl.style.opacity = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.lastTooltipIndex = dataIndex;
|
|
||||||
|
var dataIndex = context.tooltip._active[0].index;
|
||||||
var time = labels{{ metricName }}[dataIndex];
|
var time = labels{{ metricName }}[dataIndex];
|
||||||
|
|
||||||
// Fetch processes
|
// Fetch processes
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue