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
@@ -216,8 +216,6 @@
216
216
  import type { Without } from '../utils/types.js';
217
217
  import { getChartContext } from './Chart.svelte';
218
218
  import type { Snippet } from 'svelte';
219
- import { cls } from '@layerstack/tailwind';
220
- import { layerClass } from '../utils/attributes.js';
221
219
  import {
222
220
  createControlledMotion,
223
221
  createMotionTracker,
@@ -519,9 +517,17 @@
519
517
  onpointerup={onPointerUp}
520
518
  ondblclick={onDoubleClick}
521
519
  onclickcapture={onClick}
522
- class={cls(layerClass('transform-context'), 'h-full', className)}
520
+ class={['lc-transform-context', className]}
523
521
  bind:this={ref}
524
522
  {...restProps}
525
523
  >
526
524
  {@render children?.({ transformContext: transformContext })}
527
525
  </div>
526
+
527
+ <style>
528
+ @layer base {
529
+ :where(.lc-transform-context) {
530
+ height: 100%;
531
+ }
532
+ }
533
+ </style>
@@ -32,7 +32,6 @@
32
32
  <script lang="ts">
33
33
  import { type ComponentProps } from 'svelte';
34
34
  import { Button, Icon, MenuButton, Tooltip } from 'svelte-ux';
35
- import { cls } from '@layerstack/tailwind';
36
35
 
37
36
  import LucideFocus from '~icons/lucide/focus';
38
37
  import LucideChevronDown from '~icons/lucide/chevron-down';
@@ -85,22 +84,9 @@
85
84
 
86
85
  <!-- svelte-ignore a11y_no_static_element_interactions -->
87
86
  <div
88
- class={cls(
89
- 'bg-surface-300/50 border rounded-full m-1 backdrop-blur-sm z-10 flex',
90
- orientation === 'vertical' && 'flex-col',
91
- {
92
- 'top-left': 'absolute top-0 left-0',
93
- top: 'absolute top-0 left-1/2 -translate-x-1/2',
94
- 'top-right': 'absolute top-0 right-0',
95
- left: 'absolute top-1/2 left-0 -translate-y-1/2',
96
- center: 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',
97
- right: 'absolute top-1/2 right-0 -translate-y-1/2',
98
- 'bottom-left': 'absolute bottom-0 left-0',
99
- bottom: 'absolute bottom-0 left-1/2 -translate-x-1/2',
100
- 'bottom-right': 'absolute bottom-0 right-0',
101
- }[placement],
102
- className
103
- )}
87
+ class={['lc-transform-controls', className]}
88
+ data-orientation={orientation}
89
+ data-placement={placement}
104
90
  ondblclick={(e) => {
105
91
  // Stop from propagating to TransformContext
106
92
  e.stopPropagation();
@@ -173,3 +159,72 @@
173
159
  </Tooltip>
174
160
  {/if}
175
161
  </div>
162
+
163
+ <style>
164
+ @layer components {
165
+ :where(.lc-transform-controls) {
166
+ display: flex;
167
+ background: color-mix(
168
+ in oklab,
169
+ var(--color-surface-300, light-dark(white, black)) 50%,
170
+ transparent
171
+ );
172
+ border: 1px solid
173
+ color-mix(in oklab, var(--color-surface-content, currentColor) 20%, transparent);
174
+ border-radius: 9999px;
175
+ margin: 4px;
176
+ backdrop-filter: blur(8px);
177
+ z-index: 10;
178
+
179
+ &[data-orientation='vertical'] {
180
+ flex-direction: column;
181
+ }
182
+
183
+ &[data-placement] {
184
+ position: absolute;
185
+ }
186
+
187
+ &[data-placement='top-left'] {
188
+ top: 0;
189
+ left: 0;
190
+ }
191
+ &[data-placement='top'] {
192
+ top: 0;
193
+ left: 50%;
194
+ transform: translateX(-50%);
195
+ }
196
+ &[data-placement='top-right'] {
197
+ top: 0;
198
+ right: 0;
199
+ }
200
+ &[data-placement='left'] {
201
+ top: 50%;
202
+ left: 0;
203
+ transform: translateY(-50%);
204
+ }
205
+ &[data-placement='center'] {
206
+ top: 50%;
207
+ left: 50%;
208
+ transform: translate(-50%, -50%);
209
+ }
210
+ &[data-placement='right'] {
211
+ top: 50%;
212
+ right: 0;
213
+ transform: translateY(-50%);
214
+ }
215
+ &[data-placement='bottom-left'] {
216
+ bottom: 0;
217
+ left: 0;
218
+ }
219
+ &[data-placement='bottom'] {
220
+ bottom: 0;
221
+ left: 50%;
222
+ transform: translateX(-50%);
223
+ }
224
+ &[data-placement='bottom-right'] {
225
+ bottom: 0;
226
+ right: 0;
227
+ }
228
+ }
229
+ }
230
+ </style>
@@ -71,8 +71,6 @@
71
71
  import { getGeoContext } from './GeoContext.svelte';
72
72
  import CircleClipPath from './CircleClipPath.svelte';
73
73
 
74
- import { layerClass } from '../utils/attributes.js';
75
-
76
74
  let {
77
75
  data,
78
76
  r,
@@ -118,7 +116,7 @@
118
116
  const disableClip = $derived(r === 0 || r == null || r === Infinity);
119
117
  </script>
120
118
 
121
- <Group {...restProps} class={cls(layerClass('voronoi-g'), classes.root, className)}>
119
+ <Group {...restProps} class={cls('lc-voronoi-g', classes.root, className)}>
122
120
  {#if geo.projection}
123
121
  {@const polygons = geoVoronoi().polygons(points)}
124
122
  {#each polygons.features as feature}
@@ -131,11 +129,7 @@
131
129
  >
132
130
  <GeoPath
133
131
  geojson={feature}
134
- class={cls(
135
- layerClass('voronoi-geo-path'),
136
- 'fill-transparent stroke-transparent',
137
- classes.path
138
- )}
132
+ class={['lc-voronoi-geo-path', classes.path]}
139
133
  onclick={(e) => onclick?.(e, { data: feature.properties.site.data, feature })}
140
134
  onpointerenter={(e) =>
141
135
  onpointerenter?.(e, { data: feature.properties.site.data, feature })}
@@ -158,11 +152,7 @@
158
152
  <CircleClipPath cx={point[0]} cy={point[1]} r={r ?? 0} disabled={disableClip}>
159
153
  <Spline
160
154
  {pathData}
161
- class={cls(
162
- layerClass('voronoi-path'),
163
- 'fill-transparent stroke-transparent',
164
- classes.path
165
- )}
155
+ class={['lc-voronoi-path', classes.path]}
166
156
  onclick={(e) => onclick?.(e, { data: point.data, point })}
167
157
  onpointerenter={(e) => onpointerenter?.(e, { data: point.data, point })}
168
158
  onpointermove={(e) => onpointermove?.(e, { data: point.data, point })}
@@ -178,3 +168,12 @@
178
168
  {/each}
179
169
  {/if}
180
170
  </Group>
171
+
172
+ <style>
173
+ @layer components {
174
+ :global(:where(.lc-voronoi-path, .lc-voronoi-geo-path)) {
175
+ fill: transparent;
176
+ stroke: transparent;
177
+ }
178
+ }
179
+ </style>
@@ -124,7 +124,6 @@
124
124
  import { sum } from 'd3-array';
125
125
  import { format } from '@layerstack/utils';
126
126
  import { cls } from '@layerstack/tailwind';
127
- import { SelectionState } from '@layerstack/svelte-state';
128
127
 
129
128
  import Arc, { type ArcPropsWithoutHTML } from '../Arc.svelte';
130
129
  import Chart from '../Chart.svelte';
@@ -133,7 +132,13 @@
133
132
  import Legend from '../Legend.svelte';
134
133
  import * as Tooltip from '../tooltip/index.js';
135
134
 
136
- import { accessor, chartDataArray, type Accessor } from '../../utils/common.js';
135
+ import {
136
+ accessor,
137
+ chartDataArray,
138
+ getObjectOrNull,
139
+ resolveMaybeFn,
140
+ type Accessor,
141
+ } from '../../utils/common.js';
137
142
  import { asAny } from '../../utils/types.js';
138
143
  import type {
139
144
  SeriesData,
@@ -141,7 +146,8 @@
141
146
  SimplifiedChartPropsObject,
142
147
  SimplifiedChartSnippet,
143
148
  } from './types.js';
144
- import { HighlightKey } from './utils.svelte.js';
149
+ import { SeriesState } from '../../states/series.svelte.js';
150
+ import { createLegendProps } from './utils.svelte.js';
145
151
  import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
146
152
  import { getColorIfDefined } from '../../utils/color.js';
147
153
 
@@ -223,63 +229,32 @@
223
229
  });
224
230
  });
225
231
 
226
- const selectedSeries = new SelectionState();
227
-
228
- const visibleSeries = $derived(
229
- series.filter((s) => selectedSeries.isEmpty() || selectedSeries.isSelected(s.key))
230
- );
231
-
232
- const allSeriesData = $derived(
233
- visibleSeries
234
- .flatMap((s) =>
235
- s.data?.map((d) => {
236
- return { seriesKey: s.key, ...d };
237
- })
238
- )
239
- .filter((d) => d) as Array<TData & { stackData?: any }>
240
- );
232
+ const seriesState = new SeriesState(() => series);
241
233
 
242
234
  const chartData = $derived(
243
- allSeriesData.length ? allSeriesData : chartDataArray(data)
235
+ seriesState.allSeriesData.length ? seriesState.allSeriesData : chartDataArray(data)
244
236
  ) as Array<TData>;
245
237
 
246
- const seriesColors = $derived(series.map((s) => s.color).filter((d) => d != null));
247
-
248
- const highlightKey = new HighlightKey<TData, typeof Arc>();
249
- const selectedKeys = new SelectionState();
250
-
251
238
  const visibleData = $derived(
252
239
  chartData.filter((d) => {
253
240
  const dataKey = keyAccessor(d);
254
- return selectedKeys.isEmpty() || selectedKeys.isSelected(dataKey);
241
+ return seriesState.selectedKeys.isEmpty() || seriesState.selectedKeys.isSelected(dataKey);
255
242
  })
256
243
  );
257
244
 
258
245
  function getLegendProps(): ComponentProps<typeof Legend> {
259
- return {
260
- tickFormat: (tick) => {
261
- const item = chartData.find((d) => keyAccessor(d) === tick);
262
- return item ? (labelAccessor(item) ?? tick) : tick;
263
- },
264
- placement: 'bottom',
265
- variant: 'swatches',
266
- onclick: (e, item) => {
267
- selectedKeys.toggle(item.value);
268
- selectedSeries.toggle(item.value);
269
- },
270
- onpointerenter: (e, item) => (highlightKey.current = item.value),
271
- onpointerleave: (e) => (highlightKey.current = null),
272
- ...props.legend,
273
- ...(typeof legend === 'object' ? legend : null),
274
- classes: {
275
- item: (item) =>
276
- visibleData.length && !visibleData.some((d) => keyAccessor(d) === item.value)
277
- ? 'opacity-50'
278
- : '',
279
- ...props.legend?.classes,
280
- ...(typeof legend === 'object' ? legend.classes : null),
246
+ return createLegendProps({
247
+ seriesState,
248
+ props: {
249
+ tickFormat: (tick) => {
250
+ // Use data label instead of series label
251
+ const item = chartData.find((d) => keyAccessor(d) === tick);
252
+ return item ? (labelAccessor(item) ?? tick) : tick;
253
+ },
254
+ ...props.legend,
255
+ ...getObjectOrNull(legend),
281
256
  },
282
- };
257
+ });
283
258
  }
284
259
 
285
260
  function getGroupProps(): ComponentProps<typeof Group> {
@@ -317,6 +292,7 @@
317
292
  multiSeries && (trackOuterRadius ?? 0) < 0 ? i * (trackOuterRadius ?? 0) : trackOuterRadius,
318
293
  fill: s.color ?? context.cScale?.(context.c(d)),
319
294
  track: { fill: s.color ?? context.cScale?.(context.c(d)), fillOpacity: 0.1 },
295
+ opacity: seriesState.isHighlighted(keyAccessor(d), true) ? 1 : 0.1,
320
296
  tooltipContext: context.tooltip,
321
297
  data: d,
322
298
  onclick: (e) => {
@@ -326,12 +302,7 @@
326
302
  },
327
303
  ...props.arc,
328
304
  ...s.props,
329
- class: cls(
330
- 'transition-opacity',
331
- highlightKey.current && highlightKey.current !== keyAccessor(d) && 'opacity-50',
332
- props.arc?.class,
333
- s.props?.class
334
- ),
305
+ class: cls(props.arc?.class, s.props?.class),
335
306
  };
336
307
  }
337
308
 
@@ -357,7 +328,7 @@
357
328
  return key;
358
329
  },
359
330
  get visibleSeries() {
360
- return visibleSeries;
331
+ return seriesState.visibleSeries;
361
332
  },
362
333
  });
363
334
  </script>
@@ -369,19 +340,19 @@
369
340
  x={value}
370
341
  {c}
371
342
  cDomain={chartData.map(keyAccessor)}
372
- cRange={seriesColors.length
373
- ? seriesColors
343
+ cRange={seriesState.allSeriesColors.length
344
+ ? seriesState.allSeriesColors
374
345
  : c !== key
375
346
  ? chartData.map((d) => cAccessor(d))
376
347
  : [
377
- 'var(--color-primary)',
378
- 'var(--color-secondary)',
379
- 'var(--color-info)',
380
- 'var(--color-success)',
381
- 'var(--color-warning)',
382
- 'var(--color-danger)',
348
+ 'var(--color-primary, currentColor)',
349
+ 'var(--color-secondary, currentColor)',
350
+ 'var(--color-info, currentColor)',
351
+ 'var(--color-success, currentColor)',
352
+ 'var(--color-warning, currentColor)',
353
+ 'var(--color-danger, currentColor)',
383
354
  ]}
384
- padding={{ bottom: legend === true ? 32 : 0 }}
355
+ padding={{ bottom: legend ? 32 : 0 }}
385
356
  {...restProps}
386
357
  tooltip={tooltip === false
387
358
  ? false
@@ -395,10 +366,10 @@
395
366
  color: cAccessor,
396
367
  context,
397
368
  series,
398
- visibleSeries,
369
+ visibleSeries: seriesState.visibleSeries,
399
370
  visibleData,
400
- highlightKey: highlightKey.current,
401
- setHighlightKey: highlightKey.set,
371
+ highlightKey: seriesState.highlightKey.current,
372
+ setHighlightKey: seriesState.highlightKey.set,
402
373
  getLegendProps,
403
374
  getGroupProps,
404
375
  getArcProps,
@@ -452,8 +423,8 @@
452
423
  value={valueAccessor(data)}
453
424
  color={context.cScale?.(context.c(data))}
454
425
  {format}
455
- onpointerenter={() => (highlightKey.current = keyAccessor(data))}
456
- onpointerleave={() => (highlightKey.current = null)}
426
+ onpointerenter={() => (seriesState.highlightKey.current = keyAccessor(data))}
427
+ onpointerleave={() => (seriesState.highlightKey.current = null)}
457
428
  {...props.tooltip?.item}
458
429
  />
459
430
  </Tooltip.List>
@@ -67,7 +67,6 @@
67
67
 
68
68
  <script lang="ts" generics="TData">
69
69
  import { onMount, type ComponentProps } from 'svelte';
70
- import { scaleLinear, scaleTime } from 'd3-scale';
71
70
  import { stack, stackOffsetDiverging, stackOffsetExpand, stackOffsetNone } from 'd3-shape';
72
71
  import { cls } from '@layerstack/tailwind';
73
72
 
@@ -93,7 +92,8 @@
93
92
  import { asAny } from '../../utils/types.js';
94
93
  import Spline from '../Spline.svelte';
95
94
  import type { SeriesData, SimplifiedChartProps, SimplifiedChartPropsObject } from './types.js';
96
- import { createLegendProps, SeriesState } from './utils.svelte.js';
95
+ import { SeriesState } from '../../states/series.svelte.js';
96
+ import { createLegendProps } from './utils.svelte.js';
97
97
  import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
98
98
  import DefaultTooltip from './DefaultTooltip.svelte';
99
99
  import ChartAnnotations from './ChartAnnotations.svelte';
@@ -139,7 +139,7 @@
139
139
  key: 'default',
140
140
  label: typeof y === 'string' ? y : 'value',
141
141
  value: y,
142
- color: 'var(--color-primary)',
142
+ color: 'var(--color-primary, currentColor)',
143
143
  },
144
144
  ]
