add tooltip

This commit is contained in:
Scott Bell 2024-12-16 12:39:23 +01:00
parent cda7cc9d06
commit d048af108e

View File

@ -64,7 +64,8 @@ export default {
eventHistory: [], eventHistory: [],
timeSystem: timeSystem, timeSystem: timeSystem,
extendLines: false, extendLines: false,
titleKey: null titleKey: null,
tooltip: null
}; };
}, },
watch: { watch: {
@ -420,7 +421,13 @@ export default {
eventTickElement.style.width = '2px'; eventTickElement.style.width = '2px';
eventTickElement.style.height = `${String(ROW_HEIGHT - 10)}px`; eventTickElement.style.height = `${String(ROW_HEIGHT - 10)}px`;
if (this.titleKey) { if (this.titleKey) {
eventTickElement.title = event[this.titleKey]; const textToShow = event[this.titleKey];
eventWrapper.addEventListener('mouseover', () => {
this.showToolTip(textToShow, eventTickElement);
});
eventWrapper.addEventListener('mouseleave', () => {
this.tooltip?.destroy();
});
} }
eventWrapper.appendChild(eventTickElement); eventWrapper.appendChild(eventTickElement);
const limitEvaluation = this.limitEvaluator.evaluate(event, this.valueMetadata); const limitEvaluation = this.limitEvaluator.evaluate(event, this.valueMetadata);
@ -452,6 +459,13 @@ export default {
keyString: this.keyString keyString: this.keyString
}); });
} }
},
showToolTip(textToShow, referenceElement) {
this.tooltip = this.openmct.tooltips.tooltip({
toolTipText: textToShow,
toolTipLocation: this.openmct.tooltips.TOOLTIP_LOCATIONS.RIGHT,
parentElement: referenceElement
});
} }
} }
}; };