Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bda00d3

Browse files
committed
introduce layout attribute uid to provide deterministic identifiers
1 parent 6a8ac65 commit bda00d3

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3735,7 +3735,7 @@ function makePlotFramework(gd) {
37353735
d3.selectAll('defs').each(function() {
37363736
if(this.id) otherUids[this.id.split('-')[1]] = 1;
37373737
});
3738-
fullLayout._uid = Lib.randstr(otherUids);
3738+
fullLayout._uid = fullLayout.uid || Lib.randstr(otherUids);
37393739
}
37403740

37413741
fullLayout._paperdiv.selectAll('.main-svg')

src/plots/layout_attributes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,15 @@ module.exports = {
460460
'%{meta[key]}.'
461461
].join(' ')
462462
},
463-
463+
uid: {
464+
valType: 'string',
465+
role: 'info',
466+
editType: 'plot',
467+
description: [
468+
'Assign an id to this layout,',
469+
'Use this to provide deterministic identifiers within that figure.'
470+
].join(' ')
471+
},
464472
transition: extendFlat({}, animationAttrs.transition, {
465473
description: [
466474
'Sets transition options used during Plotly.react updates.'

src/plots/plots.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
15241524
coerce('modebar.uirevision', uirevision);
15251525

15261526
coerce('meta');
1527+
coerce('uid');
15271528

15281529
// do not include defaults in fullLayout when users do not set transition
15291530
if(Lib.isPlainObject(layoutIn.transition)) {

0 commit comments

Comments
 (0)