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.
@@ -34,7 +34,7 @@
34
34
  );
35
35
  </script>
36
36
 
37
- <Mark type="regression">
37
+ <Mark type="regression" {data} fx={options.fx} fy={options.fy}>
38
38
  {#each groups as group, g (g)}
39
39
  <Regression data={group as any} dependent="x" {...options as any} />
40
40
  {/each}
@@ -33,7 +33,7 @@
33
33
  );
34
34
  </script>
35
35
 
36
- <Mark type="regression">
36
+ <Mark type="regression" {data} fx={options.fx} fy={options.fy}>
37
37
  {#each groups as group, i (i)}
38
38
  <Regression data={group as any} dependent="y" {...options as any} />
39
39
  {/each}
@@ -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
- function toOutputX(value: number, scaleType: string): RawValue {
97
- return isTemporalScale(scaleType) ? new Date(value) : value;
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], plot.scales[independent].type),
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, plot.scales[independent].type),
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, plot.scales[independent].type),
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, plot.scales[independent].type),
243
+ __x: toOutputX(__x, independentIsDate),
234
244
  __y1: left,
235
245
  __y2: right
236
246
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.14.0-pr-547.0",
3
+ "version": "0.14.1-pr-549.0",
4
4
  "description": "A Svelte-native data visualization framework based on the layered grammar of graphics principles.",
5
5
  "keywords": [
6
6
  "svelte",