layerchart 0.53.0 → 0.54.1

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 (107) hide show
  1. package/dist/components/Arc.svelte +170 -144
  2. package/dist/components/Area.svelte +96 -67
  3. package/dist/components/Area.svelte.d.ts +1 -0
  4. package/dist/components/Axis.svelte +241 -234
  5. package/dist/components/Axis.svelte.d.ts +2 -1
  6. package/dist/components/Bar.svelte +72 -45
  7. package/dist/components/Bars.svelte +46 -34
  8. package/dist/components/Bars.svelte.d.ts +1 -0
  9. package/dist/components/Blur.svelte +5 -3
  10. package/dist/components/Bounds.svelte +37 -21
  11. package/dist/components/Brush.svelte +181 -110
  12. package/dist/components/Calendar.svelte +51 -38
  13. package/dist/components/Chart.svelte +296 -73
  14. package/dist/components/Chart.svelte.d.ts +42 -25
  15. package/dist/components/ChartClipPath.svelte +8 -5
  16. package/dist/components/ChartContext.svelte +243 -93
  17. package/dist/components/ChartContext.svelte.d.ts +15 -23
  18. package/dist/components/Circle.svelte +25 -16
  19. package/dist/components/CircleClipPath.svelte +16 -10
  20. package/dist/components/ClipPath.svelte +11 -7
  21. package/dist/components/ColorRamp.svelte +12 -10
  22. package/dist/components/ForceSimulation.svelte +185 -116
  23. package/dist/components/Frame.svelte +10 -6
  24. package/dist/components/GeoCircle.svelte +15 -9
  25. package/dist/components/GeoContext.svelte +109 -62
  26. package/dist/components/GeoEdgeFade.svelte +20 -14
  27. package/dist/components/GeoPath.svelte +107 -69
  28. package/dist/components/GeoPoint.svelte +32 -18
  29. package/dist/components/GeoSpline.svelte +30 -22
  30. package/dist/components/GeoTile.svelte +40 -30
  31. package/dist/components/GeoVisible.svelte +10 -7
  32. package/dist/components/Graticule.svelte +14 -8
  33. package/dist/components/Grid.svelte +178 -0
  34. package/dist/components/Grid.svelte.d.ts +35 -0
  35. package/dist/components/Group.svelte +43 -31
  36. package/dist/components/Highlight.svelte +284 -243
  37. package/dist/components/HitCanvas.svelte +75 -42
  38. package/dist/components/Hull.svelte +40 -20
  39. package/dist/components/Labels.svelte +84 -63
  40. package/dist/components/Labels.svelte.d.ts +2 -0
  41. package/dist/components/Legend.svelte +106 -75
  42. package/dist/components/Legend.svelte.d.ts +1 -1
  43. package/dist/components/Line.svelte +29 -19
  44. package/dist/components/LinearGradient.svelte +21 -15
  45. package/dist/components/Link.svelte +44 -22
  46. package/dist/components/MonthPath.svelte +23 -16
  47. package/dist/components/MotionPath.svelte +34 -25
  48. package/dist/components/Pack.svelte +21 -14
  49. package/dist/components/Partition.svelte +35 -20
  50. package/dist/components/Pattern.svelte +8 -6
  51. package/dist/components/Pie.svelte +76 -57
  52. package/dist/components/Point.svelte +11 -7
  53. package/dist/components/Points.svelte +178 -143
  54. package/dist/components/RadialGradient.svelte +25 -18
  55. package/dist/components/Rect.svelte +33 -19
  56. package/dist/components/RectClipPath.svelte +16 -11
  57. package/dist/components/Rule.svelte +66 -42
  58. package/dist/components/Rule.svelte.d.ts +2 -0
  59. package/dist/components/Sankey.svelte +55 -30
  60. package/dist/components/Spline.svelte +118 -96
  61. package/dist/components/Text.svelte +137 -104
  62. package/dist/components/Threshold.svelte +18 -7
  63. package/dist/components/TileImage.svelte +56 -50
  64. package/dist/components/TransformContext.svelte +238 -136
  65. package/dist/components/TransformControls.svelte +57 -29
  66. package/dist/components/TransformControls.svelte.d.ts +1 -1
  67. package/dist/components/Tree.svelte +33 -23
  68. package/dist/components/Treemap.svelte +69 -41
  69. package/dist/components/Voronoi.svelte +55 -28
  70. package/dist/components/charts/AreaChart.svelte +162 -87
  71. package/dist/components/charts/AreaChart.svelte.d.ts +41 -3
  72. package/dist/components/charts/BarChart.svelte +207 -108
  73. package/dist/components/charts/BarChart.svelte.d.ts +41 -3
  74. package/dist/components/charts/LineChart.svelte +119 -47
  75. package/dist/components/charts/LineChart.svelte.d.ts +41 -3
  76. package/dist/components/charts/PieChart.svelte +117 -53
  77. package/dist/components/charts/PieChart.svelte.d.ts +17 -2
  78. package/dist/components/charts/ScatterChart.svelte +92 -42
  79. package/dist/components/charts/ScatterChart.svelte.d.ts +39 -3
  80. package/dist/components/index.d.ts +1 -0
  81. package/dist/components/index.js +1 -0
  82. package/dist/components/layout/Canvas.svelte +63 -43
  83. package/dist/components/layout/Html.svelte +28 -18
  84. package/dist/components/layout/Svg.svelte +47 -32
  85. package/dist/components/tooltip/Tooltip.svelte +143 -82
  86. package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
  87. package/dist/components/tooltip/TooltipContext.svelte +315 -248
  88. package/dist/components/tooltip/TooltipContext.svelte.d.ts +7 -0
  89. package/dist/components/tooltip/TooltipHeader.svelte +9 -3
  90. package/dist/components/tooltip/TooltipItem.svelte +17 -9
  91. package/dist/components/tooltip/TooltipList.svelte +2 -1
  92. package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
  93. package/dist/docs/Blockquote.svelte +4 -3
  94. package/dist/docs/Code.svelte +15 -8
  95. package/dist/docs/CurveMenuField.svelte +17 -12
  96. package/dist/docs/GeoDebug.svelte +13 -9
  97. package/dist/docs/Header1.svelte +2 -1
  98. package/dist/docs/Json.svelte +6 -4
  99. package/dist/docs/Layout.svelte +6 -6
  100. package/dist/docs/PathDataMenuField.svelte +52 -44
  101. package/dist/docs/Preview.svelte +48 -29
  102. package/dist/docs/TilesetField.svelte +80 -62
  103. package/dist/docs/TransformDebug.svelte +8 -5
  104. package/dist/docs/ViewSourceButton.svelte +13 -9
  105. package/dist/stores/motionStore.d.ts +1 -1
  106. package/dist/utils/scales.d.ts +4 -4
  107. package/package.json +29 -30
@@ -1,46 +1,59 @@
1
- <script>import {} from 'svelte';
2
- import { timeDays, timeMonths, timeWeek, timeYear } from 'd3-time';
3
- import { index } from 'd3-array';
4
- import { format } from 'date-fns';
5
- import { chartContext } from './ChartContext.svelte';
6
- import Rect from './Rect.svelte';
7
- import MonthPath from './MonthPath.svelte';
8
- import Text from './Text.svelte';
9
- import { chartDataArray } from '../utils/common.js';
10
- export let start;
11
- export let end;
12
- /**
13
- * Size of cell. If `number`, sets width/height as same value (square). If array, sets as [width,height]. If undefined, is derived from Chart width/height
14
- */
15
- export let cellSize = undefined;
16
- /** Enable drawing path around each month. If object, pass as props to underlying <path> */
17
- export let monthPath = false;
18
- /**
19
- * Tooltip context to setup mouse events to show tooltip for related data
20
- */
21
- export let tooltip = undefined;
22
- const { width, height, x, cGet, data, config } = chartContext();
23
- $: yearDays = timeDays(start, end);
24
- $: yearMonths = timeMonths(start, end);
25
- $: yearWeeks = timeWeek.count(start, end);
26
- $: chartCellWidth = $width / (yearWeeks + 1);
27
- $: chartCellHeight = $height / 7;
28
- $: chartCellSize = Math.min(chartCellWidth, chartCellHeight); // Use smallest to fit, and keep square aspect
29
- $: [cellWidth, cellHeight] = Array.isArray(cellSize)
1
+ <script lang="ts">
2
+ import { type ComponentProps } from 'svelte';
3
+ import { timeDays, timeMonths, timeWeek, timeYear } from 'd3-time';
4
+ import { index } from 'd3-array';
5
+ import { format } from 'date-fns';
6
+
7
+ import { chartContext } from './ChartContext.svelte';
8
+ import Rect from './Rect.svelte';
9
+ import type { TooltipContextValue } from './tooltip/TooltipContext.svelte';
10
+ import MonthPath from './MonthPath.svelte';
11
+ import Text from './Text.svelte';
12
+ import { chartDataArray } from '../utils/common.js';
13
+
14
+ export let start: Date;
15
+ export let end: Date;
16
+
17
+ /**
18
+ * Size of cell. If `number`, sets width/height as same value (square). If array, sets as [width,height]. If undefined, is derived from Chart width/height
19
+ */
20
+ export let cellSize: number | [number, number] | undefined = undefined;
21
+
22
+ /** Enable drawing path around each month. If object, pass as props to underlying <path> */
23
+ export let monthPath: boolean | Partial<ComponentProps<MonthPath>> = false;
24
+
25
+ /**
26
+ * Tooltip context to setup mouse events to show tooltip for related data
27
+ */
28
+ export let tooltip: TooltipContextValue | undefined = undefined;
29
+
30
+ const { width, height, x, cGet, data, config } = chartContext();
31
+
32
+ $: yearDays = timeDays(start, end);
33
+ $: yearMonths = timeMonths(start, end);
34
+ $: yearWeeks = timeWeek.count(start, end);
35
+
36
+ $: chartCellWidth = $width / (yearWeeks + 1);
37
+ $: chartCellHeight = $height / 7;
38
+ $: chartCellSize = Math.min(chartCellWidth, chartCellHeight); // Use smallest to fit, and keep square aspect
39
+
40
+ $: [cellWidth, cellHeight] = Array.isArray(cellSize)
30
41
  ? cellSize
