Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

锚点问题 #199

Open
luoyy2013 opened this issue Sep 29, 2018 · 0 comments
Open

锚点问题 #199

luoyy2013 opened this issue Sep 29, 2018 · 0 comments

Comments

@luoyy2013
Copy link

如果是 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的时候有问题
})
顺便想问一下,带箭头的曲线怎么话呢?还有,我每次点一下按钮时,只能添加一个圆点,能不能我选一次,可以一直添加呢?
...

我的期望

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant