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
@@ -1,12 +1,14 @@
1
1
  <script lang="ts" module>
2
- import { scaleLinear, scaleOrdinal, scaleSqrt } from 'd3-scale';
2
+ import { scaleOrdinal, scaleSqrt } from 'd3-scale';
3
3
  import { type Accessor, accessor, chartDataArray } from '../utils/common.js';
4
4
  import { printDebug } from '../utils/debug.js';
5
5
  import { filterObject } from '../utils/filterObject.js';
6
6
  import {
7
+ autoScale,
7
8
  createScale,
8
9
  getRange,
9
10
  isScaleBand,
11
+ isScaleTime,
10
12
  makeAccessor,
11
13
  type AnyScale,
12
14
  type DomainType,
@@ -39,7 +41,7 @@
39
41
  import { geoFitObjectTransform } from '../utils/geo.js';
40
42
  import TransformContext, { type TransformContextValue } from './TransformContext.svelte';
41
43
  import BrushContext, { type BrushContextValue } from './BrushContext.svelte';
42
- import { layerClass } from '../utils/attributes.js';
44
+ import type { TimeInterval } from 'd3-time';
43
45
 
44
46
  const defaultPadding = { top: 0, right: 0, bottom: 0, left: 0 };
45
47
 
@@ -149,6 +151,8 @@
149
151
  cGet: (d: T) => any;
150
152
  x1Get: (d: T) => any;
151
153
  y1Get: (d: T) => any;
154
+ xInterval: TimeInterval | null;
155
+ yInterval: TimeInterval | null;
152
156
  radial: boolean;
153
157
  tooltip: TooltipContextValue<T>;
154
158
  geo: GeoContextValue;
@@ -417,21 +421,21 @@
417
421
  /**
418
422
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
419
423
  * you want to override the default or you want to extra options.
420
- * @default scaleLinear
424
+ * @default autoScale
421
425
  */
422
426
  xScale?: XScale;
423
427
 
424
428
  /**
425
429
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
426
430
  * you want to override the default or you want to extra options.
427
- * @default scaleLinear
431
+ * @default autoScale
428
432
  */
429
433
  yScale?: YScale;
430
434
 
431
435
  /**
432
436
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
433
437
  * you want to override the default or you want to extra options.
434
- * @default scaleLinear
438
+ * @default autoScale
435
439
  */
436
440
  zScale?: AnyScale;
437
441
 
@@ -445,14 +449,14 @@
445
449
  /**
446
450
  * The D3 scale that should be used for the x1-dimension. Pass in an instantiated D3 scale if
447
451
  * you want to override the default or you want to extra options.
448
- * @default scaleLinear
452
+ * @default autoScale
449
453
  */
450
454
  x1Scale?: AnyScale;
451
455
 
452
456
  /**
453
457
  * The D3 scale that should be used for the y1-dimension. Pass in an instantiated D3 scale if
454
458
  * you want to override the default or you want to extra options.
455
- * @default scaleLinear
459
+ * @default autoScale
456
460
  */
457
461
  y1Scale?: AnyScale;
458
462
 
@@ -640,6 +644,16 @@
640
644
  */
641
645
  yBaseline?: number | null;
642
646
 
647
+ /**
648
+ * Time interval to use for the x-axis when using a time scale.
649
+ */
650
+ xInterval?: TimeInterval | null;
651
+
652
+ /**
653
+ * Time interval to use for the y-axis when using a time scale.
654
+ */
655
+ yInterval?: TimeInterval | null;
656
+
643
657
  /* Props passed to ChartContext */
644
658
 
645
659
  /**
@@ -703,6 +717,7 @@
703
717
  z: zProp,
704
718
  r: rProp,
705
719
  data = [],
720
+ flatData: flatDataProp,
706
721
  xDomain: xDomainProp,
707
722
  yDomain: yDomainProp,
708
723
  zDomain: zDomainProp,
@@ -716,12 +731,12 @@
716
731
  zPadding,
717
732
  rPadding,
718
733
  // @ts-expect-error shh
719
- xScale: xScaleProp = scaleLinear(),
734
+ xScale: xScaleProp = autoScale(xDomainProp, flatDataProp ?? data, xProp),
720
735
  // @ts-expect-error shh
721
- yScale: yScaleProp = scaleLinear(),
722
- zScale: zScaleProp = scaleLinear(),
736
+ yScale: yScaleProp = autoScale(yDomainProp, flatDataProp ?? data, yProp),
737
+ // @ts-expect-error shh
738
+ zScale: zScaleProp = autoScale(zDomainProp, flatDataProp ?? data, zProp),
723
739
  rScale: rScaleProp = scaleSqrt(),
724
- flatData: flatDataProp,
725
740
  padding: paddingProp = {},
726
741
  verbose = true,
727
742
  debug = false,
@@ -738,6 +753,8 @@
738
753
  rRange: rRangeProp,
739
754
  xBaseline = null,
740
755
  yBaseline = null,
756
+ xInterval = null,
757
+ yInterval = null,
741
758
  meta = {},
742
759
  children: _children,
743
760
  radial = false,
@@ -780,6 +797,12 @@
780
797
 
781
798
  const _xDomain: DomainType | undefined = $derived.by(() => {
782
799
  if (xDomainProp !== undefined) return xDomainProp;
800
+
801
+ if (xInterval != null && Array.isArray(data) && data.length > 0) {
802
+ const lastXValue = accessor(xProp)(data[data.length - 1]);
803
+ return [null, xInterval.offset(lastXValue)];
804
+ }
805
+
783
806
  if (xBaseline != null && Array.isArray(data)) {
784
807
  const xValues = data.flatMap(accessor(xProp));
785
808
  return [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
@@ -788,6 +811,12 @@
788
811
 
789
812
  const _yDomain: DomainType | undefined = $derived.by(() => {
790
813
  if (yDomainProp !== undefined) return yDomainProp;
814
+
815
+ if (yInterval != null && Array.isArray(data) && data.length > 0) {
816
+ const lastYValue = accessor(yProp)(data[data.length - 1]);
817
+ return [null, yInterval.offset(lastYValue)];
818
+ }
819
+
791
820
  if (yBaseline != null && Array.isArray(data)) {
792
821
  const yValues = data.flatMap(accessor(yProp));
793
822
  return [min([yBaseline, ...yValues]), max([yBaseline, ...yValues])];
@@ -798,7 +827,9 @@
798
827
  _yRangeProp ?? (radial ? ({ height }: { height: number }) => [0, height / 2] : undefined)
799
828
  );
800
829
 
801
- const yReverse = $derived(yScaleProp ? !isScaleBand(yScaleProp) : true);
830
+ const yReverse = $derived(
831
+ yScaleProp ? !isScaleBand(yScaleProp) && !isScaleTime(yScaleProp) : true
832
+ );
802
833
 
803
834
  const x = $derived(makeAccessor(xProp));
804
835
  const y = $derived(makeAccessor(yProp));
@@ -844,12 +875,12 @@
844
875
  if (verbose === true) {
845
876
  if (width <= 0 && isMounted === true) {
846
877
  console.warn(
847
- '[LayerChart] Target div has zero or negative width. Did you forget to set an explicit width in CSS on the container?'
878
+ `[LayerChart] Target div has zero or negative width (${width}). Did you forget to set an explicit width in CSS on the container?`
848
879
  );
849
880
  }
850
881
  if (height <= 0 && isMounted === true) {
851
882
  console.warn(
852
- '[LayerChart] Target div has zero or negative height. Did you forget to set an explicit height in CSS on the container?'
883
+ `[LayerChart] Target div has zero or negative height (${height}). Did you forget to set an explicit height in CSS on the container?`
853
884
  );
854
885
  }
855
886
  }
@@ -979,24 +1010,36 @@
979
1010
  const rGet = $derived(createGetter(r, rScale));
980
1011
 
981
1012
  const x1Scale = $derived(
982
- x1ScaleProp && x1RangeProp
983
- ? createScale(x1ScaleProp, x1Domain, x1RangeProp, {
984
- xScale: xScale,
985
- width,
986
- height,
987
- })
1013
+ x1RangeProp
1014
+ ? createScale(
1015
+ // @ts-expect-error shh
1016
+ x1ScaleProp ?? autoScale(x1DomainProp, flatDataProp ?? data, x1Prop),
1017
+ x1Domain,
1018
+ x1RangeProp,
1019
+ {
1020
+ xScale,
1021
+ width,
1022
+ height,
1023
+ }
1024
+ )
988
1025
  : null
989
1026
  );
990
1027
 
991
1028
  const x1Get = $derived(createGetter(x1, x1Scale));
992
1029
 
993
1030
  const y1Scale = $derived(
994
- y1ScaleProp && y1RangeProp
995
- ? createScale(y1ScaleProp, y1Domain, y1RangeProp, {
996
- yScale: yScale,
997
- width,
998
- height,
999
- })
1031
+ y1RangeProp
1032
+ ? createScale(
1033
+ // @ts-expect-error shh
1034
+ y1ScaleProp ?? autoScale(y1DomainProp, flatDataProp ?? data, y1Prop),
1035
+ y1Domain,
1036
+ y1RangeProp,
1037
+ {
1038
+ yScale,
1039
+ width,
1040
+ height,
1041
+ }
1042
+ )
1000
1043
  : null
1001
1044
  );
1002
1045
 
@@ -1247,6 +1290,12 @@
1247
1290
  get y1Scale() {
1248
1291
  return y1Scale;
1249
1292
  },
1293
+ get xInterval() {
1294
+ return xInterval;
1295
+ },
1296
+ get yInterval() {
1297
+ return yInterval;
1298
+ },
1250
1299
  get radial() {
1251
1300
  return radial;
1252
1301
  },
@@ -1344,7 +1393,7 @@
1344
1393
  style:pointer-events={pointerEvents === false ? 'none' : null}
1345
1394
  bind:clientWidth={containerWidth}
1346
1395
  bind:clientHeight={containerHeight}
1347
- class={layerClass('root-container')}
1396
+ class="lc-root-container"
1348
1397
  >
1349
1398
  {#key isMounted}
1350
1399
  <!-- svelte-ignore ownership_invalid_binding -->
@@ -8,6 +8,7 @@ import type { HierarchyNode } from 'd3-hierarchy';
8
8
  import type { SankeyGraph } from 'd3-sankey';
9
9
  import TransformContext, { type TransformContextValue } from './TransformContext.svelte';
10
10
  import BrushContext, { type BrushContextValue } from './BrushContext.svelte';
11
+ import type { TimeInterval } from 'd3-time';
11
12
  export type ChartResizeDetail = {
12
13
  width: number;
13
14
  height: number;
@@ -81,6 +82,8 @@ export type ChartContextValue<T = any, XScale extends AnyScale = AnyScale, YScal
81
82
  cGet: (d: T) => any;
82
83
  x1Get: (d: T) => any;
83
84
  y1Get: (d: T) => any;
85
+ xInterval: TimeInterval | null;
86
+ yInterval: TimeInterval | null;
84
87
  radial: boolean;
85
88
  tooltip: TooltipContextValue<T>;
86
89
  geo: GeoContextValue;
@@ -285,19 +288,19 @@ export type ChartPropsWithoutHTML<T, XScale extends AnyScale = AnyScale, YScale
285
288
  /**
286
289
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
287
290
  * you want to override the default or you want to extra options.
288
- * @default scaleLinear
291
+ * @default autoScale
289
292
  */
290
293
  xScale?: XScale;
291
294
  /**
292
295
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
293
296
  * you want to override the default or you want to extra options.
294
- * @default scaleLinear
297
+ * @default autoScale
295
298
  */
296
299
  yScale?: YScale;
297
300
  /**
298
301
  * The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
299
302
  * you want to override the default or you want to extra options.
300
- * @default scaleLinear
303
+ * @default autoScale
301
304
  */
302
305
  zScale?: AnyScale;
303
306
  /**
@@ -309,13 +312,13 @@ export type ChartPropsWithoutHTML<T, XScale extends AnyScale = AnyScale, YScale
309
312
  /**
310
313
  * The D3 scale that should be used for the x1-dimension. Pass in an instantiated D3 scale if
311
314
  * you want to override the default or you want to extra options.
312
- * @default scaleLinear
315
+ * @default autoScale
313
316
  */
314
317
  x1Scale?: AnyScale;
315
318
  /**
316
319
  * The D3 scale that should be used for the y1-dimension. Pass in an instantiated D3 scale if
317
320
  * you want to override the default or you want to extra options.
318
- * @default scaleLinear
321
+ * @default autoScale
319
322
  */
320
323
  y1Scale?: AnyScale;
321
324
  /**
@@ -484,6 +487,14 @@ export type ChartPropsWithoutHTML<T, XScale extends AnyScale = AnyScale, YScale
484
487
  * @default null
485
488
  */
486
489
  yBaseline?: number | null;
490
+ /**
491
+ * Time interval to use for the x-axis when using a time scale.
492
+ */
493
+ xInterval?: TimeInterval | null;
494
+ /**
495
+ * Time interval to use for the y-axis when using a time scale.
496
+ */
497
+ yInterval?: TimeInterval | null;
487
498
  /**
488
499
  * Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial.
489
500
  * Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`)
@@ -521,10 +532,17 @@ export type ChartPropsWithoutHTML<T, XScale extends AnyScale = AnyScale, YScale
521
532
  ondragend?: ComponentProps<typeof TransformContext>['ondragend'];
522
533
  onTransform?: ComponentProps<typeof TransformContext>['onTransform'];
523
534
  };
535
+ declare function $$render<TData = any, XScale extends AnyScale = AnyScale, YScale extends AnyScale = AnyScale>(): {
536
+ props: ChartPropsWithoutHTML<TData, XScale, YScale>;
537
+ exports: {};
538
+ bindings: "ref" | "context";
539
+ slots: {};
540
+ events: {};
541
+ };
524
542
  declare class __sveltets_Render<TData = any, XScale extends AnyScale = AnyScale, YScale extends AnyScale = AnyScale> {
525
- props(): ChartPropsWithoutHTML<TData, XScale, YScale>;
526
- events(): {};
527
- slots(): {};
543
+ props(): ReturnType<typeof $$render<TData, XScale, YScale>>['props'];
544
+ events(): ReturnType<typeof $$render<TData, XScale, YScale>>['events'];
545
+ slots(): ReturnType<typeof $$render<TData, XScale, YScale>>['slots'];
528
546
  bindings(): "ref" | "context";
529
547
  exports(): {};
530
548
  }
@@ -41,5 +41,5 @@
41
41
  {disabled}
42
42
  height={ctx.height + (full ? (ctx.padding?.top ?? 0) + (ctx.padding?.bottom ?? 0) : 0)}
43
43
  width={ctx.width + (full ? (ctx.padding?.left ?? 0) + (ctx.padding?.right ?? 0) : 0)}
44
- {...extractLayerProps(restProps, 'chart-clip-path')}
44
+ {...extractLayerProps(restProps, 'lc-chart-clip-path')}
45
45
  />
@@ -68,7 +68,6 @@
68
68
  import { renderCircle, type ComputedStylesOptions } from '../utils/canvas.js';
69
69
  import type { SVGAttributes } from 'svelte/elements';
70
70
  import { createKey } from '../utils/key.svelte.js';
71
- import { layerClass } from '../utils/attributes.js';
72
71
 
73
72
  let {
74
73
  cx = 0,
@@ -115,7 +114,7 @@
115
114
  ? merge({ styles: { strokeWidth } }, styleOverrides)
116
115
  : {
117
116
  styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
118
- classes: className,
117
+ classes: cls('lc-circle', className),
119
118
  }
120
119
  );
121
120
  }
@@ -161,7 +160,49 @@
161
160
  {stroke}
162
161
  stroke-width={strokeWidth}
163
162
  {opacity}
164
- class={cls(layerClass('circle'), fill == null && 'fill-surface-content', className)}
163
+ class={cls('lc-circle', className)}
165
164
  {...restProps}
166
165
  />
166
+ {:else if renderCtx === 'html'}
167
+ <div
168
+ style:position="absolute"
169
+ style:left="{motionCx.current}px"
170
+ style:top="{motionCy.current}px"
171
+ style:width="{motionR.current * 2}px"
172
+ style:height="{motionR.current * 2}px"
173
+ style:border-radius="50%"
174
+ style:background-color={fill}
175
+ style:opacity
176
+ style:border-width={strokeWidth}
177
+ style:border-color={stroke}
178
+ style:border-style="solid"
179
+ style:transform="translate(-50%, -50%)"
180
+ class={cls('lc-circle', className)}
181
+ {...restProps}
182
+ ></div>
167
183
  {/if}
184
+
185
+ <style>
186
+ @layer base {
187
+ :global(:where(.lc-circle)) {
188
+ --fill-color: var(--color-surface-content, currentColor);
189
+ --stroke-color: initial;
190
+ }
191
+
192
+ /* Svg | Canvas layers */
193
+ :global(:where(.lc-layout-svg .lc-circle, svg.lc-circle):not([fill])) {
194
+ fill: var(--fill-color);
195
+ }
196
+ :global(:where(.lc-layout-svg .lc-circle, svg.lc-circle):not([stroke])) {
197
+ stroke: var(--stroke-color);
198
+ }
199
+
200
+ /* Html layers */
201
+ :global(:where(.lc-layout-html .lc-circle):not([background-color])) {
202
+ background-color: var(--fill-color);
203
+ }
204
+ :global(:where(.lc-layout-html .lc-circle):not([border-color])) {
205
+ border-color: var(--stroke-color);
206
+ }
207
+ }
208
+ </style>
@@ -80,6 +80,13 @@
80
80
 
81
81
  <ClipPath {id} {disabled} {children}>
82
82
  {#snippet clip()}
83
- <Circle {cx} {cy} {r} {motion} {...extractLayerProps(restProps, 'clip-path-circle')} bind:ref />
83
+ <Circle
84
+ {cx}
85
+ {cy}
86
+ {r}
87
+ {motion}
88
+ {...extractLayerProps(restProps, 'lc-clip-path-circle')}
89
+ bind:ref
90
+ />
84
91
  {/snippet}
85
92
  </ClipPath>
@@ -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>
@@ -82,7 +82,7 @@
82
82
  type = 'rounded',
83
83
  radius = 20,
84
84
  curve = curveLinear,
85
- splineRef = $bindable(),
85
+ pathRef = $bindable(),
86
86
  pathData: pathDataProp,
87
87
  marker,
88
88
  markerStart,
@@ -137,11 +137,11 @@
137
137
 
138
138
  <Spline
139
139
  pathData={motionPath.current}
140
- bind:splineRef
140
+ bind:pathRef
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} />
@@ -46,6 +46,6 @@ import { type CurveFactory } from 'd3-shape';
46
46
  import { type ConnectorCoords, type ConnectorSweep, type ConnectorType } from '../utils/connectorUtils.js';
47
47
  import { type SplineProps, type SplinePropsWithoutHTML } from './Spline.svelte';
48
48
  import type { Without } from '../utils/types.js';
49
- declare const Connector: import("svelte").Component<ConnectorProps, {}, "splineRef">;
49
+ declare const Connector: import("svelte").Component<ConnectorProps, {}, "pathRef">;
50
50
  type Connector = ReturnType<typeof Connector>;
51
51
  export default Connector;