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.
Files changed (55) hide show
  1. package/dist/bench/ComposableLineChart.svelte +1 -1
  2. package/dist/bench/GeoBench.svelte +1 -8
  3. package/dist/components/AnnotationRange.svelte +21 -8
  4. package/dist/components/Arc.svelte +1 -3
  5. package/dist/components/ArcLabel.svelte.test.js +7 -7
  6. package/dist/components/Bar.svelte +4 -2
  7. package/dist/components/BoxPlot.svelte +4 -12
  8. package/dist/components/Cell.svelte +13 -8
  9. package/dist/components/Chart.svelte +69 -26
  10. package/dist/components/ChartChildren.svelte +22 -4
  11. package/dist/components/Circle.svelte +34 -12
  12. package/dist/components/ClipPath.svelte +3 -9
  13. package/dist/components/Ellipse.svelte +27 -6
  14. package/dist/components/GeoLegend.svelte +1 -3
  15. package/dist/components/GeoPoint.svelte +25 -3
  16. package/dist/components/GeoSpline.svelte +1 -4
  17. package/dist/components/GeoTile.svelte +8 -4
  18. package/dist/components/Group.svelte +11 -5
  19. package/dist/components/Highlight.svelte +3 -3
  20. package/dist/components/Image.svelte +42 -30
  21. package/dist/components/Labels.svelte +2 -4
  22. package/dist/components/Line.svelte +7 -6
  23. package/dist/components/LinearGradient.svelte +8 -4
  24. package/dist/components/Link.svelte +0 -1
  25. package/dist/components/Marker.svelte +9 -1
  26. package/dist/components/Path.svelte +43 -23
  27. package/dist/components/Pattern.svelte +101 -5
  28. package/dist/components/Pattern.svelte.d.ts +3 -1
  29. package/dist/components/Pie.svelte +2 -6
  30. package/dist/components/RadialGradient.svelte +8 -4
  31. package/dist/components/Rect.svelte +29 -12
  32. package/dist/components/Spline.svelte +24 -6
  33. package/dist/components/Text.svelte +9 -5
  34. package/dist/components/Trail.svelte +19 -7
  35. package/dist/components/Vector.svelte +37 -14
  36. package/dist/components/Violin.svelte +1 -2
  37. package/dist/components/charts/ArcChart.svelte +8 -5
  38. package/dist/components/charts/AreaChart.svelte +6 -1
  39. package/dist/components/charts/BarChart.svelte +3 -1
  40. package/dist/components/charts/LineChart.svelte +6 -1
  41. package/dist/components/charts/PieChart.svelte +10 -3
  42. package/dist/components/tooltip/Tooltip.svelte +2 -8
  43. package/dist/contexts/chart.d.ts +1 -1
  44. package/dist/contexts/chart.js +3 -1
  45. package/dist/server/TestBarChart.svelte +28 -28
  46. package/dist/server/TestLineChart.svelte +28 -28
  47. package/dist/server/index.js +1 -1
  48. package/dist/states/brush.svelte.js +16 -13
  49. package/dist/states/chart.svelte.js +14 -4
  50. package/dist/states/chart.svelte.test.js +70 -19
  51. package/dist/states/geo.svelte.js +1 -4
  52. package/dist/states/series.svelte.js +1 -1
  53. package/dist/utils/canvas.js +7 -4
  54. package/dist/utils/trail.js +3 -4
  55. 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' ? `${strokeWidth}px` : undefined
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
- restProps.style as string | undefined,
435
- dashArrayAttr ? `stroke-dasharray: ${dashArrayAttr}` : undefined,
436
- ]
437
- .filter(Boolean)
438
- .join('; ') || undefined,
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
- {...(restProps as unknown as SVGAttributes<SVGPathElement>)}
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="{resolvedStrokeWidth}px"
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 { data, x, y, seriesKey, defined, curve, stroke, fill, opacity, motion, ...restProps }: SplineProps = $props();
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: () => ({ data, x, y, seriesKey, color: typeof stroke === 'string' ? stroke : undefined }),
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
- ctx.series.visibleSeries.length <= 1 ||
271
- ctx.series.isHighlighted(series.key, true)
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(undefined, undefined, undefined, undefined, undefined, segment.class);
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: resolvedR != null
184
- ? resolveDataProp(resolvedR, d, ctx.rScale, typeof resolvedR === 'number' ? resolvedR : 4)
185
- : 4,
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: resolvedR != null
210
- ? resolveDataProp(resolvedR, d, ctx.rScale, typeof resolvedR === 'number' ? resolvedR : 4)
211
- : 4,
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
- fillOpacity={fillOpacity}
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 { hasAnyDataProp, resolveDataProp, extractRawDataValue, resolveGeoDataPair, resolveStyleProp, resolveColorProp } from '../utils/dataProp.js';
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 { vectorArrowPath, vectorArrowFilledPath, vectorSpikePath, transformVectorPath } from '../utils/path.js';
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
- typeof stroke === 'function' ||
173
- typeof fillOpacity === 'function' ||
174
- typeof strokeWidth === 'function' ||
175
- typeof opacity === 'function' ||
176
- typeof className === 'function'
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(lengthProp, d, chartCtx.rScale, typeof lengthProp === 'number' ? lengthProp : 12),
204
- rotate: typeof rotateProp === 'number' ? rotateProp : (extractRawDataValue(rotateProp, d) ?? 0),
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(initialLength, () => (typeof lengthProp === 'number' ? lengthProp : 12), motion);
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 === 'string' ? 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={() => { if (snippetProps.context) snippetProps.context.series.highlightKey = keyAccessor(data); }}
420
- onpointerleave={() => { if (snippetProps.context) snippetProps.context.series.highlightKey = null; }}
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
- ? { axis: 'x', zoomOnBrush: true, ...(typeof brush === 'object' ? brush : null), ...props.brush }
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) ? 'edge' : 'none'
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
- ? { axis: 'x', zoomOnBrush: true, ...(typeof brush === 'object' ? brush : null), ...props.brush }
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 ? seriesIndex * (outerRadius ?? 0) : outerRadius,
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={() => { if (snippetProps.context) snippetProps.context.series.highlightKey = keyAccessor(data); }}
468
- onpointerleave={() => { if (snippetProps.context) snippetProps.context.series.highlightKey = null; }}
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
  }
@@ -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>;
@@ -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
- 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';
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
- 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();
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
- {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 }}
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
- <Bars fill="rgb(59, 130, 246)" radius={4} />
34
+ <Bars fill="rgb(59, 130, 246)" radius={4} />
35
35
  </ServerChart>
@@ -1,35 +1,35 @@
1
1
  <script lang="ts">
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';
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
- 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();
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
- {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 }}
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
- <Area fill="rgba(59, 130, 246, 0.15)" stroke="none" />
34
- <Spline stroke="rgb(59, 130, 246)" strokeWidth={2} />
33
+ <Area fill="rgba(59, 130, 246, 0.15)" stroke="none" />
34
+ <Spline stroke="rgb(59, 130, 246)" strokeWidth={2} />
35
35
  </ServerChart>
@@ -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;