layerchart 2.0.0-next.4 → 2.0.0-next.41

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 (180) hide show
  1. package/dist/components/AnnotationLine.svelte +15 -2
  2. package/dist/components/AnnotationPoint.svelte +29 -11
  3. package/dist/components/AnnotationRange.svelte +18 -4
  4. package/dist/components/Arc.svelte +5 -5
  5. package/dist/components/Area.svelte +10 -2
  6. package/dist/components/Axis.svelte +175 -58
  7. package/dist/components/Axis.svelte.d.ts +23 -6
  8. package/dist/components/Bar.svelte +20 -15
  9. package/dist/components/Bar.svelte.d.ts +2 -2
  10. package/dist/components/Bars.svelte +4 -4
  11. package/dist/components/Blur.svelte +7 -6
  12. package/dist/components/Blur.svelte.d.ts +2 -5
  13. package/dist/components/BrushContext.svelte +45 -45
  14. package/dist/components/Calendar.svelte +31 -10
  15. package/dist/components/Calendar.svelte.d.ts +2 -1
  16. package/dist/components/Chart.svelte +76 -27
  17. package/dist/components/Chart.svelte.d.ts +26 -8
  18. package/dist/components/ChartClipPath.svelte +1 -1
  19. package/dist/components/Circle.svelte +44 -3
  20. package/dist/components/CircleClipPath.svelte +8 -1
  21. package/dist/components/ClipPath.svelte +1 -2
  22. package/dist/components/ColorRamp.svelte +1 -1
  23. package/dist/components/ComputedStyles.svelte +9 -2
  24. package/dist/components/Connector.svelte +3 -3
  25. package/dist/components/Connector.svelte.d.ts +1 -1
  26. package/dist/components/Ellipse.svelte +228 -0
  27. package/dist/components/Ellipse.svelte.d.ts +64 -0
  28. package/dist/components/ForceSimulation.svelte +184 -50
  29. package/dist/components/ForceSimulation.svelte.d.ts +95 -21
  30. package/dist/components/Frame.svelte +1 -1
  31. package/dist/components/GeoCircle.svelte +1 -1
  32. package/dist/components/GeoEdgeFade.svelte +1 -1
  33. package/dist/components/GeoPath.svelte +30 -8
  34. package/dist/components/GeoPoint.svelte +4 -5
  35. package/dist/components/GeoSpline.svelte +5 -5
  36. package/dist/components/GeoSpline.svelte.d.ts +1 -1
  37. package/dist/components/GeoTile.svelte +1 -1
  38. package/dist/components/Graticule.svelte +5 -5
  39. package/dist/components/Grid.svelte +60 -63
  40. package/dist/components/Group.svelte +13 -8
  41. package/dist/components/Group.svelte.d.ts +10 -3
  42. package/dist/components/Highlight.svelte +55 -28
  43. package/dist/components/Highlight.svelte.d.ts +4 -0
  44. package/dist/components/Hull.svelte +12 -5
  45. package/dist/components/Labels.svelte +24 -13
  46. package/dist/components/Labels.svelte.d.ts +12 -5
  47. package/dist/components/Legend.svelte +143 -70
  48. package/dist/components/Legend.svelte.d.ts +12 -8
  49. package/dist/components/Line.svelte +40 -3
  50. package/dist/components/LinearGradient.svelte +35 -4
  51. package/dist/components/Link.svelte +1 -1
  52. package/dist/components/Marker.svelte +37 -26
  53. package/dist/components/MonthPath.svelte +26 -12
  54. package/dist/components/MonthPath.svelte.d.ts +4 -3
  55. package/dist/components/MotionPath.svelte +1 -1
  56. package/dist/components/Pack.svelte.d.ts +10 -3
  57. package/dist/components/Partition.svelte.d.ts +10 -3
  58. package/dist/components/Pattern.svelte +5 -5
  59. package/dist/components/Pie.svelte +1 -2
  60. package/dist/components/Points.svelte +11 -72
  61. package/dist/components/Points.svelte.d.ts +1 -8
  62. package/dist/components/Polygon.svelte +309 -0
  63. package/dist/components/Polygon.svelte.d.ts +115 -0
  64. package/dist/components/RadialGradient.svelte +4 -6
  65. package/dist/components/Rect.svelte +55 -5
  66. package/dist/components/Rect.svelte.d.ts +2 -2
  67. package/dist/components/RectClipPath.svelte +4 -3
  68. package/dist/components/RectClipPath.svelte.d.ts +2 -2
  69. package/dist/components/Rule.svelte +167 -77
  70. package/dist/components/Rule.svelte.d.ts +7 -2
  71. package/dist/components/Spline.svelte +59 -28
  72. package/dist/components/Spline.svelte.d.ts +12 -4
  73. package/dist/components/Text.svelte +121 -73
  74. package/dist/components/Text.svelte.d.ts +6 -0
  75. package/dist/components/TileImage.svelte +19 -4
  76. package/dist/components/TransformContext.svelte +9 -3
  77. package/dist/components/TransformControls.svelte +89 -38
  78. package/dist/components/Tree.svelte.d.ts +10 -3
  79. package/dist/components/Treemap.svelte +63 -26
  80. package/dist/components/Treemap.svelte.d.ts +21 -14
  81. package/dist/components/Voronoi.svelte +12 -13
  82. package/dist/components/charts/ArcChart.svelte +43 -71
  83. package/dist/components/charts/ArcChart.svelte.d.ts +10 -3
  84. package/dist/components/charts/AreaChart.svelte +29 -59
  85. package/dist/components/charts/AreaChart.svelte.d.ts +10 -3
  86. package/dist/components/charts/BarChart.svelte +79 -71
  87. package/dist/components/charts/BarChart.svelte.d.ts +10 -3
  88. package/dist/components/charts/DefaultTooltip.svelte +3 -3
  89. package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
  90. package/dist/components/charts/LineChart.svelte +69 -75
  91. package/dist/components/charts/LineChart.svelte.d.ts +21 -8
  92. package/dist/components/charts/PieChart.svelte +44 -71
  93. package/dist/components/charts/PieChart.svelte.d.ts +10 -3
  94. package/dist/components/charts/ScatterChart.svelte +10 -39
  95. package/dist/components/charts/ScatterChart.svelte.d.ts +10 -3
  96. package/dist/components/charts/utils.svelte.d.ts +1 -19
  97. package/dist/components/charts/utils.svelte.js +7 -35
  98. package/dist/components/index.d.ts +4 -0
  99. package/dist/components/index.js +5 -1
  100. package/dist/components/layout/Canvas.svelte +96 -69
  101. package/dist/components/layout/Canvas.svelte.d.ts +6 -0
  102. package/dist/components/layout/Html.svelte +15 -9
  103. package/dist/components/layout/Layer.svelte +6 -4
  104. package/dist/components/layout/Layer.svelte.d.ts +6 -4
  105. package/dist/components/layout/Svg.svelte +19 -11
  106. package/dist/components/layout/WebGL.svelte +26 -6
  107. package/dist/components/layout/WebGL.svelte.d.ts +5 -2
  108. package/dist/components/tooltip/Tooltip.svelte +73 -36
  109. package/dist/components/tooltip/Tooltip.svelte.d.ts +10 -3
  110. package/dist/components/tooltip/TooltipContext.svelte +167 -54
  111. package/dist/components/tooltip/TooltipContext.svelte.d.ts +19 -5
  112. package/dist/components/tooltip/TooltipHeader.svelte +32 -18
  113. package/dist/components/tooltip/TooltipHeader.svelte.d.ts +3 -3
  114. package/dist/components/tooltip/TooltipItem.svelte +46 -37
  115. package/dist/components/tooltip/TooltipItem.svelte.d.ts +3 -3
  116. package/dist/components/tooltip/TooltipList.svelte +12 -10
  117. package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
  118. package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
  119. package/dist/docs/Blockquote.svelte +6 -4
  120. package/dist/docs/Blockquote.svelte.d.ts +4 -19
  121. package/dist/docs/Code.svelte +70 -28
  122. package/dist/docs/Code.svelte.d.ts +9 -24
  123. package/dist/docs/Header1.svelte +4 -2
  124. package/dist/docs/Header1.svelte.d.ts +4 -28
  125. package/dist/docs/Json.svelte +11 -3
  126. package/dist/docs/Json.svelte.d.ts +9 -21
  127. package/dist/docs/Layout.svelte +10 -7
  128. package/dist/docs/Layout.svelte.d.ts +4 -19
  129. package/dist/docs/Link.svelte +7 -3
  130. package/dist/docs/Link.svelte.d.ts +4 -38
  131. package/dist/docs/Preview.svelte +22 -23
  132. package/dist/docs/Preview.svelte.d.ts +5 -6
  133. package/dist/docs/TilesetField.svelte +20 -19
  134. package/dist/docs/TilesetField.svelte.d.ts +5 -22
  135. package/dist/docs/ViewSourceButton.svelte +10 -7
  136. package/dist/docs/ViewSourceButton.svelte.d.ts +7 -21
  137. package/dist/states/series.svelte.d.ts +30 -0
  138. package/dist/states/series.svelte.js +54 -0
  139. package/dist/styles/daisyui-5.css +6 -0
  140. package/dist/styles/shadcn-svelte.css +11 -0
  141. package/dist/styles/skeleton-3.css +15 -0
  142. package/dist/utils/arcText.svelte.js +4 -4
  143. package/dist/utils/array.d.ts +11 -0
  144. package/dist/utils/array.js +23 -0
  145. package/dist/utils/array.test.d.ts +1 -0
  146. package/dist/utils/array.test.js +200 -0
  147. package/dist/utils/attributes.d.ts +3 -13
  148. package/dist/utils/attributes.js +4 -18
  149. package/dist/utils/canvas.d.ts +77 -0
  150. package/dist/utils/canvas.js +105 -41
  151. package/dist/utils/common.d.ts +9 -0
  152. package/dist/utils/common.js +18 -1
  153. package/dist/utils/common.test.js +26 -1
  154. package/dist/utils/genData.d.ts +22 -8
  155. package/dist/utils/genData.js +34 -14
  156. package/dist/utils/graph/dagre.d.ts +4 -4
  157. package/dist/utils/graph/dagre.js +5 -7
  158. package/dist/utils/index.d.ts +1 -0
  159. package/dist/utils/index.js +1 -0
  160. package/dist/utils/math.d.ts +17 -0
  161. package/dist/utils/math.js +17 -0
  162. package/dist/utils/motion.svelte.js +1 -1
  163. package/dist/utils/path.d.ts +10 -0
  164. package/dist/utils/path.js +30 -0
  165. package/dist/utils/rect.svelte.d.ts +2 -2
  166. package/dist/utils/rect.svelte.js +73 -1
  167. package/dist/utils/scales.svelte.d.ts +9 -3
  168. package/dist/utils/scales.svelte.js +47 -4
  169. package/dist/utils/shape.d.ts +43 -0
  170. package/dist/utils/shape.js +59 -0
  171. package/dist/utils/stack.js +1 -1
  172. package/dist/utils/string.d.ts +49 -0
  173. package/dist/utils/string.js +4 -2
  174. package/dist/utils/ticks.d.ts +15 -4
  175. package/dist/utils/ticks.js +140 -159
  176. package/dist/utils/ticks.test.js +16 -26
  177. package/dist/utils/treemap.d.ts +1 -1
  178. package/dist/utils/types.d.ts +15 -2
  179. package/package.json +36 -35
  180. package/dist/utils/object.js +0 -2
