How to use the @antv/util.deepMix 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 / G6 / src / shape / edges / polyline.ts View on Github external
cfg.style = {};
    }
    // const oriShapeAttrs = shape.attr();
    // cfg.style.radius = cfg.style.radius || oriShapeAttrs.radius;
    // cfg.style.offset = cfg.style.offset || oriShapeAttrs.offset;

    cfg = this.getPathPoints(cfg);
    const points = this.getControlPoints(cfg);
    
    const path = this.getPath(points, this.routeCfg);
     // 下面这些属性需要覆盖默认样式与目前样式,但若在 cfg 中有指定则应该被 cfg 的相应配置覆盖。
     const strokeStyle = {
      stroke: cfg.color,
      path
    };
    const shapeStyle = deepMix({}, shape.attr(), strokeStyle, cfg.style);

    shape.attr(shapeStyle);
    this.updateLabel(cfg, item);
  }
}, 'single-line');
github antvis / G2 / src / geometry / label / base.ts View on Github external
const content = labelCfg.content;
      if (isFunction(content)) {
        labelCfg.content = content(origin, mappingData, index);
      } else if (isUndefined(content)) {
        // 用户未配置 content,则默认为映射的第一个字段的值
        labelCfg.content = originText[0];
      }

      if (isFunction(labelCfg.position)) {
        labelCfg.position = labelCfg.position(origin, mappingData, index);
      }

      if (type === 'polygon' || (labelCfg.offset < 0 && !['line', 'point', 'path'].includes(type))) {
        // polygon 或者 offset 小于 0 时,文本展示在图形内部,将其颜色设置为 白色
        labelCfg = deepMix({}, defaultLabelCfg, theme.innerLabels, labelCfg);
      } else {
        labelCfg = deepMix({}, defaultLabelCfg, theme.labels, labelCfg);
      }

      labelCfgs.push(labelCfg);
    });
github antvis / G2Plot / src / plots / ring / layer.ts View on Github external
public getOptions(props: T) {
    const options = super.getOptions(props);
    // @ts-ignore
    const defaultOptions = this.constructor.getDefaultOptions();
    return _.deepMix({}, options, defaultOptions, props);
  }
github antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
public _initBackground() {
    const chart = this.view;
    const geom = chart.get('elements')[0];
    const shapes = geom.get('shapeContainer').get('children');
    const chartData = shapes.length > 0 ? getFirstShapeData(shapes) : chart.get('data');
    const data = (this.data = this.data || chartData);
    const xScale = chart.getXScale();
    const xAxis = this.view.xAxis || xScale.field;
    const yAxis = this.view.yAxis || chart.getYScales()[0].field;
    const scales = _.deepMix(
      {
        [`${xAxis}`]: {
          range: [0, 1],
        },
      },
      getColDefs(chart),
      this.view.scales
    ); // 用户列定义
    delete scales[xAxis].min;
    delete scales[xAxis].max;
    if (!data) {
      // 没有数据,则不创建
      throw new Error('Please specify the data!');
    }
    if (!xAxis) {
      throw new Error('Please specify the xAxis!');
github antvis / G2Plot / src / components / axis / parser.ts View on Github external
private _labelParser() {
    const { style, ...restLabelProps } = this.localProps.label;
    const labelConfig: DataPointType = { ...restLabelProps };
    /** label style */
    if (style) {
      labelConfig.textStyle = this.localProps.label.style;
    }
    labelConfig.textStyle = _.deepMix({}, _.get(this.themeConfig, 'label.style'), labelConfig.textStyle);
    this.config.label = labelConfig;
  }
github antvis / G2Plot / src / plots / group-bar / layer.ts View on Github external
public static getDefaultOptions(): Partial {
    return _.deepMix({}, super.getDefaultOptions(), {
      xAxis: {
        visible: true,
        grid: {
          visible: true,
        },
      },
      yAxis: {
        visible: true,
        title: {
          visible: false,
        },
      },
      label: {
        visible: true,
        position: 'right',
        offset: 8,
github antvis / G2Plot / src / components / axis / parser.ts View on Github external
this.config.grid = (text: string, index: number, count: number) => {
        const cfg = style(text, index, count);
        return _.deepMix({}, _.get(this.themeConfig, `grid.style`), cfg);
      };
    } else if (style) {
github antvis / G2Plot / src / util / responsive / node / shape-nodes.ts View on Github external
constructor(cfg: NodesCfg) {
    this.shapes = cfg.shapes;
    this.nodes = [];
    this._parserNodes();
    this.origion_nodes = _.deepMix([], this.nodes);
  }
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 / combo-plots / base.ts View on Github external
protected createLayers(props: T & { layers?: any }) {
    this.globalOptions = deepMix({}, this.getDefaultOptions(), this.getGlobalOptions(props));
  }
}