31
42
  : typeof cellSize === 'number'
32
- ? [cellSize, cellSize]
33
- : [chartCellSize, chartCellSize];
34
- $: dataByDate = data && $config.x ? index(chartDataArray($data), (d) => $x(d)) : new Map();
35
- $: cells = yearDays.map((date) => {
43
+ ? [cellSize, cellSize]
44
+ : [chartCellSize, chartCellSize];
45
+
46
+ $: dataByDate = data && $config.x ? index(chartDataArray($data), (d) => $x(d)) : new Map();
47
+
48
+ $: cells = yearDays.map((date) => {
36
49
  const cellData = dataByDate.get(date) ?? { date };
37
50
  return {
38
- x: timeWeek.count(timeYear(date), date) * cellWidth,
39
- y: date.getDay() * cellHeight,
40
- color: $config.c ? $cGet(cellData) : 'transparent',
41
- data: cellData,
51
+ x: timeWeek.count(timeYear(date), date) * cellWidth,
52
+ y: date.getDay() * cellHeight,
53
+ color: $config.c ? $cGet(cellData) : 'transparent',
54
+ data: cellData,
42
55
  };
43
- });
56
+ });
44
57
  </script>
45
58
 
46
59
  <slot {cells}>
@@ -1,81 +1,304 @@
1
- <script generics="TData">import { onMount } from 'svelte';
2
- import { LayerCake } from 'layercake';
3
- import { max, min } from 'd3-array';
4
- import ChartContext from './ChartContext.svelte';
5
- import GeoContext from './GeoContext.svelte';
6
- import TooltipContext from './tooltip/TooltipContext.svelte';
7
- import TransformContext from './TransformContext.svelte';
8
- import { accessor } from '../utils/common.js';
9
- import { isScaleBand } from '../utils/scales.js';
10
- import { geoFitObjectTransform } from '../utils/geo.js';
11
- export let data = [];
12
- export let x = undefined;
13
- export let xRange = undefined;
14
- export let y = undefined;
15
- export let yScale = undefined;
16
- export let yRange = undefined;
17
- export let x1 = undefined;
18
- export let x1Scale = undefined;
19
- export let x1Domain = undefined;
20
- export let x1Range = undefined;
21
- export let y1 = undefined;
22
- export let y1Scale = undefined;
23
- export let y1Domain = undefined;
24
- export let y1Range = undefined;
25
- export let c = undefined;
26
- export let cScale = undefined;
27
- export let cDomain = undefined;
28
- export let cRange = undefined;
29
- /**
30
- * x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values
31
- */
32
- export let xBaseline = null;
33
- let xDomain = undefined;
34
- $: if (xBaseline != null && Array.isArray(data)) {
1
+ <script lang="ts" generics="TData">
2
+ import { onMount, type ComponentProps } from 'svelte';
3
+ import { LayerCake } from 'layercake';
4
+ import type { HierarchyNode } from 'd3-hierarchy';
5
+ import type { SankeyGraph } from 'd3-sankey';
6
+ import { max, min } from 'd3-array';
7
+
8
+ import ChartContext from './ChartContext.svelte';
9
+ import GeoContext from './GeoContext.svelte';
10
+ import TooltipContext from './tooltip/TooltipContext.svelte';
11
+ import TransformContext from './TransformContext.svelte';
12
+
13
+ import { accessor, type Accessor } from '../utils/common.js';
14
+ import { isScaleBand, type AnyScale, type DomainType } from '../utils/scales.js';
15
+ import { geoFitObjectTransform } from '../utils/geo.js';
16
+
17
+ type LayerCakeProps = ComponentProps<LayerCake>;
18
+
19
+ interface $$Props {
20
+ /** Whether this chart should be rendered server side. @default false */
21
+ ssr?: boolean;
22
+
23
+ /** Whether to allow pointer events via CSS. Set this to `false` to set `pointer-events: none;` on all components, disabling all mouse interaction. @default true */
24
+ pointerEvents?: boolean;
25
+
26
+ /** Determine the positioning of the wrapper div. Set this to `'absolute'` when you want to stack cakes. @default 'relative' */
27
+ position?: string;
28
+
29
+ /** If `true`, set all scale ranges to `[0, 100]`. Ranges reversed via `xReverse`, `yReverse`, `zReverse` or `rReverse` props will continue to be reversed as usual. @default false */
30
+ percentRange?: boolean;
31
+
32
+ /** Override the automated width. */
33
+ width?: number;
34
+ /** Override the automated height. */
35
+ height?: number;
36
+
37
+ /** The bound container width. */
38
+ containerWidth?: number;
39
+ /**The bound container height. */
40
+ containerHeight?: number;
41
+
42
+ /** The .layercake-container `<div>` tag. Useful for bindings. */
43
+ element?: HTMLDivElement;
44
+
45
+ /** If `data` is not a flat array of objects and you want to use any of the scales, set a flat version of the data via the `flatData` prop. */
46
+ data?: typeof data;
47
+
48
+ /** A flat version of data. */
49
+ flatData?: any[];
50
+
51
+ /** The x accessor. The key in each row of data that corresponds to the x-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
52
+ x?: Accessor<TData>;
53
+ /** The y accessor. The key in each row of data that corresponds to the y-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
54
+ y?: Accessor<TData>;
55
+ /** The z accessor. The key in each row of data that corresponds to the z-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
56
+ z?: Accessor<TData>;
57
+ /** The r accessor. The key in each row of data that corresponds to the r-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
58
+ r?: Accessor<TData>;
59
+ /** The x1 accessor. The key in each row of data that corresponds to the x1-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
60
+ x1?: Accessor<TData>;
61
+ /** The y1 accessor. The key in each row of data that corresponds to the y1-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
62
+ y1?: Accessor<TData>;
63
+ /** The c (color) accessor. The key in each row of data that corresponds to the color. This can be a string or an accessor function. This property gets converted to a function when you access it through the context. */
64
+ c?: Accessor<TData>;
65
+
66
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
67
+ xDomain?: DomainType;
68
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
69
+ yDomain?: DomainType;
70
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
71
+ zDomain?: DomainType;
72
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
73
+ rDomain?: DomainType;
74
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
75
+ x1Domain?: DomainType;
76
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
77
+ y1Domain?: DomainType;
78
+ /** Set the list of color values. */
79
+ cDomain?: DomainType;
80
+
81
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the x domain. @default false */
82
+ xNice?: boolean | number;
83
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the y domain. @default false */
84
+ yNice?: boolean | number;
85
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the z domain. @default false */
86
+ zNice?: boolean | number;
87
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the r domain. @default false */
88
+ rNice?: boolean | number;
89
+
90
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
91
+ xPadding?: [number, number];
92
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
93
+ yPadding?: [number, number];
94
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
95
+ zPadding?: [number, number];
96
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
97
+ rPadding?: [number, number];
98
+
99
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
100
+ xScale?: AnyScale;
101
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
102
+ yScale?: AnyScale;
103
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
104
+ zScale?: AnyScale;
105
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleSqrt */
106
+ rScale?: AnyScale;
107
+ /** The D3 scale that should be used for the x1-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
108
+ x1Scale?: AnyScale;
109
+ /** The D3 scale that should be used for the y1-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
110
+ y1Scale?: AnyScale;
111
+ /** The D3 scale that should be used for the color dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleOrdinal */
112
+ cScale?: AnyScale;
113
+
114
+ /** Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
115
+ xRange?:
116
+ | number[]
117
+ | string[]
118
+ | ((args: { width: number; height: number }) => number[] | string[]);
119
+ /** Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
120
+ yRange?:
121
+ | number[]
122
+ | string[]
123
+ | ((args: { width: number; height: number }) => number[] | string[]);
124
+ /** Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
125
+ zRange?:
126
+ | number[]
127
+ | string[]
128
+ | ((args: { width: number; height: number }) => number[] | string[]);
129
+ /** Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
130
+ rRange?:
131
+ | number[]
132
+ | string[]
133
+ | ((args: { width: number; height: number }) => number[] | string[]);
134
+ /** Set the x1 range by setting an array or function with argument `({ xScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
135
+ x1Range?:
136
+ | number[]
137
+ | string[]
138
+ | ((args: { xScale: AnyScale; width: number; height: number }) => number[] | string[]);
139
+ /** Set the y1 range by setting an array or function with argument `({ yScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
140
+ y1Range?:
141
+ | number[]
142
+ | string[]
143
+ | ((args: { yScale: AnyScale; width: number; height: number }) => number[] | string[]);
144
+ /** Override the default y1 range of `[0, width]` by setting an array or function with argument `({ yScale, width, height})` that returns an array. Setting this prop overrides `x1Reverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
145
+ cRange?: string[] | readonly string[];
146
+
147
+ /** Reverse the default x range. By default this is `false` and the range is `[0, width]`. Ignored if you set the xRange prop. @default false */
148
+ xReverse?: boolean;
149
+ /** Reverse the default y range. By default this is `true` and the range is `[height, 0]` unless using an ordinal scale with a `.bandwidth` method for `yScale`. Ignored if you set the `yRange` prop. @default true */
150
+ yReverse?: boolean;
151
+ /** Reverse the default z range. By default this is `false` and the range is `[0, width]`. Ignored if you set the zRange prop. @default false */
152
+ zReverse?: boolean;
153
+ /** Reverse the default r range. By default this is `false` and the range is `[1, 25]`. Ignored if you set the rRange prop. @default false */
154
+ rReverse?: boolean;
155
+
156
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
157
+ xDomainSort?: boolean;
158
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
159
+ yDomainSort?: boolean;
160
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
161
+ zDomainSort?: boolean;
162
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
163
+ rDomainSort?: boolean;
164
+
165
+ /** The amount of padding to put around your chart. It operates like CSS box-sizing: border-box; where values are subtracted from the parent container's width and height, the same as a [D3 margin convention](https://bl.ocks.org/mbostock/3019563). */
166
+ padding?: { top?: Number; right?: Number; bottom?: Number; left?: Number };
167
+
168
+ /** Manually set the extents of the x, y or r scale as a two-dimensional array of the min and max you want. Setting values here will skip any dynamic extent calculation of the data for that dimension. */
169
+ extents?: {
170
+ x?: [min: Number, max: Number];
171
+ y?: [min: Number, max: Number];
172
+ r?: [min: Number, max: Number];
173
+ z?: [min: Number, max: Number];
174
+ };
175
+
176
+ /** Any extra configuration values you want available on the LayerCake context. This could be useful for color lookups or additional constants. */
177
+ custom?: Record<string, any>;
178
+
179
+ /** Enable debug printing to the console. Useful to inspect your scales and dimensions. */
180
+ debug?: boolean;
181
+
182
+ /** Show warnings in the console. */
183
+ verbose?: boolean;
184
+
185
+ /** x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values */
186
+ xBaseline?: typeof xBaseline;
187
+
188
+ /** y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values */
189
+ yBaseline?: typeof xBaseline;
190
+
191
+ /* Props passed to ChartContext */
192
+ /** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
193
+ radial?: typeof radial;
194
+
195
+ /** Props passed to GeoContext */
196
+ geo?: typeof geo;
197
+
198
+ /** Props passed to TooltipContext */
199
+ tooltip?: typeof tooltip;
200
+
201
+ /** Props passed to TransformContext */
202
+ transform?: typeof transform;
203
+
204
+ /** Expose to support `bind:transformContext` for imperative control (`transformContext.translate(...)`) */
205
+ transformContext?: typeof transformContext;
206
+
207
+ /** Exposed via bind: to support `bind:geoProjection` for external access */
208
+ geoProjection?: typeof geoProjection;
209
+
210
+ /** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
211
+ tooltipContext?: typeof tooltipContext;
212
+ }
213
+
214
+ export let data: TData[] | HierarchyNode<TData> | SankeyGraph<any, any> = [];
215
+
216
+ export let x: Accessor<TData> = undefined;
217
+ export let xRange: $$Props['xRange'] = undefined;
218
+
219
+ export let y: Accessor<TData> = undefined;
220
+ export let yScale: AnyScale | undefined = undefined;
221
+ export let yRange: $$Props['yRange'] = undefined;
222
+
223
+ export let x1: $$Props['x1'] = undefined;
224
+ export let x1Scale: $$Props['x1Scale'] = undefined;
225
+ export let x1Domain: $$Props['x1Domain'] = undefined;
226
+ export let x1Range: $$Props['x1Range'] = undefined;
227
+
228
+ export let y1: $$Props['y1'] = undefined;
229
+ export let y1Scale: $$Props['y1Scale'] = undefined;
230
+ export let y1Domain: $$Props['y1Domain'] = undefined;
231
+ export let y1Range: $$Props['y1Range'] = undefined;
232
+
233
+ export let c: $$Props['c'] = undefined;
234
+ export let cScale: $$Props['cScale'] = undefined;
235
+ export let cDomain: $$Props['cDomain'] = undefined;
236
+ export let cRange: $$Props['cRange'] = undefined;
237
+
238
+ /**
239
+ * x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values
240
+ */
241
+ export let xBaseline: number | null = null;
242
+
243
+ let xDomain: [number, number] | undefined = undefined;
244
+ $: if (xBaseline != null && Array.isArray(data)) {
35
245
  const xValues = data.flatMap(accessor(x));
36
246
  xDomain = [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
37
- }
38
- /**
39
- * y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values
40
- */
41
- export let yBaseline = null;
42
- let yDomain = undefined;
43
- $: if (yBaseline != null && Array.isArray(data)) {
247
+ }
248
+
249
+ /**
250
+ * y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values
251
+ */
252
+ export let yBaseline: number | null = null;
253
+
254
+ let yDomain: [number, number] | undefined = undefined;
255
+ $: if (yBaseline != null && Array.isArray(data)) {
44
256
  const yValues = data.flatMap(accessor(y));
45
257
  yDomain = [min([yBaseline, ...yValues]), max([yBaseline, ...yValues])];
46
- }
47
- /**
48
- * Reverse the default y range ([0, height] becomes [height, 0]). By default this is `true` unless using scaleBand y scale.
49
- * see: https://layercake.graphics/guide#yreverse
50
- * see: https://github.com/mhkeller/layercake/issues/83
51
- */
52
- $: yReverse = yScale ? !isScaleBand(yScale) : true;
53
- /** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
54
- export let radial = false;
55
- /** Props passed to GeoContext */
56
- export let geo = undefined;
57
- /** Props passed to TooltipContext */
58
- export let tooltip = undefined;
59
- /** Props passed to TransformContext */
60
- export let transform = undefined;
61
- // @ts-expect-error will only be undefined until bind:transformContext runs
62
- export let transformContext = undefined;
63
- // Binded for access within TransformContext
64
- let geoProjection = undefined;
65
- // Track when mounted since LayerCake initializes width/height with `100` until binded `clientWidth`/`clientWidth` can run
66
- // Useful to key/remount TransformContext with correct `initialTranslate` / `initialScale` values
67
- let isMounted = false;
68
- onMount(() => {
258
+ }
259
+
260
+ /**
261
+ * Reverse the default y range ([0, height] becomes [height, 0]). By default this is `true` unless using scaleBand y scale.
262
+ * see: https://layercake.graphics/guide#yreverse
263
+ * see: https://github.com/mhkeller/layercake/issues/83
264
+ */
265
+ $: yReverse = yScale ? !isScaleBand(yScale) : true;
266
+
267
+ /** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
268
+ export let radial = false;
269
+
270
+ /** Props passed to GeoContext */
271
+ export let geo: Partial<ComponentProps<GeoContext>> | undefined = undefined;
272
+
273
+ /** Props passed to TooltipContext */
274
+ export let tooltip: Partial<ComponentProps<TooltipContext>> | boolean | undefined = undefined;
275
+
276
+ /** Props passed to TransformContext */
277
+ export let transform: Partial<ComponentProps<TransformContext>> | undefined = undefined;
278
+ // @ts-expect-error will only be undefined until bind:transformContext runs
279
+ export let transformContext: TransformContext = undefined;
280
+
281
+ /** Expose bound geo projection context */
282
+ export let geoProjection: ComponentProps<GeoContext>['geo'] = undefined;
283
+
284
+ /** Expose bound tooltip context */
285
+ export let tooltipContext: ComponentProps<TooltipContext>['tooltip'] = undefined;
286
+
287
+ // Track when mounted since LayerCake initializes width/height with `100` until bound `clientWidth`/`clientWidth` can run
288
+ // Useful to key/remount TransformContext with correct `initialTranslate` / `initialScale` values
289
+ let isMounted = false;
290
+ onMount(() => {
69
291
  isMounted = true;
70
- });
71
- // TODO: Hacks until LayerCake has better typings (`Accessor<TData>`)
72
- $: _x = x;
73
- $: _y = y;
74
- $: _yRange =
292
+ });
293
+
294
+ // TODO: Hacks until LayerCake has better typings (`Accessor<TData>`)
295
+ $: _x = x as LayerCakeProps['x'];
296
+ $: _y = y as LayerCakeProps['y'];
297
+ $: _yRange =
75
298
  yRange ??
76
- (radial
77
- ? ({ height }) => [0, height / 2]
78
- : undefined);
299
+ ((radial
300
+ ? ({ height }: { height: number }) => [0, height / 2]
301
+ : undefined) as LayerCakeProps['yRange']);
79
302
  </script>
80
303
 
81
304
  <!-- Remove domain sorting by default: https://github.com/mhkeller/layercake/issues/147 -->
@@ -184,7 +407,7 @@ $: _yRange =
184
407
  >
185
408
  <GeoContext {...geo} bind:geo={geoProjection} let:projection>
186
409
  {@const tooltipProps = typeof tooltip === 'object' ? tooltip : {}}
187
- <TooltipContext {...tooltipProps} let:tooltip>
410
+ <TooltipContext {...tooltipProps} bind:tooltip={tooltipContext} let:tooltip>
188
411
  <slot
189
412
  {aspectRatio}
190
413
  {containerHeight}
@@ -86,40 +86,40 @@ declare class __sveltets_Render<TData> {
86
86
  y1Scale?: AnyScale;
87
87
  /** The D3 scale that should be used for the color dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleOrdinal */
88
88
  cScale?: AnyScale;
89
- /** Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
89
+ /** Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
90
90
  xRange?: string[] | number[] | ((args: {
91
91
  width: number;
92
92
  height: number;
93
93
  }) => number[] | string[]) | undefined;
94
- /** Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
94
+ /** Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
95
95
  yRange?: string[] | number[] | ((args: {
96
96
  width: number;
97
97
  height: number;
98
98
  }) => number[] | string[]) | undefined;
99
- /** Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
99
+ /** Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
100
100
  zRange?: string[] | number[] | ((args: {
101
101
  width: number;
102
102
  height: number;
103
103
  }) => number[] | string[]) | undefined;
104
- /** Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
104
+ /** Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
105
105
  rRange?: string[] | number[] | ((args: {
106
106
  width: number;
107
107
  height: number;
108
108
  }) => number[] | string[]) | undefined;
109
- /** Set the x1 range by setting an array or function with argument `({ xScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
109
+ /** Set the x1 range by setting an array or function with argument `({ xScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
110
110
  x1Range?: string[] | number[] | ((args: {
111
111
  xScale: AnyScale;
112
112
  width: number;
113
113
  height: number;
114
114
  }) => number[] | string[]) | undefined;
115
- /** Set the y1 range by setting an array or function with argument `({ yScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
115
+ /** Set the y1 range by setting an array or function with argument `({ yScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
116
116
  y1Range?: string[] | number[] | ((args: {
117
117
  yScale: AnyScale;
118
118
  width: number;
119
119
  height: number;
120
120
  }) => number[] | string[]) | undefined;
121
- /** Override the default y1 range of `[0, width]` by setting an array or function with argument `({ yScale, width, height})` that returns an array. Setting this prop overrides `x1Reverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
122
- cRange?: string[];
121
+ /** Override the default y1 range of `[0, width]` by setting an array or function with argument `({ yScale, width, height})` that returns an array. Setting this prop overrides `x1Reverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
122
+ cRange?: string[] | readonly string[];
123
123
  /** Reverse the default x range. By default this is `false` and the range is `[0, width]`. Ignored if you set the xRange prop. @default false */
124
124
  xReverse?: boolean;
125
125
  /** Reverse the default y range. By default this is `true` and the range is `[height, 0]` unless using an ordinal scale with a `.bandwidth` method for `yScale`. Ignored if you set the `yRange` prop. @default true */
@@ -192,6 +192,13 @@ declare class __sveltets_Render<TData> {
192
192
  onClick?: ({ data }: {
193
193
  data: any;
194
194
  }) => any;
195
+ tooltip?: import("svelte/store").Writable<{
196
+ y: number;
197
+ x: number;
198
+ data: any;
199
+ show: (e: PointerEvent, tooltipData?: any) => void;
200
+ hide: () => void;
201
+ }>;
195
202
  }> | undefined;
196
203
  /** Props passed to TransformContext */
197
204
  transform?: Partial<{
@@ -242,9 +249,19 @@ declare class __sveltets_Render<TData> {
242
249
  }> | undefined;
243
250
  /** Expose to support `bind:transformContext` for imperative control (`transformContext.translate(...)`) */
244
251
  transformContext?: TransformContext;
252
+ /** Exposed via bind: to support `bind:geoProjection` for external access */
253
+ geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
254
+ /** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
255
+ tooltipContext?: import("svelte/store").Writable<{
256
+ y: number;
257
+ x: number;
258
+ data: any;
259
+ show: (e: PointerEvent, tooltipData?: any) => void;
260
+ hide: () => void;
261
+ }> | undefined;
245
262
  };
246
263
  events(): {
247
- resize: any;
264
+ resize: CustomEvent<any>;
248
265
  transform: CustomEvent<{
249
266
  scale: number;
250
267
  translate: {
@@ -264,7 +281,7 @@ declare class __sveltets_Render<TData> {
264
281
  containerWidth: number;
265
282
  height: number;
266
283
  width: number;
267
- element: Element;
284
+ element: Element | undefined;
268
285
  projection: import("d3-geo").GeoProjection;
269
286
  transform: {
270
287
  scale: number;
@@ -305,28 +322,28 @@ declare class __sveltets_Render<TData> {
305
322
  r: Function;
306
323
  rScale: any;
307
324
  rGet: any;
308
- x1: any;
309
- x1Scale: any;
310
- x1Get: any;
311
- y1: any;
312
- y1Scale: any;
313
- y1Get: any;
314
- c: any;
315
- cScale: any;
316
- cGet: any;
325
+ x1: (d: any) => any;
326
+ x1Scale: AnyScale<any, any, any, any> | null;
327
+ x1Get: Function;
328
+ y1: (d: any) => any;
329
+ y1Scale: AnyScale<any, any, any, any> | null;
330
+ y1Get: Function;
331
+ c: (d: any) => any;
332
+ cScale: AnyScale<any, any, any, any> | null;
333
+ cGet: Function;
317
334
  padding: {
318
335
  top: number;
319
336
  right: number;
320
337
  bottom: number;
321
338
  left: number;
322
339
  } & {
323
- top?: number | undefined;
324
- right?: number | undefined;
325
- bottom?: number | undefined;
326
- left?: number | undefined;
340
+ top?: number;
341
+ right?: number;
342
+ bottom?: number;
343
+ left?: number;
327
344
  };
328
- data: any;
329
- flatData: any;
345
+ data: unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>;
346
+ flatData: import("svelte/store").Readable<unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>>;
330
347
  config: any;
331
348
  };
332
349
  };