-
Notifications
You must be signed in to change notification settings - Fork 192
color scale override for Plot.raster #1318
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
Conversation
src/marks/raster.js
Outdated
return super.scale(channels, scales, context); | ||
} | ||
render(index, scales, channels, dimensions, context) { | ||
const color = scales.color ?? ((x) => x); | ||
const color = this.recolor && scales.color ? scales.color : (x) => x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want something like this:
const color = this.recolor && scales.color ? scales.color : (x) => x; | |
const color = scales[this.channels.fill?.scale] ?? (x) => x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hadn't thought about that, but it makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.channels.fill.scale comes in as "auto" and not "color", so I had to adapt a bit
Co-authored-by: Mike Bostock <mbostock@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it wasn’t clear, but I’m trying to avoid needing a side-effect in the raster.scale method. Why can’t we just figure out the appropriate color scale in raster.render instead?
Edit: You may need to call inferChannelScale to convert auto to something more specific.
* closes observablehq#1317 * Update src/marks/raster.js Co-authored-by: Mike Bostock <mbostock@gmail.com> * don't hardcode that fill is scaled with {color} * expose channel states to render --------- Co-authored-by: Mike Bostock <mbostock@gmail.com>
Because of f028a08 color scale overrides didn't work for Plot.raster
closes #1317