svelteplot 0.10.3 → 0.11.0

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 (222) hide show
  1. package/dist/Mark.svelte +42 -25
  2. package/dist/Mark.svelte.d.ts +111 -32
  3. package/dist/Plot.svelte +21 -15
  4. package/dist/core/Facet.svelte +1 -1
  5. package/dist/core/FacetAxes.svelte +13 -8
  6. package/dist/core/FacetGrid.svelte +4 -4
  7. package/dist/core/Plot.svelte +41 -35
  8. package/dist/helpers/autoScales.d.ts +3 -3
  9. package/dist/helpers/autoScales.js +28 -18
  10. package/dist/helpers/autoTicks.js +2 -0
  11. package/dist/helpers/callWithProps.d.ts +1 -2
  12. package/dist/helpers/facets.js +0 -1
  13. package/dist/helpers/index.js +1 -1
  14. package/dist/helpers/mergeDeep.d.ts +1 -3
  15. package/dist/helpers/mergeDeep.js +15 -16
  16. package/dist/helpers/projection.d.ts +4 -3
  17. package/dist/helpers/projection.js +17 -5
  18. package/dist/helpers/reduce.d.ts +4 -4
  19. package/dist/helpers/reduce.js +6 -4
  20. package/dist/helpers/regressionLoess.js +2 -1
  21. package/dist/helpers/resolve.d.ts +6 -3
  22. package/dist/helpers/resolve.js +25 -16
  23. package/dist/helpers/scales.d.ts +10 -10
  24. package/dist/helpers/scales.js +43 -13
  25. package/dist/helpers/time.d.ts +10 -3
  26. package/dist/helpers/time.js +2 -1
  27. package/dist/hooks/index.d.ts +2 -0
  28. package/dist/hooks/index.js +2 -0
  29. package/dist/hooks/plotDefaults.d.ts +3 -1
  30. package/dist/hooks/plotDefaults.js +33 -1
  31. package/dist/hooks/usePlot.svelte.d.ts +10 -25
  32. package/dist/hooks/usePlot.svelte.js +8 -7
  33. package/dist/index.d.ts +1 -2
  34. package/dist/index.js +1 -3
  35. package/dist/marks/Area.svelte +24 -13
  36. package/dist/marks/Area.svelte.d.ts +118 -34
  37. package/dist/marks/AreaX.svelte +42 -8
  38. package/dist/marks/AreaX.svelte.d.ts +154 -71
  39. package/dist/marks/AreaY.svelte +42 -8
  40. package/dist/marks/AreaY.svelte.d.ts +154 -71
  41. package/dist/marks/Arrow.svelte +42 -23
  42. package/dist/marks/Arrow.svelte.d.ts +114 -35
  43. package/dist/marks/AxisX.svelte +43 -28
  44. package/dist/marks/AxisX.svelte.d.ts +125 -40
  45. package/dist/marks/AxisY.svelte +43 -26
  46. package/dist/marks/AxisY.svelte.d.ts +127 -40
  47. package/dist/marks/BarX.svelte +12 -10
  48. package/dist/marks/BarX.svelte.d.ts +104 -32
  49. package/dist/marks/BarY.svelte +11 -10
  50. package/dist/marks/BarY.svelte.d.ts +106 -34
  51. package/dist/marks/BollingerX.svelte +4 -7
  52. package/dist/marks/BollingerX.svelte.d.ts +105 -30
  53. package/dist/marks/BollingerY.svelte +3 -0
  54. package/dist/marks/BollingerY.svelte.d.ts +105 -30
  55. package/dist/marks/BoxX.svelte +3 -3
  56. package/dist/marks/BoxY.svelte +12 -9
  57. package/dist/marks/BoxY.svelte.d.ts +128 -53
  58. package/dist/marks/Brush.svelte +26 -21
  59. package/dist/marks/Brush.svelte.d.ts +119 -60
  60. package/dist/marks/Cell.svelte +13 -9
  61. package/dist/marks/Cell.svelte.d.ts +105 -30
  62. package/dist/marks/CellX.svelte +2 -1
  63. package/dist/marks/CellX.svelte.d.ts +105 -32
  64. package/dist/marks/CellY.svelte +2 -1
  65. package/dist/marks/CellY.svelte.d.ts +105 -32
  66. package/dist/marks/ColorLegend.svelte +24 -13
  67. package/dist/marks/ColorLegend.svelte.d.ts +1 -0
  68. package/dist/marks/CustomMark.svelte +16 -10
  69. package/dist/marks/CustomMark.svelte.d.ts +112 -31
  70. package/dist/marks/CustomMarkHTML.svelte +8 -2
  71. package/dist/marks/CustomMarkHTML.svelte.d.ts +8 -2
  72. package/dist/marks/DifferenceY.svelte +31 -20
  73. package/dist/marks/DifferenceY.svelte.d.ts +134 -55
  74. package/dist/marks/Dot.svelte +21 -11
  75. package/dist/marks/Dot.svelte.d.ts +117 -38
  76. package/dist/marks/DotX.svelte +2 -0
  77. package/dist/marks/DotX.svelte.d.ts +136 -62
  78. package/dist/marks/DotY.svelte +1 -0
  79. package/dist/marks/DotY.svelte.d.ts +135 -62
  80. package/dist/marks/Frame.svelte +47 -9
  81. package/dist/marks/Frame.svelte.d.ts +124 -41
  82. package/dist/marks/Geo.svelte +21 -12
  83. package/dist/marks/Geo.svelte.d.ts +105 -30
  84. package/dist/marks/Graticule.svelte +3 -0
  85. package/dist/marks/Graticule.svelte.d.ts +3 -0
  86. package/dist/marks/GridX.svelte +31 -16
  87. package/dist/marks/GridX.svelte.d.ts +108 -32
  88. package/dist/marks/GridY.svelte +30 -15
  89. package/dist/marks/GridY.svelte.d.ts +108 -32
  90. package/dist/marks/HTMLTooltip.svelte +14 -7
  91. package/dist/marks/HTMLTooltip.svelte.d.ts +7 -0
  92. package/dist/marks/Image.svelte +50 -25
  93. package/dist/marks/Image.svelte.d.ts +117 -35
  94. package/dist/marks/Line.svelte +67 -44
  95. package/dist/marks/Line.svelte.d.ts +119 -30
  96. package/dist/marks/LineX.svelte +2 -1
  97. package/dist/marks/LineX.svelte.d.ts +142 -69
  98. package/dist/marks/LineY.svelte +2 -1
  99. package/dist/marks/LineY.svelte.d.ts +142 -69
  100. package/dist/marks/Link.svelte +70 -46
  101. package/dist/marks/Link.svelte.d.ts +126 -41
  102. package/dist/marks/Pointer.svelte +24 -15
  103. package/dist/marks/Pointer.svelte.d.ts +7 -0
  104. package/dist/marks/Rect.svelte +13 -5
  105. package/dist/marks/Rect.svelte.d.ts +116 -35
  106. package/dist/marks/RectX.svelte +6 -3
  107. package/dist/marks/RectX.svelte.d.ts +158 -12
  108. package/dist/marks/RectY.svelte +6 -3
  109. package/dist/marks/RectY.svelte.d.ts +158 -12
  110. package/dist/marks/RegressionX.svelte +13 -6
  111. package/dist/marks/RegressionX.svelte.d.ts +8 -3
  112. package/dist/marks/RegressionY.svelte +13 -6
  113. package/dist/marks/RegressionY.svelte.d.ts +8 -3
  114. package/dist/marks/RuleX.svelte +18 -11
  115. package/dist/marks/RuleX.svelte.d.ts +112 -32
  116. package/dist/marks/RuleY.svelte +19 -12
  117. package/dist/marks/RuleY.svelte.d.ts +114 -34
  118. package/dist/marks/Spike.svelte +11 -5
  119. package/dist/marks/Spike.svelte.d.ts +146 -68
  120. package/dist/marks/Text.svelte +24 -7
  121. package/dist/marks/Text.svelte.d.ts +253 -75
  122. package/dist/marks/TickX.svelte +56 -48
  123. package/dist/marks/TickX.svelte.d.ts +114 -40
  124. package/dist/marks/TickY.svelte +59 -51
  125. package/dist/marks/TickY.svelte.d.ts +117 -43
  126. package/dist/marks/Trail.svelte +25 -13
  127. package/dist/marks/Trail.svelte.d.ts +116 -33
  128. package/dist/marks/Vector.svelte +20 -11
  129. package/dist/marks/Vector.svelte.d.ts +116 -35
  130. package/dist/marks/WaffleX.svelte +18 -16
  131. package/dist/marks/WaffleX.svelte.d.ts +131 -57
  132. package/dist/marks/WaffleY.svelte +16 -15
  133. package/dist/marks/WaffleY.svelte.d.ts +129 -56
  134. package/dist/marks/helpers/Anchor.svelte +17 -2
  135. package/dist/marks/helpers/Anchor.svelte.d.ts +16 -1
  136. package/dist/marks/helpers/AreaCanvas.svelte +8 -8
  137. package/dist/marks/helpers/BaseAxisX.svelte +38 -41
  138. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +11 -17
  139. package/dist/marks/helpers/BaseAxisY.svelte +35 -35
  140. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +12 -15
  141. package/dist/marks/helpers/Box.svelte +35 -28
  142. package/dist/marks/helpers/Box.svelte.d.ts +122 -50
  143. package/dist/marks/helpers/DotCanvas.svelte +11 -9
  144. package/dist/marks/helpers/GeoCanvas.svelte +7 -6
  145. package/dist/marks/helpers/LineCanvas.svelte +7 -7
  146. package/dist/marks/helpers/LinearGradientX.svelte +2 -2
  147. package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
  148. package/dist/marks/helpers/LinearGradientY.svelte +2 -2
  149. package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
  150. package/dist/marks/helpers/Marker.svelte +2 -2
  151. package/dist/marks/helpers/MarkerPath.svelte +15 -12
  152. package/dist/marks/helpers/MarkerPath.svelte.d.ts +105 -32
  153. package/dist/marks/helpers/MultilineText.svelte +24 -17
  154. package/dist/marks/helpers/MultilineText.svelte.d.ts +1 -1
  155. package/dist/marks/helpers/RectCanvas.svelte +31 -26
  156. package/dist/marks/helpers/RectPath.svelte +2 -2
  157. package/dist/marks/helpers/Regression.svelte +176 -86
  158. package/dist/marks/helpers/Regression.svelte.d.ts +20 -8
  159. package/dist/marks/helpers/RuleCanvas.svelte +9 -6
  160. package/dist/marks/helpers/TextCanvas.svelte +13 -9
  161. package/dist/marks/helpers/TextCanvas.svelte.d.ts +6 -6
  162. package/dist/marks/helpers/TickCanvas.svelte +6 -5
  163. package/dist/marks/helpers/TrailCanvas.svelte +16 -18
  164. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +3 -5
  165. package/dist/marks/helpers/canvas.js +16 -9
  166. package/dist/marks/helpers/events.d.ts +2 -2
  167. package/dist/marks/helpers/events.js +14 -7
  168. package/dist/marks/helpers/waffle.d.ts +3 -3
  169. package/dist/marks/helpers/waffle.js +6 -4
  170. package/dist/regression/polynomial.d.ts +1 -1
  171. package/dist/regression/polynomial.js +5 -5
  172. package/dist/regression/utils/determination.d.ts +1 -1
  173. package/dist/regression/utils/determination.js +1 -1
  174. package/dist/regression/utils/geometry.d.ts +1 -1
  175. package/dist/regression/utils/interpose.d.ts +1 -1
  176. package/dist/regression/utils/interpose.js +1 -1
  177. package/dist/regression/utils/points.d.ts +1 -1
  178. package/dist/transforms/bin.d.ts +3 -3
  179. package/dist/transforms/bin.js +29 -20
  180. package/dist/transforms/bollinger.d.ts +8 -0
  181. package/dist/transforms/bollinger.js +9 -1
  182. package/dist/transforms/centroid.d.ts +4 -0
  183. package/dist/transforms/centroid.js +4 -0
  184. package/dist/transforms/density.d.ts +4 -4
  185. package/dist/transforms/density.js +20 -13
  186. package/dist/transforms/dodge.d.ts +12 -1
  187. package/dist/transforms/dodge.js +15 -6
  188. package/dist/transforms/group.d.ts +141 -4
  189. package/dist/transforms/group.js +4 -1
  190. package/dist/transforms/interval.d.ts +204 -60
  191. package/dist/transforms/jitter.d.ts +421 -4
  192. package/dist/transforms/jitter.js +10 -1
  193. package/dist/transforms/map.d.ts +412 -4
  194. package/dist/transforms/map.js +3 -3
  195. package/dist/transforms/normalize.d.ts +276 -5
  196. package/dist/transforms/normalize.js +5 -3
  197. package/dist/transforms/recordize.d.ts +17 -5
  198. package/dist/transforms/recordize.js +13 -9
  199. package/dist/transforms/rename.d.ts +11 -4
  200. package/dist/transforms/rename.js +7 -2
  201. package/dist/transforms/select.d.ts +722 -210
  202. package/dist/transforms/select.js +13 -1
  203. package/dist/transforms/shift.d.ts +8 -0
  204. package/dist/transforms/shift.js +20 -6
  205. package/dist/transforms/sort.d.ts +13 -258
  206. package/dist/transforms/sort.js +13 -10
  207. package/dist/transforms/stack.d.ts +58 -9
  208. package/dist/transforms/stack.js +27 -11
  209. package/dist/transforms/window.d.ts +221 -66
  210. package/dist/transforms/window.js +8 -2
  211. package/dist/types/axes.d.ts +43 -0
  212. package/dist/types/axes.js +1 -0
  213. package/dist/types/channel.d.ts +30 -2
  214. package/dist/types/data.d.ts +14 -1
  215. package/dist/types/facet.d.ts +5 -0
  216. package/dist/types/index.d.ts +33 -8
  217. package/dist/types/index.js +11 -7
  218. package/dist/types/mark.d.ts +124 -35
  219. package/dist/types/plot.d.ts +118 -16
  220. package/dist/types/scale.d.ts +125 -8
  221. package/package.json +178 -175
  222. package/dist/helpers/autoTicks.d.ts +0 -12
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  interface ColorLegendMarkProps {
3
+ /** CSS class applied to the legend container element */
3
4
  class: string | null;
4
5
  }
5
6
  import Plot from '../Plot.svelte';
@@ -9,7 +10,7 @@
9
10
  import { range as d3Range, extent } from 'd3-array';
10
11
  import { maybeSymbol } from '../helpers/symbols.js';
11
12
 
12
- import { getPlotDefaults } from '../hooks/plotDefaults';
13
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
13
14
  import { usePlot } from '../hooks/usePlot.svelte.js';
14
15
 
15
16
  let { class: className = null }: ColorLegendMarkProps = $props();
@@ -28,7 +29,7 @@
28
29
  plot.options.color.tickFormat || { ...DEFAULTS.numberFormat, notation: 'compact' }
29
30
  ).format
30
31
  );
31
- const randId = Math.round(Math.random() * 1e6).toFixed(32);
32
+ const randId = Math.round(Math.random() * 1e6).toString(36);
32
33
  </script>
33
34
 
34
35
  <!--
@@ -72,7 +73,7 @@
72
73
  </div>
73
74
  {/each}
74
75
  {:else if scaleType === 'quantile' || scaleType === 'quantize' || scaleType === 'threshold'}
75
- {@const domain = extent(plot.scales.color.fn.domain())}
76
+ {@const domain = extent(plot.scales.color.fn.domain() as number[]) as [number, number]}
76
77
  {@const range = plot.scales.color.range}
