-
Notifications
You must be signed in to change notification settings - Fork 286
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
expose transform for e.g. d3.scaleSequentialLog? #171
Comments
In general d3-scale does not support inspection of scale types, so I wouldn’t expect it would support inspection of scale transforms either (if we did support generic transforms, which we do not). The hope is that the scale implementation encapsulates the behavior, and then things like axes and legends don’t need type-specific (or transform-specific) logic, which would make the axis or legend incompatible with future types. |
Concretely the question came from trying to adapt https://observablehq.com/@mbostock/color-ramp to a d3.scaleSequentialLog(); knowledge of the domain is not enough to “invert” the scale and generate the ~512 uniformly spaced points we would like to have. Using ticks() is not an option in this case, since they can't give us 500 values on a log-scale domain of e.g. [1e-7, 1e7]. But maybe that's a different issue (related: #44 #100 & #162). |
Typically, you’d just pass the scale’s interpolator to generate the ramp, not the scale itself. And interpolators are always linear in [0, 1]. |
Currently there is no simple way (or no way at all?) to discover the transform of a scaleSequential{Log,Symlog,Sqrt…} scale, which makes it difficult to generate an automatic legend.
scale.ticks() can be a proxy to this information, but it might be nice to be able to read the transform directly.
The text was updated successfully, but these errors were encountered: