Skip to content

思维导图 怎么默认只展开二级节点, 三级节点不展开 #7010

Answered by yvonneyx
Shouone asked this question in Q&A
Discussion options

You must be logged in to vote

需要对数据进行单独处理,可以参考下述例子:

const graph = new Graph({
    container: 'container',
    data: treeToGraphData(data, {
        getNodeData: (datum, depth) => {
          if (!datum.style) datum.style = {};
          datum.style.collapsed = depth >= 2;
          if (!datum.children) return datum;
          const { children, ...restDatum } = datum;
          return { ...restDatum, children: children.map((child) => child.id) };
        },
      }),

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Shouone
Comment options

@Shouone
Comment options

@yvonneyx
Comment options

Answer selected by yvonneyx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants