layerchart 2.0.0-next.38 → 2.0.0-next.39

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 (96) hide show
  1. package/dist/components/AnnotationLine.svelte +15 -2
  2. package/dist/components/AnnotationPoint.svelte +13 -2
  3. package/dist/components/AnnotationRange.svelte +16 -2
  4. package/dist/components/Arc.svelte +3 -3
  5. package/dist/components/Area.svelte +10 -2
  6. package/dist/components/Axis.svelte +43 -26
  7. package/dist/components/Bar.svelte +6 -5
  8. package/dist/components/Bar.svelte.d.ts +2 -2
  9. package/dist/components/Bars.svelte +3 -3
  10. package/dist/components/Blur.svelte +2 -3
  11. package/dist/components/BrushContext.svelte +44 -44
  12. package/dist/components/Calendar.svelte +21 -4
  13. package/dist/components/Chart.svelte +1 -2
  14. package/dist/components/ChartClipPath.svelte +1 -1
  15. package/dist/components/Circle.svelte +44 -3
  16. package/dist/components/CircleClipPath.svelte +8 -1
  17. package/dist/components/ClipPath.svelte +1 -2
  18. package/dist/components/ColorRamp.svelte +1 -1
  19. package/dist/components/ComputedStyles.svelte +9 -2
  20. package/dist/components/Connector.svelte +1 -1
  21. package/dist/components/Ellipse.svelte +44 -3
  22. package/dist/components/Frame.svelte +1 -1
  23. package/dist/components/GeoCircle.svelte +1 -1
  24. package/dist/components/GeoEdgeFade.svelte +1 -1
  25. package/dist/components/GeoPath.svelte +18 -3
  26. package/dist/components/GeoPoint.svelte +3 -3
  27. package/dist/components/GeoSpline.svelte +1 -1
  28. package/dist/components/GeoTile.svelte +1 -1
  29. package/dist/components/Graticule.svelte +5 -5
  30. package/dist/components/Grid.svelte +57 -60
  31. package/dist/components/Group.svelte +11 -6
  32. package/dist/components/Highlight.svelte +46 -22
  33. package/dist/components/Highlight.svelte.d.ts +4 -0
  34. package/dist/components/Hull.svelte +11 -4
  35. package/dist/components/Labels.svelte +21 -11
  36. package/dist/components/Legend.svelte +133 -67
  37. package/dist/components/Legend.svelte.d.ts +7 -3
  38. package/dist/components/Line.svelte +40 -3
  39. package/dist/components/LinearGradient.svelte +35 -4
  40. package/dist/components/Link.svelte +1 -1
  41. package/dist/components/Marker.svelte +37 -26
  42. package/dist/components/MonthPath.svelte +14 -3
  43. package/dist/components/MotionPath.svelte +1 -1
  44. package/dist/components/Pattern.svelte +5 -5
  45. package/dist/components/Pie.svelte +1 -2
  46. package/dist/components/Points.svelte +1 -1
  47. package/dist/components/Polygon.svelte +27 -3
  48. package/dist/components/RadialGradient.svelte +3 -3
  49. package/dist/components/Rect.svelte +55 -5
  50. package/dist/components/Rect.svelte.d.ts +2 -2
  51. package/dist/components/RectClipPath.svelte +4 -3
  52. package/dist/components/RectClipPath.svelte.d.ts +2 -2
  53. package/dist/components/Rule.svelte +30 -23
  54. package/dist/components/Spline.svelte +29 -10
  55. package/dist/components/Text.svelte +59 -13
  56. package/dist/components/TileImage.svelte +19 -4
  57. package/dist/components/TransformContext.svelte +9 -3
  58. package/dist/components/TransformControls.svelte +72 -17
  59. package/dist/components/Voronoi.svelte +12 -13
  60. package/dist/components/charts/ArcChart.svelte +40 -69
  61. package/dist/components/charts/AreaChart.svelte +19 -42
  62. package/dist/components/charts/BarChart.svelte +7 -18
  63. package/dist/components/charts/DefaultTooltip.svelte +2 -2
  64. package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
  65. package/dist/components/charts/LineChart.svelte +61 -66
  66. package/dist/components/charts/LineChart.svelte.d.ts +11 -5
  67. package/dist/components/charts/PieChart.svelte +41 -69
  68. package/dist/components/charts/ScatterChart.svelte +8 -19
  69. package/dist/components/charts/utils.svelte.d.ts +1 -19
  70. package/dist/components/charts/utils.svelte.js +7 -39
  71. package/dist/components/layout/Canvas.svelte +29 -20
  72. package/dist/components/layout/Html.svelte +15 -9
  73. package/dist/components/layout/Svg.svelte +19 -11
  74. package/dist/components/layout/WebGL.svelte +26 -6
  75. package/dist/components/layout/WebGL.svelte.d.ts +5 -2
  76. package/dist/components/tooltip/Tooltip.svelte +60 -29
  77. package/dist/components/tooltip/TooltipContext.svelte +73 -36
  78. package/dist/components/tooltip/TooltipContext.svelte.d.ts +7 -0
  79. package/dist/components/tooltip/TooltipHeader.svelte +27 -14
  80. package/dist/components/tooltip/TooltipItem.svelte +41 -33
  81. package/dist/components/tooltip/TooltipList.svelte +12 -10
  82. package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
  83. package/dist/states/series.svelte.d.ts +30 -0
  84. package/dist/states/series.svelte.js +54 -0
  85. package/dist/styles/daisyui-5.css +6 -0
  86. package/dist/styles/shadcn-svelte.css +11 -0
  87. package/dist/styles/skeleton-3.css +15 -0
  88. package/dist/utils/attributes.d.ts +3 -13
  89. package/dist/utils/attributes.js +4 -18
  90. package/dist/utils/common.d.ts +9 -0
  91. package/dist/utils/common.js +18 -1
  92. package/dist/utils/common.test.js +26 -1
  93. package/dist/utils/math.d.ts +17 -0
  94. package/dist/utils/math.js +17 -0
  95. package/dist/utils/types.d.ts +15 -2
  96. package/package.json +5 -1
@@ -1,7 +1,6 @@
1
1
  <script lang="ts" module>
2
2
  import { createId } from '../utils/createId.js';
3
3
  import type { Without } from '../utils/types.js';
4
- import { layerClass } from '../utils/attributes.js';
5
4
  import type { Snippet } from 'svelte';
6
5
  import type { SVGAttributes } from 'svelte/elements';
7
6
  import { getRenderContext } from './Chart.svelte';
@@ -76,7 +75,7 @@
76
75
  {#if disabled || renderContext !== 'svg'}
77
76
  {@render children({ id, url, useId })}
78
77
  {:else}
79
- <g style:clip-path={url} class={layerClass('clip-path-g')}>
78
+ <g style:clip-path={url} class="lc-clip-path-g">
80
79
  {@render children({ id, url, useId })}
81
80
  </g>
82
81
  {/if}
@@ -83,5 +83,5 @@
83
83
  preserveAspectRatio="none"
84
84
  {height}
85
85
  {width}
86
- {...extractLayerProps(restProps, 'color-ramp')}
86
+ {...extractLayerProps(restProps, 'lc-color-ramp')}
87
87
  />
@@ -13,7 +13,6 @@
13
13
  <script lang="ts">
14
14
  import { computedStyles } from '@layerstack/svelte-actions';
15
15
  import { cls } from '@layerstack/tailwind';
16
- import { layerClass } from '../utils/attributes.js';
17
16
 
18
17
  let { class: className, children }: ComputedStylesProps = $props();
19
18
 
@@ -21,8 +20,16 @@
21
20
  </script>
22
21
 
23
22
  <div
24
- class={cls(layerClass('computed-styles'), 'hidden', className)}
23
+ class={cls('lc-computed-styles', className)}
25
24
  use:computedStyles={(_styles) => (styles = _styles)}
26
25
  ></div>
27
26
 
28
27
  {@render children?.({ styles })}
28
+
29
+ <style>
30
+ @layer base {
31
+ :global(:where(.lc-computed-styles)) {
32
+ display: none;
33
+ }
34
+ }
35
+ </style>
@@ -141,7 +141,7 @@
141
141
  marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
142
142
  marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
143
143
  marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
144
- {...extractLayerProps(restProps, 'connector')}
144
+ {...extractLayerProps(restProps, 'lc-connector')}
145
145
  {...restProps}
146
146
  />
147
147
  <MarkerWrapper id={markerStartId} marker={markerStart} />
@@ -82,7 +82,6 @@
82
82
  import { renderEllipse, type ComputedStylesOptions } from '../utils/canvas.js';
83
83
  import type { SVGAttributes } from 'svelte/elements';
84
84
  import { createKey } from '../utils/key.svelte.js';
85
- import { layerClass } from '../utils/attributes.js';
86
85
 
87
86
  let {
88
87
  cx = 0,
@@ -133,7 +132,7 @@
133
132
  ? merge({ styles: { strokeWidth } }, styleOverrides)
134
133
  : {
135
134
  styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
136
- classes: className,
135
+ classes: cls('lc-ellipse', className),
137
136
  }
138
137
  );
139
138
  }
@@ -181,7 +180,49 @@
181
180
  {stroke}
182
181
  stroke-width={strokeWidth}
183
182
  {opacity}
184
- class={cls(layerClass('ellipse'), fill == null && 'fill-surface-content', className)}
183
+ class={cls('lc-ellipse', className)}
185
184
  {...restProps}
186
185
  />
186
+ {:else if renderCtx === 'html'}
187
+ <div
188
+ style:position="absolute"
189
+ style:left="{motionCx.current}px"
190
+ style:top="{motionCy.current}px"
191
+ style:width="{motionRx.current * 2}px"
192
+ style:height="{motionRy.current * 2}px"
193
+ style:border-radius="50%"
194
+ style:background-color={fill}
195
+ style:opacity
196
+ style:border-width={strokeWidth}
197
+ style:border-color={stroke}
198
+ style:border-style="solid"
199
+ style:transform="translate(-50%, -50%)"
200
+ class={cls('lc-ellipse', className)}
201
+ {...restProps}
202
+ ></div>
187
203
  {/if}
204
+
205
+ <style>
206
+ @layer base {
207
+ :global(:where(.lc-ellipse)) {
208
+ --fill-color: var(--color-surface-content, currentColor);
209
+ --stroke-color: initial;
210
+ }
211
+
212
+ /* Svg | Canvas layers */
213
+ :global(:where(.lc-layout-svg .lc-ellipse, svg.lc-ellipse):not([fill])) {
214
+ fill: var(--fill-color);
215
+ }
216
+ :global(:where(.lc-layout-svg .lc-ellipse, svg.lc-ellipse):not([stroke])) {
217
+ stroke: var(--stroke-color);
218
+ }
219
+
220
+ /* Html layers */
221
+ :global(:where(.lc-layout-html .lc-ellipse):not([background-color])) {
222
+ background-color: var(--fill-color);
223
+ }
224
+ :global(:where(.lc-layout-html .lc-ellipse):not([border-color])) {
225
+ border-color: var(--stroke-color);
226
+ }
227
+ }
228
+ </style>
@@ -37,5 +37,5 @@
37
37
  width={ctx.width + (full ? (ctx.padding?.left ?? 0) + (ctx.padding?.right ?? 0) : 0)}
38
38
  height={ctx.height + (full ? (ctx.padding?.top ?? 0) + (ctx.padding?.bottom ?? 0) : 0)}
39
39
  bind:ref
40
- {...extractLayerProps(restProps, 'frame')}
40
+ {...extractLayerProps(restProps, 'lc-frame')}
41
41
  />
@@ -34,4 +34,4 @@
34
34
  const geojson = $derived(geoCircle().radius(radius).center(center).precision(precision)());
35
35
  </script>
36
36
 
37
- <GeoPath {geojson} {...extractLayerProps(restProps, 'geo-circle')} />
37
+ <GeoPath {geojson} {...extractLayerProps(restProps, 'lc-geo-circle')} />
@@ -56,6 +56,6 @@
56
56
  const opacity = $derived(opacityProp ?? clamper(fade(distance)));
57
57
  </script>
58
58
 
59
- <Group {opacity} bind:ref {...extractLayerProps(restProps, 'geo-edge-fade')}>
59
+ <Group {opacity} bind:ref {...extractLayerProps(restProps, 'lc-geo-edge-fade')}>
60
60
  {@render children?.()}
61
61
  </Group>
@@ -66,7 +66,6 @@
66
66
  </script>
67
67
 
68
68
  <script lang="ts">
69
- import { cls } from '@layerstack/tailwind';
70
69
  import { merge } from 'lodash-es';
71
70
 
72
71
  import { getRenderContext } from './Chart.svelte';
@@ -74,7 +73,6 @@
74
73
  import { geoCurvePath } from '../utils/geo.js';
75
74
  import { getGeoContext } from './GeoContext.svelte';
76
75
  import { createKey } from '../utils/key.svelte.js';
77
- import { layerClass } from '../utils/attributes.js';
78
76
 
79
77
  let {
80
78
  fill,
@@ -199,6 +197,23 @@
199
197
  onpointerenter={_onPointerEnter}
200
198
  onpointermove={_onPointerMove}
201
199
  onpointerleave={_onPointerLeave}
202
- class={cls(layerClass('geo-path'), fill == null && 'fill-transparent', className)}
200
+ class={['lc-geo-path', className]}
203
201
  />
204
202
  {/if}
203
+
204
+ <style>
205
+ @layer base {
206
+ :global(:where(.lc-geo-path)) {
207
+ --fill-color: transparent;
208
+ --stroke-color: initial;
209
+ }
210
+
211
+ /* Svg | Canvas layers */
212
+ :global(:where(.lc-layout-svg .lc-geo-path, svg.lc-geo-path):not([fill])) {
213
+ fill: var(--fill-color);
214
+ }
215
+ :global(:where(.lc-layout-svg .lc-geo-path, svg.lc-geo-path):not([stroke])) {
216
+ stroke: var(--stroke-color);
217
+ }
218
+ }
219
+ </style>
@@ -53,11 +53,11 @@
53
53
 
54
54
  {#if renderContext === 'svg'}
55
55
  {#if children}
56
- <Group {x} {y} {...extractLayerProps(restProps, 'geo-point-group')}>
56
+ <Group {x} {y} {...extractLayerProps(restProps, 'lc-geo-point-group')}>
57
57
  {@render children({ x, y })}
58
58
  </Group>
59
59
  {:else}
60
- <Circle cx={x} cy={y} {...extractLayerProps(restProps, 'geo-point')} />
60
+ <Circle cx={x} cy={y} {...extractLayerProps(restProps, 'lc-geo-point')} />
61
61
  {/if}
62
62
  {/if}
63
63
 
@@ -68,6 +68,6 @@
68
68
  {@render children({ x, y })}
69
69
  <!-- </Group> -->
70
70
  {:else}
71
- <Circle cx={x} cy={y} {...extractLayerProps(restProps, 'geo-point')} />
71
+ <Circle cx={x} cy={y} {...extractLayerProps(restProps, 'lc-geo-point')} />
72
72
  {/if}
73
73
  {/if}
@@ -81,5 +81,5 @@
81
81
  x={(d) => d[0]}
82
82
  y={(d) => d[1]}
83
83
  {curve}
84
- {...extractLayerProps(restProps, 'geo-spline')}
84
+ {...extractLayerProps(restProps, 'lc-geo-spline')}
85
85
  />
@@ -106,7 +106,7 @@
106
106
  <Group
107
107
  x={-ctx.padding.left}
108
108
  y={-ctx.padding.top}
109
- {...extractLayerProps(group, 'geo-tile-group')}
109
+ {...extractLayerProps(group, 'lc-geo-tile-group')}
110
110
  >
111
111
  {#each tiles as [x, y, z] (url(x, y, z))}
112
112
  <TileImage
@@ -15,7 +15,7 @@
15
15
 
16
16
  <script lang="ts">
17
17
  import { geoGraticule } from 'd3-geo';
18
- import { extractLayerProps, layerClass } from '../utils/attributes.js';
18
+ import { extractLayerProps } from '../utils/attributes.js';
19
19
  import Group from './Group.svelte';
20
20
 
21
21
  let { lines, outline, step = [10, 10], ...restProps }: GraticuleProps = $props();
@@ -27,22 +27,22 @@
27
27
  });
28
28
  </script>
29
29
 
30
- <Group class={layerClass('graticule-g')}>
30
+ <Group class="lc-graticule-g">
31
31
  <!-- TODO: Any reason to still render the single `MultiLineString` path if using `lines` and/or `outline` -->
32
32
  {#if !lines && !outline}
33
- <GeoPath geojson={graticule()} {...extractLayerProps(restProps, 'graticule-geo-path')} />
33
+ <GeoPath geojson={graticule()} {...extractLayerProps(restProps, 'lc-graticule-geo-path')} />
34
34
  {/if}
35
35
 
36
36
  {#if lines}
37
37
  {#each graticule.lines() as line}
38
- <GeoPath geojson={line} {...extractLayerProps(lines, 'graticule-geo-line')} />
38
+ <GeoPath geojson={line} {...extractLayerProps(lines, 'lc-graticule-geo-line')} />
39
39
  {/each}
40
40
  {/if}
41
41
 
42
42
  {#if outline}
43
43
  <GeoPath
44
44
  geojson={graticule.outline()}
45
- {...extractLayerProps(outline, 'graticule-geo-outline')}
45
+ {...extractLayerProps(outline, 'lc-graticule-geo-outline')}
46
46
  />
47
47
  {/if}
48
48
  </Group>
@@ -98,7 +98,7 @@
98
98
  import Rule from './Rule.svelte';
99
99
  import Spline from './Spline.svelte';
100
100
  import { getChartContext } from './Chart.svelte';
101
- import { extractLayerProps, layerClass } from '../utils/attributes.js';
101
+ import { extractLayerProps } from '../utils/attributes.js';
102
102
  import { autoTickVals, type TicksConfig } from '../utils/ticks.js';
103
103
 
104
104
  const ctx = getChartContext();
@@ -151,11 +151,11 @@
151
151
  );
152
152
  </script>
153
153
 
154
- <Group bind:ref class={cls(layerClass('grid'), classes.root, className)} {...restProps}>
154
+ <Group bind:ref class={cls('lc-grid', classes.root, className)} {...restProps}>
155
155
  {#if x}
156
- {@const splineProps = extractLayerProps(x, 'grid-x-line')}
156
+ {@const splineProps = extractLayerProps(x, 'lc-grid-x-line')}
157
157
 
158
- <Group {transitionIn} {transitionInParams} class={layerClass('grid-x')}>
158
+ <Group {transitionIn} {transitionInParams} class="lc-grid-x">
159
159
  {#each xTickVals as x (x)}
160
160
  {#if ctx.radial}
161
161
  {@const [x1, y1] = pointRadial(ctx.xScale(x), ctx.yRange[0])}
@@ -167,12 +167,7 @@
167
167
  {y2}
168
168
  motion={tweenConfig}
169
169
  {...splineProps}
170
- class={cls(
171
- layerClass('grid-x-radial-line'),
172
- 'stroke-surface-content/10',
173
- classes.line,
174
- splineProps?.class
175
- )}
170
+ class={cls('lc-grid-x-radial-line', classes.line, splineProps?.class)}
176
171
  />
177
172
  {:else}
178
173
  <Rule
@@ -180,37 +175,28 @@
180
175
  xOffset={xBandOffset}
181
176
  {motion}
182
177
  {...splineProps}
183
- class={cls(
184
- layerClass('grid-x-rule'),
185
- 'stroke-surface-content/10',
186
- classes.line,
187
- splineProps?.class
188
- )}
178
+ class={cls('lc-grid-x-rule', classes.line, splineProps?.class)}
189
179
  />
190
180
  {/if}
191
181
  {/each}
192
182
 
193
183
  <!-- Add extra rule after last band -->
194
184
  {#if isScaleBand(ctx.xScale) && bandAlign === 'between' && !ctx.radial && xTickVals.length}
185
+ {@const x = ctx.xScale(xTickVals[xTickVals.length - 1])! + ctx.xScale.step() + xBandOffset}
195
186
  <Rule
196
187
  x={xTickVals[xTickVals.length - 1]}
197
188
  xOffset={ctx.xScale.step() + xBandOffset}
198
189
  {motion}
199
190
  {...splineProps}
200
- class={cls(
201
- layerClass('grid-x-end-rule'),
202
- 'stroke-surface-content/10',
203
- classes.line,
204
- splineProps?.class
205
- )}
191
+ class={cls('lc-grid-x-end-rule', classes.line, splineProps?.class)}
206
192
  />
207
193
  {/if}
208
194
  </Group>
209
195
  {/if}
210
196
 
211
197
  {#if y}
212
- {@const splineProps = extractLayerProps(y, 'grid-y-line')}
213
- <Group {transitionIn} {transitionInParams} class={layerClass('grid-y')}>
198
+ {@const splineProps = extractLayerProps(y, 'lc-grid-y-line')}
199
+ <Group {transitionIn} {transitionInParams} class="lc-grid-y">
214
200
  {#each yTickVals as y (y)}
215
201
  {#if ctx.radial}
216
202
  {#if radialY === 'circle'}
@@ -218,12 +204,7 @@
218
204
  r={ctx.yScale(y) + yBandOffset}
219
205
  {motion}
220
206
  {...splineProps}
221
- class={cls(
222
- layerClass('grid-y-radial-circle'),
223
- 'fill-none stroke-surface-content/10',
224
- classes.line,
225
- splineProps?.class
226
- )}
207
+ class={cls('lc-grid-y-radial-circle', classes.line, splineProps?.class)}
227
208
  />
228
209
  {:else}
229
210
  <Spline
@@ -233,26 +214,18 @@
233
214
  motion={tweenConfig}
234
215
  curve={curveLinearClosed}
235
216
  {...splineProps}
236
- class={cls(
237
- layerClass('grid-y-radial-line'),
238
- 'stroke-surface-content/10',
239
- classes.line,
240
- splineProps?.class
241
- )}
217
+ class={cls('lc-grid-y-radial-line', classes.line, splineProps?.class)}
242
218
  />
243
219
  {/if}
244
220
  {:else}
245
- <Rule
246
- {y}
247
- yOffset={yBandOffset}
221
+ <Line
222
+ x1={ctx.xRange[0]}
223
+ y1={ctx.yScale(y) + yBandOffset}
224
+ x2={ctx.xRange[1]}
225
+ y2={ctx.yScale(y) + yBandOffset}
248
226
  {motion}
249
227
  {...splineProps}
250
- class={cls(
251
- layerClass('grid-y-rule'),
252
- 'stroke-surface-content/10',
253
- classes.line,
254
- splineProps?.class
255
- )}
228
+ class={cls('lc-grid-y-rule', classes.line, splineProps?.class)}
256
229
  />
257
230
  {/if}
258
231
  {/each}
@@ -264,28 +237,52 @@
264
237
  r={ctx.yScale(yTickVals[yTickVals.length - 1])! + ctx.yScale.step() + yBandOffset}
265
238
  {motion}
266
239
  {...splineProps}
267
- class={cls(
268
- layerClass('grid-y-radial-circle'),
269
- 'fill-none stroke-surface-content/10',
270
- classes.line,
271
- splineProps?.class
272
- )}
240
+ class={cls('lc-grid-y-radial-circle', classes.line, splineProps?.class)}
273
241
  />
274
242
  {:else}
275
- <Rule
276
- y={yTickVals[yTickVals.length - 1]}
277
- yOffset={ctx.yScale.step() + yBandOffset}
243
+ {@const y =
244
+ ctx.yScale(yTickVals[yTickVals.length - 1])! + ctx.yScale.step() + yBandOffset}
245
+ <Line
246
+ x1={ctx.xRange[0]}
247
+ y1={y}
248
+ x2={ctx.xRange[1]}
249
+ y2={y}
278
250
  {motion}
279
251
  {...splineProps}
280
- class={cls(
281
- layerClass('grid-y-end-rule'),
282
- 'stroke-surface-content/10',
283
- classes.line,
284
- splineProps?.class
285
- )}
252
+ class={cls('lc-grid-y-end-rule', classes.line, splineProps?.class)}
286
253
  />
287
254
  {/if}
288
255
  {/if}
289
256
  </Group>
290
257
  {/if}
291
258
  </Group>
259
+
260
+ <style>
261
+ @layer components {
262
+ :global(
263
+ :where(
264
+ .lc-grid-x-rule,
265
+ .lc-grid-x-end-rule,
266
+ .lc-grid-x-radial-line,
267
+ .lc-grid-y-rule,
268
+ .lc-grid-y-end-rule,
269
+ .lc-grid-y-radial-line
270
+ )
271
+ ) {
272
+ --stroke-color: color-mix(
273
+ in oklab,
274
+ var(--color-surface-content, currentColor) 10%,
275
+ transparent
276
+ );
277
+ }
278
+
279
+ :global(:where(.lc-grid-y-radial-circle)) {
280
+ --fill-color: none;
281
+ --stroke-color: color-mix(
282
+ in oklab,
283
+ var(--color-surface-content, currentColor) 10%,
284
+ transparent
285
+ );
286
+ }
287
+ }
288
+ </style>
@@ -83,13 +83,10 @@
83
83
  import { fade } from 'svelte/transition';
84
84
  import { cubicIn } from 'svelte/easing';
85
85
 
86
- import { cls } from '@layerstack/tailwind';
87
-
88
86
  import { getRenderContext } from './Chart.svelte';
89
87
  import { registerCanvasComponent } from './layout/Canvas.svelte';
90
88
 
91
89
  import { getChartContext } from './Chart.svelte';
92
- import { layerClass } from '../utils/attributes.js';
93
90
 
94
91
  const ctx = getChartContext();
95
92
 
@@ -178,7 +175,7 @@
178
175
  {:else if renderCtx === 'svg'}
179
176
  <g
180
177
  style:transform
181
- class={cls(layerClass('group-g'), className)}
178
+ class={['lc-group-g', className]}
182
179
  in:transitionIn={transitionInParams}
183
180
  {opacity}
184
181
  {...restProps}
@@ -187,16 +184,24 @@
187
184
  >
188
185
  {@render children?.()}
189
186
  </g>
190
- {:else}
187
+ {:else if renderCtx === 'html'}
191
188
  <div
192
189
  bind:this={ref}
193
190
  style:transform
194
191
  style:opacity
195
192
  in:transitionIn={transitionInParams}
196
193
  {...restProps}
197
- class={cls(layerClass('group-div'), 'absolute', className)}
194
+ class={['lc-group-div', className]}
198
195
  ontouchmove={handleTouchMove}
199
196
  >
200
197
  {@render children?.()}
201
198
  </div>
202
199
  {/if}
200
+
201
+ <style>
202
+ @layer base {
203
+ :where(.lc-group-div) {
204
+ position: absolute;
205
+ }
206
+ }
207
+ </style>
@@ -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,7 +119,6 @@
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
123
  import { isScaleBand, isScaleTime } from '../utils/scales.svelte.js';
120
124
  import { asAny } from '../utils/types.js';
@@ -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,
@@ -435,11 +440,6 @@
435
440
  return tmpPoints;
436
441
  }
437
442
  );
438
-
439
- const areaProps = $derived(extractLayerProps(area, 'highlight-area'));
440
- const barProps = $derived(extractLayerProps(bar, 'highlight-bar'));
441
- const linesProps = $derived(extractLayerProps(linesProp, 'highlight-line'));
442
- const pointsProps = $derived(extractLayerProps(points, 'highlight-point'));
443
443
  </script>
444
444
 
445
445
  {#if highlightData}
@@ -454,15 +454,16 @@
454
454
  endAngle={_area.x + _area.width}
455
455
  innerRadius={_area.y}
456
456
  outerRadius={_area.y + _area.height}
457
- class={cls(!areaProps.fill && 'fill-surface-content/5', areaProps.class)}
457
+ {opacity}
458
+ class="lc-highlight-area"
458
459
  onclick={onAreaClick && ((e) => onAreaClick(e, { data: highlightData }))}
459
460
  />
460
461
  {:else}
461
462
  <Rect
462
463
  motion={motion === 'spring' ? 'spring' : undefined}
464
+ {opacity}
463
465
  {..._area}
464
- {...areaProps}
465
- class={cls(!areaProps.fill && 'fill-surface-content/5', areaProps.class)}
466
+ {...extractLayerProps(area, 'lc-highlight-area')}
466
467
  onclick={onAreaClick && ((e) => onAreaClick(e, { data: highlightData }))}
467
468
  />
468
469
  {/if}
@@ -475,8 +476,8 @@
475
476
  <Bar
476
477
  motion={motion === 'spring' ? 'spring' : undefined}
477
478
  data={highlightData}
478
- {...barProps}
479
- class={cls(!barProps.fill && 'fill-primary', barProps.class)}
479
+ {opacity}
480
+ {...extractLayerProps(bar, 'lc-highlight-bar')}
480
481
  onclick={onBarClick && ((e) => onBarClick(e, { data: highlightData }))}
481
482
  />
482
483
  {/if}
@@ -493,11 +494,8 @@
493
494
  y1={line.y1}
494
495
  x2={line.x2}
495
496
  y2={line.y2}
496
- {...linesProps}
497
- class={cls(
498
- 'stroke-surface-content/20 stroke-2 [stroke-dasharray:2,2] pointer-events-none',
499
- linesProps.class
500
- )}
497
+ {opacity}
498
+ {...extractLayerProps(linesProp, 'lc-highlight-line')}
501
499
  />
502
500
  {/each}
503
501
  {/if}
@@ -515,12 +513,8 @@
515
513
  fill={point.fill}
516
514
  r={4}
517
515
  strokeWidth={6}
518
- {...pointsProps}
519
- class={cls(
520
- 'stroke-white [paint-order:stroke] drop-shadow-sm',
521
- !point.fill && (typeof points === 'boolean' || !points.fill) && 'fill-primary',
522
- pointsProps.class
523
- )}
516
+ {opacity}
517
+ {...extractLayerProps(points, 'lc-highlight-point')}
524
518
  onpointerdown={onPointClick &&
525
519
  ((e) => {
526
520
  // Do not propagate `pointerdown` event to `BrushContext` if `onclick` is provided
@@ -546,3 +540,33 @@
546
540
  {/if}
547
541
  {/if}
548
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;