-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
undeprecate colorCalculator and fix the fishy code #1493
Comments
The current deprecation leads to questions like this one: Not the first time this has come up. For one, the discussion in #1225 is not conclusive. I've also seen somewhere people switching between different scales based on the data, which is also a reasonable thing to do. |
Hi, I had the same kind of problem as you mentioned for the venture capital, what I ended up doing was: if value == undefined return -42
return value; and kind of work, but really clunky IMO. I do miss the colorAccessor, +1 adding it back ;) |
Thanks @tttp, it's good to know there is a workaround but yeah what a mess... why force a scale to perform logic, when the language itself is so much better at it? |
More recent versions of d3-scale include .unknown() and diverging scales, which cover some of the use cases for I'm fixing this by adding an override function |
Released in 3.0.11; backported to 2.2.2 for all those folks still using d3v3! |
Although scales and accessors are bright and shiny, they don't cover all use cases.
In particular, it's much easier to special-case a specific value using the
colorCalculator
, as seen in the venture capital example. I don't know how to create a scale that returns normal values for everything except for one exact value (undefined
in this case).I had two reasons for deprecating this method:
getColor
, which is a horrible horrible thing for a setter to doThe second reason isn't all that good - D3 is not supposed to be a framework that stops you from writing code! Sometimes writing a little logic is better than the best-abstracted toolkit.
The first reason can be fixed without hurting efficiency too much.
The text was updated successfully, but these errors were encountered: