How to use the @antv/util.get function in @antv/util

To help you get started, we’ve selected a few @antv/util 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 / geometry / label / labels.ts View on Github external
private drawLabelLine(labelCfg: LabelItem, container: IGroup) {
    if (!labelCfg.labelLine) {
      // labelLine: null | false,关闭 label 对应的 labelLine
      return;
    }
    const labelLineCfg = get(labelCfg, 'labelLine', {});
    let path = labelLineCfg.path;
    if (!path) {
      const start = labelCfg.start;
      path = [
        ['M', start.x, start.y],
        ['L', labelCfg.x, labelCfg.y],
      ];
    }
    container.addShape('path', {
      capture: false, // labelLine 默认不参与事件捕获
      attrs: {
        path,
        stroke: labelCfg.color ? labelCfg.color : get(labelCfg, ['style', 'fill'], '#000'),
        fill: null,
        ...labelLineCfg.style,
      },
github antvis / G2 / src / geometry / interval.ts View on Github external
max: Math.max(Math.max.apply(null, yScale.values), yScale.max),
      });
    } else {
      // 柱状图数值轴默认从 0 开始
      const scaleDefs = this.scaleDefs;
      const { field, min, max, type } = yScale;
      if (type !== 'time') {
        // time 类型不做调整
        // 柱状图的 Y 轴要从 0 开始生长,但是如果用户设置了则以用户的为准
        if (min > 0 && !get(scaleDefs, [field, 'min'])) {
          yScale.change({
            min: 0,
          });
        }
        // 柱当柱状图全为负值时也需要从 0 开始生长,但是如果用户设置了则以用户的为准
        if (max <= 0 && !get(scaleDefs, [field, 'max'])) {
          yScale.change({
            max: 0,
          });
        }
      }
    }
  }
}
github antvis / G2 / src / chart / controller / legend.ts View on Github external
private getCategoryCfg(geometry: Geometry, attr: Attribute, scale: Scale, legendOption: any): object {
    const container = this.container;
    // if position is not set, use top as default
    const direction = get(legendOption, 'position', DIRECTION.BOTTOM);

    // the default marker style
    const themeMarker = get(this.view.getTheme(), ['components', 'legend', direction, 'marker']);
    const userMarker = get(legendOption, 'marker');
    const layout = getLegendLayout(direction);

    const baseCfg = {
      container,
      layout,
      items: getLegendItems(this.view, geometry, attr, themeMarker, userMarker),
      ...this.getCategoryLegendSizeCfg(layout),
    };

    return this.mergeLegendCfg(baseCfg, legendOption, direction);
  }
github antvis / G2 / src / geometry / label / labels.ts View on Github external
each(lastShapesMap, (deleteShape) => {
      const animateCfg = get(deleteShape.get('animateCfg'), 'leave');
      if (animateCfg) {
        doAnimate(deleteShape, animateCfg, {
          toAttrs: null,
          coordinate: deleteShape.get('coordinate'),
        });
      } else {
        deleteShape.remove(true); // 移除
      }
    });
github antvis / G2 / src / chart / controller / axis.ts View on Github external
function getAxisOption(axes: Record | boolean, field: string) {
  if (isBoolean(axes)) {
    return axes === false ? false : {};
  } else {
    return get(axes, [field]);
  }
}
github antvis / G2Plot / src / base / controller / canvas.ts View on Github external
public updateCanvasTheme() {
    const { theme } = this.plot;
    const globalTheme = ThemeController.getGlobalTheme(theme);
    const fill: string = _.get(globalTheme, 'backgroundStyle.fill');
    if (fill) {
      this.updateCanvasStyle({
        backgroundColor: fill,
      });
    }
  }
github antvis / G2Plot / src / geoms / point / guide.ts View on Github external
private _getColorMappingField(props) {
    for (const m of COLOR_MAPPER) {
      if (_.get(props, m)) {
        return [props[m]];
      }
    }
  }
}
github antvis / G2 / src / geometry / shape / base.ts View on Github external
getMarker(shapeType: string, markerCfg: ShapeMarkerCfg): ShapeMarkerAttrs {
    let shape = this.getShape(shapeType);

    if (!shape.getMarker) {
      const defaultShapeType = this.defaultShapeType;
      shape = this.getShape(defaultShapeType);
    }

    const theme = this.theme;
    const shapeStyle = get(theme, [shapeType, 'default'], {});
    const markerStyle = shape.getMarker(markerCfg);

    return deepMix({}, { style: shapeStyle }, markerStyle);
  },
  /**
github antvis / G2Plot / src / geoms / line / guide.ts View on Github external
private _getColorMappingField() {
    const props = this.plot.options;
    const colorMapper = ['stackField', 'seriesField'];
    for (const m of colorMapper) {
      if (_.get(props, m)) {
        return [props[m]];
      }
    }
  }
}
github antvis / G2Plot / src / components / axis / parser.ts View on Github external
private _titleParser() {
    const titleConfig: DataPointType = { ...this.localProps.title };
    const { visible, style, text } = this.localProps.title;
    if (!visible) {
      this.config.showTitle = false;
    } else {
      this.config.showTitle = true;
      if (style) {
        titleConfig.textStyle = style;
      }
      titleConfig.textStyle = _.deepMix({}, _.get(this.config, 'title.style'), titleConfig.textStyle);

      if (text) {
        titleConfig.text = text;
      }
    }
    this.config.title = titleConfig;
  }