jpb12/react-tree-graph

Color leaf in diffrent color

Closed this issue · 6 comments

Can I color some nodes in the tree? Set only the leaf to red, for example.

Thanks for the super fast response @jpb12 !. I try to set the leaves in a different className and see it is working.
However, the rest of the nodes get undefined for their className. shouldn't the default className suppose to be applied?

jpb12 commented

Can you share the relevant code?

Here is my animatedTree:

<AnimatedTree
      data={root}
      height={props.height * 0.95}
      width={props.width}
      keyProp="id"
      gProps={{
	      className: 'node',
	      onClick: handleClick
      }}
      pathProps={{
	      className: 'path link'
      }}
      textProps={{
	      dy: 3.5
      }}
      steps={30}/>

To set the root in red, for example, I would do the following

root.gProps = {className: 'redNode'}

As a result, onClick will not work on the root node, but will work on the rest.

Moreover, I encounter this example, but it is not working.

jpb12 commented

Should be fixed in 8.0.1

Thank you so much for the super fast release @jpb12 . Tested 8.0.1 and it works!