@@ -62,10 +62,17 @@ export type GroupPropsWithoutHTML<In extends Transition = Transition> = {
62
62
  transitionInParams?: TransitionParams<In>;
63
63
  };
64
64
  export type GroupProps = GroupPropsWithoutHTML & Without<HTMLAttributes<Element>, GroupPropsWithoutHTML>;
65
+ declare function $$render<T extends Transition = Transition>(): {
66
+ props: GroupProps;
67
+ exports: {};
68
+ bindings: "ref";
69
+ slots: {};
70
+ events: {};
71
+ };
65
72
  declare class __sveltets_Render<T extends Transition = Transition> {
66
- props(): GroupProps;
67
- events(): {};
68
- slots(): {};
73
+ props(): ReturnType<typeof $$render<T>>['props'];
74
+ events(): ReturnType<typeof $$render<T>>['events'];
75
+ slots(): ReturnType<typeof $$render<T>>['slots'];
69
76
  bindings(): "ref";
70
77
  exports(): {};
71
78
  }
@@ -101,6 +101,11 @@
101
101
  */
102
102
  motion?: MotionProp;
103
103
 
104
+ /**
105
+ * The opacity of the element. (0 to 1)
106
+ */
107
+ opacity?: number;
108
+
104
109
  onAreaClick?: (e: MouseEvent, detail: { data: any }) => void;
105
110
  onBarClick?: (e: MouseEvent, detail: { data: any }) => void;
106
111
 
@@ -114,9 +119,8 @@
114
119
  import { max, min } from 'd3-array';
115
120
  import { pointRadial, type Series, type SeriesPoint } from 'd3-shape';
116
121
  import { notNull } from '@layerstack/utils';
117
- import { cls } from '@layerstack/tailwind';
118
122
 
119
- import { isScaleBand } from '../utils/scales.svelte.js';
123
+ import { isScaleBand, isScaleTime } from '../utils/scales.svelte.js';
120
124
  import { asAny } from '../utils/types.js';
121
125
  import { getChartContext } from './Chart.svelte';
122
126
  import { getTooltipContext } from './tooltip/TooltipContext.svelte';
@@ -136,6 +140,7 @@
136
140
  lines: linesProp = false,
137
141
  area = false,
138
142
  bar = false,
143
+ opacity,
139
144
  motion = 'spring',
140
145
  onAreaClick,
141
146
  onBarClick,
@@ -158,7 +163,9 @@
158
163
  Array.isArray(yValue) ? yValue.map((v) => ctx.yScale(v)) : ctx.yScale(yValue)
159
164
  );
160
165
  const yOffset = $derived(isScaleBand(ctx.yScale) && !ctx.radial ? ctx.yScale.bandwidth() / 2 : 0);
