默认是收缩起来的图谱
逐步节点展开
演示如何在树结构中逐步显示节点,一次显示一个级别。
逐步节点展开
功能概述
此示例演示如何在树结构中逐步显示节点,一次显示一个级别或分支,以便更好地理解数据。
核心特性实现
渐进式展开逻辑
实现逐步节点显示:
const expandGradually = async (rootNode: RGNode, delay: number = 500) => {
const children = rootNode.lot.childs;
for (const child of children) {
await graphInstance.sleep(delay);
graphInstance.expandNode(child);
}
};
延迟子节点显示
使用时间间隔显示子节点:
const onNodeClick = async (node: RGNode) => {
if (node.lot.childs.length > 0) {
await expandGradually(node, 300);
}
};
创意使用场景
- 教程:引导用户了解复杂的层级结构
- 数据演练:以可理解的块呈现信息
- 叙事:逐步显示情节要点
- 培训材料:逐步介绍概念
- 产品游览:以用户的节奏发现功能