Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handler(view, event, item, value) {
this.hideTooltip();
// hide tooltip for null, undefined, or empty string values
if (value == null || value === '') {
return;
}
const el = document.createElement('div');
el.setAttribute('id', tooltipId);
el.classList.add('vgaVis__tooltip', 'euiToolTipPopover', 'euiToolTip', `euiToolTip--${this.position}`);
// Sanitized HTML is created by the tooltip library,
// with a large number of tests, hence suppressing eslint here.
// eslint-disable-next-line no-unsanitized/property
el.innerHTML = createTooltipContent(value, _.escape);
// add to DOM to calculate tooltip size
document.body.appendChild(el);
// if centerOnMark numeric value is smaller than the size of the mark, use mouse [x,y]
let anchorBounds;
if (item.bounds.width() > this.centerOnMark || item.bounds.height() > this.centerOnMark) {
// I would expect clientX/Y, but that shows incorrectly
anchorBounds = createRect(event.pageX, event.pageY, 0, 0);
} else {
const containerBox = this.container.getBoundingClientRect();
anchorBounds = createRect(
containerBox.left + view._origin[0] + item.bounds.x1,
containerBox.top + view._origin[1] + item.bounds.y1,
item.bounds.width(),
item.bounds.height()
// hide tooltip for null, undefined, or empty string values
if (value == null || value === '') {
return;
}
const el = document.createElement('div');
el.setAttribute('id', tooltipId);
['vgaVis__tooltip', 'euiToolTipPopover', 'euiToolTip', `euiToolTip--${this.position}`].forEach(className => {
el.classList.add(className);
});
// Sanitized HTML is created by the tooltip library,
// with a large number of tests, hence suppressing eslint here.
// eslint-disable-next-line no-unsanitized/property
el.innerHTML = createTooltipContent(value, _.escape);
// add to DOM to calculate tooltip size
document.body.appendChild(el);
// if centerOnMark numeric value is smaller than the size of the mark, use mouse [x,y]
let anchorBounds;
if (item.bounds.width() > this.centerOnMark || item.bounds.height() > this.centerOnMark) {
// I would expect clientX/Y, but that shows incorrectly
anchorBounds = createRect(event.pageX, event.pageY, 0, 0);
} else {
const containerBox = this.container.getBoundingClientRect();
anchorBounds = createRect(
containerBox.left + view._origin[0] + item.bounds.x1 + window.pageXOffset,
containerBox.top + view._origin[1] + item.bounds.y1 + window.pageYOffset,
item.bounds.width(),
item.bounds.height()