How to use the @antv/scale/lib.identity function in @antv/scale

To help you get started, we’ve selected a few @antv/scale 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 / scale.js View on Github external
createScale(field, data) {
    const self = this;
    const def = self._getDef(field);
    let scale;
    const validData = data || [];
    const firstValue = Util.Array.firstValue(validData, field);
    if (Util.isNumber(field) || (Util.isNil(firstValue)) && !def) {
      scale = Scale.identity({
        value: field,
        field: field.toString(),
        values: [ field ]
      });
    } else { // 如果已经定义过这个度量
      let type;
      if (def) {
        type = def.type;
      }
      type = type || self._getDefaultType(field, validData);
      const cfg = self._getScaleCfg(type, field, validData);
      if (def) {
        Util.mix(cfg, def);
      }
      scale = Scale[type](cfg);
    }

@antv/scale

Toolkit for mapping abstract data into visual representation.

MIT
Latest version published 5 months ago

Package Health Score

73 / 100
Full package analysis