@@ -48,16 +48,21 @@ const Inputs = ({..._Inputs, table})
48
48
49
49
function table (data , options = {}) {
50
50
if (! data) return data;
51
+ const table = _Inputs .table (data, options);
51
52
52
- const container = document .createElement (" div" );
53
- container .append (_Inputs .table (data, options));
54
-
55
- // Duck typing Arrow table
53
+ // Duck typing Arrow table
56
54
if (! Array .isArray (data? .schema ? .fields )) return container;
57
55
58
56
// Get the fields as described by Arrow, in the order given (potentially) by the options.
59
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)}));
60
58
59
+ const container = document .createElement (" div" );
60
+ container .append (table);
61
+ container .setAttribute (" class" , " summary-table" );
62
+ d3 .select (table)
63
+ .style (" min-width" , ` ${ 120 * fields .length } px` )
64
+ .style (" max-width" , ` ${ 280 * fields .length } px` );
65
+
61
66
const th = d3 .select (container).select (" thead" ).selectAll (" th" ).data ([{}, ... fields]);
62
67
th .append (" div" ).classed (" type" , true ).html (({type}) => type);
63
68
const summaries = th .append (" div" ).classed (" summary" , true );
@@ -192,8 +197,9 @@ async function summary(div) {
192
197
193
198
<style>
194
199
195
- table .type {font-size: smaller; font-weight: normal; color: var(--theme-foreground-muted); height: 1.35em;}
196
- table .summary {font-size: smaller; font-weight: normal; height: 33px;}
197
- footer {font-family: var(--sans-serif); font-size: small; color: var(--theme-foreground-faint)}
200
+ .summary-table {max-width: 100%; overflow-x: auto;}
201
+ .summary-table table .type {font-size: smaller; font-weight: normal; color: var(--theme-foreground-muted); height: 1.35em;}
202
+ .summary-table table .summary {font-size: smaller; font-weight: normal; height: 33px;}
203
+ .summary-table footer {font-family: var(--sans-serif); font-size: small; color: var(--theme-foreground-faint)}
198
204
199
205
</style>
0 commit comments