Skip to content

Commit b0c4d32

Browse files
committed
581a dry colors - share between color_attributes and attributes
1 parent eb4d42a commit b0c4d32

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

src/components/colorscale/attributes.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
'use strict';
1010

11-
1211
module.exports = {
1312
zauto: {
1413
valType: 'boolean',

src/components/colorscale/color_attributes.js

+15-29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
'use strict';
1010

11+
var colorScaleAttributes = require('./attributes');
12+
var extendDeep = require('../../lib/extend').extendDeep;
13+
1114
module.exports = function makeColorScaleAttributes(context) {
1215
return {
1316
color: {
@@ -21,9 +24,7 @@ module.exports = function makeColorScaleAttributes(context) {
2124
' `cmin` and `cmax` if set.'
2225
].join('')
2326
},
24-
colorscale: {
25-
valType: 'colorscale',
26-
role: 'style',
27+
colorscale: extendDeep({}, colorScaleAttributes.colorscale, {
2728
description: [
2829
'Sets the colorscale and only has an effect',
2930
' if `', context, '.color` is set to a numerical array.',
@@ -36,57 +37,42 @@ module.exports = function makeColorScaleAttributes(context) {
3637
' To control the bounds of the colorscale in color space,',
3738
' use `', context, '.cmin` and `', context, '.cmax`.'
3839
].join('')
39-
},
40-
cauto: {
41-
valType: 'boolean',
42-
dflt: true,
43-
role: 'style',
40+
}),
41+
cauto: extendDeep({}, colorScaleAttributes.zauto, {
4442
description: [
4543
'Has an effect only if `', context, '.color` is set to a numerical array.',
4644
' Determines the whether or not the color domain is computed',
4745
' automatically.'
4846
].join('')
49-
},
50-
cmax: {
51-
valType: 'number',
52-
dflt: null,
53-
role: 'info',
47+
}),
48+
cmax: extendDeep({}, colorScaleAttributes.zmax, {
5449
description: [
5550
'Has an effect only if `', context, '.color` is set to a numerical array.',
5651
' Sets the upper bound of the color domain.',
5752
' Value should be associated to the `', context, '.color` array index,',
5853
' and if set, `', context, '.cmin` must be set as well.'
5954
].join('')
60-
},
61-
cmin: {
62-
valType: 'number',
63-
dflt: null,
64-
role: 'info',
55+
}),
56+
cmin: extendDeep({}, colorScaleAttributes.zmin, {
6557
description: [
6658
'Has an effect only if `', context, '.color` is set to a numerical array.',
6759
' Sets the lower bound of the color domain.',
6860
' Value should be associated to the `', context, '.color` array index,',
6961
' and if set, `', context, '.cmax` must be set as well.'
7062
].join('')
71-
},
72-
autocolorscale: {
73-
valType: 'boolean',
74-
dflt: true,
75-
role: 'style',
63+
}),
64+
autocolorscale: extendDeep({}, colorScaleAttributes.autocolorscale, {
7665
description: [
7766
'Has an effect only if `', context, '.color` is set to a numerical array.',
7867
' Determines whether or not the colorscale is picked using',
7968
' values inside `', context, '.color`.'
8069
].join('')
81-
},
82-
reversescale: {
83-
valType: 'boolean',
84-
role: 'style',
85-
dflt: false,
70+
}),
71+
reversescale: extendDeep({}, colorScaleAttributes.reversescale, {
8672
description: [
8773
'Has an effect only if `', context, '.color` is set to a numerical array.',
8874
' Reverses the colorscale.'
8975
].join('')
90-
}
76+
})
9177
};
9278
};

0 commit comments

Comments
 (0)