Skip to content

Commit 9a1aa45

Browse files
committed
closes #1317
1 parent 46a3cdd commit 9a1aa45

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

src/marks/raster.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ export class Raster extends AbstractRaster {
9595
}
9696
// Ignore the color scale, so the fill channel is returned unscaled.
9797
scale(channels, {color, ...scales}, context) {
98+
this.recolor = channels.fill?.scale;
9899
return super.scale(channels, scales, context);
99100
}
100101
render(index, scales, channels, dimensions, context) {
101-
const color = scales.color ?? ((x) => x);
102+
const color = this.recolor && scales.color ? scales.color : (x) => x;
102103
const {x: X, y: Y} = channels;
103104
const {document} = context;
104105
const [x1, y1, x2, y2] = renderBounds(channels, dimensions, context);

test/output/rasterVapor2.html

Lines changed: 96 additions & 0 deletions
Large diffs are not rendered by default.

test/plots/raster-vapor.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ export async function rasterVapor() {
1717
});
1818
}
1919

20+
export async function rasterVapor2() {
21+
return Plot.plot({
22+
color: {scheme: "blues", legend: true},
23+
x: {transform: (x) => x - 180},
24+
y: {transform: (y) => 90 - y},
25+
marks: [
26+
Plot.raster(await vapor(), {
27+
width: 360,
28+
height: 180
29+
}),
30+
Plot.raster(await vapor(), {
31+
width: 360,
32+
height: 180,
33+
fill: {value: (d) => (d > 4 ? "red" : null), scale: null}
34+
})
35+
]
36+
});
37+
}
38+
2039
export async function contourVapor() {
2140
return Plot.plot({
2241
width: 960,

0 commit comments

Comments
 (0)