Published-release documentation · 281 actions; release compatibility · contract 5520b0fa9525
Revise facet source and shared guides
Replace a facet’s retained source program, rename its headers, and arrange outer axes with a shared categorical legend.
Prerequisites
Use the Getting Started browser module setup, install the full
ggaction entry, and provide <canvas id="chart"></canvas>. This complete example
includes its data and imports. These APIs require ggaction 0.0.15 or later;
check the documentation version for release compatibility.
Decision sequence: faceting → source replay → header and guide policies.
Complete program
import { chart } from "ggaction";
import { render } from "ggaction";
export function createFacetSourceWorkflow() {
function source(values) {
return chart()
.createCanvas({ width: 320, height: 300, margin: { top: 55, right: 25, bottom: 95, left: 65 } })
.createData({ id: "rows", values })
.createScatterPlot({ id: "points", x: "x", y: "y", color: "kind",
guides: { legend: false } });
}
const values = [
{ panel: "N", kind: "A", x: 1, y: 2 }, { panel: "N", kind: "B", x: 3, y: 4 },
{ panel: "S", kind: "A", x: 2, y: 3 }, { panel: "S", kind: "B", x: 4, y: 1 }
];
const before = source(values).facet({ field: "panel", values: ["N", "S"],
scales: { x: "shared", y: "shared", color: "shared" },
guides: { axes: "each", legend: "shared" }, gap: 20 });
return before
.editFacetSource({ program: source(values.map(row => ({ ...row, y: row.y + 1 }))) })
.editFacetHeaders({ role: "column", labelMap: [
{ value: "N", label: "North: revised source" },
{ value: "S", label: "South: revised source" }
], align: "center", side: "top" })
.editFacetGuides({ axes: "outer", legend: "shared" });
}
const program = createFacetSourceWorkflow();
render(program, document.querySelector("#chart").getContext("2d"));
Expected result
Both panels rebuild from rows whose y values increased by one. Raw keys N and S remain unchanged while headers display North and South. The parent retains a shared color legend and uses outer positional axes.
Boundaries and failure behavior
Facet children derive from the source recipe and cannot be replaced with concat child editors. Header display maps do not rename data values or change grouping. side and align require an explicit header role. Shared guides require compatible shared channel semantics; they are not inferred by matching labels.
Related
Authoring conventions · Data policies · Complete action reference