145
145
  : seriesProp
@@ -221,13 +221,6 @@
221
221
  ...(typeof s.props?.line === 'object' ? s.props.line : null),
222
222
  };
223
223
 
224
- const highlightClass =
225
- seriesState.visibleSeries.length > 1 &&
226
- seriesState.highlightKey.current &&
227
- seriesState.highlightKey.current !== s.key
228
- ? 'opacity-10'
229
- : '';
230
-
231
224
  return {
232
225
  data: s.data,
233
226
  y0: stackSeries
@@ -242,19 +235,18 @@
242
235
  : (s.value ?? (s.data ? undefined : s.key)),
243
236
  fill: s.color,
244
237
  fillOpacity: 0.3,
238
+ opacity:
239
+ // Checking `visibleSeries.length <= 1` fixes re-animated tweened areas on hover
240
+ seriesState.visibleSeries.length <= 1 || seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
245
241
  ...props.area,
246
242
  ...s.props,
247
- class: cls(
248
- 'transition-opacity',
249
- // Checking `visibleSeries.length > 1` fixes re-animated tweened areas on hover
250
- highlightClass,
251
- props.area?.class,
252
- s.props?.class
253
- ),
243
+ class: cls(props.area?.class, s.props?.class),
254
244
  line: {
255
245
  stroke: s.color,
246
+ opacity:
247
+ // Checking `visibleSeries.length <= 1` fixes re-animated tweened areas on hover
248
+ seriesState.visibleSeries.length <= 1 || seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
256
249
  ...lineProps,
257
- class: cls('transition-opacity', highlightClass, lineProps.class),
258
250
  },
259
251
  };
