Skip to content

Commit 8b4da94

Browse files
committed
Merge branch 'fil/brush-x' into fil/brush-merge
2 parents baf1e48 + 76474e8 commit 8b4da94

30 files changed

+9148
-3
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export default defineConfig({
145145
text: "Interactions",
146146
collapsed: true,
147147
items: [
148+
{text: "Brush", link: "/interactions/brush"},
148149
{text: "Crosshair", link: "/interactions/crosshair"},
149150
{text: "Pointer", link: "/interactions/pointer"}
150151
]

docs/components/links.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function getAnchors(text) {
1313
.toLowerCase()
1414
);
1515
}
16-
for (const [, anchor] of text.matchAll(/ \{#([\w\d-]+)\}/g)) {
16+
for (const [, anchor] of text.matchAll(/ \{#([\w\d.-]+)\}/g)) {
1717
anchors.push(anchor);
1818
}
1919
return anchors;

docs/features/interactions.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as Plot from "@observablehq/plot";
44
import * as d3 from "d3";
55
import {shallowRef, onMounted} from "vue";
6+
import penguins from "../data/penguins.ts";
67

78
const olympians = shallowRef([
89
{weight: 31, height: 1.21, sex: "female"},
@@ -66,7 +67,27 @@ Plot.plot({
6667

6768
## Selecting
6869

69-
Support for selecting points within a plot through direct manipulation is under development. If you are interested in this feature, please upvote [#5](https://github.com/observablehq/plot/issues/5). See [#721](https://github.com/observablehq/plot/pull/721) for some early work on brushing.
70+
The [brush mark](../interactions/brush.md) lets the reader select a rectangular region by clicking and dragging. The selected region is then exposed as the plot’s `value` and can be used to filter data. Optionally, when combined with reactive marks — **inactive**, **context**, and **focus** — the brush highlights the selected data while dimming the rest.
71+
72+
:::plot defer hidden
73+
```js
74+
Plot.plot({
75+
marks: ((brush) => (d3.timeout(() => d3.select(brush._brushNodes[0]).call(brush._brush.move, [[100, 60], [300, 200]])), [
76+
Plot.dot(penguins, {x: "culmen_length_mm", y: "culmen_depth_mm", stroke: "species"}),
77+
brush
78+
]))(Plot.brush())
79+
})
80+
```
81+
:::
82+
83+
```js
84+
Plot.plot({
85+
marks: [
86+
Plot.dot(penguins, {x: "culmen_length_mm", y: "culmen_depth_mm", stroke: "species"}),
87+
Plot.brush()
88+
]
89+
})
90+
```
7091

7192
## Zooming
7293

0 commit comments

Comments
 (0)