-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
DRY up color attributes #609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d226c7a
7e7a6db
689a680
dc2f6f4
9f0cd81
90e438a
40a51f2
eb4d42a
b0c4d32
4aed9b4
99abf13
e5222d0
bc9f70a
7e89f81
01d1041
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright 2012-2016, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var colorScaleAttributes = require('./attributes'); | ||
var extendDeep = require('../../lib/extend').extendDeep; | ||
|
||
module.exports = function makeColorScaleAttributes(context) { | ||
return { | ||
color: { | ||
valType: 'color', | ||
arrayOk: true, | ||
role: 'style', | ||
description: [ | ||
'Sets the ', context, ' color. It accepts either a specific color', | ||
' or an array of values that are mapped to the colorscale', | ||
' relative to the max and min values of the array or relative to', | ||
' `cmin` and `cmax` if set.' | ||
].join('') | ||
}, | ||
colorscale: extendDeep({}, colorScaleAttributes.colorscale, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes in general I might have been overly defensive with |
||
description: [ | ||
'Sets the colorscale and only has an effect', | ||
' if `', context, '.color` is set to a numerical array.', | ||
' The colorscale must be an array containing', | ||
' arrays mapping a normalized value to an', | ||
' rgb, rgba, hex, hsl, hsv, or named color string.', | ||
' At minimum, a mapping for the lowest (0) and highest (1)', | ||
' values are required. For example,', | ||
' `[[0, \'rgb(0,0,255)\', [1, \'rgb(255,0,0)\']]`.', | ||
' To control the bounds of the colorscale in color space,', | ||
' use `', context, '.cmin` and `', context, '.cmax`.' | ||
].join('') | ||
}), | ||
cauto: extendDeep({}, colorScaleAttributes.zauto, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Determines the whether or not the color domain is computed', | ||
' automatically.' | ||
].join('') | ||
}), | ||
cmax: extendDeep({}, colorScaleAttributes.zmax, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Sets the upper bound of the color domain.', | ||
' Value should be associated to the `', context, '.color` array index,', | ||
' and if set, `', context, '.cmin` must be set as well.' | ||
].join('') | ||
}), | ||
cmin: extendDeep({}, colorScaleAttributes.zmin, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Sets the lower bound of the color domain.', | ||
' Value should be associated to the `', context, '.color` array index,', | ||
' and if set, `', context, '.cmax` must be set as well.' | ||
].join('') | ||
}), | ||
autocolorscale: extendDeep({}, colorScaleAttributes.autocolorscale, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Determines whether or not the colorscale is picked using', | ||
' values inside `', context, '.color`.' | ||
].join('') | ||
}), | ||
reversescale: extendDeep({}, colorScaleAttributes.reversescale, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Reverses the colorscale.' | ||
].join('') | ||
}) | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!