@juspay/svelte-ui-components 2.109.0 → 2.110.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.
|
@@ -204,11 +204,25 @@
|
|
|
204
204
|
series.map((s, si) => {
|
|
205
205
|
const color = s.color ?? getColor(si);
|
|
206
206
|
const points: Point[] = s.data.map((d) => ({ x: xScale(d.x), y: yScale(d.y) }));
|
|
207
|
+
const finitePoints = points.filter(
|
|
208
|
+
(point) => Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
209
|
+
);
|
|
210
|
+
// Design-system contract: a series with a single data point renders as a
|
|
211
|
+
// flat line at that y across the full plot width (a lone dot reads as a
|
|
212
|
+
// glitch), while the point marker itself still renders at its true x.
|
|
213
|
+
const isSinglePoint = finitePoints.length === 1;
|
|
214
|
+
const pathPoints: Point[] = isSinglePoint
|
|
215
|
+
? [
|
|
216
|
+
{ x: 0, y: finitePoints[0].y },
|
|
217
|
+
{ x: dims.innerWidth, y: finitePoints[0].y }
|
|
218
|
+
]
|
|
219
|
+
: points;
|
|
207
220
|
return {
|
|
208
221
|
color,
|
|
209
222
|
points,
|
|
210
|
-
|
|
211
|
-
|
|
223
|
+
dash: s.dash === true ? '6 4' : typeof s.dash === 'string' ? s.dash : null,
|
|
224
|
+
path: linePath(pathPoints, isSinglePoint ? 'linear' : curve),
|
|
225
|
+
areaD: areaPath(pathPoints, dims.innerHeight, isSinglePoint ? 'linear' : curve),
|
|
212
226
|
hidden: hiddenSeries.has(si)
|
|
213
227
|
};
|
|
214
228
|
})
|
|
@@ -639,6 +653,7 @@
|
|
|
639
653
|
d={line.path}
|
|
640
654
|
stroke={line.color}
|
|
641
655
|
stroke-width={strokeWidth}
|
|
656
|
+
stroke-dasharray={line.dash}
|
|
642
657
|
fill="none"
|
|
643
658
|
/>
|
|
644
659
|
{#if line.points.length === 1 && !showDots && Number.isFinite(line.points[0].x) && Number.isFinite(line.points[0].y)}
|
|
@@ -10,6 +10,12 @@ export type LineChartSeries = {
|
|
|
10
10
|
name: string;
|
|
11
11
|
data: LineChartDataPoint[];
|
|
12
12
|
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Dashed stroke for this series (e.g. a comparison/previous-period line).
|
|
15
|
+
* `true` uses the default `'6 4'` pattern; a string is passed through as a
|
|
16
|
+
* custom SVG `stroke-dasharray`. Omit for a solid line.
|
|
17
|
+
*/
|
|
18
|
+
dash?: boolean | string;
|
|
13
19
|
};
|
|
14
20
|
export type LineChartTooltipContext = {
|
|
15
21
|
x: number;
|