260
252
  }
@@ -271,16 +263,11 @@
271
263
  ? s.value[1]
272
264
  : (s.value ?? (s.data ? undefined : s.key)),
273
265
  fill: s.color,
266
+ stroke: 'var(--color-surface-100, light-dark(white, black))',
267
+ opacity: seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
274
268
  ...props.points,
275
269
  ...(typeof points === 'object' ? points : null),
276
- class: cls(
277
- 'stroke-surface-200 transition-opacity',
278
- seriesState.highlightKey.current &&
279
- seriesState.highlightKey.current !== s.key &&
280
- 'opacity-10',
281
- props.points?.class,
282
- typeof points === 'object' && points.class
283
- ),
270
+ class: cls(props.points?.class, typeof points === 'object' && points.class),
284
271
  };
285
272
  }
286
273
 
@@ -295,16 +282,11 @@
295
282
  : Array.isArray(s.value)
296
283
  ? s.value[1]
297
284
  : (s.value ?? (s.data ? undefined : s.key)),
285
+ stroke: 'var(--color-surface-100, light-dark(white, black))',
286
+ opacity: seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
298
287
  ...props.labels,
299
288
  ...(typeof labels === 'object' ? labels : null),
300
- class: cls(
301
- 'stroke-surface-200 transition-opacity',
302
- seriesState.highlightKey.current &&
303
- seriesState.highlightKey.current !== s.key &&
304
- 'opacity-10',
305
- props.labels?.class,
306
- typeof labels === 'object' && labels.class
307
- ),
289
+ class: cls(props.labels?.class, typeof labels === 'object' && labels.class),
308
290
  };
