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

自定义布局的问题 #5232

Closed
zhangyang-igloo opened this issue Dec 6, 2023 · 4 comments
Closed

自定义布局的问题 #5232

zhangyang-igloo opened this issue Dec 6, 2023 · 4 comments
Labels
good first issue Outdate This issue is too old to be resolved stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed

Comments

@zhangyang-igloo
Copy link

问题描述

需求:第1层级横向排列,从第2层级开始纵向排列
实现方式:整体紧凑树布局,从第2层级开始使用缩进树布局的自定义布局
问题:缩进树布局的节点起始位置不对
image

重现链接

暂无

重现步骤

预期行为

image

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • G6 版本: [4.5.1 ... ]

屏幕截图或视频(可选)

No response

补充说明(可选)

代码参考了#5062 中的 https://codesandbox.io/s/ecstatic-phoebe-95kxjg
附上layout部分代码
` layout: ((d: any) => {
const compactBoxConfig = {
type: 'compactBox',
direction: 'TB',
getId: function getId(d: any) {
return d.id;
},
getHeight: function getHeight() {
return 84;
},
getWidth: function getWidth() {
return 233;
},
getVGap: function getVGap() {
return 20;
},
getHGap: function getHGap() {
return 20;
},
};
const layoutData = Hierarchy[compactBoxConfig.type](
d,
compactBoxConfig,
);

    const indentConfig = {
      type: 'indented',
      isHorizontal: true,
      direction: 'LR',
      indent: 140,
      getHeight: function getHeight() {
        return 84;
      },
      getWidth: function getWidth() {
        return 233;
      },
    };

    const loop = (tree: any) => {
      if (tree.depth >= 2 && tree.children?.length > 0) {
        const subLayoutData = Hierarchy[indentConfig.type](
          tree,
          indentConfig,
        );
        const childrenBeginX = subLayoutData.children[0].x;
        const displacementX = subLayoutData.x - childrenBeginX;
        G6.Util.traverseTree(subLayoutData, (node: any) => {
          if (node.id === subLayoutData.id) return;
          node.x += displacementX;
        });
      } else {
        if (tree.children?.length > 0) {
          tree.children.forEach((item: any) => {
            loop(item);
          });
        }
      }
    };

    loop(layoutData);

    return layoutData;
  }) as any,`
Copy link

github-actions bot commented Dec 6, 2023

hi @zhangyang-igloo, welcome!

Copy link

github-actions bot commented Dec 6, 2023

Hi @zhangyang-igloo, Please star this repo if you find it useful! Thanks ⭐!
你好 @zhangyang-igloo。如果该仓库对你有用,可以 star 一下,感谢你的 ⭐!

@KTBOY
Copy link

KTBOY commented Jan 2, 2024

提供重现链接

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 17, 2024
@Aarebecca Aarebecca added the Outdate This issue is too old to be resolved label Jul 5, 2024
Copy link

github-actions bot commented Jul 5, 2024

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。

@github-actions github-actions bot closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Outdate This issue is too old to be resolved stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Projects
None yet
Development

No branches or pull requests

3 participants