How to use the @antv/component/lib/legend.Color 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 / packages / g2 / src / plot / controller / legend.ts View on Github external
const legendCfg = _.deepMix({}, defaultCfg, this.getFieldLegendOption(field, legendOptions), {
      items,
      attr,
      formatter: scale.formatter,
      container,
      position,
    });

    if (legendCfg.showTitle) {
      _.mix(legendCfg, { title: scale.field });
    }

    let legend;
    if (attr.type === 'color') {
      legend = new Color(legendCfg);
    } else if (attr.type === 'size') {
      legend = new Size(legendCfg);
    } else {
      return;
    }

    this.bindFilterEvent(legend, scale);

    return legend;
  }