How to use the @antv/component/lib.Legend.CatPageHtml 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 / legend.js View on Github external
const id = htmlContainer.replace('#', '');
        htmlContainer = document.getElementById(id);
      } else if (!htmlContainer) {
        htmlContainer = container.get('canvas').get('el').parentNode;
      }
      legendCfg.container = htmlContainer;
      if (legendCfg.legendStyle === undefined) legendCfg.legendStyle = {};
      if (!legendCfg.legendStyle.CONTAINER_CLASS) {
        legendCfg.legendStyle.CONTAINER_CLASS = {
          height: (posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto',
          width: !(posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto',
          position: 'absolute',
          overflow: 'auto'
        };
      }
      if (legendOptions.flipPage) legend = new Legend.CatPageHtml(legendCfg);
      else legend = new Legend.CatHtml(legendCfg);
    } else legend = new Legend.Category(legendCfg);
    legends[position].push(legend);

    legend.on('itemclick', ev => {
      if (legendOptions.onClick) { // 用户自定义了图例点击事件
        legendOptions.onClick(ev);
      }
    });

    self._bindHoverEvent(legend);
    return legend;
  }
github antvis / G2 / src / chart / controller / legend.js View on Github external
}
        if (!container) {
          container = canvasEle.parentNode;
        }
        legendCfg.container = container;
        if (legendCfg.legendStyle === undefined) legendCfg.legendStyle = {};
        legendCfg.legendStyle.CONTAINER_CLASS = {
          ...(legendCfg.legendStyle.CONTAINER_CLASS),
          position: 'absolute',
          overflow: 'auto',
          'z-index': canvasEle.style.zIndex === '' ? 1 : parseInt(canvasEle.style.zIndex, 10) + 1
        };
        if (legendOptions.flipPage) {
          legendCfg.legendStyle.CONTAINER_CLASS.height = (posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto';
          legendCfg.legendStyle.CONTAINER_CLASS.width = !(posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto';
          legend = new Legend.CatPageHtml(legendCfg);
        } else {
          legend = new Legend.CatHtml(legendCfg);
        }
      } else {
        legend = new Legend.Category(legendCfg);
      }
    }
    self._bindClickEvent(legend, scale, filterVals);

    legends[position].push(legend);
    return legend;
  }