Skip to content

Conversation

@mbostock
Copy link
Member

@mbostock mbostock commented Jan 20, 2022

When the defined values associated with an ordinal or categorical color scale are entirely boolean (true or false), construct a default range from the greys color scheme, assigning the light gray to false and the dark gray to true (rather than turbo or tableau10). In addition, make the n = 2 ordinal schemes higher contrast by favoring the extrema.

I considered having categorical color scales continue to use tableau10, restricting this behavior to ordinal color scales. This would require changing the logic in asOrdinalType to similarly check whether the associated defined values are boolean. I wasn’t sure if it was desirable to do this check twice. And I went back and forth over whether this should be an exhaustive check or a fast check (looking only at the first defined value). But I think it’s better to do an exhaustive check here since the the greys color scheme won’t work very well if there are many values.

Screen Shot 2022-01-20 at 11 27 54 AM

@mbostock mbostock requested a review from Fil January 20, 2022 19:32
@mbostock mbostock force-pushed the mbostock/boolean-greys branch from b4ee717 to 9236c44 Compare January 20, 2022 19:37
@Fil
Copy link
Contributor

Fil commented Jan 20, 2022

Yes. Can we extend this to having systematically two greys when the domain is boolean, always associating false with the lighter grey and true with the darker one? Right now if everything is true or everything is false, we get the same output. (This is what I had in mind in #692 (comment))

@mbostock
Copy link
Member Author

Ah, whoops. I thought I did that, but then it got lost in the iterations… Let me think some more.

@mbostock mbostock force-pushed the mbostock/boolean-greys branch from 9236c44 to e9f82b1 Compare January 20, 2022 21:05
@mbostock
Copy link
Member Author

Okay, take another look @Fil? 🙏

@mbostock mbostock force-pushed the mbostock/boolean-greys branch from e9f82b1 to 00df37b Compare January 20, 2022 21:08
Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In combination with #692 it's 👍

And a great solution for the legend when only one boolean is present

@mbostock mbostock merged commit 9f9dd9c into main Jan 20, 2022
@mbostock mbostock deleted the mbostock/boolean-greys branch January 20, 2022 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants