@@ -73,7 +73,7 @@ function table(data, options = {}) {
73
73
74
74
function summary ({name, type, values}) {
75
75
const {width: w , height } = this .getBoundingClientRect ();
76
- const width = Math .min (200 , (w ?? 80 ) - 10 );
76
+ const width = Math .min (200 , (w ?? 80 ));
77
77
let chart;
78
78
79
79
// Count values, NaN, nulls, distinct
@@ -145,18 +145,21 @@ function summary({name, type, values}) {
145
145
}
146
146
// temporal, quantitative
147
147
else {
148
+ const niceK = 5 ;
149
+ const isDate = type .startsWith (" Date" );
148
150
const thresholds = Math .max (10 , Math .min (50 , d3 .thresholdScott (values, min, max))); // TODO optimize thresholdScott
151
+ const domain = d3 .nice (min, max, niceK);
152
+ if (domain .length > 2 ) domain .splice (1 , domain .length - 2 );
153
+ const ticks = isDate ? d3 .utcTicks (... domain, niceK) : d3 .ticks (... domain, niceK);
154
+ if (ticks .length > 2 ) ticks .splice (1 , ticks .length - 2 );
149
155
chart = Plot .plot ({
150
156
width,
151
157
height,
152
158
style: " overflow: visible;" ,
153
- x: {
154
- round: true ,
155
- nice: true
156
- },
159
+ x: {round: true , nice: niceK},
157
160
y: {axis: null },
158
- marginLeft: 9 ,
159
- marginRight: 9 ,
161
+ marginLeft: 4 ,
162
+ marginRight: 12 ,
160
163
marginTop: 0 ,
161
164
marginBottom: 13 ,
162
165
marks: [
@@ -171,9 +174,9 @@ function summary({name, type, values}) {
171
174
inset: 0 ,
172
175
insetRight: 1 ,
173
176
})),
174
- min * max <= 0 ? Plot .ruleX ([0 ]) : [],
177
+ domain[ 0 ] * domain[ 1 ] <= 0 ? Plot .ruleX ([0 ]) : [],
175
178
Plot .ruleY ([0 ]),
176
- Plot .axisX ({tickSpacing : 41 , tickSize: 3 , tickPadding: 2 , fontSize: 8 , ... (! type . startsWith ( " Date " ) && Math . max ( Math . abs (min), Math . abs (max)) >= 1e5 && {tickFormat: " s" })}),
179
+ Plot .axisX (ticks, { tickSize: 3 , tickPadding: 2 , fontSize: 8 , ... (! isDate && {tickFormat: " s" })}),
177
180
]
178
181
});
179
182
}
0 commit comments