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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ The <a name="facetanchor">*mark*.**facetAnchor**</a> option controls the placeme
* null - display the mark on each non-empty facet (default for all marks, with the exception of axis marks)
* *top*, *right*, *bottom*, or *left* - display the mark on facets on the specified side
* *top-empty*, *right-empty*, *bottom-empty*, or *left-empty* - display the mark on facets that have an empty space on the specified side (the empty space being either the margin, or an empty facet); this is the default for axis marks
* *empty* - display the mark on empty facets only

## Legends

Expand Down
7 changes: 6 additions & 1 deletion src/facet.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const facetAnchors = new Map([
["top-empty", facetAnchorTopEmpty],
["right-empty", facetAnchorRightEmpty],
["bottom-empty", facetAnchorBottomEmpty],
["left-empty", facetAnchorLeftEmpty]
["left-empty", facetAnchorLeftEmpty],
["empty", facetAnchorEmpty]
]);

export function maybeFacetAnchor(facetAnchor) {
Expand Down Expand Up @@ -153,6 +154,10 @@ function facetAnchorRightEmpty(facets, {x: X}, {x, y, empty}) {
}
}

function facetAnchorEmpty(facets, channels, {empty}) {
return empty;
}

function and(a, b) {
return function () {
return a.apply(null, arguments) && b.apply(null, arguments);
Expand Down
232 changes: 232 additions & 0 deletions test/output/futureSplom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions test/plots/frame.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";

export async function frameCorners() {
return Plot.frame({rx: 16, ry: 10}).plot();
Expand Down Expand Up @@ -26,3 +27,27 @@ export async function frameSidesX() {
export async function frameSidesY() {
return Plot.plot({width: 350, height: 250, y: {domain: [0, 1]}, marks});
}

export async function futureSplom() {
const data = {columns: ["A", "B", "C"]};
return Plot.plot({
width: 400,
height: 400,
fx: {domain: data.columns, axis: null},
fy: {domain: data.columns, axis: null},
x: {type: "linear", domain: [-1.5, 1.5]},
y: {type: "linear", domain: [-1.5, 1.5]},
marks: [
Plot.gridX({ticks: 7}),
Plot.gridY({ticks: 7}),
Plot.axisX({facetAnchor: "bottom", ticks: 3}),
Plot.axisY({facetAnchor: "left", ticks: 3}),
Plot.text(
d3.cross(data.columns, data.columns).filter(([key1, key2]) => key2 !== key1),
{fx: "0", fy: "1", text: () => "*", frameAnchor: "middle"}
),
Plot.axisFx({label: null, frameAnchor: "middle", dy: 10, facetAnchor: "empty"}),
Plot.frame({facetAnchor: "empty"})
]
});
}