Comments (9)
Awesome work @bkrem
but I decided to build my own tree
as I noticed I need to connect the lines to centers of the node etc 👍
from react-d3-tree.
Hey @dyennam,
Here's a relatively simple way you can achieve what I think you're looking for with foreignObjects by leveraging the nodeLabelComponent
, nodeSvgShape
and nodeSize
props:
https://codesandbox.io/s/zrw16nnxox
Note that I also moved the text you hardcoded in the card into each child's attributes
key. This let's you pass whatever you want from within your node's dataset into nodeLabelComponent
, since the component you use for nodeLabelComponent
's render will be passed the respective node's nodeData
as a prop :)
cc @tzookb, might be interesting for you too
from react-d3-tree.
Hi @tzookb,
Apologies for the wait. Removing the node element isn't actually possible right now, but I'll work on this later tonight or tomorrow since it should be possible to just pass none
to svgShape
.
That should then let you do what you suggested, although you'll most likely have to fiddle with the positioning/sizing of your boxes to make them align nicely with the graph.
from react-d3-tree.
Just released v1.9.1 with an option to set nodeSvgShape
's shape
key to 'none'
, meaning no svg shapes will be rendered for the nodes.
This should hopefully allow you to achieve what you were asking about :)
from react-d3-tree.
Hello @tzookb
Could you please give me an example of how you were able to build you tree with your boxes instead of the default nodes. I am trying to do a similar implementation where i want to override each node(CIRCLE) with like a bootstrap card element. But the cards i render are not getting attached at the node level, they are offset just like you mentioned in your original post.
@bkrem Any way we can have user interaction within foreignObjects? (Ex. clicking buttons inside nodes)
<Tree
data={myTreeData}
zoomable={true}
scaleExtent={{min: 1, max: 3}}
pathFunc='elbow'
allowForeignObjects={true}
nodeSvgShape={svgCircle}
translate={{x:200, y: 200}}
nodeLabelComponent={{
render:
<div>
<div className='card'>
<div className='card-body'>
<h5 className='card-title'>Card title</h5>
<h6 className='card-subtitle mb-2 text-muted'>Card subtitle</h6>
<p className='card-text'>Some text to build on the card.</p>
</div>
</div>
</div>,
foreignObjectWrapper: {
}
}}
/>
from react-d3-tree.
@bkrem Thanks for the example, helped me out a bunch.
But if I want to take actions on the cards without it having to collapse / expand, how would i go about it? Like i want to be able to add child/sibling nodes, or capture on click events in certain regions to show popups or such things. I want to collapse on a button click per say, instead of on the node.
I have attached a example: https://codesandbox.io/s/ypz7rp61z
from react-d3-tree.
@dyennam did you manage to figure this out?
from react-d3-tree.
@dyennam did you manage to figure this out?
@Ben-Tai I wasn't able to figure it out. But to be honest to the dev, I haven't used this library in 8+ months. So not sure if it has been fixed or not either.
from react-d3-tree.
Closing since the discussion here has drifted from the issue topic onto other feature proposals. Feel free to open a feature request issue for said proposals if relevant.
from react-d3-tree.
Related Issues (20)
- Is it possible to add Scroll bars to view the chart?
- draggable prop issue HOT 3
- [question] Default tree is not centered and nodes are cut off HOT 1
- LeafNode still not targeted correctly HOT 1
- Is there a way to open previous node on route back to page having react-d3-tree.im routing user to next page from react d3tree.
- Is there a search option available to open d3tree and show ?
- Cannot find a declaration file for module HOT 3
- How to use non-copyable objects as data?
- Getting error: selection2.interrupt is not a function at zoom.transform
- How to center a node HOT 1
- Safari: foreignobject render issue HOT 2
- Zoom and Drag not working on NextJS HOT 2
- How to center a node on from external event
- Tree not centering when using renderCustomNodeElement prop
- This is having older version of "@bkrem/react-transition-group": "^1.3.3", in package.json.
- How to restrict the drag area?
- Intersection bug
- Codesandbox examples not available HOT 2
- Can I change the key of children in data list from 'children' to be any key I want something like have props called valueKey or something like that , thanks
- Unable to install this package where I have react-native running on v0.74
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-d3-tree.