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

Update @vx/scales to be consistent with d3 v5.0.0 #262

Closed
trainorpj opened this issue Apr 3, 2018 · 2 comments
Closed

Update @vx/scales to be consistent with d3 v5.0.0 #262

trainorpj opened this issue Apr 3, 2018 · 2 comments

Comments

@trainorpj
Copy link
Contributor

I was looking through @vx/scale, when I noticed that it's not up-to-date with d3 v5.0.0 (the most current version)

The release notes have these two announcements:

  • Add d3-scale-chromatic.
  • Remove d3.schemeCategory20* categorical color schemes. (See note below.)
    .
    .
    D3 now includes new categorical color schemes from ColorBrewer, along with ColorBrewer’s excellent diverging, sequential single-hue and sequential multi-hue color schemes. The twenty-color schemes were removed because their grouped design often falsely implied non-existent relationships in the data: a shared hue can imply that the encoded data are part of a group (a super-category), while the relative lightness can falsely imply order.

Issues that come from this:

  • vx is not consistent with the latest release of d3
    • If someone wanted to learn more about d3-scales page, they'd be confused as to why vx says there are colors, but d3 says otherwise 😢
  • Images on the @vx/scales readme are broken

Proposed Solution:

Port d3-scale-chromatic to @vx/scales, and update the docs. This won't change the API, i.e.

// old way
import {schemeCategory10} from '@vx/scale'

// new way... it's the same :)
import {schemeCategory10} from '@vx/scale'

Breaking Changes:

For better or for worse (seems like for better) schemeCategory20[b,c] won't work anymore

Thanks for reading 😄

Let me know if you'd like help on this. I'd be happy to submit a PR once this has @hshoff's blessing 🙏

@hshoff
Copy link
Member

hshoff commented Apr 10, 2018

We should follow d3s lead here and remove the categorical color schemes from @vx/scale altogether. The reasoning makes sense to me:

The twenty-color schemes were removed because their grouped design often falsely implied non-existent relationships in the data: a shared hue can imply that the encoded data are part of a group (a super-category), while the relative lightness can falsely imply order.

Then we can point folks to d3-scale-chromatic and not have to worry about maintaining a wrapper around it.

@vx/scale was made with the plan of eventually making scales play nicer in react land by making them immutable (easier checking in shouldComponentUpdate()). Currently @vx/scale just provides the non-fluent api around d3-scale:

// d3
scaleLiner().domain().range()

// vx
scaleLinear({ domain, range })

Tracking immutable scale progress here: #170

@trainorpj
Copy link
Contributor Author

Sounds good. I agree with linking to d3-scale-chromatic. Maybe the readme can include a note on how to make color scales, i.e.

import { ordinal } from '@vx/scale'
import { schemeCategory10 } from 'd3-scale-chromatic'

colorScale = ordinal({
  range: category10
})

I'll work on this. After updating the dependency, most of the work will be in fixing up the readme 📝and fixing tests

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