示例#1
0
文件: polyline.js 项目: AlexZ33/g2
  getLinePath() {
    const self = this;
    const tickPoints = self.get('tickPoints');
    const start = self.get('start');
    const end = self.get('end');
    const points = [];
    points.push(start.x);
    points.push(start.y);
    Util.each(tickPoints, function(tick) {
      points.push(tick.x);
      points.push(tick.y);
    });
    points.push(end.x);
    points.push(end.y);

    const path = PathUtil.catmullRomToBezier(points);
    path.unshift([ 'M', start.x, start.y ]);
    return path;
  }
示例#2
0
文件: venn.js 项目: RbClimber/g2
    };
  },
  getSelectedCfg(type, cfg) {
    if (cfg && cfg.style) {
      return cfg.style;
    }
    return this.getActiveCfg(type, cfg);
  }
});

Shape.registerShape('venn', 'venn', {
  draw(cfg, container) {
    const origin = cfg.origin._origin;
    const path = origin.path;
    const attrs = getAttrs(cfg);
    const segments = PathUtil.parsePathString(path);

    const pathShape = container.addShape('path', {
      attrs: Util.mix(attrs, {
        path: segments
      })
    });
    return pathShape;
  },
  getMarkerCfg(cfg) {
    return Util.mix({
      symbol: 'circle',
      radius: 4
    }, getAttrs(cfg));
  }
});
示例#3
0
文件: shape.js 项目: RbClimber/g2
 /**
  * 设置坐标系
  * @param {Coord} coord 坐标系
  */
 setCoord(coord) {
   this._coord = coord;
 },
 /**
  * 0~1 path 转 画布 path
  * @param  {path} path 路径
  * @param  {Boolean} islineToArc 是否转换成圆弧
  * @return {path} path 转换到画布坐标的path
  */
 parsePath(path, islineToArc) {
   const coord = this._coord;
   path = GPath.parsePathString(path);
   if (coord.isPolar && islineToArc !== false) {
     path = PathUtil.convertPolarPath(coord, path);
   } else {
     path = PathUtil.convertNormalPath(coord, path);
   }
   return path;
 },
 /**
  * 0~1 point 转 画布 point
  * @param  {point} point 节点
  * @return {point} point 转换后的点
  */
 parsePoint(point) {
   const coord = this._coord;
   return coord.convertPoint(point);