Skip to content

[FEATURE]: Add Bottom-Up and Right-Left Sankey Diagram Option #7865

Description

@wf-r

Summary

Sankey supports orientation: 'h' and 'v'. 'h' always runs left→right and 'v' always runs top-down, so there is no way to render a flow that builds up (sources at the bottom) or runs right→left. Both are common conventions and currently impossible.

Proposed change

Extend orientation with four explicit, direction-named values while keeping the existing values as synonyms:

  • left-right — sources left, flow rightward (synonym of the legacy h)
  • right-left — sources right, flow leftward (new)
  • top-down — sources top, flow downward (synonym of the legacy v)
  • bottom-up — sources bottom, flow upward (new)

h/v keep working; default stays h.

The vertical/horizontal layout is already produced by transposing the horizontal layout via a single group-level SVG transform in sankeyTransform(). The two new directions are mirrors of the existing ones, each expressible as one matrix + translate:

  • right-leftmatrix(-1 0 0 1 0 0), translateX += width (horizontal mirror of left-right)
  • bottom-upmatrix(0 -1 1 0 0 0), translateY += height (vertical mirror of top-down)

Touched files:

  • attributes.js — extend the orientation enum + description.
  • render.js — adjust orientation flags, sankeyTransform and label flipText / text-anchor
  • plot.js — adjust link-hover positioning

Backward compatibility

Existing figures using 'v'/'h' render identically; only additive enum values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions