LegendLayer.setSource¶
Summary¶
LegendLayer.setSource switches the legend data source and marks legend state dirty for redraw. The layer unsubscribes from previous source signals and subscribes to the new source when available. Use this when changing scalar fields or colormaps interactively.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
source |
OverlayLegendSource |
Yes | New legend source object or explicit scale/colormap descriptor. |
Returns¶
void - No return value.
Type Details¶
OverlayLegendExplicitSource¶
type OverlayLegendExplicitSource = {
scaleTransform: ScaleTransformDescriptor | ScaleTransform;
colormap: Colormap | BuiltinColormapName;
colormapStops?: ReadonlyArray<Color4>;
};
OverlayLegendSource¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const legend = wgpu.createOverlay.legend({
source: { scaleTransform: { mode: "linear", domainMin: 0, domainMax: 1 }, colormap: "viridis" }
});
legend.setSource({
scaleTransform: { mode: "linear", domainMin: -2, domainMax: 2 },
colormap: "plasma"
});