@@ -56,6 +56,8 @@ function table(data, options = {}) {
56
56
// Get the fields as described by Arrow, in the order given (potentially) by the options.
57
57
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)}));
58
58
59
+ options .columns = fields .map (({name}) => name);
60
+
59
61
const container = document .createElement (" div" );
60
62
container .append (table);
61
63
container .setAttribute (" class" , " summary-table" );
@@ -68,7 +70,7 @@ function table(data, options = {}) {
68
70
const summaries = th .append (" div" ).classed (" summary" , true );
69
71
70
72
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 >` ;
72
74
const footer = html ` <footer style =" width : 100% ; height : 1em ;" >
73
75
${ textFields .length ? html ` <div style =" position : absolute ; left : 0 ;" ><input type =" search" placeholder =" Search text fields" onkeyup =${search} onchange =${search} ></div >` : " " }
74
76
${ tally}
@@ -102,7 +104,7 @@ function table(data, options = {}) {
102
104
th .append ((d , i ) => thtype[i]);
103
105
th .append ((d , i ) => thsummary[i]);
104
106
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 " ) } ` ;
106
108
}
107
109
108
110
function take (data , index ) {
@@ -251,8 +253,7 @@ async function summary(div, filters, refresh) {
251
253
252
254
const X = Array .from (values, chart .scale (" x" ).apply );
253
255
const brush = d3 .brushX ()
254
- .on (" end" , refresh)
255
- .on (" brush" , ({selection}) => {
256
+ .on (" brush end" , ({selection}) => {
256
257
if (selection) {
257
258
const [min , max ] = selection;
258
259
filters .set (name, (i ) => min <= X [i] && X [i] <= max);
@@ -275,5 +276,6 @@ async function summary(div, filters, refresh) {
275
276
.summary-table table .summary {font-size: smaller; font-weight: normal; height: 33px;}
276
277
.summary-table footer {font-family: var(--sans-serif); font-size: small; color: var(--theme-foreground-faint)}
277
278
.summary-table rect.selected { fill: orange; }
279
+ .summary-table .tally {position: absolute; right: 0; font-variant-numeric: tabular-nums;}
278
280
279
281
</style>
0 commit comments