Skip to content

Commit c20370a

Browse files
committed
merge shapes/defaults.js
2 parents d9bef04 + dfb608e commit c20370a

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

src/components/shapes/defaults.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,19 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
136136
// Label options
137137
coerce('label.text');
138138
coerce('label.textangle', shapeType === 'line' ? 'auto' : 0);
139+
<<<<<<< HEAD
139140
var labelTextPosition = coerce(
140141
'label.textposition',
141142
shapeType === 'line' ? 'middle' : 'middle center'
142143
);
143144
coerce('label.xanchor');
144145
// Default yanchor value depends on shape type and label textposition
145146
coerce('label.yanchor', dfltLabelYanchor(shapeType, labelTextPosition));
147+
=======
148+
coerce('label.textposition', shapeType === 'line' ? 'middle' : 'middle center');
149+
coerce('label.xanchor');
150+
coerce('label.yanchor');
151+
>>>>>>> dfb608eb8a3a7a139b2f418edbc9e74c96782091
146152
coerce('label.padding');
147153
Lib.coerceFont(coerce, 'label.font', fullLayout.font);
148154
}

src/components/shapes/draw_newshape/attributes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ module.exports = {
8383
text: {
8484
valType: 'string',
8585
dflt: '',
86+
editType: 'none',
8687
description: 'Sets the text to display with shape.'
8788
},
8889
font: fontAttrs({
89-
editType: 'calc+arraydraw',
90+
editType: 'none',
9091
description: 'Sets the shape label text font.'
9192
}),
9293
textposition: {
@@ -97,6 +98,7 @@ module.exports = {
9798
'bottom left', 'bottom center', 'bottom right',
9899
'start', 'middle', 'end',
99100
],
101+
editType: 'none',
100102
description: 'Sets the position of the label text relative to the shape.'
101103
},
102104
textangle: {

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
};

src/components/shapes/draw_newshape/newshapes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ module.exports = function newShapes(outlines, dragOptions) {
7777
var newShape = {
7878
editable: true,
7979

80+
label: newStyle.label,
81+
8082
xref: xPaper ? 'paper' : xaxis._id,
8183
yref: yPaper ? 'paper' : yaxis._id,
8284

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,

test/plot-schema.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,21 +3577,21 @@
35773577
"editType": "none",
35783578
"font": {
35793579
"color": {
3580-
"editType": "calc+arraydraw",
3580+
"editType": "none",
35813581
"valType": "color"
35823582
},
35833583
"description": "Sets the shape label text font.",
3584-
"editType": "calc+arraydraw",
3584+
"editType": "none",
35853585
"family": {
35863586
"description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.",
3587-
"editType": "calc+arraydraw",
3587+
"editType": "none",
35883588
"noBlank": true,
35893589
"strict": true,
35903590
"valType": "string"
35913591
},
35923592
"role": "object",
35933593
"size": {
3594-
"editType": "calc+arraydraw",
3594+
"editType": "none",
35953595
"min": 1,
35963596
"valType": "number"
35973597
}
@@ -3606,6 +3606,7 @@
36063606
"text": {
36073607
"description": "Sets the text to display with shape.",
36083608
"dflt": "",
3609+
"editType": "none",
36093610
"valType": "string"
36103611
},
36113612
"textangle": {
@@ -3615,6 +3616,7 @@
36153616
},
36163617
"textposition": {
36173618
"description": "Sets the position of the label text relative to the shape.",
3619+
"editType": "none",
36183620
"valType": "enumerated",
36193621
"values": [
36203622
"top left",

0 commit comments

Comments
 (0)