Skip to content

Opt-out of the color scale on a channel-by-channel basis #1246

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

Closed
mbostock opened this issue Feb 2, 2023 · 0 comments · Fixed by #1247
Closed

Opt-out of the color scale on a channel-by-channel basis #1246

mbostock opened this issue Feb 2, 2023 · 0 comments · Fixed by #1247
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Feb 2, 2023

Currently we have some special logic that checks to see if the color channels are literal colors:

plot/src/scales.js

Lines 411 to 417 in b97ba31

// For color scales, if no range or scheme is specified and all associated
// defined values (from the domain if present, and otherwise from channels)
// are valid colors, then default to the identity scale. This allows, for
// example, a fill channel to return literal colors; without this, the colors
// would be remapped to a categorical scheme!
if (kind === color && range === undefined && scheme === undefined && isAll(domain, channels, isColor))
return "identity";

This works well in the simple case where you have one (or more) marks that wants to specify literal colors.

But what if you want to have some marks that use a color scale, and other marks such as grid lines that want to specify literal colors? It would be nice if you could opt-out of the color scale by providing literal colors on a channel-by-channel basis. Essentially, instead of adopting an identity color scale if all color channels are literal colors, we would instead ignore the scale: "color" declaration if the provided channel values are already literal colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant