layerchart 1.0.3 → 1.0.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.
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import Spline from './Spline.svelte';
|
|
18
18
|
import { accessor, type Accessor } from '../utils/common.js';
|
|
19
19
|
import { isScaleBand } from '../utils/scales.js';
|
|
20
|
+
import { flattenPathData } from '../utils/path.js';
|
|
20
21
|
import { getCanvasContext } from './layout/Canvas.svelte';
|
|
21
22
|
import { renderPathData, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
22
23
|
const {
|
|
@@ -78,21 +79,30 @@
|
|
|
78
79
|
|
|
79
80
|
/** Provide initial `0` horizontal baseline and initially hide/untrack scale changes so not reactive (only set on initial mount) */
|
|
80
81
|
function defaultPathData() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
if (!tweenedOptions) {
|
|
83
|
+
// If not tweened, return empty string (faster initial render)
|
|
84
|
+
return '';
|
|
85
|
+
} else if (pathData) {
|
|
86
|
+
// Flatten all `y` coordinates of pre-defined `pathData`
|
|
87
|
+
return flattenPathData(pathData, Math.min($yScale(0), $yRange[0]));
|
|
88
|
+
} else if ($config.x) {
|
|
89
|
+
// Only use default line if `x` accessor is defined (cartesian chart)
|
|
90
|
+
const path = $radial
|
|
91
|
+
? areaRadial()
|
|
92
|
+
.angle((d) => $xScale(xAccessor(d)))
|
|
93
|
+
.innerRadius((d) => Math.min($yScale(0), $yRange[0]))
|
|
94
|
+
.outerRadius((d) => Math.min($yScale(0), $yRange[0]))
|
|
95
|
+
: d3Area()
|
|
96
|
+
.x((d) => $xScale(xAccessor(d)) + xOffset)
|
|
97
|
+
.y0((d) => Math.min($yScale(0), $yRange[0]))
|
|
98
|
+
.y1((d) => Math.min($yScale(0), $yRange[0]));
|
|
99
|
+
|
|
100
|
+
path.defined(defined ?? ((d) => xAccessor(d) != null && y1Accessor(d) != null));
|
|
101
|
+
|
|
102
|
+
if (curve) path.curve(curve);
|
|
103
|
+
|
|
104
|
+
return path(data ?? $contextData);
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
const tweenedOptions = tweened
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
x: xMax + getOffset(xMax, offsetX, $xScale) - ($config.r ? $rGet(d) : r),
|
|
144
144
|
y: y,
|
|
145
145
|
},
|
|
146
|
+
data: d,
|
|
146
147
|
};
|
|
147
148
|
} else if (Array.isArray(yValue)) {
|
|
148
149
|
/*
|
|
@@ -160,6 +161,7 @@
|
|
|
160
161
|
x: x,
|
|
161
162
|
y: yMax + getOffset(yMax, offsetY, $yScale),
|
|
162
163
|
},
|
|
164
|
+
data: d,
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
167
|
});
|
|
@@ -170,7 +172,7 @@
|
|
|
170
172
|
{#each _links as link}
|
|
171
173
|
<Link
|
|
172
174
|
data={link}
|
|
173
|
-
|
|
175
|
+
stroke={fill ?? ($config.c ? $cGet(link.data) : null)}
|
|
174
176
|
{...typeof links === 'object' ? links : null}
|
|
175
177
|
/>
|
|
176
178
|
{/each}
|
|
@@ -433,15 +433,17 @@
|
|
|
433
433
|
onpointenter={() => (highlightSeriesKey = s.key)}
|
|
434
434
|
onpointleave={() => (highlightSeriesKey = null)}
|
|
435
435
|
{...props.highlight}
|
|
436
|
-
points={
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
436
|
+
points={props.highlight?.points == false
|
|
437
|
+
? false
|
|
438
|
+
: {
|
|
439
|
+
...highlightPointsProps,
|
|
440
|
+
fill: s.color,
|
|
441
|
+
class: cls(
|
|
442
|
+
'transition-opacity',
|
|
443
|
+
highlightSeriesKey && highlightSeriesKey !== s.key && 'opacity-10',
|
|
444
|
+
highlightPointsProps?.class
|
|
445
|
+
),
|
|
446
|
+
}}
|
|
445
447
|
/>
|
|
446
448
|
{/each}
|
|
447
449
|
</slot>
|
|
@@ -363,15 +363,17 @@
|
|
|
363
363
|
onpointenter={() => (highlightSeriesKey = s.key)}
|
|
364
364
|
onpointleave={() => (highlightSeriesKey = null)}
|
|
365
365
|
{...props.highlight}
|
|
366
|
-
points={
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
366
|
+
points={props.highlight?.points == false
|
|
367
|
+
? false
|
|
368
|
+
: {
|
|
369
|
+
...highlightPointsProps,
|
|
370
|
+
fill: s.color,
|
|
371
|
+
class: cls(
|
|
372
|
+
'transition-opacity',
|
|
373
|
+
highlightSeriesKey && highlightSeriesKey !== s.key && 'opacity-10',
|
|
374
|
+
highlightPointsProps?.class
|
|
375
|
+
),
|
|
376
|
+
}}
|
|
375
377
|
/>
|
|
376
378
|
{/each}
|
|
377
379
|
</slot>
|