layerchart 0.58.1 → 0.58.3

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.
@@ -59,10 +59,29 @@
59
59
  $: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0;
60
60
  $: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0;
61
61
 
62
+ /** Provide initial `0` horizontal baseline and initially hide/untrack scale changes so not reactive (only set on initial mount) */
63
+ function defaultPathData() {
64
+ const path = $radial
65
+ ? areaRadial()
66
+ .angle((d) => $xScale(xAccessor(d)))
67
+ .innerRadius((d) => Math.min($yScale(0), $yRange[0]))
68
+ .outerRadius((d) => Math.min($yScale(0), $yRange[0]))
69
+ : d3Area()
70
+ .x((d) => $xScale(xAccessor(d)) + xOffset)
71
+ .y0((d) => Math.min($yScale(0), $yRange[0]))
72
+ .y1((d) => Math.min($yScale(0), $yRange[0]));
73
+
74
+ path.defined(defined ?? ((d) => xAccessor(d) != null && y1Accessor(d) != null));
75
+
76
+ if (curve) path.curve(curve);
77
+
78
+ return path(data ?? $contextData);
79
+ }
80
+
62
81
  $: tweenedOptions = tweened
63
82
  ? { interpolate: interpolatePath, ...(typeof tweened === 'object' ? tweened : null) }
64
83
  : false;
65
- $: tweened_d = motionStore('', { tweened: tweenedOptions });
84
+ $: tweened_d = motionStore(defaultPathData(), { tweened: tweenedOptions });
66
85
  $: {
67
86
  const path = $radial
68
87
  ? areaRadial()
@@ -21,7 +21,15 @@
21
21
  import { accessor, type Accessor } from '../utils/common.js';
22
22
  import { isScaleBand } from '../utils/scales.js';
23
23
 
24
- const { data: contextData, xScale, yScale, x: contextX, y: contextY, radial } = chartContext();
24
+ const {
25
+ data: contextData,
26
+ xScale,
27
+ yScale,
28
+ x: contextX,
29
+ y: contextY,
30
+ yRange,
31
+ radial,
32
+ } = chartContext();
25
33
 
26
34
  /** Override data instead of using context */
27
35
  export let data: any = undefined;
@@ -90,10 +98,27 @@
90
98
  $: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0;
91
99
  $: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0;
92
100
 
101
+ /** Provide initial `0` horizontal baseline and initially hide/untrack scale changes so not reactive (only set on initial mount) */
102
+ function defaultPathData() {
103
+ const path = $radial
104
+ ? lineRadial()
105
+ .angle((d) => $xScale(xAccessor(d)))
106
+ .radius((d) => Math.min($yScale(0), $yRange[0]))
107
+ : d3Line()
108
+ .x((d) => $xScale(xAccessor(d)) + xOffset)
109
+ .y((d) => Math.min($yScale(0), $yRange[0]));
110
+
111
+ path.defined(defined ?? ((d) => xAccessor(d) != null && yAccessor(d) != null));
112
+
113
+ if (curve) path.curve(curve);
114
+
115
+ return path(data ?? $contextData);
116
+ }
117
+
93
118
  let d: string | null = '';
94
119
  // @ts-expect-error
95
120
  $: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
96
- $: tweened_d = motionStore('', { tweened: tweenedOptions });
121
+ $: tweened_d = motionStore(defaultPathData(), { tweened: tweenedOptions });
97
122
  $: {
98
123
  const path = $radial
99
124
  ? lineRadial()
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.58.1",
7
+ "version": "0.58.3",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.9",
10
10
  "@mdi/js": "^7.4.47",