Skip to content

锚点问题 #199

Description

@luoyy2013

如果是 G2、G2-mobile、G6、可视化基础的使用问题,请您按照下面的模板来提 issue,并打上 label,真心感谢~~~

我的需求/我的问题

 锚点设置为(0.5,0.5)的小圆圈时,锚点正确显示在圆心,但是连接两个圆点时,报错:

index.js:6 Uncaught TypeError: Cannot read property 'x' of undefined
at t._getEdgePoints (index.js:6)
at t.beforeDraw (index.js:6)
at t.draw (index.js:1)
at t.update (index.js:1)
at t.updateItem (index.js:6)
at i (index.js:8)
at index.js:1
at index.js:3
at Object.each (index.js:5)
at t.fire (index.js:3)
at onMouseUp (index.js:6)
at HTMLCanvasElement.n (index.js:5)

数据以及出现问题的源代码

   drawPoint = (pointColor,pointType) => {
    G6.registNode(pointType, {
      draw: (cfg, group) => {
        // cfg.origin.haha="haha"; // 添加属性
        const shape = group.addShape('circle', {
          attrs: {
            x: cfg.x,
            y: cfg.y,
            r: 5,
            fill: pointColor,
          },
        });
        group.addShape('text', {
          attrs: {
            x: cfg.x,
            y: cfg.y,
            fill: 'black',
            text: pointType,
            fontSize: 5,
          },
        });
        return shape;
      },
      getAnchorPoints: () => {
        return [
          [0.5, 0.5],
          // [1, 0.5],
          // [0.5, 0],
          // [0.5, 1],
        ];
      },
    });

    this.net.beginAdd('node', {
      shape: pointType,
    });
  };

this.net.beginAdd('edge', {
      shape: 'line',
    });

G2 or G2-mobile or G6 的版本以及使用环境

G6 -1.2.8

  • G2 or G2-mobile or G6 版本: 1.2.0
  • 使用环境: Mac OS X, Chrome 40...
    ubuntu16.04
    如果是其他的问题,请按照如下模板来提 issue,并打上 label,真心感谢~~~

我的问题

当net.beginAdd('edge',{
shape://换成smooth或者arrow时,不会有问题,只有line的时候有问题
})
顺便想问一下,带箭头的曲线怎么话呢?还有,我每次点一下按钮时,只能添加一个圆点,能不能我选一次,可以一直添加呢?
...

我的期望

...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions