Skip to content

Conversation

@nikodraca
Copy link

@nikodraca nikodraca commented Feb 1, 2022

The logic for inferring colors in the schema was setting any string field as a color. This is because the d3.rgb still returns an object even if the color isn't valid:

> const {rgb} = require('d3');
> rgb("not-a-color")
Rgb { r: NaN, g: NaN, b: NaN, opacity: NaN }

This checks to see if the return values are non-null.

Closes #21

@Wattenberger
Copy link

thanks for the PR @nikodraca! this should have been handled in commit 00df00c

I think destructuring color would lead to errors, since rgb() can return null, eg for an empty string:

image

testing in this Observable notebook

definitely let me know if the current check return !!color && !Number.isNaN(color.r) is missing any use cases, and thanks for taking the time here!

@nikodraca
Copy link
Author

Ah my bad! I didn't see this was updated in the mean time.

@nikodraca nikodraca deleted the nikodraca/fix-color-bug branch February 2, 2022 15:20
@Wattenberger
Copy link

haha I snuck it past you! thanks for the time and thought, though!

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.

Multiselect on categories

2 participants