309
291
  }
310
292
 
@@ -317,7 +299,7 @@
317
299
  if (!context) return {};
318
300
  const seriesTooltipData =
319
301
  s.data && context.tooltip.data
320
- ? findRelatedData(s.data, context.tooltip.data, context.x)
302
+ ? (findRelatedData(s.data, context.tooltip.data, context.x) ?? {})
321
303
  : null;
322
304
  const highlightPointsProps =
323
305
  typeof props.highlight?.points === 'object' ? props.highlight.points : null;
@@ -332,19 +314,14 @@
332
314
  onPointEnter: () => (seriesState.highlightKey.current = s.key),
333
315
  onPointLeave: () => (seriesState.highlightKey.current = null),
334
316
  ...props.highlight,
317
+ opacity:
318
+ seriesState.highlightKey.current && seriesState.highlightKey.current !== s.key ? 0.1 : 1,
335
319
  points:
336
320
  props.highlight?.points == false
337
321
  ? false
338
322
  : {
339
323
  ...highlightPointsProps,
340
324
  fill: s.color,
341
- class: cls(
342
- 'transition-opacity',
343
- seriesState.highlightKey.current &&
344
- seriesState.highlightKey.current !== s.key &&
345
- 'opacity-10',
346
- highlightPointsProps?.class
347
- ),
348
325
  },
