How to use the @antv/component/lib.Tooltip.Canvas function in @antv/component

To help you get started, we’ve selected a few @antv/component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G2 / src / chart / controller / tooltip.js View on Github external
options.visible = false;
    // @2018-09-13 by blue.lb 如果设置shared为false不需要指定position
    // if (options.shared === false && Util.isNil(options.position)) {
    //   options.position = 'top';
    // }
    let tooltip;
    if (options.type === 'mini') {
      options.crosshairs = false;
      // this.options.shared = false;
      options.position = 'top';
      tooltip = new Tooltip.Mini(options);
    } else if (options.useHtml) {
      tooltip = new Tooltip.Html(options);
    } else {
      tooltip = new Tooltip.Canvas(options);
    }
    self.tooltip = tooltip;

    const triggerEvent = self._getTriggerEvent();
    const tooltipContainer = tooltip.get('container');
    if (!tooltip.get('enterable') && triggerEvent === 'plotmove') { // 鼠标不允许进入 tooltip 容器
      if (tooltipContainer) {
        tooltipContainer.onmousemove = e => {
          // 避免 tooltip 频繁闪烁
          const eventObj = self._normalizeEvent(e);
          chart.emit(triggerEvent, eventObj);
        };
      }
    }

    // 优化:鼠标移入 tooltipContainer 然后再移出时,需要隐藏 tooltip