chuckzel / cytoscape-tidytree

A Cytoscape.js layout extension for trees
https://chuckzel.github.io/cytoscape-tidytree/
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Support for different directions of the layout #3

Closed michalhabala closed 2 months ago

michalhabala commented 5 months ago

Would it be possible to add support for different layout directions? Typically, users want the resulting tree to be oriented left-right or top-down, and I don't see any option to change the direction like in the other tree layouts in Cytoscape. Thank you.

daemontus commented 5 months ago

Hi! Thank you for the suggestion! This is certainly something we are considering.

@chuckzel, will you have time to look at this, or should I try to address it?

chuckzel commented 5 months ago

I will add support for this in the coming weeks. If you need the functionality sooner, it is possible to use sizeGetter and transform options for this. For example, these options result in a left-right layout:

 opts: {
    sizeGetter: (n) => {
        const dims = n.layoutDimensions();
        return { w: dims.h, h: dims.w };
    },
    transform: (n, pos) => ({ x: pos.y, y: pos.x })
 }
daemontus commented 5 months ago

Awesome, thank you!

michalhabala commented 5 months ago

Thank you very much! We are okay with waiting a few weeks for this feature. Thanks for this great layout; we can't wait to include it in our app.

chuckzel commented 2 months ago

Sorry for the longer wait, direction option is now added in 0.2.0

direction: "LR" | "RL" | "TB" | "BT" = "TB";  // the direction of the tree, left to right, right to left, top to bottom, bottom to top
daemontus commented 2 months ago

Awesome! Thank you very much. I was rather occupied with other projects, so I'm glad you had time to look into this :)