Closed jamesscottbrown closed 5 months ago
We've decided to move these color functions to the themes
package instead.
Actually we'll put them in utils.
@mikeldn, since getColorScale()
returns an array of colors, how would you feel about renaming it to something like getColorScheme()
(since what it returns is similar to, e.g. d3.schemeBlues[9]
) or getColorRamp()
?
We could then use the name getColorScale()
for a function that constructs a d3.scaleOrdinal
color scale.
@jamesscottbrown hmm... good point. It's not really returning a scale is it.. you're right. I think getColorRamp() is best. If we used scheme, you might expect to be able to pass it in ('blue') and get back a blue scheme... which isn't a terrible idea actually :) (But actually that is in ldnColors.perceptual.blue.... (all of which need work).
so, yes, getColorRamp() is good. Don't forget that getThresholdBreaksColorsLabels() uses it, so will need changing too.
What does this change?
This adds the definitions of
ldnColors
,theme
,getColorScale()
, andgetThresholdBreaksColorsLabels()
from https://observablehq.com/@ldn/color-system, so that they can be easily imported by chart components or projects.After this has been published to npm, the notebook can be updated to import the functions form
@ldn-viz/charts
, so that there is a single source-of-truth.The functions
swatch()
/swatches()
/swatchGrid()
/asRamp()
/ramp()
haven't been added, as they are specific to showing color schemes/ramps in Observable notebooks.This replaces https://github.com/Greater-London-Authority/ldn-viz-tools/pull/185.