Skip to content

Commit 8895347

Browse files
committed
brush
1 parent 16259e2 commit 8895347

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/summary-table.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ function table(data, options = {}) {
9595
// In the meantime, here's a very dirty approach
9696
const _data = index === index0 ? data : take(data, index);
9797
table.replaceWith(table = _Inputs.table(_data, options));
98+
d3.select(table)
99+
.style("min-width", `${120 * fields.length}px`)
100+
.style("max-width", `${280 * fields.length}px`);
98101
const th = d3.select(table).selectAll("th");
99102
th.append((d, i) => thtype[i]);
100103
th.append((d, i) => thsummary[i]);
@@ -245,6 +248,18 @@ async function summary(div, filters, refresh) {
245248
Plot.axisX(ticks, {tickSize: 3, tickPadding: 2, fontSize: 8, ...(!isDate && {tickFormat: "s"})}),
246249
]
247250
});
251+
252+
const X = Array.from(values, chart.scale("x").apply);
253+
const brush = d3.brushX()
254+
.on("end", refresh)
255+
.on("brush", ({selection}) => {
256+
if (selection) {
257+
const [min, max] = selection;
258+
filters.set(name, (i) => min <= X[i] && X[i] <= max);
259+
} else filters.delete(name);
260+
refresh(); // TODO debounce
261+
});
262+
d3.select(chart).call(brush);
248263
}
249264
div.append(chart ? html`<div style=${type === "Utf8" ? "" : {
250265
position: "absolute",

0 commit comments

Comments
 (0)