@@ -86,9 +86,15 @@ function table(data, options = {}) {
86
86
// save table headers for the dirty copy below
87
87
const thtype = [... d3 .select (table).selectAll (" th :nth-child(2)" )]
88
88
const thsummary = [... d3 .select (table).selectAll (" th :nth-child(3)" )]
89
+ let debounce;
89
90
return container;
90
91
92
+ // debounce refreshes
91
93
function refresh () {
94
+ debounce |= setTimeout (refresh1, 50 );
95
+ }
96
+
97
+ function refresh1 () {
92
98
const index0 = d3 .range (data .length ?? data .numRows );
93
99
let index = index0;
94
100
for (const [, f ] of filters) index = index .filter (f);
@@ -105,6 +111,7 @@ function table(data, options = {}) {
105
111
th .append ((d , i ) => thsummary[i]);
106
112
107
113
tally .innerHTML = index === index0 ? ` ${ index .length .toLocaleString (" en-US" )} rows` : ` <b>${ index .length .toLocaleString (" en-US" )} </b> / ${ index0 .length .toLocaleString (" en-US" )} ` ;
114
+ debounce = null ;
108
115
}
109
116
110
117
function take (data , index ) {
@@ -223,6 +230,8 @@ async function summary(div, filters, refresh) {
223
230
if (domain .length > 2 ) domain .splice (1 , domain .length - 2 );
224
231
const ticks = isDate ? d3 .utcTicks (... domain, niceK) : d3 .ticks (... domain, niceK);
225
232
if (ticks .length > 2 ) ticks .splice (1 , ticks .length - 2 );
233
+
234
+ // TODO show count of invalid values, make them selectable.
226
235
chart = Plot .plot ({
227
236
width,
228
237
height,
@@ -258,7 +267,7 @@ async function summary(div, filters, refresh) {
258
267
const [min , max ] = selection;
259
268
filters .set (name, (i ) => min <= X [i] && X [i] <= max);
260
269
} else filters .delete (name);
261
- refresh (); // TODO debounce
270
+ refresh ();
262
271
});
263
272
d3 .select (chart).append (" g" ).call (brush);
264
273
}
0 commit comments