Add labels on sankey links - #7888
Open
wf-r wants to merge 11 commits into
Open
Conversation
Author
|
If you are interested in this please let me know. #7870 was just merged into |
Contributor
|
@wf-r go for it. You'll need to change the target branch to v4.0. |
wf-r
marked this pull request as draft
July 27, 2026 07:13
added 4 commits
July 27, 2026 09:16
Author
I think I am not allowed to do it (or I don't find the option). Can you do this, please? |
wf-r
marked this pull request as ready for review
July 27, 2026 08:09
Author
|
Please have a look at this. |
…ominant-baseline, use block-shift like node labels), thread _d3locale/_meta/fallback through texttemplateString, and dedupe the orientation counter-transform into a shared uprightTransform helper.Also make opted-out traces free of per-link work by short-circuiting linkTextGetter to null.
Author
|
I'm done for today. Things one could discuss:
|
… group (fixes z-order with entering link paths), thread the label selection through updateShapes/attachDragHandler/startForce instead of DOM-querying every drag frame, and build each link's model once via a shared linkModels cache instead of duplicating it for paths and labels; exiting labels now fade out like links, and per-link texttemplate lookups use pointNumber instead of the loop index. Also switch link.texttemplate to the shared texttemplateAttrs() helper for a standard description and %{meta} support. More details in draftlog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add permanent text labels to Sankey links
What
Adds persistent, always-visible text labels to Sankey links, analogous to the existing node
labels. Five new attributes under
link:link.textinfo"label","value","none"link.texttemplatetextinfowhen setlink.textfontlink.valueformatlink.valuesuffixWhy
Link information is currently hover-only, making Sankey diagrams unsuitable for static export
(PNG/SVG/print) wherever flow values or names need to be visible at all times. There is
long-standing community interest in this — see #4746.
External SVG overlays (the current workaround) are fragile: they break on node drags, require
timing hacks after layout transitions, and are excluded from
toImageexport. Native labelssolve all three problems.
How
Labels are rendered as real SVG
<text>elements inside the.sankeygroup, immediately afterthe link paths. This means:
handvlayouts with no extra handling.updateShapeshook — no separate drag listenerneeded.
toImage/PNG/SVG export — no overlay required.For circular (backward) links the label anchor reuses the same
circularPathDatamidpoint asthe hover label, so the position is consistent. Vertical centering on the anchor uses
dominant-baseline="central".Template rendering follows the established
funnel/piepattern viaLib.texttemplateString.Available template variables:
%{label},%{value},%{valueLabel}(formatted value +suffix),
%{source},%{target},%{customdata}.Backward compatibility
Fully backward compatible. All new attributes default to
textinfo: 'none'/texttemplate: '',so existing figures render identically. No existing tests or baselines are affected.
Related