svelteplot 0.12.0-pr-532.3 → 0.12.0-pr-532.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/marks/Density.svelte +30 -13
- package/package.json +1 -1
|
@@ -295,28 +295,45 @@
|
|
|
295
295
|
*/
|
|
296
296
|
const extent = $derived.by(() => {
|
|
297
297
|
if (!data?.length) return null;
|
|
298
|
-
let xMin
|
|
299
|
-
xMax
|
|
300
|
-
yMin
|
|
301
|
-
yMax
|
|
298
|
+
let xMin = Infinity,
|
|
299
|
+
xMax = -Infinity,
|
|
300
|
+
yMin = Infinity,
|
|
301
|
+
yMax = -Infinity;
|
|
302
|
+
let xUsesDate = false,
|
|
303
|
+
yUsesDate = false;
|
|
302
304
|
for (const d of data as any[]) {
|
|
303
305
|
const xv = resolveAcc(xAcc, d);
|
|
304
306
|
const yv = resolveAcc(yAcc, d);
|
|
305
|
-
if (
|
|
307
|
+
if (xv instanceof Date) {
|
|
308
|
+
xUsesDate = true;
|
|
309
|
+
const ms = xv.getTime();
|
|
310
|
+
if (isFinite(ms)) {
|
|
311
|
+
if (ms < xMin) xMin = ms;
|
|
312
|
+
if (ms > xMax) xMax = ms;
|
|
313
|
+
}
|
|
314
|
+
} else if (typeof xv === 'number' && isFinite(xv)) {
|
|
306
315
|
if (xv < xMin) xMin = xv;
|
|
307
316
|
if (xv > xMax) xMax = xv;
|
|
308
317
|
}
|
|
309
|
-
if (
|
|
318
|
+
if (yv instanceof Date) {
|
|
319
|
+
yUsesDate = true;
|
|
320
|
+
const ms = yv.getTime();
|
|
321
|
+
if (isFinite(ms)) {
|
|
322
|
+
if (ms < yMin) yMin = ms;
|
|
323
|
+
if (ms > yMax) yMax = ms;
|
|
324
|
+
}
|
|
325
|
+
} else if (typeof yv === 'number' && isFinite(yv)) {
|
|
310
326
|
if (yv < yMin) yMin = yv;
|
|
311
327
|
if (yv > yMax) yMax = yv;
|
|
312
328
|
}
|
|
313
329
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
:
|
|
330
|
+
if (!isFinite(xMin) || !isFinite(xMax) || !isFinite(yMin) || !isFinite(yMax)) return null;
|
|
331
|
+
return {
|
|
332
|
+
x1: xUsesDate ? new Date(xMin) : xMin,
|
|
333
|
+
x2: xUsesDate ? new Date(xMax) : xMax,
|
|
334
|
+
y1: yUsesDate ? new Date(yMin) : yMin,
|
|
335
|
+
y2: yUsesDate ? new Date(yMax) : yMax
|
|
336
|
+
};
|
|
320
337
|
});
|
|
321
338
|
|
|
322
339
|
/**
|
|
@@ -334,7 +351,7 @@
|
|
|
334
351
|
const markData = $derived.by((): DataRecord[] => {
|
|
335
352
|
const ext = extent;
|
|
336
353
|
const records: any[] = [];
|
|
337
|
-
|
|
354
|
+
console.log({ extent });
|
|
338
355
|
// Bootstrap extent record(s) so x/y scales are available for density
|
|
339
356
|
// computation on the first render pass. When faceted, emit one record
|
|
340
357
|
// per unique (fxVal, fyVal) combination so no record carries an
|