Skip to content

Commit 51a28f9

Browse files
committed
use overrideAll in newshape and fix bundling issue
1 parent d3004c1 commit 51a28f9

File tree

2 files changed

+11
-42
lines changed

2 files changed

+11
-42
lines changed

src/components/shapes/draw_newshape/attributes.js

+9-39
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
'use strict';
22

3+
var overrideAll = require('../../../plot_api/edit_types').overrideAll;
34
var basePlotAttributes = require('../../../plots/attributes');
45
var fontAttrs = require('../../../plots/font_attributes');
56
var dash = require('../../drawing/attributes').dash;
67
var extendFlat = require('../../../lib/extend').extendFlat;
78
var shapeTexttemplateAttrs = require('../../../plots/template_attributes').shapeTexttemplateAttrs;
89
var shapeLabelTexttemplateVars = require('../label_texttemplate');
910

10-
11-
module.exports = {
11+
module.exports = overrideAll({
1212
newshape: {
1313
visible: extendFlat({}, basePlotAttributes.visible, {
14-
editType: 'none',
1514
description: [
1615
'Determines whether or not new shape is visible.',
1716
'If *legendonly*, the shape is not drawn,',
@@ -23,15 +22,13 @@ module.exports = {
2322
showlegend: {
2423
valType: 'boolean',
2524
dflt: false,
26-
editType: 'none',
2725
description: [
2826
'Determines whether or not new',
2927
'shape is shown in the legend.'
3028
].join(' ')
3129
},
3230

3331
legend: extendFlat({}, basePlotAttributes.legend, {
34-
editType: 'none',
3532
description: [
3633
'Sets the reference to a legend to show new shape in.',
3734
'References to these legends are *legend*, *legend2*, *legend3*, etc.',
@@ -41,7 +38,6 @@ module.exports = {
4138
}),
4239

4340
legendgroup: extendFlat({}, basePlotAttributes.legendgroup, {
44-
editType: 'none',
4541
description: [
4642
'Sets the legend group for new shape.',
4743
'Traces and shapes part of the same legend group hide/show at the same time',
@@ -51,19 +47,15 @@ module.exports = {
5147

5248
legendgrouptitle: {
5349
text: extendFlat({}, basePlotAttributes.legendgrouptitle.text, {
54-
editType: 'none'
5550
}),
5651
font: fontAttrs({
57-
editType: 'none',
5852
description: [
5953
'Sets this legend group\'s title font.'
6054
].join(' '),
61-
}),
62-
editType: 'none',
55+
})
6356
},
6457

6558
legendrank: extendFlat({}, basePlotAttributes.legendrank, {
66-
editType: 'none',
6759
description: [
6860
'Sets the legend rank for new shape.',
6961
'Items and groups with smaller ranks are presented on top/left side while',
@@ -75,14 +67,12 @@ module.exports = {
7567
}),
7668

7769
legendwidth: extendFlat({}, basePlotAttributes.legendwidth, {
78-
editType: 'none',
7970
description: 'Sets the width (in px or fraction) of the legend for new shape.',
8071
}),
8172

8273
line: {
8374
color: {
8475
valType: 'color',
85-
editType: 'none',
8676
description: [
8777
'Sets the line color.',
8878
'By default uses either dark grey or white',
@@ -93,19 +83,15 @@ module.exports = {
9383
valType: 'number',
9484
min: 0,
9585
dflt: 4,
96-
editType: 'none',
9786
description: 'Sets the line width (in px).'
9887
},
9988
dash: extendFlat({}, dash, {
10089
dflt: 'solid',
101-
editType: 'none'
102-
}),
103-
editType: 'none'
90+
})
10491
},
10592
fillcolor: {
10693
valType: 'color',
10794
dflt: 'rgba(0,0,0,0)',
108-
editType: 'none',
10995
description: [
11096
'Sets the color filling new shapes\' interior.',
11197
'Please note that if using a fillcolor with alpha greater than half,',
@@ -117,7 +103,6 @@ module.exports = {
117103
valType: 'enumerated',
118104
values: ['evenodd', 'nonzero'],
119105
dflt: 'evenodd',
120-
editType: 'none',
121106
description: [
122107
'Determines the path\'s interior.',
123108
'For more info please visit https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule'
@@ -128,21 +113,18 @@ module.exports = {
128113
min: 0,
129114
max: 1,
130115
dflt: 1,
131-
editType: 'none',
132116
description: 'Sets the opacity of new shapes.'
133117
},
134118
layer: {
135119
valType: 'enumerated',
136120
values: ['below', 'above'],
137121
dflt: 'above',
138-
editType: 'none',
139122
description: 'Specifies whether new shapes are drawn below or above traces.'
140123
},
141124
drawdirection: {
142125
valType: 'enumerated',
143126
values: ['ortho', 'horizontal', 'vertical', 'diagonal'],
144127
dflt: 'diagonal',
145-
editType: 'none',
146128
description: [
147129
'When `dragmode` is set to *drawrect*, *drawline* or *drawcircle*',
148130
'this limits the drag to be horizontal, vertical or diagonal.',
@@ -156,12 +138,10 @@ module.exports = {
156138
text: {
157139
valType: 'string',
158140
dflt: '',
159-
editType: 'none',
160141
description: 'Sets the text to display with the new shape.'
161142
},
162-
texttemplate: shapeTexttemplateAttrs({newshape: true, editType: 'none'}, {keys: Object.keys(shapeLabelTexttemplateVars)}),
143+
texttemplate: shapeTexttemplateAttrs({newshape: true}, {keys: Object.keys(shapeLabelTexttemplateVars)}),
163144
font: fontAttrs({
164-
editType: 'none',
165145
description: 'Sets the new shape label text font.'
166146
}),
167147
textposition: {
@@ -172,7 +152,6 @@ module.exports = {
172152
'bottom left', 'bottom center', 'bottom right',
173153
'start', 'middle', 'end',
174154
],
175-
editType: 'none',
176155
description: [
177156
'Sets the position of the label text relative to the new shape.',
178157
'Supported values for rectangles, circles and paths are',
@@ -186,7 +165,6 @@ module.exports = {
186165
textangle: {
187166
valType: 'angle',
188167
dflt: 'auto',
189-
editType: 'none',
190168
description: [
191169
'Sets the angle at which the label text is drawn',
192170
'with respect to the horizontal. For lines, angle *auto*',
@@ -198,7 +176,6 @@ module.exports = {
198176
valType: 'enumerated',
199177
values: ['auto', 'left', 'center', 'right'],
200178
dflt: 'auto',
201-
editType: 'none',
202179
description: [
203180
'Sets the label\'s horizontal position anchor',
204181
'This anchor binds the specified `textposition` to the *left*, *center*',
@@ -212,7 +189,6 @@ module.exports = {
212189
yanchor: {
213190
valType: 'enumerated',
214191
values: ['top', 'middle', 'bottom'],
215-
editType: 'none',
216192
description: [
217193
'Sets the label\'s vertical position anchor',
218194
'This anchor binds the specified `textposition` to the *top*, *middle*',
@@ -227,29 +203,23 @@ module.exports = {
227203
valType: 'number',
228204
dflt: 3,
229205
min: 0,
230-
editType: 'none',
231206
description: 'Sets padding (in px) between edge of label and edge of new shape.'
232-
},
233-
editType: 'none'
234-
},
235-
editType: 'none'
207+
}
208+
}
236209
},
237210

238211
activeshape: {
239212
fillcolor: {
240213
valType: 'color',
241214
dflt: 'rgb(255,0,255)',
242-
editType: 'none',
243215
description: 'Sets the color filling the active shape\' interior.'
244216
},
245217
opacity: {
246218
valType: 'number',
247219
min: 0,
248220
max: 1,
249221
dflt: 0.5,
250-
editType: 'none',
251222
description: 'Sets the opacity of the active shape.'
252-
},
253-
editType: 'none'
223+
}
254224
}
255-
};
225+
}, 'none', 'from-root');

src/plot_api/edit_types.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
var Lib = require('../lib');
4-
var extendFlat = Lib.extendFlat;
5-
var isPlainObject = Lib.isPlainObject;
3+
var extendFlat = require('../lib/extend').extendFlat;
4+
var isPlainObject = require('../lib/is_plain_object');
65

76
var traceOpts = {
87
valType: 'flaglist',

0 commit comments

Comments
 (0)