349
326
  };
350
327
  }
@@ -109,7 +109,8 @@
109
109
  import type { Insets } from '../../utils/rect.svelte.js';
110
110
  import type { SeriesData, SimplifiedChartProps, SimplifiedChartPropsObject } from './types.js';
111
111
  import { isScaleTime, type AnyScale } from '../../utils/scales.svelte.js';
112
- import { createLegendProps, SeriesState } from './utils.svelte.js';
112
+ import { SeriesState } from '../../states/series.svelte.js';
113
+ import { createLegendProps } from './utils.svelte.js';
113
114
  import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
114
115
  import DefaultTooltip from './DefaultTooltip.svelte';
115
116
  import ChartAnnotations from './ChartAnnotations.svelte';
@@ -311,17 +312,11 @@
311
312
  strokeWidth: 1,
312
313
  insets: stackInsets,
313
314
  fill: s.color,
315
+ opacity: seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
314
316
  onBarClick: (e, detail) => onBarClick(e, { ...detail, series: s }),
315
317
  ...props.bars,
316
318
  ...s.props,
317
- class: cls(
318
- 'transition-opacity',
319
- seriesState.highlightKey.current &&
320
- seriesState.highlightKey.current !== s.key &&
321
- 'opacity-10',
322
- props.bars?.class,
323
- s.props?.class
324
- ),
319
+ class: cls(props.bars?.class, s.props?.class),
325
320
  };
326
321
  }
327
322
 
@@ -333,16 +328,10 @@
333
328
  // TODO: Improve placement when using `seriesLayout="group"`
334
329
  // data: s.data,
335
330
  // y: s.value ?? (s.data ? undefined : s.key),
331
+ opacity: seriesState.isHighlighted(s.key, true) ? 1 : 0.1,
336
332
  ...props.labels,
337
333
  ...(typeof labels === 'object' ? labels : null),
338
- class: cls(
339
- 'stroke-surface-200 transition-opacity',
340
- seriesState.highlightKey.current &&
341
- seriesState.highlightKey.current !== s.key &&
342
- 'opacity-10',
343
- props.labels?.class,
344
- typeof labels === 'object' && labels.class
345
- ),
334
+ class: cls(props.labels?.class, typeof labels === 'object' && labels.class),
346
335
  };
347
336
  }
348
337
 
@@ -452,7 +441,7 @@
452
441
  {y1Range}
453
442
  {yInterval}
454
443
  c={isVertical ? yProp : xProp}
455
- cRange={['var(--color-primary)']}
444
+ cRange={['var(--color-primary, currentColor)']}
456
445
  {radial}
457
446
  padding={radial ? undefined : defaultChartPadding(axis, legend)}
458
447
  {...restProps}
@@ -4,7 +4,7 @@
4
4
  import { getChartContext } from '../Chart.svelte';
5
5
  import * as Tooltip from '../tooltip/index.js';
6
6
  import type { SimplifiedChartPropsObject } from './types.js';
7
- import type { SeriesState } from './utils.svelte.js';
7
+ import type { SeriesState } from '../../states/series.svelte.js';
8
8
  import { format } from '@layerstack/utils';
9
9
  import { accessor, findRelatedData } from '../../utils/common.js';
10
10
 
@@ -48,7 +48,7 @@
48
48
  value={sum(seriesState.visibleSeries, (s) => {
49
49
  const seriesTooltipData = s.data ? findRelatedData(s.data, data, context.x) : data;
50
50
  const valueAccessor = accessor(s.value ?? (s.data ? context.y : s.key));
51
- return valueAccessor(seriesTooltipData);
51
+ return seriesTooltipData ? valueAccessor(seriesTooltipData) : 0;
52
52
  })}
53
53
  format="integer"
54
54
  valueAlign="right"
@@ -1,5 +1,5 @@
1
1
  import type { SimplifiedChartPropsObject } from './types.js';
2
- import type { SeriesState } from './utils.svelte.js';
2
+ import type { SeriesState } from '../../states/series.svelte.js';
3
3
  type $$ComponentProps = {
4
4
  tooltipProps?: SimplifiedChartPropsObject['tooltip'];
5
5
  seriesState: SeriesState<any, any>;