@@ -56,6 +56,8 @@ function table(data, options = {}) {
5656 // Get the fields as described by Arrow, in the order given (potentially) by the options.
5757 const fields = (options .columns ? .map (k => data .schema .find (({name}) => name === k)) ?? data .schema .fields ).map (({name, type}) => ({name: String (name), type: String (type), values: data .getChild (name)}));
5858
59+ options .columns = fields .map (({name}) => name);
60+
5961 const container = document .createElement (" div" );
6062 container .append (table);
6163 container .setAttribute (" class" , " summary-table" );
@@ -68,7 +70,7 @@ function table(data, options = {}) {
6870 const summaries = th .append (" div" ).classed (" summary" , true );
6971
7072 const textFields = fields .filter (({type}) => type === " Utf8" );
71- const tally = html ` <div style = " position : absolute ; right : 0 ; " >${ data .numRows .toLocaleString (" en-US" )} rows</div >` ;
73+ const tally = html ` <div class = " tally " >${ data .numRows .toLocaleString (" en-US" )} rows</div >` ;
7274 const footer = html ` <footer style =" width : 100% ; height : 1em ;" >
7375 ${ textFields .length ? html ` <div style =" position : absolute ; left : 0 ;" ><input type =" search" placeholder =" Search text fields" onkeyup =${search} onchange =${search} ></div >` : " " }
7476 ${ tally}
@@ -102,7 +104,7 @@ function table(data, options = {}) {
102104 th .append ((d , i ) => thtype[i]);
103105 th .append ((d , i ) => thsummary[i]);
104106
105- tally .innerHTML = index === index0 ? ` ${ index .length } rows` : ` <b>${ index .length } </b> / ${ index0 .length } ` ;
107+ tally .innerHTML = index === index0 ? ` ${ index .length . toLocaleString ( " en-US " ) } rows` : ` <b>${ index .length . toLocaleString ( " en-US " ) } </b> / ${ index0 .length . toLocaleString ( " en-US " ) } ` ;
106108 }
107109
108110 function take (data , index ) {
@@ -251,8 +253,7 @@ async function summary(div, filters, refresh) {
251253
252254 const X = Array .from (values, chart .scale (" x" ).apply );
253255 const brush = d3 .brushX ()
254- .on (" end" , refresh)
255- .on (" brush" , ({selection}) => {
256+ .on (" brush end" , ({selection}) => {
256257 if (selection) {
257258 const [min , max ] = selection;
258259 filters .set (name, (i ) => min <= X [i] && X [i] <= max);
@@ -275,5 +276,6 @@ async function summary(div, filters, refresh) {
275276 .summary-table table .summary {font-size: smaller; font-weight: normal; height: 33px;}
276277 .summary-table footer {font-family: var(--sans-serif); font-size: small; color: var(--theme-foreground-faint)}
277278 .summary-table rect.selected { fill: orange; }
279+ .summary-table .tally {position: absolute; right: 0; font-variant-numeric: tabular-nums;}
278280
279281</style>
0 commit comments