Skip to content

Conversation

@defghy
Copy link

@defghy defghy commented Jul 11, 2019

I need some custom props
separation, foreignObjectWrapper, depthFactor

Usage

    <Tree
        data={[tree]}
        allowForeignObjects
        translate={{x: -100, y: 450}}
        nodeLabelComponent={{
          render: (<TreeNode />),
          foreignObjectWrapper: ({node}) => {
            if (node.dataIndexes && node.dataIndexes.length) {
              return {width: NodeSize.width, height: NodeSize.height * node.dataIndexes.length};
            }
            return {width: NodeSize.width, height: NodeSize.height};
          }
        }}
        nodeSvgShape={{ shape: 'circle', shapeProps: {r: 5} }}
        nodeSize={{x: NodeSize.width, y: NodeSize.height}}
        collapsible={false}
        separation={(a, b) => {
          if (b.dataIndexes && b.dataIndexes.length) {
            return b.dataIndexes.length + 0.3;
          }
          return 1.5;
        }}
        depthFactor={({ node }) => {
          // if (node.parent && node.parent.height) {
          //   return node.parent.height;
          // }
          return 150;
        }}
      />

Result

image

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.2%) to 94.524% when pulling 68ecdc4 on defghy:develop into 1306492 on bkrem:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.2%) to 94.524% when pulling 68ecdc4 on defghy:develop into 1306492 on bkrem:master.

@kkyang63
Copy link

    // nodeSize={{ x: dimensions.width / maxLevel, y: 100 }}
      // separation={(a, b) => {
      //   console.log(a, b);
      //   if (b.dataIndexes && b.dataIndexes.length) {
      //     return b.dataIndexes.length + 0.3;
      //   }
      //   return 1.5;
      // }}  我这样设置直接就报错了  

貌似不支持这种方式 3.6.2 版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants