Skip to content

fix ramp legend colorSpace#2419

Merged
mbostock merged 5 commits intomainfrom
mbostock/fix-legend-color-space
Apr 12, 2026
Merged

fix ramp legend colorSpace#2419
mbostock merged 5 commits intomainfrom
mbostock/fix-legend-color-space

Conversation

@mbostock
Copy link
Copy Markdown
Member

This replaces the SVG filter added in #2416 with a simpler color-mix(…) which is available since the ramp legend directly sets context.fillStyle (and hence we don’t have to worry, as we did with the raster mark, about converting a color string into RGBA values). It also allows the caller to set the colorSpace when constructing an opacity legend, so that P3 colors can be used as intended.

I’m not sure why the snapshots aren’t appearing correctly here; the tests seem to be correct locally.

@mbostock mbostock requested a review from Fil April 11, 2026 20:34
@mbostock mbostock changed the title fix opacity legend colorSpace fix ramp legend colorSpace Apr 11, 2026
@mbostock
Copy link
Copy Markdown
Member Author

I think the snapshots don’t render correctly because node-canvas doesn’t support CSS Color Module Level 5 color-mix(…)… But I think this is still a preferable implementation and it should make #2285 easier.

@Fil
Copy link
Copy Markdown
Contributor

Fil commented Apr 11, 2026

I'm not seeing why it's preferable or simpler than the basic greyscale ramp + svg filter to add the color. (But as long as it works I'm fine with it.)

@mbostock
Copy link
Copy Markdown
Member Author

It’s simpler because you don’t need the filter — as the diff shows.

@mbostock mbostock merged commit dff4583 into main Apr 12, 2026
1 check passed
@mbostock mbostock deleted the mbostock/fix-legend-color-space branch April 12, 2026 01:11
@mbostock mbostock mentioned this pull request Apr 12, 2026
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

Successfully merging this pull request may close these issues.

2 participants