77
78
  {@const tickLabels =
78
79
  scaleType === 'quantile'
@@ -94,28 +95,34 @@
94
95
  marginBottom={20}
95
96
  height={38}
96
97
  inset={0}
97
- x={{ domain, ticks }}>
98
+ x={{ domain: domain as [number, number], ticks }}>
98
99
  <defs>
99
100
  <linearGradient id="gradient-{randId}" x2="1">
100
- <stop offset="0%" stop-color={range[0]} />
101
+ <stop offset="0%" stop-color={range[0] as string} />
101
102
  {#each ticks as t, i (i)}
102
103
  {@const offset = (100 * (t - domain[0])) / (domain[1] - domain[0])}
103
104
  <stop
104
105
  offset="{offset - 0.001}%"
105
- stop-color={plot.scales.color.fn(tickLabels[i] - 0.1)} />
106
+ stop-color={plot.scales.color.fn(
107
+ (tickLabels[i] as number) - 0.1
108
+ )} />
106
109
  <stop
107
110
  offset="{offset}%"
108
- stop-color={plot.scales.color.fn(tickLabels[i])} />
111
+ stop-color={plot.scales.color.fn(tickLabels[i] as number)} />
109
112
  {/each}
110
- <stop offset="100%" stop-color={range.at(-1)} />
113
+ <stop offset="100%" stop-color={range.at(-1) as string} />
111
114
  </linearGradient>
112
115
  </defs>
113
- <Frame dy={-5} stroke={null} fill="url(#gradient-{randId})" />
114
- <AxisX tickSize={18} dy={-17} tickFormat={(d, i) => tickFormat(tickLabels[i])} />
116
+ <Frame dy={-5} stroke={undefined} fill="url(#gradient-{randId})" />
117
+ <AxisX
118
+ tickSize={18}
119
+ dy={-17}
120
+ tickFormat={(d, i) =>
121
+ (tickFormat as (d: number) => string)(tickLabels[i] as number)} />
115
122
  </Plot>
116
123
  {:else}
117
124
  <!--- continuous -->
118
- {@const domain = extent(plot.scales.color.domain)}
125
+ {@const domain = extent(plot.scales.color.domain as number[]) as [number, number]}
119
126
  {@const ticks = d3Range(domain[0], domain[1], (domain[1] - domain[0]) / 7).slice(1)}
120
127
 
121
128
  <Plot
@@ -127,7 +134,11 @@
127
134
  marginBottom={20}
128
135
  height={38}
129
136
  inset={0}
130
- x={{ domain, tickSpacing: 30, tickFormat }}>
137
+ x={{
138
+ domain: domain as [number, number],
139
+ tickSpacing: 30,
140
+ tickFormat: tickFormat as any
141
+ }}>
131
142
  <defs>
132
143
  <linearGradient id="gradient-{randId}" x2="1">
133
144
  {#each ticks as t (t)}
@@ -137,7 +148,7 @@
137
148
  {/each}
138
149
  </linearGradient>
139
150
  </defs>
140
- <Frame dy={-5} stroke={null} fill="url(#gradient-{randId})" />
151
+ <Frame dy={-5} stroke={undefined} fill="url(#gradient-{randId})" />
141
152
  <AxisX tickSize={18} dy={-17} />
142
153
  </Plot>
143
154
  {/if}
@@ -1,4 +1,5 @@
1
1
  interface ColorLegendMarkProps {
2
+ /** CSS class applied to the legend container element */
2
3
  class: string | null;
3
4
  }
4
5
  /**
@@ -4,23 +4,31 @@
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
6
  interface CustomMarkProps extends BaseMarkProps<Datum> {
7
+ /** the input data array */
7
8
  data?: Datum[];
8
- type?: string;
9
+ /** the horizontal position channel; bound to the x scale */
9
10
  x?: ChannelAccessor<Datum>;
11
+ /** the starting horizontal position; bound to the x scale */
10
12
  x1?: ChannelAccessor<Datum>;
13
+ /** the ending horizontal position; bound to the x scale */
11
14
  x2?: ChannelAccessor<Datum>;
15
+ /** the vertical position channel; bound to the y scale */
12
16
  y?: ChannelAccessor<Datum>;
17
+ /** the starting vertical position; bound to the y scale */
13
18
  y1?: ChannelAccessor<Datum>;
19
+ /** the ending vertical position; bound to the y scale */
14
20
  y2?: ChannelAccessor<Datum>;
21
+ /** the radius channel; bound to the r scale */
15
22
  r?: ChannelAccessor<Datum>;
23
+ /** snippet rendered once per data point with the scaled record */
16
24
  mark?: Snippet<
17
25
  [{ record: ScaledDataRecord<Datum>; index: number; usedScales: UsedScales }]
18
26
  >;
27
+ /** snippet rendered once with all scaled records */
19
28
  marks?: Snippet<[{ records: ScaledDataRecord<Datum>[]; usedScales: UsedScales }]>;
20
29
  }
21
30
 
22
31
  import type {
23
- PlotContext,
24
32
  DataRecord,
25
33
  ChannelAccessor,
26
34
  BaseMarkProps,
@@ -33,13 +41,7 @@
33
41
 
34
42
  import Mark from '../Mark.svelte';
35
43
 
36
- let {
37
- data = [{} as Datum],
38
- mark,
39
- type = 'custom',
40
- marks,
41
- ...options
42
- }: CustomMarkProps = $props();
44
+ let { data = [{} as Datum], mark, marks, ...options }: CustomMarkProps = $props();
43
45
 
44
46
  const args = $derived(sort({ data, ...options })) as CustomMarkProps;
45
47
 
@@ -59,7 +61,11 @@
59
61
  ];
60
62
  </script>
61
63
 
62
- <Mark {type} required={[]} channels={channels.filter((d) => !!options[d])} {...args}>
64
+ <Mark
65
+ type="custom"
66
+ required={[]}
67
+ channels={channels.filter((d) => !!(options as Record<string, unknown>)[d])}
68
+ {...args}>
63
69
  {#snippet children({ scaledData, usedScales })}
64
70
  {#if marks}
65
71
  {@render marks({ records: scaledData.filter((d) => d.valid), usedScales })}
@@ -12,6 +12,16 @@ declare function $$render<Datum extends DataRecord>(): {
12
12
  dodgeY: import("../transforms/dodge.js").DodgeYOptions;
13
13
  fill: ChannelAccessor<Datum>;
14
14
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
15
+ fontFamily: import("../types/index.js").ConstantAccessor<import("csstype").Property.FontFamily, Datum>;
16
+ fontSize: import("../types/index.js").ConstantAccessor<number | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "math" | (string & {}) | "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large" | "larger" | "smaller", Datum>;
17
+ fontStyle: import("../types/index.js").ConstantAccessor<import("csstype").Property.FontStyle, Datum>;
18
+ fontVariant: import("../types/index.js").ConstantAccessor<import("csstype").Property.FontVariant, Datum>;
19
+ fontWeight: import("../types/index.js").ConstantAccessor<import("csstype").Property.FontWeight, Datum>;
20
+ letterSpacing: import("../types/index.js").ConstantAccessor<import("csstype").Property.LetterSpacing<0 | (string & {})>, Datum>;
21
+ wordSpacing: import("../types/index.js").ConstantAccessor<import("csstype").Property.WordSpacing<0 | (string & {})>, Datum>;
22
+ textAnchor: import("../types/index.js").ConstantAccessor<import("csstype").Property.TextAnchor, Datum>;
23
+ textTransform: import("../types/index.js").ConstantAccessor<import("csstype").Property.TextTransform, Datum>;
24
+ textDecoration: import("../types/index.js").ConstantAccessor<import("csstype").Property.TextDecoration<0 | (string & {})>, Datum>;
15
25
  sort: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
16
26
  channel: string;
17
27
  order?: "ascending" | "descending";
@@ -25,60 +35,131 @@ declare function $$render<Datum extends DataRecord>(): {
25
35
  opacity: ChannelAccessor<Datum>;
26
36
  strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
27
37
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
38
+ blend: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
39
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
40
  clipPath: string;
30
41
  mask: string;
31
42
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
32
43
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
33
44
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
34
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
63
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
+ onclick: (event: Event & {
46
+ currentTarget: SVGPathElement;
47
+ }, datum: Datum, index: number) => void;
48
+ ondblclick: (event: Event & {
49
+ currentTarget: SVGPathElement;
50
+ }, datum: Datum, index: number) => void;
51
+ onmouseup: (event: Event & {
52
+ currentTarget: SVGPathElement;
53
+ }, datum: Datum, index: number) => void;
54
+ onmousedown: (event: Event & {
55
+ currentTarget: SVGPathElement;
56
+ }, datum: Datum, index: number) => void;
57
+ onmouseenter: (event: Event & {
58
+ currentTarget: SVGPathElement;
59
+ }, datum: Datum, index: number) => void;
60
+ onmousemove: (event: Event & {
61
+ currentTarget: SVGPathElement;
62
+ }, datum: Datum, index: number) => void;
63
+ onmouseleave: (event: Event & {
64
+ currentTarget: SVGPathElement;
65
+ }, datum: Datum, index: number) => void;
66
+ onmouseout: (event: Event & {
67
+ currentTarget: SVGPathElement;
68
+ }, datum: Datum, index: number) => void;
69
+ onmouseover: (event: Event & {
70
+ currentTarget: SVGPathElement;
71
+ }, datum: Datum, index: number) => void;
72
+ onpointercancel: (event: Event & {
73
+ currentTarget: SVGPathElement;
74
+ }, datum: Datum, index: number) => void;
75
+ onpointerdown: (event: Event & {
76
+ currentTarget: SVGPathElement;
77
+ }, datum: Datum, index: number) => void;
78
+ onpointerup: (event: Event & {
79
+ currentTarget: SVGPathElement;
80
+ }, datum: Datum, index: number) => void;
81
+ onpointerenter: (event: Event & {
82
+ currentTarget: SVGPathElement;
83
+ }, datum: Datum, index: number) => void;
84
+ onpointerleave: (event: Event & {
85
+ currentTarget: SVGPathElement;
86
+ }, datum: Datum, index: number) => void;
87
+ onpointermove: (event: Event & {
88
+ currentTarget: SVGPathElement;
89
+ }, datum: Datum, index: number) => void;
90
+ onpointerover: (event: Event & {
91
+ currentTarget: SVGPathElement;
92
+ }, datum: Datum, index: number) => void;
93
+ onpointerout: (event: Event & {
94
+ currentTarget: SVGPathElement;
95
+ }, datum: Datum, index: number) => void;
96
+ ondrag: (event: Event & {
97
+ currentTarget: SVGPathElement;
98
+ }, datum: Datum, index: number) => void;
99
+ ondrop: (event: Event & {
100
+ currentTarget: SVGPathElement;
101
+ }, datum: Datum, index: number) => void;
102
+ ondragstart: (event: Event & {
103
+ currentTarget: SVGPathElement;
104
+ }, datum: Datum, index: number) => void;
105
+ ondragenter: (event: Event & {
106
+ currentTarget: SVGPathElement;
107
+ }, datum: Datum, index: number) => void;
108
+ ondragleave: (event: Event & {
109
+ currentTarget: SVGPathElement;
110
+ }, datum: Datum, index: number) => void;
111
+ ondragover: (event: Event & {
112
+ currentTarget: SVGPathElement;
113
+ }, datum: Datum, index: number) => void;
114
+ ondragend: (event: Event & {
115
+ currentTarget: SVGPathElement;
116
+ }, datum: Datum, index: number) => void;
117
+ ontouchstart: (event: Event & {
118
+ currentTarget: SVGPathElement;
119
+ }, datum: Datum, index: number) => void;
120
+ ontouchmove: (event: Event & {
121
+ currentTarget: SVGPathElement;
122
+ }, datum: Datum, index: number) => void;
123
+ ontouchend: (event: Event & {
124
+ currentTarget: SVGPathElement;
125
+ }, datum: Datum, index: number) => void;
126
+ ontouchcancel: (event: Event & {
127
+ currentTarget: SVGPathElement;
128
+ }, datum: Datum, index: number) => void;
129
+ oncontextmenu: (event: Event & {
130
+ currentTarget: SVGPathElement;
131
+ }, datum: Datum, index: number) => void;
132
+ onwheel: (event: Event & {
133
+ currentTarget: SVGPathElement;
134
+ }, datum: Datum, index: number) => void;
64
135
  class: string;
65
136
  style: string;
66
137
  cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
138
+ title: import("../types/index.js").ConstantAccessor<string, Datum>;
67
139
  }> & {
140
+ /** the input data array */
68
141
  data?: Datum[];
69
- type?: string;
142
+ /** the horizontal position channel; bound to the x scale */
70
143
  x?: ChannelAccessor<Datum>;
144
+ /** the starting horizontal position; bound to the x scale */
71
145
  x1?: ChannelAccessor<Datum>;
146
+ /** the ending horizontal position; bound to the x scale */
72
147
  x2?: ChannelAccessor<Datum>;
148
+ /** the vertical position channel; bound to the y scale */
73
149
  y?: ChannelAccessor<Datum>;
150
+ /** the starting vertical position; bound to the y scale */
74
151
  y1?: ChannelAccessor<Datum>;
152
+ /** the ending vertical position; bound to the y scale */
75
153
  y2?: ChannelAccessor<Datum>;
154
+ /** the radius channel; bound to the r scale */
76
155
  r?: ChannelAccessor<Datum>;
156
+ /** snippet rendered once per data point with the scaled record */
77
157
  mark?: Snippet<[{
78
158
  record: ScaledDataRecord<Datum>;
79
159
  index: number;
80
160
  usedScales: UsedScales;
81
161
  }]>;
162
+ /** snippet rendered once with all scaled records */
82
163
  marks?: Snippet<[{
83
164
  records: ScaledDataRecord<Datum>[];
84
165
  usedScales: UsedScales;
@@ -5,9 +5,13 @@
5
5
 
6
6
  <script lang="ts" generics="Datum extends DataRecord">
7
7
  interface CustomMarkHTMLProps {
8
+ /** the input data array */
8
9
  data: Datum[];
10
+ /** the horizontal position channel; bound to the x scale */
9
11
  x?: ChannelAccessor<Datum>;
12
+ /** the vertical position channel; bound to the y scale */
10
13
  y?: ChannelAccessor<Datum>;
14
+ /** anchor position within the frame when x or y is not specified */
11
15
  frameAnchor?: ConstantAccessor<
12
16
  | 'bottom'
13
17
  | 'top'
@@ -20,8 +24,10 @@
20
24
  | 'center',
21
25
  Datum
22
26
  >;
27
+ /** CSS class applied to the wrapper element */
23
28
  class: string | null;
24
- children: Snippet<{ datum: Datum; x: number; y: number }>;
29
+ /** snippet rendered for each data point with the datum and its projected coordinates */
30
+ children: Snippet<[{ datum: Datum; x: number; y: number }]>;
25
31
  }
26
32
  import { type Snippet } from 'svelte';
27
33
  import type { ChannelAccessor, ConstantAccessor, DataRecord } from '../types/index.js';
@@ -43,7 +49,7 @@
43
49
  }: CustomMarkHTMLProps = $props();
44
50
 
45
51
  function getXY(datum: Datum) {
46
- const fa = frameAnchor || 'center';
52
+ const fa = (frameAnchor || 'center') as string;
47
53
  const isLeft = fa.endsWith('left');
48
54
  const isRight = fa.endsWith('right');
49
55
  const isTop = fa.startsWith('top');
@@ -2,16 +2,22 @@ import { type Snippet } from 'svelte';
2
2
  import type { ChannelAccessor, ConstantAccessor, DataRecord } from '../types/index.js';
3
3
  declare function $$render<Datum extends DataRecord>(): {
4
4
  props: {
5
+ /** the input data array */
5
6
  data: Datum[];
7
+ /** the horizontal position channel; bound to the x scale */
6
8
  x?: ChannelAccessor<Datum>;
9
+ /** the vertical position channel; bound to the y scale */
7
10
  y?: ChannelAccessor<Datum>;
11
+ /** anchor position within the frame when x or y is not specified */
8
12
  frameAnchor?: ConstantAccessor<"bottom" | "top" | "left" | "right" | "top-left" | "bottom-left" | "top-right" | "bottom-right" | "center", Datum>;
13
+ /** CSS class applied to the wrapper element */
9
14
  class: string | null;
10
- children: Snippet<{
15
+ /** snippet rendered for each data point with the datum and its projected coordinates */
16
+ children: Snippet<[{
11
17
  datum: Datum;
12
18
  x: number;
13
19
  y: number;
14
- }>;
20
+ }]>;
15
21
  };
16
22
  exports: {};
17
23
  bindings: "";
@@ -1,25 +1,29 @@
1
1
  <script lang="ts" generics="Datum extends DataRecord">
2
2
  interface DifferenceYMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
3
+ /** the input data array */
3
4
  data: Datum[];
4
- /*
5
+ /**
5
6
  * the horizontal position of the comparison; bound to the x scale
6
7
  */
7
- x1: ChannelAccessor<Datum>;
8
+ x1?: ChannelAccessor<Datum>;
8
9
  /**
9
10
  * the horizontal position of the metric; bound to the x scale
10
11
  */
11
- x2: ChannelAccessor<Datum>;
12
- x: ChannelAccessor<Datum>;
12
+ x2?: ChannelAccessor<Datum>;
13
+ /** the shared horizontal position channel; used when x1 and x2 are the same */
14
+ x?: ChannelAccessor<Datum>;
13
15
  /**
14
16
  * the vertical position of the comparison; bound to the y scale
15
17
  */
16
- y1: ChannelAccessor<Datum>;
18
+ y1?: ChannelAccessor<Datum>;
17
19
  /**
18
20
  * the vertical position of the metric; bound to the y scale
19
21
  */
20
- y2: ChannelAccessor<Datum>;
21
- y: ChannelAccessor<Datum>;
22
- fillOpacity?: number;
22
+ y2?: ChannelAccessor<Datum>;
23
+ /** the shared vertical position channel; used when y1 and y2 are the same */
24
+ y?: ChannelAccessor<Datum>;
25
+ /** the fill opacity for both positive and negative areas */
26
+ fillOpacity?: ConstantAccessor<number, Datum>;
23
27
  /**
24
28
  * the stroke color of the "positive" area; defaults to 'blue'
25
29
  */
@@ -48,6 +52,7 @@
48
52
  import type {
49
53
  BaseMarkProps,
50
54
  ChannelAccessor,
55
+ ConstantAccessor,
51
56
  CurveName,
52
57
  DataRecord
53
58
  } from '../types/index.js';
@@ -76,7 +81,7 @@
76
81
  const {
77
82
  data,
78
83
  stroke,
79
- class: className = null,
84
+ class: className = '',
80
85
  ...options
81
86
  }: DifferenceYMarkProps = $derived({
82
87
  ...DEFAULTS,
@@ -87,27 +92,33 @@
87
92
  const x1x2Differ = $derived((x1 == null || x2 == null) && x1 !== x2);
88
93
 
89
94
  const xExtent = $derived(
90
- x1x2Differ && x != null ? extent(data, (d) => resolveChannel('x', d, options)) : null
95
+ x1x2Differ && x != null
96
+ ? extent(data, (d) => resolveChannel('x', d, options) as number | null | undefined)
97
+ : null
91
98
  );
92
99
  const x1Extent = $derived(
93
- x1x2Differ && x1 != null ? extent(data, (d) => resolveChannel('x1', d, options)) : null
100
+ x1x2Differ && x1 != null
101
+ ? extent(data, (d) => resolveChannel('x1', d, options) as number | null | undefined)
102
+ : null
94
103
  );
95
104
  const x2Extent = $derived(
96
- x1x2Differ && x2 != null ? extent(data, (d) => resolveChannel('x2', d, options)) : null
105
+ x1x2Differ && x2 != null
106
+ ? extent(data, (d) => resolveChannel('x2', d, options) as number | null | undefined)
107
+ : null
97
108
  );
98
109
 
99
110
  const maxMin = $derived(
100
- max([xExtent, x1Extent, x2Extent].filter((d) => d != null).map((d) => d[0]))
111
+ max([xExtent, x1Extent, x2Extent].filter((d) => d != null).map((d) => d![0] as number))
101
112
  );
102
113
  const minMax = $derived(
103
- min([xExtent, x1Extent, x2Extent].filter((d) => d != null).map((d) => d[1]))
114
+ min([xExtent, x1Extent, x2Extent].filter((d) => d != null).map((d) => d![1] as number))
104
115
  );
105
116
 
106
117
  const croppedX1 = $derived(
107
118
  x1x2Differ
108
119
  ? data.filter((d) => {
109
- const x1val = resolveChannel(x1 != null ? 'x1' : 'x', d, options);
110
- return x1val >= maxMin && x1val <= minMax;
120
+ const x1val = resolveChannel(x1 != null ? 'x1' : 'x', d, options) as number;
121
+ return x1val >= (maxMin as number) && x1val <= (minMax as number);
111
122
  })
112
123
  : data
113
124
  );
@@ -115,8 +126,8 @@
115
126
  const croppedX2 = $derived(
116
127
  x1x2Differ
117
128
  ? data.filter((d) => {
118
- const x2val = resolveChannel(x2 != null ? 'x2' : 'x', d, options);
119
- return x2val >= maxMin && x2val <= minMax;
129
+ const x2val = resolveChannel(x2 != null ? 'x2' : 'x', d, options) as number;
130
+ return x2val >= (maxMin as number) && x2val <= (minMax as number);
120
131
  })
121
132
  : data
122
133
  );
@@ -141,7 +152,7 @@
141
152
  data={croppedX1}
142
153
  {...options}
143
154
  fill={options.positiveFill || 'pink'}
144
- fillOpacity={coalesce(options.positiveFillOpacity, options.fillOpacity, 1)}
155
+ fillOpacity={coalesce(options.positiveFillOpacity, options.fillOpacity, 1) as number}
145
156
  x1={coalesce(x1, x2, x)}
146
157
  y1={{ scale: null, value: 0 }}
147
158
  y2={coalesce(y1, x1x2Differ ? coalesce(y2, y) : 0)} />
@@ -163,7 +174,7 @@
163
174
  data={croppedX2}
164
175
  {...options}
165
176
  fill={options.negativeFill || 'cyan'}
166
- fillOpacity={coalesce(options.negativeFillOpacity, options.fillOpacity, 1)}
177
+ fillOpacity={coalesce(options.negativeFillOpacity, options.fillOpacity, 1) as number}
167
178
  x1={coalesce(x2, x)}
168
179
  y1={{ scale: null, value: 0 }}
169
180
  y2={coalesce(y2, y)} />