Skip to content
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

use d3.color('rgba(255,255,255,0)'), the rgb is all NaN. #52

Closed
FEliuyg opened this issue Dec 17, 2018 · 4 comments
Closed

use d3.color('rgba(255,255,255,0)'), the rgb is all NaN. #52

FEliuyg opened this issue Dec 17, 2018 · 4 comments

Comments

@FEliuyg
Copy link

FEliuyg commented Dec 17, 2018

when i use d3.color parse rgba(255,255,255,0), the result of r,g,b is NaN.
why the a is 0, the r,g,b is NaN.

@mbostock
Copy link
Member

The color parser treats transparent colors as having undefined R, G and B values because CSS does not support an explicit way of representing undefined channel values and therefore supporting achromatic interpolation. If you want to construct a transparent color with defined R, G and B values, you need to use the d3.rgb constructor instead:

d3.rgb(255, 255, 255, 0)

@nickofthyme
Copy link

Is this intentionally different functionality for hexadecimal colors?

d3.rgb('#00000000)');

// returns
{
  r: 0,
  b: 0,
  g: 0,
  opacity: 0,
}

@mbostock
Copy link
Member

That looks like a bug in #67.

@mbostock
Copy link
Member

Fixed in f176ff1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants