layerchart 2.0.0-next.55 → 2.0.0-next.57
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.
- package/dist/bench/ComposableLineChart.svelte +1 -1
- package/dist/bench/GeoBench.svelte +1 -8
- package/dist/components/AnnotationRange.svelte +21 -8
- package/dist/components/Arc.svelte +1 -3
- package/dist/components/ArcLabel.svelte.test.js +7 -7
- package/dist/components/Bar.svelte +4 -2
- package/dist/components/BoxPlot.svelte +4 -12
- package/dist/components/Cell.svelte +13 -8
- package/dist/components/Chart.svelte +69 -26
- package/dist/components/ChartChildren.svelte +22 -4
- package/dist/components/Circle.svelte +34 -12
- package/dist/components/ClipPath.svelte +3 -9
- package/dist/components/Ellipse.svelte +27 -6
- package/dist/components/GeoLegend.svelte +1 -3
- package/dist/components/GeoPoint.svelte +25 -3
- package/dist/components/GeoSpline.svelte +1 -4
- package/dist/components/GeoTile.svelte +8 -4
- package/dist/components/Group.svelte +11 -5
- package/dist/components/Highlight.svelte +3 -3
- package/dist/components/Image.svelte +42 -30
- package/dist/components/Labels.svelte +2 -4
- package/dist/components/Line.svelte +7 -6
- package/dist/components/LinearGradient.svelte +8 -4
- package/dist/components/Link.svelte +0 -1
- package/dist/components/Marker.svelte +9 -1
- package/dist/components/Path.svelte +43 -23
- package/dist/components/Pattern.svelte +101 -5
- package/dist/components/Pattern.svelte.d.ts +3 -1
- package/dist/components/Pie.svelte +2 -6
- package/dist/components/RadialGradient.svelte +8 -4
- package/dist/components/Rect.svelte +29 -12
- package/dist/components/Spline.svelte +24 -6
- package/dist/components/Text.svelte +9 -5
- package/dist/components/Trail.svelte +19 -7
- package/dist/components/Vector.svelte +37 -14
- package/dist/components/Violin.svelte +1 -2
- package/dist/components/charts/ArcChart.svelte +8 -5
- package/dist/components/charts/AreaChart.svelte +6 -1
- package/dist/components/charts/BarChart.svelte +3 -1
- package/dist/components/charts/LineChart.svelte +6 -1
- package/dist/components/charts/PieChart.svelte +10 -3
- package/dist/components/tooltip/Tooltip.svelte +2 -8
- package/dist/contexts/chart.d.ts +1 -1
- package/dist/contexts/chart.js +3 -1
- package/dist/server/TestBarChart.svelte +28 -28
- package/dist/server/TestLineChart.svelte +28 -28
- package/dist/server/index.js +1 -1
- package/dist/states/brush.svelte.js +16 -13
- package/dist/states/chart.svelte.js +14 -4
- package/dist/states/chart.svelte.test.js +70 -19
- package/dist/states/geo.svelte.js +1 -4
- package/dist/states/series.svelte.js +1 -1
- package/dist/utils/canvas.js +7 -4
- package/dist/utils/trail.js +3 -4
- package/package.json +1 -1
|
@@ -313,9 +313,7 @@
|
|
|
313
313
|
const resolved = resolveCorners(corners, Infinity, Infinity);
|
|
314
314
|
return cornersUniform(resolved) ? resolved[0] : undefined;
|
|
315
315
|
});
|
|
316
|
-
const cornersNonUniform = $derived(
|
|
317
|
-
corners !== undefined && cornersUniformValue === undefined
|
|
318
|
-
);
|
|
316
|
+
const cornersNonUniform = $derived(corners !== undefined && cornersUniformValue === undefined);
|
|
319
317
|
|
|
320
318
|
// Normalize rx/ry - if only one is provided, use it for both (SVG behavior)
|
|
321
319
|
// Coerce to number for canvas rendering (SVG allows string like "50%")
|
|
@@ -368,8 +366,14 @@
|
|
|
368
366
|
const staticStrokeWidth = $derived(typeof strokeWidth === 'number' ? strokeWidth : undefined);
|
|
369
367
|
const staticOpacity = $derived(typeof opacity === 'number' ? opacity : undefined);
|
|
370
368
|
const staticClassName = $derived(typeof className === 'string' ? className : undefined);
|
|
369
|
+
// Match SVG's implicit `stroke-width: 1` default: if `stroke` is set but
|
|
370
|
+
// `strokeWidth` is not, render a 1px border so HTML matches SVG/Canvas layers.
|
|
371
371
|
const staticBorderWidth = $derived(
|
|
372
|
-
typeof strokeWidth === 'number'
|
|
372
|
+
typeof strokeWidth === 'number'
|
|
373
|
+
? `${strokeWidth}px`
|
|
374
|
+
: typeof stroke === 'string'
|
|
375
|
+
? '1px'
|
|
376
|
+
: undefined
|
|
373
377
|
);
|
|
374
378
|
const htmlRestProps = $derived(restProps as unknown as HTMLAttributes<HTMLDivElement>);
|
|
375
379
|
|
|
@@ -430,12 +434,13 @@
|
|
|
430
434
|
'lc-rect',
|
|
431
435
|
itemClass ?? (typeof className === 'string' ? className : undefined)
|
|
432
436
|
),
|
|
433
|
-
style:
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
437
|
+
style:
|
|
438
|
+
[
|
|
439
|
+
restProps.style as string | undefined,
|
|
440
|
+
dashArrayAttr ? `stroke-dasharray: ${dashArrayAttr}` : undefined,
|
|
441
|
+
]
|
|
442
|
+
.filter(Boolean)
|
|
443
|
+
.join('; ') || undefined,
|
|
439
444
|
};
|
|
440
445
|
}
|
|
441
446
|
|
|
@@ -596,7 +601,7 @@
|
|
|
596
601
|
opacity={staticOpacity}
|
|
597
602
|
stroke-dasharray={dashArrayAttr}
|
|
598
603
|
class={cls('lc-rect', staticClassName)}
|
|
599
|
-
{...
|
|
604
|
+
{...restProps as unknown as SVGAttributes<SVGPathElement>}
|
|
600
605
|
{onclick}
|
|
601
606
|
{ondblclick}
|
|
602
607
|
{onpointerenter}
|
|
@@ -641,6 +646,12 @@
|
|
|
641
646
|
{@const resolvedStrokeWidth = resolveStyleProp(strokeWidth, item.d)}
|
|
642
647
|
{@const resolvedOpacity = resolveStyleProp(opacity, item.d)}
|
|
643
648
|
{@const resolvedClass = resolveStyleProp(className, item.d)}
|
|
649
|
+
{@const resolvedBorderWidth =
|
|
650
|
+
resolvedStrokeWidth != null
|
|
651
|
+
? `${resolvedStrokeWidth}px`
|
|
652
|
+
: resolvedStroke != null
|
|
653
|
+
? '1px'
|
|
654
|
+
: undefined}
|
|
644
655
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
645
656
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
646
657
|
<div
|
|
@@ -650,8 +661,9 @@
|
|
|
650
661
|
style:width="{item.width}px"
|
|
651
662
|
style:height="{item.height}px"
|
|
652
663
|
style:background={resolvedFill}
|
|
664
|
+
style:background-origin="border-box"
|
|
653
665
|
style:opacity={resolvedOpacity}
|
|
654
|
-
style:border-width=
|
|
666
|
+
style:border-width={resolvedBorderWidth}
|
|
655
667
|
style:border-style={dashArrayResolved ? 'dashed' : 'solid'}
|
|
656
668
|
style:border-color={resolvedStroke}
|
|
657
669
|
style:border-radius="{rx}px"
|
|
@@ -676,6 +688,7 @@
|
|
|
676
688
|
style:width="{motionWidth.current}px"
|
|
677
689
|
style:height="{motionHeight.current}px"
|
|
678
690
|
style:background={staticFill}
|
|
691
|
+
style:background-origin="border-box"
|
|
679
692
|
style:opacity={staticOpacity}
|
|
680
693
|
style:border-width={staticBorderWidth}
|
|
681
694
|
style:border-style={dashArrayResolved ? 'dashed' : 'solid'}
|
|
@@ -712,6 +725,10 @@
|
|
|
712
725
|
}
|
|
713
726
|
|
|
714
727
|
/* Html layers */
|
|
728
|
+
:global(:where(.lc-layout-html .lc-rect)) {
|
|
729
|
+
/* Match SVG sizing/positioning (visual extent equals `width`×`height`, border on outer edge) */
|
|
730
|
+
box-sizing: border-box;
|
|
731
|
+
}
|
|
715
732
|
:global(:where(.lc-layout-html .lc-rect):not([background])) {
|
|
716
733
|
background: var(--fill-color);
|
|
717
734
|
}
|
|
@@ -95,12 +95,30 @@
|
|
|
95
95
|
const ctx = getChartContext();
|
|
96
96
|
const geo = getGeoContext();
|
|
97
97
|
|
|
98
|
-
let {
|
|
98
|
+
let {
|
|
99
|
+
data,
|
|
100
|
+
x,
|
|
101
|
+
y,
|
|
102
|
+
seriesKey,
|
|
103
|
+
defined,
|
|
104
|
+
curve,
|
|
105
|
+
stroke,
|
|
106
|
+
fill,
|
|
107
|
+
opacity,
|
|
108
|
+
motion,
|
|
109
|
+
...restProps
|
|
110
|
+
}: SplineProps = $props();
|
|
99
111
|
|
|
100
112
|
ctx.registerComponent({
|
|
101
113
|
name: 'Spline',
|
|
102
114
|
kind: 'mark',
|
|
103
|
-
markInfo: () => ({
|
|
115
|
+
markInfo: () => ({
|
|
116
|
+
data,
|
|
117
|
+
x,
|
|
118
|
+
y,
|
|
119
|
+
seriesKey,
|
|
120
|
+
color: typeof stroke === 'string' ? stroke : undefined,
|
|
121
|
+
}),
|
|
104
122
|
});
|
|
105
123
|
|
|
106
124
|
function getScaleValue(
|
|
@@ -267,8 +285,8 @@
|
|
|
267
285
|
|
|
268
286
|
const seriesOpacity = $derived(
|
|
269
287
|
series?.key == null ||
|
|
270
|
-
|
|
271
|
-
|
|
288
|
+
ctx.series.visibleSeries.length <= 1 ||
|
|
289
|
+
ctx.series.isHighlighted(series.key, true)
|
|
272
290
|
? 1
|
|
273
291
|
: 0.1
|
|
274
292
|
);
|
|
@@ -283,9 +301,9 @@
|
|
|
283
301
|
pathData={seg.d}
|
|
284
302
|
stroke={seg.stroke}
|
|
285
303
|
fill={seg.fill}
|
|
304
|
+
opacity={seg.opacity ?? seriesOpacity}
|
|
286
305
|
{...series?.props}
|
|
287
306
|
{...restProps}
|
|
288
|
-
opacity={seg.opacity ?? seriesOpacity}
|
|
289
307
|
/>
|
|
290
308
|
{/each}
|
|
291
309
|
{:else}
|
|
@@ -293,8 +311,8 @@
|
|
|
293
311
|
pathData={isTweened ? tweenState.current : d}
|
|
294
312
|
stroke={(typeof stroke === 'string' ? stroke : undefined) ?? series?.color}
|
|
295
313
|
fill={typeof fill === 'string' ? fill : undefined}
|
|
314
|
+
opacity={(typeof opacity === 'number' ? opacity : undefined) ?? seriesOpacity}
|
|
296
315
|
{...series?.props}
|
|
297
316
|
{...restProps}
|
|
298
|
-
opacity={(typeof opacity === 'number' ? opacity : undefined) ?? seriesOpacity}
|
|
299
317
|
/>
|
|
300
318
|
{/if}
|
|
@@ -686,7 +686,14 @@
|
|
|
686
686
|
if (segments) {
|
|
687
687
|
let xOffset = baseX;
|
|
688
688
|
for (const segment of segments) {
|
|
689
|
-
const segStyles = getTextStyles(
|
|
689
|
+
const segStyles = getTextStyles(
|
|
690
|
+
undefined,
|
|
691
|
+
undefined,
|
|
692
|
+
undefined,
|
|
693
|
+
undefined,
|
|
694
|
+
undefined,
|
|
695
|
+
segment.class
|
|
696
|
+
);
|
|
690
697
|
const text = String(segment.value);
|
|
691
698
|
// Set font before rendering and measuring so width is accurate
|
|
692
699
|
const segComputedStyles = getComputedStyles(ctx.canvas, segStyles);
|
|
@@ -838,10 +845,7 @@
|
|
|
838
845
|
>
|
|
839
846
|
{#if segments}
|
|
840
847
|
{#each segments as segment, index (index)}
|
|
841
|
-
<tspan
|
|
842
|
-
dy={index === 0 ? startDy : 0}
|
|
843
|
-
class={['lc-text-tspan', segment.class]}
|
|
844
|
-
>
|
|
848
|
+
<tspan dy={index === 0 ? startDy : 0} class={['lc-text-tspan', segment.class]}>
|
|
845
849
|
{segment.value}
|
|
846
850
|
</tspan>
|
|
847
851
|
{/each}
|
|
@@ -180,9 +180,15 @@
|
|
|
180
180
|
.map((d: any) => ({
|
|
181
181
|
x: getScaleValue(d, ctx.xScale, xAccessor) + xOffset,
|
|
182
182
|
y: getScaleValue(d, ctx.yScale, yAccessor) + yOffset,
|
|
183
|
-
r:
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
r:
|
|
184
|
+
resolvedR != null
|
|
185
|
+
? resolveDataProp(
|
|
186
|
+
resolvedR,
|
|
187
|
+
d,
|
|
188
|
+
ctx.rScale,
|
|
189
|
+
typeof resolvedR === 'number' ? resolvedR : 4
|
|
190
|
+
)
|
|
191
|
+
: 4,
|
|
186
192
|
}));
|
|
187
193
|
|
|
188
194
|
return computeTrailPath(points, { curve, cap, tension, resolution });
|
|
@@ -206,9 +212,15 @@
|
|
|
206
212
|
.map((d: any) => ({
|
|
207
213
|
x: getScaleValue(d, ctx.xScale, xAccessor) + xOffset,
|
|
208
214
|
y: baseline,
|
|
209
|
-
r:
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
r:
|
|
216
|
+
resolvedR != null
|
|
217
|
+
? resolveDataProp(
|
|
218
|
+
resolvedR,
|
|
219
|
+
d,
|
|
220
|
+
ctx.rScale,
|
|
221
|
+
typeof resolvedR === 'number' ? resolvedR : 4
|
|
222
|
+
)
|
|
223
|
+
: 4,
|
|
212
224
|
}));
|
|
213
225
|
|
|
214
226
|
return computeTrailPath(points, { curve, cap, tension, resolution });
|
|
@@ -236,7 +248,7 @@
|
|
|
236
248
|
<Path
|
|
237
249
|
pathData={isTweened ? tweenState.current : trailPath}
|
|
238
250
|
{fill}
|
|
239
|
-
|
|
251
|
+
{fillOpacity}
|
|
240
252
|
{opacity}
|
|
241
253
|
stroke="none"
|
|
242
254
|
class={cls('lc-trail', className)}
|
|
@@ -127,10 +127,22 @@
|
|
|
127
127
|
import { getGeoContext } from '../contexts/geo.js';
|
|
128
128
|
import { getLayerContext } from '../contexts/layer.js';
|
|
129
129
|
import { createMotion, createDataMotionMap, type MotionProp } from '../utils/motion.svelte.js';
|
|
130
|
-
import {
|
|
130
|
+
import {
|
|
131
|
+
hasAnyDataProp,
|
|
132
|
+
resolveDataProp,
|
|
133
|
+
extractRawDataValue,
|
|
134
|
+
resolveGeoDataPair,
|
|
135
|
+
resolveStyleProp,
|
|
136
|
+
resolveColorProp,
|
|
137
|
+
} from '../utils/dataProp.js';
|
|
131
138
|
import { chartDataArray } from '../utils/common.js';
|
|
132
139
|
import { cls } from '@layerstack/tailwind';
|
|
133
|
-
import {
|
|
140
|
+
import {
|
|
141
|
+
vectorArrowPath,
|
|
142
|
+
vectorArrowFilledPath,
|
|
143
|
+
vectorSpikePath,
|
|
144
|
+
transformVectorPath,
|
|
145
|
+
} from '../utils/path.js';
|
|
134
146
|
import Path from './Path.svelte';
|
|
135
147
|
|
|
136
148
|
let {
|
|
@@ -169,11 +181,11 @@
|
|
|
169
181
|
// Per-item style mode: when any style prop is a function, we must render individual paths
|
|
170
182
|
const hasPerItemStyles = $derived(
|
|
171
183
|
typeof fill === 'function' ||
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
typeof stroke === 'function' ||
|
|
185
|
+
typeof fillOpacity === 'function' ||
|
|
186
|
+
typeof strokeWidth === 'function' ||
|
|
187
|
+
typeof opacity === 'function' ||
|
|
188
|
+
typeof className === 'function'
|
|
177
189
|
);
|
|
178
190
|
|
|
179
191
|
// Contexts
|
|
@@ -182,9 +194,7 @@
|
|
|
182
194
|
const layerCtx = getLayerContext();
|
|
183
195
|
|
|
184
196
|
// Data to iterate over in data mode
|
|
185
|
-
const resolvedData: any[] = $derived(
|
|
186
|
-
dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []
|
|
187
|
-
);
|
|
197
|
+
const resolvedData: any[] = $derived(dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []);
|
|
188
198
|
|
|
189
199
|
// Resolve a single data item to pixel coordinates and values
|
|
190
200
|
function resolveVector(d: any) {
|
|
@@ -200,8 +210,14 @@
|
|
|
200
210
|
return {
|
|
201
211
|
x: resolvedX,
|
|
202
212
|
y: resolvedY,
|
|
203
|
-
length: resolveDataProp(
|
|
204
|
-
|
|
213
|
+
length: resolveDataProp(
|
|
214
|
+
lengthProp,
|
|
215
|
+
d,
|
|
216
|
+
chartCtx.rScale,
|
|
217
|
+
typeof lengthProp === 'number' ? lengthProp : 12
|
|
218
|
+
),
|
|
219
|
+
rotate:
|
|
220
|
+
typeof rotateProp === 'number' ? rotateProp : (extractRawDataValue(rotateProp, d) ?? 0),
|
|
205
221
|
};
|
|
206
222
|
}
|
|
207
223
|
|
|
@@ -289,7 +305,11 @@
|
|
|
289
305
|
|
|
290
306
|
const motionX = createMotion(initialX, () => (typeof x === 'number' ? x : 0), motion);
|
|
291
307
|
const motionY = createMotion(initialY, () => (typeof y === 'number' ? y : 0), motion);
|
|
292
|
-
const motionLength = createMotion(
|
|
308
|
+
const motionLength = createMotion(
|
|
309
|
+
initialLength,
|
|
310
|
+
() => (typeof lengthProp === 'number' ? lengthProp : 12),
|
|
311
|
+
motion
|
|
312
|
+
);
|
|
293
313
|
|
|
294
314
|
const pixelRotate = $derived(typeof rotateProp === 'number' ? rotateProp : 0);
|
|
295
315
|
|
|
@@ -346,7 +366,10 @@
|
|
|
346
366
|
stroke={stroke as string}
|
|
347
367
|
strokeWidth={strokeWidth as number}
|
|
348
368
|
opacity={opacity as number}
|
|
349
|
-
class="lc-vector {isFilled ? 'lc-vector-filled' : 'lc-vector-stroked'} {typeof className ===
|
|
369
|
+
class="lc-vector {isFilled ? 'lc-vector-filled' : 'lc-vector-stroked'} {typeof className ===
|
|
370
|
+
'string'
|
|
371
|
+
? className
|
|
372
|
+
: ''}"
|
|
350
373
|
/>
|
|
351
374
|
{/if}
|
|
352
375
|
|
|
@@ -148,8 +148,7 @@
|
|
|
148
148
|
const ext: [number, number] = [sorted[0], sorted[sorted.length - 1]];
|
|
149
149
|
|
|
150
150
|
// Silverman's rule of thumb for bandwidth
|
|
151
|
-
const bw =
|
|
152
|
-
bandwidthProp ?? 1.06 * (deviation(sorted) ?? 1) * Math.pow(sorted.length, -1 / 5);
|
|
151
|
+
const bw = bandwidthProp ?? 1.06 * (deviation(sorted) ?? 1) * Math.pow(sorted.length, -1 / 5);
|
|
153
152
|
|
|
154
153
|
const kernelFn = epanechnikov(bw);
|
|
155
154
|
|
|
@@ -240,9 +240,7 @@
|
|
|
240
240
|
);
|
|
241
241
|
|
|
242
242
|
// Compute series colors locally to avoid derived_references_self cycle through context.series.allSeriesColors
|
|
243
|
-
const allSeriesColors = $derived(
|
|
244
|
-
series.map((s) => s.color).filter((c) => c != null) as string[]
|
|
245
|
-
);
|
|
243
|
+
const allSeriesColors = $derived(series.map((s) => s.color).filter((c) => c != null) as string[]);
|
|
246
244
|
|
|
247
245
|
// Custom tickFormat for ArcChart legends - uses data labels instead of series labels
|
|
248
246
|
const legendTickFormat = (tick: any) => {
|
|
@@ -416,8 +414,13 @@
|
|
|
416
414
|
value={valueAccessor(data)}
|
|
417
415
|
color={snippetProps.context.cScale?.(snippetProps.context.c(data))}
|
|
418
416
|
{format}
|
|
419
|
-
onpointerenter={() => {
|
|
420
|
-
|
|
417
|
+
onpointerenter={() => {
|
|
418
|
+
if (snippetProps.context)
|
|
419
|
+
snippetProps.context.series.highlightKey = keyAccessor(data);
|
|
420
|
+
}}
|
|
421
|
+
onpointerleave={() => {
|
|
422
|
+
if (snippetProps.context) snippetProps.context.series.highlightKey = null;
|
|
423
|
+
}}
|
|
421
424
|
{...props.tooltip?.item}
|
|
422
425
|
/>
|
|
423
426
|
</Tooltip.List>
|
|
@@ -108,7 +108,12 @@
|
|
|
108
108
|
...(typeof tooltipContext === 'object' ? tooltipContext : null),
|
|
109
109
|
}}
|
|
110
110
|
brush={brush
|
|
111
|
-
? {
|
|
111
|
+
? {
|
|
112
|
+
axis: 'x',
|
|
113
|
+
zoomOnBrush: true,
|
|
114
|
+
...(typeof brush === 'object' ? brush : null),
|
|
115
|
+
...props.brush,
|
|
116
|
+
}
|
|
112
117
|
: false}
|
|
113
118
|
{series}
|
|
114
119
|
{seriesLayout}
|
|
@@ -184,7 +184,9 @@
|
|
|
184
184
|
x1={valueAxis === 'y' && isGroupSeries ? (d) => s.value ?? s.key : undefined}
|
|
185
185
|
y1={valueAxis === 'x' && isGroupSeries ? (d) => s.value ?? s.key : undefined}
|
|
186
186
|
rounded={context.series.divergingEdgeKeys
|
|
187
|
-
? context.series.divergingEdgeKeys.has(s.key)
|
|
187
|
+
? context.series.divergingEdgeKeys.has(s.key)
|
|
188
|
+
? 'edge'
|
|
189
|
+
: 'none'
|
|
188
190
|
: context.series.isStacked && i !== context.series.visibleSeries.length - 1
|
|
189
191
|
? 'none'
|
|
190
192
|
: Array.isArray(xProp) || Array.isArray(yProp)
|
|
@@ -133,7 +133,12 @@
|
|
|
133
133
|
...(typeof tooltipContext === 'object' ? tooltipContext : null),
|
|
134
134
|
}}
|
|
135
135
|
brush={brush
|
|
136
|
-
? {
|
|
136
|
+
? {
|
|
137
|
+
axis: 'x',
|
|
138
|
+
zoomOnBrush: true,
|
|
139
|
+
...(typeof brush === 'object' ? brush : null),
|
|
140
|
+
...props.brush,
|
|
141
|
+
}
|
|
137
142
|
: false}
|
|
138
143
|
{series}
|
|
139
144
|
highlight={highlightWithPointClick as any}
|
|
@@ -308,7 +308,9 @@
|
|
|
308
308
|
startAngle: arc.startAngle,
|
|
309
309
|
endAngle: arc.endAngle,
|
|
310
310
|
outerRadius:
|
|
311
|
-
(context?.series.visibleSeries.length ?? 0) > 1
|
|
311
|
+
(context?.series.visibleSeries.length ?? 0) > 1
|
|
312
|
+
? seriesIndex * (outerRadius ?? 0)
|
|
313
|
+
: outerRadius,
|
|
312
314
|
innerRadius,
|
|
313
315
|
cornerRadius,
|
|
314
316
|
padAngle,
|
|
@@ -464,8 +466,13 @@
|
|
|
464
466
|
value={valueAccessor(data)}
|
|
465
467
|
color={snippetProps.context.cScale?.(snippetProps.context.c(data))}
|
|
466
468
|
{format}
|
|
467
|
-
onpointerenter={() => {
|
|
468
|
-
|
|
469
|
+
onpointerenter={() => {
|
|
470
|
+
if (snippetProps.context)
|
|
471
|
+
snippetProps.context.series.highlightKey = keyAccessor(data);
|
|
472
|
+
}}
|
|
473
|
+
onpointerleave={() => {
|
|
474
|
+
if (snippetProps.context) snippetProps.context.series.highlightKey = null;
|
|
475
|
+
}}
|
|
469
476
|
{...props.tooltip?.item}
|
|
470
477
|
/>
|
|
471
478
|
</Tooltip.List>
|
|
@@ -377,10 +377,7 @@
|
|
|
377
377
|
) {
|
|
378
378
|
rect.left = alignValue(xValue, 'end', xOffset, tooltipWidth);
|
|
379
379
|
}
|
|
380
|
-
if (
|
|
381
|
-
(xAlign === 'end' || xAlign === 'center') &&
|
|
382
|
-
containerRect.left + rect.left < 0
|
|
383
|
-
) {
|
|
380
|
+
if ((xAlign === 'end' || xAlign === 'center') && containerRect.left + rect.left < 0) {
|
|
384
381
|
rect.left = alignValue(xValue, 'start', xOffset, tooltipWidth);
|
|
385
382
|
}
|
|
386
383
|
}
|
|
@@ -393,10 +390,7 @@
|
|
|
393
390
|
) {
|
|
394
391
|
rect.top = alignValue(yValue, 'end', yOffset, tooltipHeight);
|
|
395
392
|
}
|
|
396
|
-
if (
|
|
397
|
-
(yAlign === 'end' || yAlign === 'center') &&
|
|
398
|
-
containerRect.top + rect.top < 0
|
|
399
|
-
) {
|
|
393
|
+
if ((yAlign === 'end' || yAlign === 'center') && containerRect.top + rect.top < 0) {
|
|
400
394
|
rect.top = alignValue(yValue, 'start', yOffset, tooltipHeight);
|
|
401
395
|
}
|
|
402
396
|
}
|
package/dist/contexts/chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChartState } from '../states/chart.svelte.js';
|
|
2
2
|
import type { AnyScale } from '../utils/scales.svelte.js';
|
|
3
3
|
export type { ChartState };
|
|
4
|
-
export type { NodeKind, ComponentNode, RegisterComponentOptions } from '../states/chart.svelte.js';
|
|
4
|
+
export type { NodeKind, ComponentNode, RegisterComponentOptions, } from '../states/chart.svelte.js';
|
|
5
5
|
export declare function getChartContext<T, XScale extends AnyScale = AnyScale, YScale extends AnyScale = AnyScale>(): ChartState<T, XScale, YScale>;
|
|
6
6
|
export declare function setChartContext<T, XScale extends AnyScale = AnyScale, YScale extends AnyScale = AnyScale>(context: ChartState<T, XScale, YScale>): ChartState<T, XScale, YScale>;
|
package/dist/contexts/chart.js
CHANGED
|
@@ -5,7 +5,9 @@ const _ChartContext = new Context('ChartContext');
|
|
|
5
5
|
* Provides safe defaults to prevent runtime errors.
|
|
6
6
|
*/
|
|
7
7
|
const fallbackContext = {
|
|
8
|
-
registerMark: () => () => {
|
|
8
|
+
registerMark: () => () => {
|
|
9
|
+
/* no-op */
|
|
10
|
+
},
|
|
9
11
|
registerComponent: (_options) => ({
|
|
10
12
|
id: Symbol('noop'),
|
|
11
13
|
kind: 'mark',
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { scaleBand } from 'd3-scale';
|
|
3
|
+
import ServerChart from './ServerChart.svelte';
|
|
4
|
+
import type { CaptureTarget } from './captureStore.js';
|
|
5
|
+
import Bars from '../components/Bars.svelte';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
let {
|
|
8
|
+
data,
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
capture,
|
|
12
|
+
onCapture,
|
|
13
|
+
}: {
|
|
14
|
+
data: { category: string; value: number }[];
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
capture?: CaptureTarget;
|
|
18
|
+
onCapture?: (data: CaptureTarget) => void;
|
|
19
|
+
} = $props();
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<ServerChart
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
{capture}
|
|
24
|
+
{onCapture}
|
|
25
|
+
{width}
|
|
26
|
+
{height}
|
|
27
|
+
{data}
|
|
28
|
+
x="category"
|
|
29
|
+
xScale={scaleBand().paddingInner(0.2).paddingOuter(0.1)}
|
|
30
|
+
y="value"
|
|
31
|
+
yDomain={[0, null]}
|
|
32
|
+
padding={{ top: 20, right: 20, bottom: 30, left: 40 }}
|
|
33
33
|
>
|
|
34
|
-
|
|
34
|
+
<Bars fill="rgb(59, 130, 246)" radius={4} />
|
|
35
35
|
</ServerChart>
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import ServerChart from './ServerChart.svelte';
|
|
3
|
+
import type { CaptureTarget } from './captureStore.js';
|
|
4
|
+
import Area from '../components/Area.svelte';
|
|
5
|
+
import Spline from '../components/Spline.svelte';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
let {
|
|
8
|
+
data,
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
capture,
|
|
12
|
+
onCapture,
|
|
13
|
+
}: {
|
|
14
|
+
data: { date: number; value: number }[];
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
capture?: CaptureTarget;
|
|
18
|
+
onCapture?: (data: CaptureTarget) => void;
|
|
19
|
+
} = $props();
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<ServerChart
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
{capture}
|
|
24
|
+
{onCapture}
|
|
25
|
+
{width}
|
|
26
|
+
{height}
|
|
27
|
+
{data}
|
|
28
|
+
x="date"
|
|
29
|
+
y="value"
|
|
30
|
+
yDomain={[0, null]}
|
|
31
|
+
padding={{ top: 20, right: 20, bottom: 20, left: 20 }}
|
|
32
32
|
>
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
<Area fill="rgba(59, 130, 246, 0.15)" stroke="none" />
|
|
34
|
+
<Spline stroke="rgb(59, 130, 246)" strokeWidth={2} />
|
|
35
35
|
</ServerChart>
|
package/dist/server/index.js
CHANGED
|
@@ -64,7 +64,7 @@ export function renderChart(component, options) {
|
|
|
64
64
|
const captureTarget = {};
|
|
65
65
|
// SSR render to build the component tree and capture chart state
|
|
66
66
|
const rendered = render(component, {
|
|
67
|
-
props: { ...props, width, height, capture: captureTarget }
|
|
67
|
+
props: { ...props, width, height, capture: captureTarget },
|
|
68
68
|
});
|
|
69
69
|
// Force the SSR render to fully flush
|
|
70
70
|
void rendered.body;
|