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

ColorScale #42

Closed
ccorcos opened this issue Dec 5, 2014 · 4 comments
Closed

ColorScale #42

ccorcos opened this issue Dec 5, 2014 · 4 comments

Comments

@ccorcos
Copy link

ccorcos commented Dec 5, 2014

https://github.com/gka/chroma.js/wiki/Color-Scales

Does this feature still work? When I type chroma.ColorScale, I get undefined

@arya-s
Copy link
Contributor

arya-s commented Dec 5, 2014

I think that is outdated. Have a look at https://github.com/gka/chroma.js/blob/master/doc/api.md#working-with-color-scales

@ccorcos
Copy link
Author

ccorcos commented Dec 5, 2014

OK, so I found this code in a project:

var hot = new chroma.ColorScale({
    colors: [ '#000000', '#0B16B5', '#FFF782', '#EB1250' ],
    positions: [ 0, 0.4, 0.68, 0.85 ],
    mode:'rgb',
    limits:[0, 300]
});

hot.getColor(value).hex();

How can I translate this to the new format?

@arya-s
Copy link
Contributor

arya-s commented Dec 5, 2014

I think your example would be:

var hot = chroma.scale(
                       ['#000000', '#0B16B5', '#FFF782', '#EB1250'],
                       [0, 0.4, 0.68, 0.85]
                      )
                       .mode('rgb')
                       .domain([0, 300])

hot(value).hex()

Does this do what you're expecting it to do?

@ccorcos
Copy link
Author

ccorcos commented Dec 5, 2014

that works! thanks

@ccorcos ccorcos closed this as completed Dec 5, 2014
@arya-s arya-s mentioned this issue Dec 5, 2014
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

No branches or pull requests

2 participants