Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
canvas,
frontgroundGroup: view.get('frontgroundGroup'),
theme: theme.tooltip,
backgroundGroup: view.get('backgroundGroup'),
},
defaultCfg,
options
);
if (options.crosshairs && options.crosshairs.type === 'rect') {
options.zIndex = 0; // toolip 背景框不可遮盖住 geom,防止用户配置了 crosshairs
}
options.visible = false;
let tooltip: any;
if (options.useHtml) {
tooltip = new Tooltip.Html(options);
const triggerEvent = this._getTriggerEvent();
if (!tooltip.get('enterable') && triggerEvent === 'panel:mousemove') {
const tooltipContainer = tooltip.get('container');
if (tooltipContainer) {
tooltipContainer.onmousemove = (e) => {
// 避免 tooltip 频繁闪烁
const eventObj = this._normalizeEvent(e);
view.emit(triggerEvent, eventObj);
};
}
}
} else {
tooltip = new Tooltip.Canvas(options);
}
this.tooltip = tooltip;
// 需要保存当前 tooltip 的配置项,否则当用户关闭 tooltip 再手动调用 view.showTooltip() 时会报错
function renderTooltip(layer, canvas) {
const tooltipTheme = getGlobalTheme().tooltip;
const options = {
panelGroup: layer.view.get('panelGroup'),
panelRange: layer.view.get('panelRange'),
capture: false,
canvas,
frontgroundGroup: layer.view.get('frontgroundGroup'),
theme: tooltipTheme,
backgroundGroup: layer.view.get('backgroundGroup'),
};
return new Tooltip.Html(options);
}