@@ -86,9 +86,15 @@ function table(data, options = {}) {
8686 // save table headers for the dirty copy below
8787 const thtype = [... d3 .select (table).selectAll (" th :nth-child(2)" )]
8888 const thsummary = [... d3 .select (table).selectAll (" th :nth-child(3)" )]
89+ let debounce;
8990 return container;
9091
92+ // debounce refreshes
9193 function refresh () {
94+ debounce |= setTimeout (refresh1, 50 );
95+ }
96+
97+ function refresh1 () {
9298 const index0 = d3 .range (data .length ?? data .numRows );
9399 let index = index0;
94100 for (const [, f ] of filters) index = index .filter (f);
@@ -105,6 +111,7 @@ function table(data, options = {}) {
105111 th .append ((d , i ) => thsummary[i]);
106112
107113 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 ;
108115 }
109116
110117 function take (data , index ) {
@@ -223,6 +230,8 @@ async function summary(div, filters, refresh) {
223230 if (domain .length > 2 ) domain .splice (1 , domain .length - 2 );
224231 const ticks = isDate ? d3 .utcTicks (... domain, niceK) : d3 .ticks (... domain, niceK);
225232 if (ticks .length > 2 ) ticks .splice (1 , ticks .length - 2 );
233+
234+ // TODO show count of invalid values, make them selectable.
226235 chart = Plot .plot ({
227236 width,
228237 height,
@@ -258,7 +267,7 @@ async function summary(div, filters, refresh) {
258267 const [min , max ] = selection;
259268 filters .set (name, (i ) => min <= X [i] && X [i] <= max);
260269 } else filters .delete (name);
261- refresh (); // TODO debounce
270+ refresh ();
262271 });
263272 d3 .select (chart).append (" g" ).call (brush);
264273 }
0 commit comments