Skip to content

Commit e980e44

Browse files
committed
Linting/formatting
1 parent d86b977 commit e980e44

File tree

101 files changed

+11769
-9849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+11769
-9849
lines changed

src/components/drawing/index.js

Lines changed: 536 additions & 462 deletions
Large diffs are not rendered by default.

src/components/fx/hover.js

Lines changed: 611 additions & 498 deletions
Large diffs are not rendered by default.

src/components/shapes/attributes.js

Lines changed: 43 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ module.exports = templatedArray('shape', {
2626
valType: 'boolean',
2727
dflt: false,
2828
editType: 'calc+arraydraw',
29-
description: [
30-
'Determines whether or not this',
31-
'shape is shown in the legend.'
32-
].join(' ')
29+
description: ['Determines whether or not this', 'shape is shown in the legend.'].join(' ')
3330
},
3431

3532
legend: extendFlat({}, basePlotAttributes.legend, {
@@ -57,11 +54,9 @@ module.exports = templatedArray('shape', {
5754
}),
5855
font: fontAttrs({
5956
editType: 'calc+arraydraw',
60-
description: [
61-
'Sets this legend group\'s title font.'
62-
].join(' '),
57+
description: ["Sets this legend group's title font."].join(' ')
6358
}),
64-
editType: 'calc+arraydraw',
59+
editType: 'calc+arraydraw'
6560
},
6661

6762
legendrank: extendFlat({}, basePlotAttributes.legendrank, {
@@ -80,7 +75,7 @@ module.exports = templatedArray('shape', {
8075

8176
legendwidth: extendFlat({}, basePlotAttributes.legendwidth, {
8277
editType: 'calc+arraydraw',
83-
description: 'Sets the width (in px or fraction) of the legend for this shape.',
78+
description: 'Sets the width (in px or fraction) of the legend for this shape.'
8479
}),
8580

8681
type: {
@@ -91,20 +86,20 @@ module.exports = templatedArray('shape', {
9186
'Specifies the shape type to be drawn.',
9287

9388
'If *line*, a line is drawn from (`x0`,`y0`) to (`x1`,`y1`)',
94-
'with respect to the axes\' sizing mode.',
89+
"with respect to the axes' sizing mode.",
9590

9691
'If *circle*, a circle is drawn from',
9792
'((`x0`+`x1`)/2, (`y0`+`y1`)/2))',
9893
'with radius',
9994
'(|(`x0`+`x1`)/2 - `x0`|, |(`y0`+`y1`)/2 -`y0`)|)',
100-
'with respect to the axes\' sizing mode.',
95+
"with respect to the axes' sizing mode.",
10196

10297
'If *rect*, a rectangle is drawn linking',
10398
'(`x0`,`y0`), (`x1`,`y0`), (`x1`,`y1`), (`x0`,`y1`), (`x0`,`y0`)',
104-
'with respect to the axes\' sizing mode.',
99+
"with respect to the axes' sizing mode.",
105100

106101
'If *path*, draw a custom SVG path using `path`.',
107-
'with respect to the axes\' sizing mode.'
102+
"with respect to the axes' sizing mode."
108103
].join(' ')
109104
},
110105

@@ -121,7 +116,7 @@ module.exports = templatedArray('shape', {
121116

122117
xref: extendFlat({}, annAttrs.xref, {
123118
description: [
124-
'Sets the shape\'s x coordinate axis.',
119+
"Sets the shape's x coordinate axis.",
125120
axisPlaceableObjs.axisRefDescription('x', 'left', 'right')
126121
].join(' ')
127122
}),
@@ -131,9 +126,9 @@ module.exports = templatedArray('shape', {
131126
dflt: 'scaled',
132127
editType: 'calc+arraydraw',
133128
description: [
134-
'Sets the shapes\'s sizing mode along the x axis.',
129+
"Sets the shapes's sizing mode along the x axis.",
135130
'If set to *scaled*, `x0`, `x1` and x coordinates within `path` refer to',
136-
'data values on the x axis or a fraction of the plot area\'s width',
131+
"data values on the x axis or a fraction of the plot area's width",
137132
'(`xref` set to *paper*).',
138133
'If set to *pixel*, `xanchor` specifies the x position in terms',
139134
'of data or plot fraction but `x0`, `x1` and x coordinates within `path`',
@@ -156,18 +151,12 @@ module.exports = templatedArray('shape', {
156151
x0: {
157152
valType: 'any',
158153
editType: 'calc+arraydraw',
159-
description: [
160-
'Sets the shape\'s starting x position.',
161-
'See `type` and `xsizemode` for more info.'
162-
].join(' ')
154+
description: ["Sets the shape's starting x position.", 'See `type` and `xsizemode` for more info.'].join(' ')
163155
},
164156
x1: {
165157
valType: 'any',
166158
editType: 'calc+arraydraw',
167-
description: [
168-
'Sets the shape\'s end x position.',
169-
'See `type` and `xsizemode` for more info.'
170-
].join(' ')
159+
description: ["Sets the shape's end x position.", 'See `type` and `xsizemode` for more info.'].join(' ')
171160
},
172161
x0shift: {
173162
valType: 'number',
@@ -195,7 +184,7 @@ module.exports = templatedArray('shape', {
195184
},
196185
yref: extendFlat({}, annAttrs.yref, {
197186
description: [
198-
'Sets the shape\'s y coordinate axis.',
187+
"Sets the shape's y coordinate axis.",
199188
axisPlaceableObjs.axisRefDescription('y', 'bottom', 'top')
200189
].join(' ')
201190
}),
@@ -205,9 +194,9 @@ module.exports = templatedArray('shape', {
205194
dflt: 'scaled',
206195
editType: 'calc+arraydraw',
207196
description: [
208-
'Sets the shapes\'s sizing mode along the y axis.',
197+
"Sets the shapes's sizing mode along the y axis.",
209198
'If set to *scaled*, `y0`, `y1` and y coordinates within `path` refer to',
210-
'data values on the y axis or a fraction of the plot area\'s height',
199+
"data values on the y axis or a fraction of the plot area's height",
211200
'(`yref` set to *paper*).',
212201
'If set to *pixel*, `yanchor` specifies the y position in terms',
213202
'of data or plot fraction but `y0`, `y1` and y coordinates within `path`',
@@ -230,18 +219,12 @@ module.exports = templatedArray('shape', {
230219
y0: {
231220
valType: 'any',
232221
editType: 'calc+arraydraw',
233-
description: [
234-
'Sets the shape\'s starting y position.',
235-
'See `type` and `ysizemode` for more info.'
236-
].join(' ')
222+
description: ["Sets the shape's starting y position.", 'See `type` and `ysizemode` for more info.'].join(' ')
237223
},
238224
y1: {
239225
valType: 'any',
240226
editType: 'calc+arraydraw',
241-
description: [
242-
'Sets the shape\'s end y position.',
243-
'See `type` and `ysizemode` for more info.'
244-
].join(' ')
227+
description: ["Sets the shape's end y position.", 'See `type` and `ysizemode` for more info.'].join(' ')
245228
},
246229
y0shift: {
247230
valType: 'number',
@@ -291,8 +274,8 @@ module.exports = templatedArray('shape', {
291274
'of categories because using the categories themselves there would',
292275
'be no way to describe fractional positions',
293276
'On data axes: because space and T are both normal components of path',
294-
'strings, we can\'t use either to separate date from time parts.',
295-
'Therefore we\'ll use underscore for this purpose:',
277+
"strings, we can't use either to separate date from time parts.",
278+
"Therefore we'll use underscore for this purpose:",
296279
'2015-02-21_13:45:56.789'
297280
].join(' ')
298281
},
@@ -306,18 +289,16 @@ module.exports = templatedArray('shape', {
306289
description: 'Sets the opacity of the shape.'
307290
},
308291
line: {
309-
color: extendFlat({}, scatterLineAttrs.color, {editType: 'arraydraw'}),
310-
width: extendFlat({}, scatterLineAttrs.width, {editType: 'calc+arraydraw'}),
311-
dash: extendFlat({}, dash, {editType: 'arraydraw'}),
292+
color: extendFlat({}, scatterLineAttrs.color, { editType: 'arraydraw' }),
293+
width: extendFlat({}, scatterLineAttrs.width, { editType: 'calc+arraydraw' }),
294+
dash: extendFlat({}, dash, { editType: 'arraydraw' }),
312295
editType: 'calc+arraydraw'
313296
},
314297
fillcolor: {
315298
valType: 'color',
316299
dflt: 'rgba(0,0,0,0)',
317300
editType: 'arraydraw',
318-
description: [
319-
'Sets the color filling the shape\'s interior. Only applies to closed shapes.'
320-
].join(' ')
301+
description: ["Sets the color filling the shape's interior. Only applies to closed shapes."].join(' ')
321302
},
322303
fillrule: {
323304
valType: 'enumerated',
@@ -349,7 +330,7 @@ module.exports = templatedArray('shape', {
349330
'It is also used for legend item if `name` is not provided.'
350331
].join(' ')
351332
},
352-
texttemplate: shapeTexttemplateAttrs({}, {keys: Object.keys(shapeLabelTexttemplateVars)}),
333+
texttemplate: shapeTexttemplateAttrs({}, { keys: Object.keys(shapeLabelTexttemplateVars) }),
353334
font: fontAttrs({
354335
editType: 'calc+arraydraw',
355336
colorEditType: 'arraydraw',
@@ -358,10 +339,18 @@ module.exports = templatedArray('shape', {
358339
textposition: {
359340
valType: 'enumerated',
360341
values: [
361-
'top left', 'top center', 'top right',
362-
'middle left', 'middle center', 'middle right',
363-
'bottom left', 'bottom center', 'bottom right',
364-
'start', 'middle', 'end',
342+
'top left',
343+
'top center',
344+
'top right',
345+
'middle left',
346+
'middle center',
347+
'middle right',
348+
'bottom left',
349+
'bottom center',
350+
'bottom right',
351+
'start',
352+
'middle',
353+
'end'
365354
],
366355
editType: 'arraydraw',
367356
description: [
@@ -371,7 +360,7 @@ module.exports = templatedArray('shape', {
371360
'*middle center*, *middle right*, *bottom left*, *bottom center*,',
372361
'and *bottom right*.',
373362
'Supported values for lines are *start*, *middle*, and *end*.',
374-
'Default: *middle center* for rectangles, circles, and paths; *middle* for lines.',
363+
'Default: *middle center* for rectangles, circles, and paths; *middle* for lines.'
375364
].join(' ')
376365
},
377366
textangle: {
@@ -391,27 +380,27 @@ module.exports = templatedArray('shape', {
391380
dflt: 'auto',
392381
editType: 'calc+arraydraw',
393382
description: [
394-
'Sets the label\'s horizontal position anchor',
383+
"Sets the label's horizontal position anchor",
395384
'This anchor binds the specified `textposition` to the *left*, *center*',
396385
'or *right* of the label text.',
397386
'For example, if `textposition` is set to *top right* and',
398387
'`xanchor` to *right* then the right-most portion of the',
399388
'label text lines up with the right-most edge of the',
400-
'shape.',
401-
].join(' '),
389+
'shape.'
390+
].join(' ')
402391
},
403392
yanchor: {
404393
valType: 'enumerated',
405394
values: ['top', 'middle', 'bottom'],
406395
editType: 'calc+arraydraw',
407396
description: [
408-
'Sets the label\'s vertical position anchor',
397+
"Sets the label's vertical position anchor",
409398
'This anchor binds the specified `textposition` to the *top*, *middle*',
410399
'or *bottom* of the label text.',
411400
'For example, if `textposition` is set to *top right* and',
412401
'`yanchor` to *top* then the top-most portion of the',
413402
'label text lines up with the top-most edge of the',
414-
'shape.',
403+
'shape.'
415404
].join(' ')
416405
},
417406
padding: {

src/components/shapes/defaults.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var handleArrayContainerDefaults = require('../../plots/array_container_defaults
77
var attributes = require('./attributes');
88
var helpers = require('./helpers');
99

10-
1110
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
1211
handleArrayContainerDefaults(layoutIn, layoutOut, {
1312
name: 'shapes',
@@ -19,9 +18,13 @@ function dfltLabelYanchor(isLine, labelTextPosition) {
1918
// If shape is a line, default y-anchor is 'bottom' (so that text is above line by default)
2019
// Otherwise, default y-anchor is equal to y-component of `textposition`
2120
// (so that text is positioned inside shape bounding box by default)
22-
return isLine ? 'bottom' :
23-
labelTextPosition.indexOf('top') !== -1 ? 'top' :
24-
labelTextPosition.indexOf('bottom') !== -1 ? 'bottom' : 'middle';
21+
return isLine
22+
? 'bottom'
23+
: labelTextPosition.indexOf('top') !== -1
24+
? 'top'
25+
: labelTextPosition.indexOf('bottom') !== -1
26+
? 'bottom'
27+
: 'middle';
2528
}
2629

2730
function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
@@ -32,10 +35,10 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
3235
shapeOut._isShape = true;
3336

3437
var visible = coerce('visible');
35-
if(!visible) return;
38+
if (!visible) return;
3639

3740
var showlegend = coerce('showlegend');
38-
if(showlegend) {
41+
if (showlegend) {
3942
coerce('legend');
4043
coerce('legendwidth');
4144
coerce('legendgroup');
@@ -48,15 +51,15 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
4851
var dfltType = path ? 'path' : 'rect';
4952
var shapeType = coerce('type', dfltType);
5053
var noPath = shapeType !== 'path';
51-
if(noPath) delete shapeOut.path;
54+
if (noPath) delete shapeOut.path;
5255

5356
coerce('editable');
5457
coerce('layer');
5558
coerce('opacity');
5659
coerce('fillcolor');
5760
coerce('fillrule');
5861
var lineWidth = coerce('line.width');
59-
if(lineWidth) {
62+
if (lineWidth) {
6063
coerce('line.color');
6164
coerce('line.dash');
6265
}
@@ -66,26 +69,25 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
6669

6770
// positioning
6871
var axLetters = ['x', 'y'];
69-
for(var i = 0; i < 2; i++) {
72+
for (var i = 0; i < 2; i++) {
7073
var axLetter = axLetters[i];
7174
var attrAnchor = axLetter + 'anchor';
7275
var sizeMode = axLetter === 'x' ? xSizeMode : ySizeMode;
73-
var gdMock = {_fullLayout: fullLayout};
76+
var gdMock = { _fullLayout: fullLayout };
7477
var ax;
7578
var pos2r;
7679
var r2pos;
7780

7881
// xref, yref
79-
var axRef = Axes.coerceRef(shapeIn, shapeOut, gdMock, axLetter, undefined,
80-
'paper');
82+
var axRef = Axes.coerceRef(shapeIn, shapeOut, gdMock, axLetter, undefined, 'paper');
8183
var axRefType = Axes.getRefType(axRef);
8284

83-
if(axRefType === 'range') {
85+
if (axRefType === 'range') {
8486
ax = Axes.getFromId(gdMock, axRef);
8587
ax._shapeIndices.push(shapeOut._index);
8688
r2pos = helpers.rangeToShapePosition(ax);
8789
pos2r = helpers.shapePositionToRange(ax);
88-
if(ax.type === 'category' || ax.type === 'multicategory') {
90+
if (ax.type === 'category' || ax.type === 'multicategory') {
8991
coerce(axLetter + '0shift');
9092
coerce(axLetter + '1shift');
9193
}
@@ -94,7 +96,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
9496
}
9597

9698
// Coerce x0, x1, y0, y1
97-
if(noPath) {
99+
if (noPath) {
98100
var dflt0 = 0.25;
99101
var dflt1 = 0.75;
100102

@@ -109,7 +111,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
109111
shapeIn[attr0] = pos2r(shapeIn[attr0], true);
110112
shapeIn[attr1] = pos2r(shapeIn[attr1], true);
111113

112-
if(sizeMode === 'pixel') {
114+
if (sizeMode === 'pixel') {
113115
coerce(attr0, 0);
114116
coerce(attr1, 10);
115117
} else {
@@ -125,7 +127,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
125127
}
126128

127129
// Coerce xanchor and yanchor
128-
if(sizeMode === 'pixel') {
130+
if (sizeMode === 'pixel') {
129131
// Hack for log axis described above
130132
var inAnchor = shapeIn[attrAnchor];
131133
shapeIn[attrAnchor] = pos2r(shapeIn[attrAnchor], true);
@@ -138,16 +140,20 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
138140
}
139141
}
140142

141-
if(noPath) {
143+
if (noPath) {
142144
Lib.noneOrAll(shapeIn, shapeOut, ['x0', 'x1', 'y0', 'y1']);
143145
}
144146

145147
// Label options
146148
var isLine = shapeType === 'line';
147149
var labelTextTemplate, labelText;
148-
if(noPath) { labelTextTemplate = coerce('label.texttemplate'); }
149-
if(!labelTextTemplate) { labelText = coerce('label.text'); }
150-
if(labelText || labelTextTemplate) {
150+
if (noPath) {
151+
labelTextTemplate = coerce('label.texttemplate');
152+
}
153+
if (!labelTextTemplate) {
154+
labelText = coerce('label.text');
155+
}
156+
if (labelText || labelTextTemplate) {
151157
coerce('label.textangle');
152158
var labelTextPosition = coerce('label.textposition', isLine ? 'middle' : 'middle center');
153159
coerce('label.xanchor');

0 commit comments

Comments
 (0)