Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/marks/raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Raster extends AbstractRaster {
return super.scale(channels, scales, context);
}
render(index, scales, channels, dimensions, context) {
const {color} = scales;
const color = scales.color ?? ((x) => x);
const {x: X, y: Y} = channels;
const {document} = context;
const [x1, y1, x2, y2] = renderBounds(channels, dimensions, context);
Expand Down
19 changes: 19 additions & 0 deletions test/output/rasterCa55Color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions test/plots/raster-ca55.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ export async function rasterCa55Nearest() {
return rasterCa55({interpolate: "nearest"});
}

export async function rasterCa55Color() {
const ca55 = await d3.csv("data/ca55-south.csv", d3.autoType);
const domain = {type: "MultiPoint", coordinates: ca55.map((d) => [d.GRID_EAST, d.GRID_NORTH])};
return Plot.plot({
width: 640,
height: 484,
projection: {type: "reflect-y", inset: 3, domain},
marks: [
Plot.raster(ca55, {
x: "GRID_EAST",
y: "GRID_NORTH",
interpolate: "random-walk",
fill: (d) => d3.hcl(d.MAG_IGRF90, 120, 80).formatHex()
})
]
});
}

export async function contourCa55() {
return plotCa55((ca55) =>
Plot.contour(ca55, {
Expand Down