Skip to content

Commit bd525ea

Browse files
committed
Add Sankey node align property
1 parent 33dc2de commit bd525ea

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

src/traces/sankey/attributes.js

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ var attrs = module.exports = overrideAll({
164164
description: 'Variables `sourceLinks` and `targetLinks` are arrays of link objects.',
165165
keys: ['value', 'label']
166166
}),
167+
align: {
168+
valType: 'enumerated',
169+
values: ['justify', 'left', 'right', 'center'],
170+
dflt: 'justify',
171+
description: 'Sets the alignment method used to position the nodes along the horizontal axis.'
172+
},
167173
description: 'The nodes of the Sankey plot.'
168174
},
169175

src/traces/sankey/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3434
coerceNode('hoverinfo', traceIn.hoverinfo);
3535
handleHoverLabelDefaults(nodeIn, nodeOut, coerceNode, hoverlabelDefault);
3636
coerceNode('hovertemplate');
37+
coerceNode('align');
3738

3839
var colors = layout.colorway;
3940

src/traces/sankey/render.js

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ function sankeyModel(layout, d, traceIndex) {
3535
var horizontal = trace.orientation === 'h';
3636
var nodePad = trace.node.pad;
3737
var nodeThickness = trace.node.thickness;
38+
var nodeAlign = {
39+
'justify': d3Sankey.sankeyJustify,
40+
'left': d3Sankey.sankeyLeft,
41+
'right': d3Sankey.sankeyRight,
42+
'center': d3Sankey.sankeyCenter
43+
}[trace.node.align];
3844

3945
var width = layout.width * (domain.x[1] - domain.x[0]);
4046
var height = layout.height * (domain.y[1] - domain.y[0]);
@@ -61,6 +67,7 @@ function sankeyModel(layout, d, traceIndex) {
6167
.nodeId(function(d) {
6268
return d.pointNumber;
6369
})
70+
.nodeAlign(nodeAlign)
6471
.nodes(nodes)
6572
.links(links);
6673

test/plot-schema.json

+12
Original file line numberDiff line numberDiff line change
@@ -44358,6 +44358,18 @@
4435844358
"valType": "string"
4435944359
},
4436044360
"node": {
44361+
"align": {
44362+
"description": "Sets the alignment method used to position the nodes along the horizontal axis.",
44363+
"dflt": "justify",
44364+
"editType": "calc",
44365+
"valType": "enumerated",
44366+
"values": [
44367+
"justify",
44368+
"left",
44369+
"right",
44370+
"center"
44371+
]
44372+
},
4436144373
"color": {
4436244374
"arrayOk": true,
4436344375
"description": "Sets the `node` color. It can be a single value, or an array for specifying color for each `node`. If `node.color` is omitted, then the default `Plotly` color palette will be cycled through to have a variety of colors. These defaults are not fully opaque, to allow some visibility of what is beneath the node.",

0 commit comments

Comments
 (0)