antvis/G6

自定义节点registerNode的getAnchorPoints方法不被触发 #4766

hzzou posted onGitHub

Describe the bug

registerNode的getAnchorPoints方法不被触发

CodeSandBox

https://codesandbox.io/p/sandbox/gallant-booth-rlj33t?file=%2Fsrc%2Fcomponents%2FbloodG6%2Findex.vue%3A1%2C1

Your Example Website or App

https://rlj33t-5173.csb.app/

Steps to Reproduce the Bug or Issue

Expected behavior

触发getAnchorPoints,进行锚点位置的自定义

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response


给个在线复现 demo?看不到代码呀

posted by Yanyan-Wang over 1 year ago

给个在线复现 demo?看不到代码呀

不好意思,贴错地址,已附上

posted by hzzou over 1 year ago

需要配置啥吗 为啥我的getAnchorPoints也触发不了? G6.registerNode( "card-node", { drawShape: function drawShape(cfg, group) { const color = cfg.error ? "#F4664A" : "#30BF78"; const r = 2; const shape = group.addShape("rect", { attrs: { x: 0, y: 0, width: 100, height: 100, // stroke: color, fill: color, }, name: "main-box", draggable: true, });

      group.addShape("text", {
        attrs: {
          textBaseline: "middle",
          y: 60 / 2 - 10,
          x: 100 / 2,
          textAlign: "center",
          lineHeight: 20,
          fontSize: 12,
          text: cfg.title,
          fill: "#fff",
        },
        name: "title",
      });
      group.addShape("text", {
        attrs: {
          textBaseline: "middle",
          y: 60 / 2 + 10,
          x: 100 / 2,
          textAlign: "center",
          lineHeight: 20,
          fontSize: 12,
          text: "重要变更",
          fill: "#fff",
        },
        name: "title",
      });
      cfg.panels.forEach((item, index) => {
        group.addShape("image", {
          attrs: {
            y: 70,
            x: 24 + index * 40,
            height: 16,
            width: 16,
            cursor: "pointer",
            img: item,
          },
          name: `node-icon-${index}`,
        });
      });
      return shape;
    },
    getControlPoints() {
      console.log(1111);
    },
    getAnchorPoints() {
      return [
        [0, 0.5], // 左侧中间
        [1, 0.5], // 右侧中间
      ];
    },
  },
  "react"
);
posted by bobobabab over 1 year ago

请问有什么进展吗?

posted by ZhenmingTang over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests