Comments (3)
Hi @djBirdman,
thanks for using js_family_tree
. The proposals you make to improve the ordering of the nodes seem promising. Unfortunately, I did not have time to play around with the settings yet to achieve this. In fact, I would be thankful for your help! Under the hood, js_family_tree uses d3-dag
's sugiyama
layout to position nodes. You can find it's documentation here. The behavior you are describing should be achievable by manipulating the decross
and coord
properties with appropriate operators. Unfortunately, I cannot help you beyond this point, because this is also how far my knowledge of d3-dag
goes ;) Keep me updated if you make any progress here. Maybe we can crack this nut together.
Thanks.
Ben
from js_family_tree.
Looking at the sugiyama docs, my understanding is that you're already using the correct coord accessor, and while decross can change the order of the layer, it's doing so to decross the graph edges and not to specifically order each layer. I noticed that d3-hierarchy
has nodes.sort()
that might be the right thing, but d3-dag does not.
What I have done is to work out the order and manually update the x-position of the nodes. First I added unionyear
in the union data; then within update()
iterate over all visible nodes to work out a sort order based on both birthyear
and unionyear
and record the current node x-positions; I then re-order the x-positions using the calculated order. For partners that union into the family, I use their partner's sort order. For children I also take into account their parent's order, and by iterating top-down this sorting works for all descendants.
This works for my purpose, but realise it's a bit of a rough hack: I'm happy to share my additions if you're OK with the way I've done it. Will try and tidy it up a bit, comment etc. and also throw a bit more test data at it over the weekend.
from js_family_tree.
Hi @djBirdman,
Thank you for looking into this! I am glad to hear that you managed to achieve the desired behavior and would be very interested in seeing the associated code :) Is it on your GitHub fork?
Thanks!
Ben
from js_family_tree.
Related Issues (10)
- Guide to Insert|Delete|Update node HOT 2
- Can it be used in a react or vue framework? HOT 3
- Formatting options for family tree usage HOT 1
- "Maximum call stack exceeded" error HOT 8
- tooltip_div blocks mouse events from underlying nodes when faded out by opacity HOT 1
- Rendering Issue when Clicking Rapidly HOT 1
- Cannot set property 'points' of undefined HOT 7
- advice for dynamic data HOT 7
- Making a vertical family tree HOT 2
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 js_family_tree.