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

[BUG] Colors not being rendered when alpha is expressed in scientific notation #3823

Closed
mapombo opened this issue Jan 24, 2017 · 5 comments
Closed

Comments

@mapombo
Copy link

mapombo commented Jan 24, 2017

When defining a color using RGBA, it's not rendered if the alpha component is expressed using scientific notation.
A candidate fix could be redefining the rgba regex used in getRgba function to the following:

/^rgba?(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d.]+(e[+-]\d+)?)\s*)?)$/

@etimberg
Copy link
Member

I think this would be better filed against https://github.com/chartjs/chartjs-color or even better, https://github.com/Qix-/color

@Qix-
Copy link

Qix- commented Jan 25, 2017

@etimberg A little off-topic, but since the repositories were handed off to moox and then myself by harthur, they have become active again. Did you guys fork for redundancy, or would the ChartJS be interested in PRing whatever relevant changes it'd need and updating to the new versions?

@etimberg
Copy link
Member

@Qix- we had initially had a fork because we made some internal changes to make it build in our old build process (before browserify) so we had to wrap the dependencies in UMD headers.

We also have a dependency on chartjs/chartjs-color-string because we needed to change the regex that detects when a string is a color. chartjs/chartjs-color-string@4a7753e Previously, if the string was '0' that would be interpreted as a colour which caused problems because we take the correct parsing of a string to a color to mean that the value is a color but we don't allow arbitrary numbers to be treated as colours.

We've since made some performance changes (removing removing redundant clipping checks was on that springs to mind). See chartjs/chartjs-color@4fb3e10 and chartjs/chartjs-color@2b50dd2

@Qix-
Copy link

Qix- commented Jan 25, 2017

The regex change you made in chartjs/chartjs-color-string@4a7753e should definitely be pulled back into the main repo (not sure why \D was used, but \w suffices and is the more correct solution anyway).

Those chartjs-color changes have been obliterated anyway after color got revamped in qix-/color#96, though I agree with both of those changes for their respective version of the library. Not sure what your stance is on updating to the new v1 API (the biggest change is that it's now immutable by popular demand) but I'd be willing to take a look at submitting a migration PR if you'd be interested.

@etimberg
Copy link
Member

@Qix- awesome, I've set up #3827 to track this . Thanks for commenting 😄

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

No branches or pull requests

3 participants