Skip to content

Commit 4011faa

Browse files
committed
Linting/formatting
1 parent e661a4c commit 4011faa

File tree

4 files changed

+379
-364
lines changed

4 files changed

+379
-364
lines changed

src/components/colorscale/attributes.js

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,24 @@ module.exports = function colorScaleAttrs(context, opts) {
5959
opts = opts || {};
6060

6161
var cLetter = opts.cLetter || 'c';
62-
var onlyIfNumerical = ('onlyIfNumerical' in opts) ? opts.onlyIfNumerical : Boolean(context);
63-
var noScale = ('noScale' in opts) ? opts.noScale : context === 'marker.line';
64-
var showScaleDflt = ('showScaleDflt' in opts) ? opts.showScaleDflt : cLetter === 'z';
62+
var onlyIfNumerical = 'onlyIfNumerical' in opts ? opts.onlyIfNumerical : Boolean(context);
63+
var noScale = 'noScale' in opts ? opts.noScale : context === 'marker.line';
64+
var showScaleDflt = 'showScaleDflt' in opts ? opts.showScaleDflt : cLetter === 'z';
6565
var colorscaleDflt = typeof opts.colorscaleDflt === 'string' ? palettes[opts.colorscaleDflt] : null;
6666
var editTypeOverride = opts.editTypeOverride || '';
67-
var contextHead = context ? (context + '.') : '';
67+
var contextHead = context ? context + '.' : '';
6868

6969
var colorAttr, colorAttrFull;
7070

71-
if('colorAttr' in opts) {
71+
if ('colorAttr' in opts) {
7272
colorAttr = opts.colorAttr;
7373
colorAttrFull = opts.colorAttr;
7474
} else {
75-
colorAttr = {z: 'z', c: 'color'}[cLetter];
75+
colorAttr = { z: 'z', c: 'color' }[cLetter];
7676
colorAttrFull = 'in ' + code(contextHead + colorAttr);
7777
}
7878

79-
var effectDesc = onlyIfNumerical ?
80-
' Has an effect only if ' + colorAttrFull + ' is set to a numerical array.' :
81-
'';
79+
var effectDesc = onlyIfNumerical ? ' Has an effect only if ' + colorAttrFull + ' is set to a numerical array.' : '';
8280

8381
var auto = cLetter + 'auto';
8482
var min = cLetter + 'min';
@@ -95,21 +93,24 @@ module.exports = function colorScaleAttrs(context, opts) {
9593

9694
var attrs = {};
9795

98-
if(colorAttr === 'color') {
96+
if (colorAttr === 'color') {
9997
attrs.color = {
10098
valType: 'color',
10199
arrayOk: true,
102100
editType: editTypeOverride || 'style',
103101
description: [
104-
'Sets the', context, 'color.',
102+
'Sets the',
103+
context,
104+
'color.',
105105
'It accepts either a specific color',
106106
'or an array of numbers that are mapped to the colorscale',
107107
'relative to the max and min values of the array or relative to',
108-
minmaxFull, 'if set.'
108+
minmaxFull,
109+
'if set.'
109110
].join(' ')
110111
};
111112

112-
if(opts.anim) {
113+
if (opts.anim) {
113114
attrs.color.anim = true;
114115
}
115116
}
@@ -123,7 +124,9 @@ module.exports = function colorScaleAttrs(context, opts) {
123124
'Determines whether or not the color domain is computed',
124125
'with respect to the input data (here ' + colorAttrFull + ') or the bounds set in',
125126
minmaxFull + effectDesc,
126-
'Defaults to `false` when', minmaxFull, 'are set by the user.'
127+
'Defaults to `false` when',
128+
minmaxFull,
129+
'are set by the user.'
127130
].join(' ')
128131
};
129132

@@ -134,8 +137,11 @@ module.exports = function colorScaleAttrs(context, opts) {
134137
impliedEdits: minmaxImpliedEdits,
135138
description: [
136139
'Sets the lower bound of the color domain.' + effectDesc,
137-
'Value should have the same units as', colorAttrFull,
138-
'and if set,', maxFull, 'must be set as well.'
140+
'Value should have the same units as',
141+
colorAttrFull,
142+
'and if set,',
143+
maxFull,
144+
'must be set as well.'
139145
].join(' ')
140146
};
141147

@@ -146,8 +152,11 @@ module.exports = function colorScaleAttrs(context, opts) {
146152
impliedEdits: minmaxImpliedEdits,
147153
description: [
148154
'Sets the upper bound of the color domain.' + effectDesc,
149-
'Value should have the same units as', colorAttrFull,
150-
'and if set,', minFull, 'must be set as well.'
155+
'Value should have the same units as',
156+
colorAttrFull,
157+
'and if set,',
158+
minFull,
159+
'must be set as well.'
151160
].join(' ')
152161
};
153162

@@ -157,28 +166,35 @@ module.exports = function colorScaleAttrs(context, opts) {
157166
editType: 'calc',
158167
impliedEdits: autoImpliedEdits,
159168
description: [
160-
'Sets the mid-point of the color domain by scaling', minFull,
161-
'and/or', maxFull, 'to be equidistant to this point.' + effectDesc,
162-
'Value should have the same units as', colorAttrFull + '.',
163-
'Has no effect when', autoFull, 'is `false`.'
169+
'Sets the mid-point of the color domain by scaling',
170+
minFull,
171+
'and/or',
172+
maxFull,
173+
'to be equidistant to this point.' + effectDesc,
174+
'Value should have the same units as',
175+
colorAttrFull + '.',
176+
'Has no effect when',
177+
autoFull,
178+
'is `false`.'
164179
].join(' ')
165180
};
166181

167182
attrs.colorscale = {
168183
valType: 'colorscale',
169184
editType: 'calc',
170185
dflt: colorscaleDflt,
171-
impliedEdits: {autocolorscale: false},
186+
impliedEdits: { autocolorscale: false },
172187
description: [
173188
'Sets the colorscale.' + effectDesc,
174189
'The colorscale must be an array containing',
175190
'arrays mapping a normalized value to an',
176191
'rgb, rgba, hex, hsl, hsv, or named color string.',
177192
'At minimum, a mapping for the lowest (0) and highest (1)',
178193
'values are required. For example,',
179-
'`[[0, \'rgb(0,0,255)\'], [1, \'rgb(255,0,0)\']]`.',
194+
"`[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`.",
180195
'To control the bounds of the colorscale in color space,',
181-
'use', minmaxFull + '.',
196+
'use',
197+
minmaxFull + '.',
182198
'Alternatively, `colorscale` may be a palette name string',
183199
'of the following list: ' + paletteStr + '.'
184200
].join(' ')
@@ -189,10 +205,11 @@ module.exports = function colorScaleAttrs(context, opts) {
189205
// gets overrode in 'heatmap' & 'surface' for backwards comp.
190206
dflt: opts.autoColorDflt === false ? false : true,
191207
editType: 'calc',
192-
impliedEdits: {colorscale: undefined},
208+
impliedEdits: { colorscale: undefined },
193209
description: [
194210
'Determines whether the colorscale is a default palette (`autocolorscale: true`)',
195-
'or the palette determined by', code(contextHead + 'colorscale') + '.' + effectDesc,
211+
'or the palette determined by',
212+
code(contextHead + 'colorscale') + '.' + effectDesc,
196213
'In case `colorscale` is unspecified or `autocolorscale` is true, the default',
197214
'palette will be chosen according to whether numbers in the `color` array are',
198215
'all positive, all negative or mixed.'
@@ -205,25 +222,27 @@ module.exports = function colorScaleAttrs(context, opts) {
205222
editType: 'plot',
206223
description: [
207224
'Reverses the color mapping if true.' + effectDesc,
208-
'If true,', minFull, 'will correspond to the last color',
209-
'in the array and', maxFull, 'will correspond to the first color.'
225+
'If true,',
226+
minFull,
227+
'will correspond to the last color',
228+
'in the array and',
229+
maxFull,
230+
'will correspond to the first color.'
210231
].join(' ')
211232
};
212233

213-
if(!noScale) {
234+
if (!noScale) {
214235
attrs.showscale = {
215236
valType: 'boolean',
216237
dflt: showScaleDflt,
217238
editType: 'calc',
218-
description: [
219-
'Determines whether or not a colorbar is displayed for this trace.' + effectDesc
220-
].join(' ')
239+
description: ['Determines whether or not a colorbar is displayed for this trace.' + effectDesc].join(' ')
221240
};
222241

223242
attrs.colorbar = colorbarAttrs;
224243
}
225244

226-
if(!opts.noColorAxis) {
245+
if (!opts.noColorAxis) {
227246
attrs.coloraxis = {
228247
valType: 'subplotid',
229248
regex: counterRegex('coloraxis'),

0 commit comments

Comments
 (0)