svelteplot 0.14.0-pr-547.0 → 0.14.1-pr-549.0
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.
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
regressionLoess
|
|
44
44
|
} from '../../regression/index.js';
|
|
45
45
|
import { resolveChannel } from '../../helpers/resolve.js';
|
|
46
|
-
import { isTemporalScale } from '../../helpers/typeChecks.js';
|
|
47
46
|
import { confidenceInterval } from '../../helpers/math.js';
|
|
48
47
|
import callWithProps from '../../helpers/callWithProps.js';
|
|
49
48
|
import type { DataRecord, FacetContext, RawValue } from '../../types/index.js';
|
|
@@ -93,8 +92,12 @@
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
// Convert generated points back to Date for time scales so downstream marks render correctly.
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
// Takes a boolean instead of the scale type to avoid a circular dependency: if we used
|
|
96
|
+
// plot.scales[independent].type, the Line mark would register numeric __x values during the
|
|
97
|
+
// first render pass (before the scale type is resolved), causing scale inference to see a mix
|
|
98
|
+
// of Dates and numbers and fall back to 'linear' permanently.
|
|
99
|
+
function toOutputX(value: number, isTemporal: boolean): RawValue {
|
|
100
|
+
return isTemporal ? new Date(value) : value;
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
function makeTicks(domain: [number, number], count = 40): number[] {
|
|
@@ -129,6 +132,13 @@
|
|
|
129
132
|
|
|
130
133
|
const regressionFn = $derived(maybeRegression(type));
|
|
131
134
|
|
|
135
|
+
// Detect temporality from the raw data rather than from the computed scale type to avoid a
|
|
136
|
+
// circular dependency that would cause the scale type to be permanently inferred as 'linear'.
|
|
137
|
+
const independentIsDate = $derived(
|
|
138
|
+
filteredData.length > 0 &&
|
|
139
|
+
resolveChannel(independent, filteredData[0], options as any) instanceof Date
|
|
140
|
+
);
|
|
141
|
+
|
|
132
142
|
// Build a clean numeric input set for regression fitting, dropping invalid rows early.
|
|
133
143
|
const regressionInput = $derived(
|
|
134
144
|
filteredData
|
|
@@ -193,18 +203,18 @@
|
|
|
193
203
|
// Prefer batch prediction when supported, then per-point predict, then raw curve output.
|
|
194
204
|
if (typeof regression.predictMany === 'function') {
|
|
195
205
|
return regression.predictMany(regrPoints).map((__y, i) => ({
|
|
196
|
-
__x: toOutputX(regrPoints[i],
|
|
206
|
+
__x: toOutputX(regrPoints[i], independentIsDate),
|
|
197
207
|
__y
|
|
198
208
|
}));
|
|
199
209
|
}
|
|
200
210
|
if (typeof regression.predict === 'function') {
|
|
201
211
|
return regrPoints.map((point) => ({
|
|
202
|
-
__x: toOutputX(point,
|
|
212
|
+
__x: toOutputX(point, independentIsDate),
|
|
203
213
|
__y: regression.predict!(point)
|
|
204
214
|
}));
|
|
205
215
|
}
|
|
206
216
|
return regression.map(([__x, __y]) => ({
|
|
207
|
-
__x: toOutputX(__x,
|
|
217
|
+
__x: toOutputX(__x, independentIsDate),
|
|
208
218
|
__y
|
|
209
219
|
}));
|
|
210
220
|
});
|
|
@@ -230,7 +240,7 @@
|
|
|
230
240
|
return regrPoints.map((x) => {
|
|
231
241
|
const { x: __x, left, right } = confBandGen(x);
|
|
232
242
|
return {
|
|
233
|
-
__x: toOutputX(__x,
|
|
243
|
+
__x: toOutputX(__x, independentIsDate),
|
|
234
244
|
__y1: left,
|
|
235
245
|
__y2: right
|
|
236
246
|
};
|