Skip to content

sankey separators #2894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
8 changes: 5 additions & 3 deletions lib/locales/it.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
'q1:': 'q1:', // traces/box/calc.js:130
'q3:': 'q3:', // traces/box/calc.js:131
'source:': 'sorgente:', // traces/sankey/plot.js:140
'target:': 'target:', // traces/sankey/plot.js:141
'target:': 'destinazione:', // traces/sankey/plot.js:141
'max:': 'max.:', // traces/box/calc.js:132
'mean ± σ:': 'media ± σ:', // traces/box/calc.js:133
'mean:': 'media:', // traces/box/calc.js:133
Expand All @@ -67,8 +67,8 @@ module.exports = {
'high:': 'alto:', // traces/ohlc/transform.js:137
'kde:': 'kde:', // traces/violin/calc.js:73
'low:': 'basso:', // traces/ohlc/transform.js:138
'incoming flow count:': 'Flusso in entrata:', // traces/sankey/plot.js:142
'outgoing flow count:': 'Flusso in uscita:', // traces/sankey/plot.js:143
'incoming flow count:': 'Flussi in entrata:', // traces/sankey/plot.js:142
'outgoing flow count:': 'Flussi in uscita:', // traces/sankey/plot.js:143
'Toggle show closest data on hover': 'Abilita mostra i dati più vicini al passaggio del mouse', // components/modebar/buttons.js:353
},
format: {
Expand All @@ -85,6 +85,8 @@ module.exports = {
'Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu',
'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'
],
decimal: ',',
thousands: '.',
date: '%d/%m/%Y'
}
};
2 changes: 1 addition & 1 deletion src/lib/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ lib.numSeparate = function(value, separators, separatethousands) {
x2 = x.length > 1 ? decimalSep + x[1] : '';

// Years are ignored for thousands separators
if(thouSep && (x.length > 1 || x1.length > 4 || separatethousands)) {
if(thouSep && x.length > 1 && separatethousands) {
while(thousandsRe.test(x1)) {
x1 = x1.replace(thousandsRe, '$1' + thouSep + '$2');
}
Expand Down
10 changes: 10 additions & 0 deletions src/traces/sankey/attributes.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ module.exports = overrideAll({
].join(' ')
},

separatethousands: {
valType: 'boolean',
dflt: false,
role: 'style',
editType: 'calc',
description: [
'If "true", even 4-digit integers are separated'
].join(' ')
},

arrangement: {
valType: 'enumerated',
values: ['snap', 'perpendicular', 'freeform', 'fixed'],
Expand Down
1 change: 1 addition & 0 deletions src/traces/sankey/defaults.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('orientation');
coerce('valueformat');
coerce('valuesuffix');
coerce('separatethousands');
coerce('arrangement');

Lib.coerceFont(coerce, 'textfont', Lib.extendFlat({}, layout.font));
Expand Down
4 changes: 2 additions & 2 deletions src/traces/sankey/plot.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module.exports = function plot(gd, calcData) {
var tooltip = Fx.loneHover({
x: hoverCenterX - rootBBox.left,
y: hoverCenterY - rootBBox.top,
name: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix,
name: Lib.numSeparate(d3.format(d.valueFormat)(d.link.value),gd._fullLayout.separators,d.separatethousands) + d.valueSuffix,
text: [
d.link.label || '',
sourceLabel + d.link.source.label,
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports = function plot(gd, calcData) {
x0: hoverCenterX0,
x1: hoverCenterX1,
y: hoverCenterY,
name: d3.format(d.valueFormat)(d.node.value) + d.valueSuffix,
name: Lib.numSeparate(d3.format(d.valueFormat)(d.node.value),gd._fullLayout.separators,d.separatethousands) + d.valueSuffix,
text: [
d.node.label,
incomingLabel + d.node.targetLinks.length,
Expand Down
4 changes: 4 additions & 0 deletions src/traces/sankey/render.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function sankeyModel(layout, d, traceIndex) {
var linkLineWidth = trace.link.line.width;
var valueFormat = trace.valueformat;
var valueSuffix = trace.valuesuffix;
var separatethousands = trace.separatethousands;
var textFont = trace.textfont;

var width = layout.width * (domain.x[1] - domain.x[0]);
Expand Down Expand Up @@ -171,6 +172,7 @@ function sankeyModel(layout, d, traceIndex) {
linkLineWidth: linkLineWidth,
valueFormat: valueFormat,
valueSuffix: valueSuffix,
separatethousands: separatethousands,
textFont: textFont,
translateX: domain.x[0] * width + layout.margin.l,
translateY: layout.height - domain.y[1] * layout.height + layout.margin.t,
Expand Down Expand Up @@ -209,6 +211,7 @@ function linkModel(uniqueKeys, d, l) {
linkLineWidth: d.linkLineWidth,
valueFormat: d.valueFormat,
valueSuffix: d.valueSuffix,
separatethousands: d.separatethousands,
sankey: d.sankey,
interactionState: d.interactionState
};
Expand Down Expand Up @@ -255,6 +258,7 @@ function nodeModel(uniqueKeys, d, n) {
tinyColorAlpha: tc.getAlpha(),
valueFormat: d.valueFormat,
valueSuffix: d.valueSuffix,
separatethousands: d.separatethousands,
sankey: d.sankey,
arrangement: d.arrangement,
uniqueNodeLabelPathId: [d.guid, d.key, key].join(' '),
Expand Down