Skip to content

Commit f54f102

Browse files
committed
input newshape label attributes
1 parent e493873 commit f54f102

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/components/shapes/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
119119

120120
// Label options
121121
coerce('label.text');
122-
coerce('label.xanchor');
123-
coerce('label.yanchor');
124122
coerce('label.textangle', shapeType === 'line' ? 'auto' : 0);
125123
coerce('label.textposition', shapeType === 'line' ? 'middle' : 'middle center');
124+
coerce('label.xanchor');
125+
coerce('label.yanchor');
126126
coerce('label.padding');
127127
Lib.coerceFont(coerce, 'label.font', fullLayout.font);
128128
}

src/components/shapes/draw_newshape/defaults.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var Color = require('../../color');
4-
4+
var Lib = require('../../../lib');
55

66
module.exports = function supplyDrawNewShapeDefaults(layoutIn, layoutOut, coerce) {
77
coerce('newshape.drawdirection');
@@ -16,6 +16,15 @@ module.exports = function supplyDrawNewShapeDefaults(layoutIn, layoutOut, coerce
1616
coerce('newshape.line.dash');
1717
}
1818

19+
var isLine = layoutIn.dragmode === 'drawline';
20+
coerce('newshape.label.text');
21+
coerce('newshape.label.textangle', isLine ? 'auto' : 0);
22+
coerce('newshape.label.textposition', isLine ? 'middle' : 'middle center');
23+
coerce('newshape.label.xanchor');
24+
coerce('newshape.label.yanchor');
25+
coerce('newshape.label.padding');
26+
Lib.coerceFont(coerce, 'newshape.label.font', layoutOut.font);
27+
1928
coerce('activeshape.fillcolor');
2029
coerce('activeshape.opacity');
2130
};

test/image/mocks/zz-text_on_shapes_reversed_axes.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@
119119
"fillcolor": "yellow",
120120
"path": "M300,70C300,10 380,10 380,70C380,90 300,90 300,70ZM320,60C320,50 332,50 332,60ZM348,60C348,50 360,50 360,60ZM320,70C326,80 354,80 360,70Z"
121121
}
122-
]
122+
],
123+
"dragmode": "drawline",
124+
"newshape": {
125+
"label": {
126+
"text": "TEXT"
127+
}
128+
}
123129
},
124130
"config": {
125131
"editable": false,

0 commit comments

Comments
 (0)