antvis/G6

collapse-expand does not take effect, version 5.0.24 #6412

halaproliu posted onGitHub

Describe the bug / 问题描述

使用collapse-expand插件,展开收缩不生效

https://stackblitz.com/edit/vitejs-vite-cnvaiy?file=src%2FApp.vue

Steps to Reproduce the Bug or Issue / 重现步骤

复现链接中有

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

macOS

Browser / 浏览器

Chrome

Additional context / 补充说明

麻烦帮忙看下


collapse-expand 交互会去处理节点数据中的 children 字段,请先检查数据中是否包含此字段

interface NodeData {
    id: ID;
    type: string;
    data?: Record<string, unknown>;
    children?: ID[];
}
posted by yvonneyx 6 months ago

collapse-expand 交互会去处理节点数据中的 children 字段,请先检查数据中是否包含此字段

interface NodeData {
    id: ID;
    type: string;
    data?: Record<string, unknown>;
    children?: ID[];
}

https://g6-next.antv.antgroup.com/zh/examples/scene-case/default#organization-chart组织架构图的这个demo数据是不含children字段的,所以这种图标是不能折叠展开的嘛

posted by halaproliu 6 months ago

直接加交互肯定是没办法生效的呀,需要再处理一下数据~

posted by yvonneyx 6 months ago

直接加交互肯定是没办法生效的呀,需要再处理一下数据~

其实相当于是,如果数据结构是带children的,插件会自动处理。但是如果没有带的话,需要自己通过onCollpse和onExpand函数去处理吧?

posted by halaproliu 6 months ago

无论是使用内置的 collapse-expand交互,还是使用 graph API expandElementcollapseElement,都需要消费 children 字段,以告知哪些元素需要被展开或收起。否则,从数据层面很难推断出需要展开或收起的元素。

posted by yvonneyx 6 months ago

无论是使用内置的 collapse-expand交互,还是使用 graph API expandElementcollapseElement,都需要消费 children 字段,以告知哪些元素需要被展开或收起。否则,从数据层面很难推断出需要展开或收起的元素。

目前dagre布局,所使用的data结构是GraphData类型的,是否意味着这种布局无法使用collapse-expand组件?

posted by halaproliu 6 months ago

你预处理一下数据不就可以了?

halapro.liu @.***>于2024年10月24日 周四17:49写道:

无论是使用内置的 collapse-expand 交互,还是使用 graph API expandElement 和 collapseElement,都需要消费 children 字段,以告知哪些元素需要被展开或收起。否则,从数据层面很难推断出需要展开或收起的元素。

目前dagre布局,所使用的data结构是GraphData类型的,是否意味着这种布局无法使用collapse-expand组件?

— Reply to this email directly, view it on GitHub https://github.com/antvis/G6/issues/6412#issuecomment-2434808306, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANJVVEIT7SHJNUGPEDWDV2LZ5C7B7AVCNFSM6AAAAABQAUI242VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZUHAYDQMZQGY . You are receiving this because you commented.Message ID: @.***>

posted by yvonneyx 6 months ago

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. | 由于该 issue 缺少关键信息且已闲置 7 天,现已自动关闭。如需重新打开此问题,请提供所缺失的信息。。

posted by github-actions[bot] 4 months ago

Fund this Issue

$0.00
Funded

Pull requests