-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Colorspec doc corrections and clarifications #625
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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
var colorScaleAttributes = require('./attributes'); | ||
var extendDeep = require('../../lib/extend').extendDeep; | ||
var palettes = require('./scales.js'); | ||
|
||
module.exports = function makeColorScaleAttributes(context) { | ||
return { | ||
|
@@ -19,7 +20,7 @@ module.exports = function makeColorScaleAttributes(context) { | |
role: 'style', | ||
description: [ | ||
'Sets the ', context, ' color. It accepts either a specific color', | ||
' or an array of values that are mapped to the colorscale', | ||
' or an array of numbers 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('') | ||
|
@@ -35,14 +36,19 @@ module.exports = function makeColorScaleAttributes(context) { | |
' 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('') | ||
' use `', context, '.cmin` and `', context, '.cmax`.', | ||
' Alternatively, `colorscale` may be a palette name string', | ||
' of the following list: ' | ||
].join('').concat(Object.keys(palettes).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.' | ||
'Has an effect only if `', context, '.color` is set to a numerical array', | ||
' and `cmin`, `cmax` are set by the user. In this case,', | ||
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. Hmm. 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. @etpinard The term "set by the user" is being used to avoid this ambiguity (I wanted to stick to user visible / user controllable things in the doc) 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. @etpinard in line with your above notes on the Sorry to be so tedious about the doc strings but I'm adding some test cases in general to reify the official API behaviors and since it's nontrivial stuff (and in some cases, by necessity, there are semiarbitrary choices), I feel the need to work against definitions that are clear to me. E.g. if you want to permit that only one of |
||
' it controls whether the range of colors in `colorscale` is mapped to', | ||
' the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax`', | ||
' values (`cauto: false`).', | ||
' Defaults to `false` when `cmin`, `cmax` are set by the user.' | ||
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. This is just clarification as the former text is explanatory only once the user is already familiar with it. 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. I think the wording in this is still a bit muddy - the Can we not say (in some way) the 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. @mdtusz I've updated it to
Is it okay? I feel there's a tradeoff among using the best terminology (concept of mapping), comprehension by all ('what is mapping?') and brevity; maybe this version is at a better point in that space. (I haven't pushed it yet to avoid unnecessary CI testing) 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. Summoning Docs-Master @cldougl! 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. taking a 👀 now -- give me 1 min to catch up on the context |
||
].join('') | ||
}), | ||
cmax: extendDeep({}, colorScaleAttributes.zmax, { | ||
|
@@ -64,14 +70,18 @@ module.exports = function makeColorScaleAttributes(context) { | |
autocolorscale: extendDeep({}, colorScaleAttributes.autocolorscale, { | ||
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. @etpinard Is it still true that both or neither of cmin,cmax must be set? My experience with 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. Correct. It is a little more subtle at the moment. See this line in the colorscale defaults. If one of 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. @etpinard yes, tests support you, assuming you actually meant In any case, our common conclusion is that the user does not need to set both of 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. p.s. by the way, a reason for even considering partial |
||
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`.' | ||
' Determines whether the colorscale is a default palette (`autocolorscale: true`)', | ||
' or the palette determined by `', context, '.colorscale`.', | ||
' In case `colorscale` is unspecified or `autocolorscale` is true, the default ', | ||
' palette will be chosen according to whether numbers in the `color` array are', | ||
' all positive, all negative or mixed.' | ||
].join('') | ||
}), | ||
reversescale: extendDeep({}, colorScaleAttributes.reversescale, { | ||
description: [ | ||
'Has an effect only if `', context, '.color` is set to a numerical array.', | ||
' Reverses the colorscale.' | ||
' Reverses the color mapping if true (`cmin` will correspond to the last color', | ||
' in the array and `cmax` will correspond to the first color).' | ||
].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.
Numbers or numeric strings to be more precise. Not sure if it's worth adding that amount of details in here though.
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.
@etpinard I can cancel the PR and just make this single word change in the main PR. However to understand my motive, I started some work on the basis of what these docs say, and while their meanings are trivial to you due to developing these props in the first place, it was partly opaque to me, and in one case, misleading, so I had to resort to trial / error (at that point I intentionally didn't just look at the code). So I thought that if I as a developer had a problem understanding it then others may benefit from a modest rephrasing. So I'm glad to do what's the best fit for the system overall. Unrelated: I didn't quite understand the numeric string part as in JSON you'd pass on an array of plain numbers.