Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple orientations? #55

Open
limzgiser opened this issue Apr 24, 2018 · 11 comments
Open

Support multiple orientations? #55

limzgiser opened this issue Apr 24, 2018 · 11 comments

Comments

@limzgiser
Copy link

No description provided.

@curran
Copy link

curran commented Apr 24, 2018

Seems out of scope for the library. You can center the container vertically.

Can you provide any more details? Or a working example where you'd like centering?

@limzgiser limzgiser reopened this Apr 26, 2018
@limzgiser
Copy link
Author

Thank you for your answer.

The value attribute of link array's item is set to 1.

The result like this image. https://pan.baidu.com/s/1XDIRTNsB0I7CfbLzLruqEA

Can the nodes be centered in the y direction?

@leonardfischer
Copy link

@curran I think @limzgiser is asking for a option to display an vertical sankey diagram (But I'm not sure since his image won't load)... I'm building one for a project by simply swapping x and y values, but it's a bit tedious and makes the code hard to read / understand.

Also d3-sankey does not implement a sankeyLinkVertical, which I built myself using

function sankeyLinkVertical () {
    return d3.linkVertical()
        .source(function(d) { return [d.y0, d.source.x1]; })
        .target(function(d) { return [d.y1, d.target.x0]; });
}

(Again: swapping x and y)

@mbostock
Copy link
Member

mbostock commented Sep 1, 2019

Yep, you can swap x and y to change the orientation of the Sankey diagram. That said it might be nice for the Sankey diagram to support orientations similar to d3/d3-hierarchy#63, so I’ll re-interpret this issue as that.

If you want the nodes to be centered vertically within their columns, that’s not currently supported, but I expect you could just move the nodes into the middle manually by computing the total column size and then the desired node positions.

@mbostock mbostock changed the title Can you center it vertically? Support multiple orientations? Sep 1, 2019
@jayaddison
Copy link

@mbostock @curran do you have any thoughts on the vertical orientation approach offered in #71 ?

@curran
Copy link

curran commented Jan 15, 2020

Reviewed the PR at a high level. Generally looks good!

@jayaddison
Copy link

Thanks @curran !

@mbostock
Copy link
Member

Related d3/d3-hierarchy#63.

I think I’d follow the approach there (and in d3-axis) and have aliases for the different orientations d3.sankeyUp, d3.sankeyDown, d3.sankeyLeft, d3.sankeyRight with the default d3.sankey = d3.sankeyRight.

But, I’m a little busy right now with other stuff so I don’t know when I’ll get a chance to review this.

@jayaddison
Copy link

@mbostock Great, that makes sense. I've implemented only two orientations (d3.sankeyHorizontal and d3.sankeyVertical) so far but the bottom-to-top and right-to-left use cases do make sense too. I'll add support for those (and update the orientation names) in the PR at some point soon.

@jayaddison
Copy link

jayaddison commented Sep 10, 2020

@mbostock @curran Rendering for each of the four cardinal directions is now available in #71 #110; these are provisionally exported as orientLeft, orientRight by the library since there is currently a naming conflict with existing exports for sankeyLeft, sankeyRight, ... (these relate to node alignment within the graph, rather than the rendering orientation of the overall diagram).

It's not the most elegant implementation and relies on some conditional behaviour -- for bottom-to-top rendering in particular -- and I'd welcome any suggestions for improvements.

@Spenhouet
Copy link

@jayaddison Nice work. Wondering when this will be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants