Skip to content

Commit 62e91e7

Browse files
authored
facetAnchor: empty (#1287)
1 parent 37a160f commit 62e91e7

File tree

4 files changed

+264
-1
lines changed

4 files changed

+264
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ The <a name="facetanchor">*mark*.**facetAnchor**</a> option controls the placeme
593593
* null - display the mark on each non-empty facet (default for all marks, with the exception of axis marks)
594594
* *top*, *right*, *bottom*, or *left* - display the mark on facets on the specified side
595595
* *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
596+
* *empty* - display the mark on empty facets only
596597

597598
## Legends
598599

src/facet.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ const facetAnchors = new Map([
9191
["top-empty", facetAnchorTopEmpty],
9292
["right-empty", facetAnchorRightEmpty],
9393
["bottom-empty", facetAnchorBottomEmpty],
94-
["left-empty", facetAnchorLeftEmpty]
94+
["left-empty", facetAnchorLeftEmpty],
95+
["empty", facetAnchorEmpty]
9596
]);
9697

9798
export function maybeFacetAnchor(facetAnchor) {
@@ -153,6 +154,10 @@ function facetAnchorRightEmpty(facets, {x: X}, {x, y, empty}) {
153154
}
154155
}
155156

157+
function facetAnchorEmpty(facets, channels, {empty}) {
158+
return empty;
159+
}
160+
156161
function and(a, b) {
157162
return function () {
158163
return a.apply(null, arguments) && b.apply(null, arguments);

test/output/futureSplom.svg

Lines changed: 232 additions & 0 deletions
Loading

test/plots/frame.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Plot from "@observablehq/plot";
2+
import * as d3 from "d3";
23

34
export async function frameCorners() {
45
return Plot.frame({rx: 16, ry: 10}).plot();
@@ -26,3 +27,27 @@ export async function frameSidesX() {
2627
export async function frameSidesY() {
2728
return Plot.plot({width: 350, height: 250, y: {domain: [0, 1]}, marks});
2829
}
30+
31+
export async function futureSplom() {
32+
const data = {columns: ["A", "B", "C"]};
33+
return Plot.plot({
34+
width: 400,
35+
height: 400,
36+
fx: {domain: data.columns, axis: null},
37+
fy: {domain: data.columns, axis: null},
38+
x: {type: "linear", domain: [-1.5, 1.5]},
39+
y: {type: "linear", domain: [-1.5, 1.5]},
40+
marks: [
41+
Plot.gridX({ticks: 7}),
42+
Plot.gridY({ticks: 7}),
43+
Plot.axisX({facetAnchor: "bottom", ticks: 3}),
44+
Plot.axisY({facetAnchor: "left", ticks: 3}),
45+
Plot.text(
46+
d3.cross(data.columns, data.columns).filter(([key1, key2]) => key2 !== key1),
47+
{fx: "0", fy: "1", text: () => "*", frameAnchor: "middle"}
48+
),
49+
Plot.axisFx({label: null, frameAnchor: "middle", dy: 10, facetAnchor: "empty"}),
50+
Plot.frame({facetAnchor: "empty"})
51+
]
52+
});
53+
}

0 commit comments

Comments
 (0)