161
- const axis = $derived(axisProp == null ? (isScaleBand(ctx.yScale) ? 'y' : 'x') : axisProp);
166
+ const axis = $derived(
167
+ axisProp == null ? (isScaleBand(ctx.yScale) || isScaleTime(ctx.yScale) ? 'y' : 'x') : axisProp
168
+ );
162
169
 
163
170
  const _lines: { x1: number; y1: number; x2: number; y2: number }[] = $derived.by(() => {
164
171
  let tmpLines: { x1: number; y1: number; x2: number; y2: number }[] = [];
@@ -175,7 +182,7 @@
175
182
  y2: max(ctx.yRange) as unknown as number,
176
183
  })),
177
184
  ];
178
- } else if (xCoord) {
185
+ } else if (xCoord != null) {
179
186
  tmpLines = [
180
187
  ...tmpLines,
181
188
  {
@@ -201,7 +208,7 @@
201
208
  y2: yItem + yOffset,
202
209
  })),
203
210
  ];
204
- } else if (yCoord) {
211
+ } else if (yCoord != null) {
205
212
  tmpLines = [
206
213
  ...tmpLines,
207
214
  {
@@ -249,6 +256,7 @@
249
256
  height: 0,
250
257
  };
251
258
  if (!highlightData) return tmpArea;
259
+
252
260
  if (axis === 'x' || axis === 'both') {
253
261
  // x area
254
262
  if (Array.isArray(xCoord)) {
@@ -284,9 +292,9 @@
284
292
  tmpArea.height = ctx.yScale.step();
285
293
  } else {
286
294
  // Find width to next data point
287
- const index = ctx.flatData.findIndex((d) => Number(x(d)) === Number(x(highlightData)));
295
+ const index = ctx.flatData.findIndex((d) => Number(y(d)) === Number(y(highlightData)));
288
296
  const isLastPoint = index + 1 === ctx.flatData.length;
289
- const nextDataPoint = isLastPoint ? max(ctx.yDomain) : x(ctx.flatData[index + 1]);
297
+ const nextDataPoint = isLastPoint ? max(ctx.yDomain) : y(ctx.flatData[index + 1]);
290
298
  tmpArea.height = (ctx.yScale(nextDataPoint) ?? 0) - (yCoord ?? 0);
291
299
  }
292
300
 
@@ -432,11 +440,6 @@
432
440
  return tmpPoints;
433
441
  }
434
442
  );
435
-
436
- const areaProps = $derived(extractLayerProps(area, 'highlight-area'));
437
- const barProps = $derived(extractLayerProps(bar, 'highlight-bar'));
438
- const linesProps = $derived(extractLayerProps(linesProp, 'highlight-line'));
439
- const pointsProps = $derived(extractLayerProps(points, 'highlight-point'));
440
443
  </script>
441
444
 
442
445
  {#if highlightData}
@@ -451,15 +454,16 @@
451
454
  endAngle={_area.x + _area.width}
452
455
  innerRadius={_area.y}
453
456
  outerRadius={_area.y + _area.height}
454
- class={cls(!areaProps.fill && 'fill-surface-content/5', areaProps.class)}
457
+ {opacity}
458
+ class="lc-highlight-area"
455
459
  onclick={onAreaClick && ((e) => onAreaClick(e, { data: highlightData }))}
456
460
  />
457
461
  {:else}
458
462
  <Rect
459
463
  motion={motion === 'spring' ? 'spring' : undefined}
464
+ {opacity}
460
465
  {..._area}
461
- {...areaProps}
462
- class={cls(!areaProps.fill && 'fill-surface-content/5', areaProps.class)}
466
+ {...extractLayerProps(area, 'lc-highlight-area')}
463
467
  onclick={onAreaClick && ((e) => onAreaClick(e, { data: highlightData }))}
464
468
  />
465
469
  {/if}
@@ -472,8 +476,8 @@
472
476
  <Bar
473
477
  motion={motion === 'spring' ? 'spring' : undefined}
474
478
  data={highlightData}
475
- {...barProps}
476
- class={cls(!barProps.fill && 'fill-primary', barProps.class)}
479
+ {opacity}
480
+ {...extractLayerProps(bar, 'lc-highlight-bar')}
477
481
  onclick={onBarClick && ((e) => onBarClick(e, { data: highlightData }))}
478
482
  />
479
483
  {/if}
@@ -490,11 +494,8 @@
490
494
  y1={line.y1}
491
495
  x2={line.x2}
492
496
  y2={line.y2}
493
- {...linesProps}
494
- class={cls(
495
- 'stroke-surface-content/20 stroke-2 [stroke-dasharray:2,2] pointer-events-none',
496
- linesProps.class
497
- )}
497
+ {opacity}
498
+ {...extractLayerProps(linesProp, 'lc-highlight-line')}
498
499
  />
499
500
  {/each}
500
501
  {/if}
@@ -512,12 +513,8 @@
512
513
  fill={point.fill}
513
514
  r={4}
514
515
  strokeWidth={6}
515
- {...pointsProps}
516
- class={cls(
517
- 'stroke-white [paint-order:stroke] drop-shadow-sm',
518
- !point.fill && (typeof points === 'boolean' || !points.fill) && 'fill-primary',
519
- pointsProps.class
520
- )}
516
+ {opacity}
517
+ {...extractLayerProps(points, 'lc-highlight-point')}
521
518
  onpointerdown={onPointClick &&
522
519
  ((e) => {
523
520
  // Do not propagate `pointerdown` event to `BrushContext` if `onclick` is provided
@@ -543,3 +540,33 @@
543
540
  {/if}
544
541
  {/if}
545
542
  {/if}
543
+
544
+ <style>
545
+ @layer components {
546
+ :global(:where(.lc-highlight-area)) {
547
+ --fill-color: color-mix(in oklab, var(--color-surface-content, currentColor) 5%, transparent);
548
+ }
549
+
550
+ :global(:where(.lc-highlight-bar)) {
551
+ --fill-color: var(--color-primary, currentColor);
552
+ }
553
+
554
+ :global(:where(.lc-highlight-line)) {
555
+ --stroke-color: color-mix(
556
+ in oklab,
557
+ var(--color-surface-content, currentColor) 20%,
558
+ transparent
559
+ );
560
+ stroke-width: 2;
561
+ stroke-dasharray: 2 2;
562
+ pointer-events: none;
563
+ }
564
+
565
+ :global(:where(.lc-highlight-point)) {
566
+ --stroke-color: white;
567
+ --fill-color: var(--color-primary, currentColor);
568
+ paint-order: stroke;
569
+ filter: drop-shadow(var(--drop-shadow-sm, 0 1px 2px rgb(0 0 0 / 0.15)));
570
+ }
571
+ }
572
+ </style>
@@ -82,6 +82,10 @@ export type HighlightPropsWithoutHTML = {
82
82
  * @default true
83
83
  */
84
84
  motion?: MotionProp;
85
+ /**
86
+ * The opacity of the element. (0 to 1)
87
+ */
88
+ opacity?: number;
85
89
  onAreaClick?: (e: MouseEvent, detail: {
86
90
  data: any;
87
91
  }) => void;
@@ -55,7 +55,7 @@
55
55
  <script lang="ts">
56
56
  import { min } from 'd3-array';
57
57
  import { Delaunay } from 'd3-delaunay';
58
- // @ts-expect-error
58
+ // @ts-expect-error - no types available
59
59
  import { geoVoronoi } from 'd3-geo-voronoi';
60
60
  import { curveLinearClosed } from 'd3-shape';
61
61
  import { cls } from '@layerstack/tailwind';
@@ -65,7 +65,6 @@
65
65
  import Spline from './Spline.svelte';
66
66
  import { getChartContext } from './Chart.svelte';
67
67
  import { getGeoContext } from './GeoContext.svelte';
68
- import { layerClass } from '../utils/attributes.js';
69
68
 
70
69
  let {
71
70
  data,
@@ -104,13 +103,13 @@
104
103
  );
105
104
  </script>
106
105
 
107
- <Group {...restProps} class={cls(layerClass('hull-g'), classes.root, className)} bind:ref>
106
+ <Group {...restProps} class={cls('lc-hull-g', classes.root, className)} bind:ref>
108
107
  {#if geoCtx.projection}
109
108
  {@const polygon = geoVoronoi().hull(points)}
110
109
  <GeoPath
111
110
  geojson={polygon}
112
111
  {curve}
113
- class={cls(layerClass('hull-path'), 'fill-transparent', classes.path)}
112
+ class={['lc-hull-path', classes.path]}
114
113
  onclick={(e) => onclick?.(e, { points, polygon })}
115
114
  onpointermove={(e) => onpointermove?.(e, { points, polygon })}
116
115
  {onpointerleave}
@@ -123,10 +122,18 @@
123
122
  x={(d) => d[0]}
124
123
  y={(d) => d[1]}
125
124
  {curve}
126
- class={cls(layerClass('hull-class'), 'fill-transparent', classes.path)}
125
+ class={['lc-hull-class', classes.path]}
127
126
  onclick={(e) => onclick?.(e, { points, polygon })}
128
127
  onpointermove={(e) => onpointermove?.(e, { points, polygon })}
129
128
  {onpointerleave}
130
129
  />
131
130
  {/if}
132
131
  </Group>
132
+
133
+ <style>
134
+ @layer components {
135
+ :global(:where(.lc-hull-path, .lc-hull-geo-path)) {
136
+ fill: transparent;
137
+ }
138
+ }
139
+ </style>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" module>
2
2
  import Text, { type TextProps } from './Text.svelte';
3
3
  import { type ComponentProps, type Snippet } from 'svelte';
4
- import { format as formatValue, type FormatType } from '@layerstack/utils';
4
+ import { format as formatValue, type FormatType, type FormatConfig } from '@layerstack/utils';
5
5
  import type { Without } from '../utils/types.js';
6
6
  import Points, { type Point } from './Points.svelte';
7
7
  import { accessor, type Accessor } from '../utils/common.js';
@@ -51,7 +51,7 @@
51
51
  /**
52
52
  * The format of the label
53
53
  */
54
- format?: FormatType;
54
+ format?: FormatType | FormatConfig;
55
55
 
56
56
  /**
57
57
  * Define unique value for {#each} `(key)` expressions to improve transitions.
@@ -74,7 +74,7 @@
74
74
  import { isScaleBand } from '../utils/scales.svelte.js';
75
75
  import { getChartContext } from './Chart.svelte';
76
76
  import Group from './Group.svelte';
77
- import { extractLayerProps, layerClass } from '../utils/attributes.js';
77
+ import { extractLayerProps } from '../utils/attributes.js';
78
78
 
79
79
  const ctx = getChartContext();
80
80
 
@@ -109,6 +109,7 @@
109
109
 
110
110
  const formattedValue = formatValue(
111
111
  displayValue,
112
+ // @ts-expect-error - improve types
112
113
  format ??
113
114
  (value
114
115
  ? undefined
@@ -173,28 +174,38 @@
173
174
  }
174
175
  </script>
175
176
 
176
- <Group class={layerClass('labels-g')}>
177
+ <Group class="lc-labels-g">
177
178
  <Points {data} {x} {y}>
178
179
  {#snippet children({ points })}
179
180
  {#each points as point, i (key(point.data, i))}
180
- {@const textProps = extractLayerProps(getTextProps(point), 'labels-text')}
181
+ {@const textProps = extractLayerProps(getTextProps(point), 'lc-labels-text')}
181
182
  {#if childrenProp}
182
183
  {@render childrenProp({ data: point, textProps })}
183
184
  {:else}
184
185
  <Text
186
+ data-placement={placement}
185
187
  {...textProps}
186
188
  {...restProps}
187
- class={cls(
188
- 'text-xs',
189
- placement === 'inside'
190
- ? 'fill-surface-300 stroke-surface-content'
191
- : 'fill-surface-content stroke-surface-100',
192
- textProps.class,
193
- className
194
- )}
189
+ {...extractLayerProps(getTextProps(point), 'lc-labels-text', className ?? '')}
195
190
  />
196
191
  {/if}
197
192
  {/each}
198
193
  {/snippet}
199
194
  </Points>
200
195
  </Group>
196
+
197
+ <style>
198
+ @layer components {
199
+ :global(:where(.lc-labels-text)) {
200
+ font-size: 12px;
201
+
202
+ --fill-color: var(--color-surface-content, currentColor);
203
+ --stroke-color: var(--color-surface-100, light-dark(white, black));
204
+
205
+ &[data-placement='inside'] {
206
+ --fill-color: var(--color-surface-100, light-dark(white, black));
207
+ --stroke-color: var(--color-surface-content, currentColor);
208
+ }
209
+ }
210
+ }
211
+ </style>
@@ -1,6 +1,6 @@
1
1
  import Text, { type TextProps } from './Text.svelte';
2
2
  import { type ComponentProps, type Snippet } from 'svelte';
3
- import { type FormatType } from '@layerstack/utils';
3
+ import { type FormatType, type FormatConfig } from '@layerstack/utils';
4
4
  import type { Without } from '../utils/types.js';
5
5
  import { type Point } from './Points.svelte';
6
6
  import { type Accessor } from '../utils/common.js';
@@ -42,7 +42,7 @@ export type LabelsPropsWithoutHTML<T = any> = {
42
42
  /**
43
43
  * The format of the label
44
44
  */
45
- format?: FormatType;
45
+ format?: FormatType | FormatConfig;
46
46
  /**
47
47
  * Define unique value for {#each} `(key)` expressions to improve transitions.
48
48
  * `index` position used by default
@@ -56,10 +56,17 @@ export type LabelsPropsWithoutHTML<T = any> = {
56
56
  }]>;
57
57
  };
58
58
  export type LabelsProps<T = any> = LabelsPropsWithoutHTML<T> & Without<TextProps, LabelsPropsWithoutHTML<T>>;
59
+ declare function $$render<TData = any>(): {
60
+ props: LabelsProps<TData>;
61
+ exports: {};
62
+ bindings: "";
63
+ slots: {};
64
+ events: {};
65
+ };
59
66
  declare class __sveltets_Render<TData = any> {
60
- props(): LabelsProps<TData>;
61
- events(): {};
62
- slots(): {};
67
+ props(): ReturnType<typeof $$render<TData>>['props'];
68
+ events(): ReturnType<typeof $$render<TData>>['events'];
69
+ slots(): ReturnType<typeof $$render<TData>>['slots'];
63
70
  bindings(): "";
64
71
  exports(): {};
65
72
  }