Giter VIP home page Giter VIP logo

Comments (3)

BenPortner avatar BenPortner commented on May 18, 2024

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.

djBirdman avatar djBirdman commented on May 18, 2024

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.

BenPortner avatar BenPortner commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.