Skip to content

Commit

Permalink
added suppport for different type of label placement in sankey
Browse files Browse the repository at this point in the history
  • Loading branch information
ishubin committed Feb 6, 2025
1 parent 55c0e38 commit 770df32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/templates/diagrams/sankey.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/templates/diagrams/sankey.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ args:
font: {group: "Labels & Text", type: font, value: Arial, name: Font}
fontSize: {group: "Labels & Text", type: number, value: 14, name: "Font size", min: 1}
magnify: {group: "Labels & Text", type: number, value: 0, name: "Magnify value", min: -50, max: 50}
labelPlacement: {group: "Labels & Text", type: choice, value: inside, options: ['inside', 'outside'], name: 'Label placement'}
conLabel: {group: "Labels & Text", type: boolean, value: true, name: 'Connection labels enabled', description: 'Displays the value of the connection'}
showLabelFill: {group: "Labels & Text", type: boolean, value: true, name: 'Show label fill'}
labelFill: {group: "Labels & Text", type: advanced-color, value: {type: solid, color: '#FCE6AC82'}, name: "Background", depends: {showLabelFill: true}}
Expand Down
8 changes: 7 additions & 1 deletion assets/templates/diagrams/src/sankey.sch
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,13 @@ func buildNodeLabels(nodes) {
local valueText = formatValue(node.value)
local valueTextSize = calculateTextSize(valueText, font, valueFontSize)
local totalHeight = if (showNodeValues) { (textHeight + valueTextSize.h)*1.8 + 8 } else { textHeight*1.8 + 8 }
local isLeft = node.dstNodes.size == 0
local isLeft = true
if (labelPlacement == 'outside') {
isLeft = ((node.level + 1) / max(1, levels.size) <= 0.5)
} else {
isLeft = (node.dstNodes.size == 0)
}

local halign = 'right'
if (!isLeft) {
halign = 'left'
Expand Down

0 comments on commit 770df32

Please sign in to comment.