Repository navigation
Conversation
|
If you are interested in this please let me know. #7870 was just merged into |
|
@wf-r go for it. You'll need to change the target branch to v4.0. |
I think I am not allowed to do it (or I don't find the option). Can you do this, please? |
|
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.
|
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.
|
|
I'm back, sorry I was busy with other work.
You are right,
Sankey nodes and links do a while the link label just does So if we e.g. filter links we get a slightly different behaviour between link label and link itself. |
|
This got closed by accident! I still want to get the work merged, but the v4.0 branch got deleted and now I can't change the base branch of the PR. I'll see if there's another way to get this open again. |
|
@wf-r are you still interested in finishing this PR? |
Yes, very much so. My last status was that it is ready for review (yet this was 3 months ago, so orobably an update to the current state of main would be in order). |
|
Ah, my comments never got added. I now see they all say pending. Sorry about that! I'll get my review fixed up and post an update. |
# Conflicts: # src/traces/sankey/constants.js
camdecoster
left a comment
There was a problem hiding this comment.
This is a good start. Could you please make a few changes?
…ix, node-object templates, arrow-body anchor, exit fade-out
Done. Please have a look at it |
Add labels on sankey links
What
Adds persistent, always-visible text labels to Sankey links, analogous to the existing node
labels. Four new attributes under
link:link.textinfo"label","value","none"link.texttemplatetextinfowhen setlink.texttemplatefallbacktexttemplateproduces empty outputlink.textfontValue formatting uses the trace-level
valueformatandvaluesuffixattributes.Why
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. Straight links centre on the arrow body: when
arrows are shown, the arrow head is excluded from the span, clamped exactly like the drawn
path. Vertical centering uses the same block metric as the node labels, so the whole text block
is centred on the anchor.
Template rendering follows the established
funnel/piepattern viaLib.texttemplateString.Available template variables:
%{label},%{value},%{valueLabel}(formatted value +suffix),
%{source}and%{target}(full node objects, e.g.%{source.label}),%{customdata},%{meta}.Removed labels fade out with the same transition as the links.
Backward compatibility
Fully backward compatible. All new attributes default to
textinfo: 'none'/texttemplate: '', so existing figures render identically. Thesankey_circular/sankey_circular_with_arrowsmock families now setlink.textinfo: "value", and their imagebaselines were regenerated to cover the new label rendering.
Related