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
@@ -6,36 +6,35 @@
6
6
  import type {
7
7
  AutoMarginStores,
8
8
  ConstantAccessor,
9
- DataRecord,
10
9
  PlotState,
10
+ PlotScaleFunction,
11
11
  RawValue,
12
12
  ScaledDataRecord,
13
13
  ScaleType
14
14
  } from '../../types/index.js';
15
- import { RAW_VALUE } from '../../transforms/recordize';
16
- import { INDEX } from '../../constants';
15
+ import type { AxisTickDatum, AxisYTick, BaseAxisYOptions } from '../../types/axes.js';
16
+ import { RAW_VALUE } from '../../transforms/recordize.js';
17
+ import { INDEX } from '../../constants.js';
18
+ type AxisDatum = AxisTickDatum<typeof RAW_VALUE, typeof INDEX>;
19
+ type AxisTick = AxisYTick<AxisDatum>;
17
20
 
18
21
  type BaseAxisYProps = {
19
- scaleFn: (d: RawValue) => number;
22
+ scaleFn: PlotScaleFunction;
20
23
  scaleType: ScaleType;
21
24
  ticks: RawValue[];
22
25
  tickFormat: (d: RawValue, i: number, ticks: RawValue[]) => string | string[];
23
- anchor: 'left' | 'right';
24
- lineAnchor: 'top' | 'center' | 'bottom';
25
- tickSize: number;
26
- tickPadding: number;
27
- tickFontSize: ConstantAccessor<number>;
28
- tickClass: ConstantAccessor<number>;
26
+ anchor?: 'left' | 'right';
27
+ lineAnchor?: 'top' | 'center' | 'bottom';
28
+ tickSize?: number;
29
+ tickPadding?: number;
30
+ tickFontSize?: ConstantAccessor<number>;
31
+ tickClass?: ConstantAccessor<string>;
29
32
  marginLeft: number;
30
33
  width: number;
31
- title: string | null;
32
- options: {
33
- dx: ConstantAccessor<number>;
34
- dy: ConstantAccessor<number>;
35
- textAnchor: 'start' | 'middle' | 'end';
36
- };
34
+ title?: string | null;
35
+ options: BaseAxisYOptions;
37
36
  plot: PlotState;
38
- text: boolean | null;
37
+ text?: boolean | null;
39
38
  class: string | undefined;
40
39
  };
41
40
 
@@ -44,15 +43,15 @@
44
43
  scaleType,
45
44
  ticks,
46
45
  tickFormat,
47
- anchor,
48
- lineAnchor,
49
- tickSize,
50
- tickPadding,
51
- tickFontSize,
52
- tickClass,
46
+ anchor = 'left',
47
+ lineAnchor = 'center',
48
+ tickSize = 6,
49
+ tickPadding = 3,
50
+ tickFontSize = 11,
51
+ tickClass = null,
53
52
  marginLeft,
54
53
  width,
55
- title,
54
+ title = null,
56
55
  plot,
57
56
  options,
58
57
  text = true,
@@ -63,16 +62,17 @@
63
62
  top: 'hanging',
64
63
  center: 'middle',
65
64
  bottom: 'auto'
66
- };
65
+ } as const;
66
+ const toScaledDatum = (tick: AxisTick) => ({ datum: tick }) as unknown as ScaledDataRecord;
67
67
 
68
68
  const positionedTicks = $derived.by(() => {
69
- let tickObjects = ticks.map((tick, i) => {
70
- const datum = { [RAW_VALUE]: tick, [INDEX]: i };
69
+ let tickObjects: AxisTick[] = ticks.map((tick, i) => {
70
+ const datum: AxisDatum = { [RAW_VALUE]: tick, [INDEX]: i };
71
71
  return {
72
72
  ...datum,
73
73
  hidden: false,
74
- dx: +resolveProp(options.dx, datum, 0),
75
- dy: +resolveProp(options.dy, datum, 0),
74
+ dx: Number(resolveProp(options.dx, datum, 0) ?? 0),
75
+ dy: Number(resolveProp(options.dy, datum, 0) ?? 0),
76
76
  y: scaleFn(tick) + (scaleType === 'band' ? scaleFn.bandwidth() * 0.5 : 0),
77
77
  text: tickFormat(tick, i, ticks),
78
78
  element: null as SVGTextElement | null
@@ -95,7 +95,7 @@
95
95
  return tickObjects;
96
96
  });
97
97
 
98
- let tickTexts = $state([] as SVGTextElement[]);
98
+ let tickTexts = $state([] as (SVGTextElement | undefined)[]);
99
99
 
100
100
  const isQuantitative = $derived(scaleType !== 'point' && scaleType !== 'band');
101
101
 
@@ -122,7 +122,7 @@
122
122
  if (tickTexts[i]) return tickTexts[i].getBoundingClientRect().width;
123
123
  return 0;
124
124
  }) as number[]
125
- )
125
+ ) ?? 0
126
126
  ) + Math.max(0, tickPadding + tickSize);
127
127
 
128
128
  if (!isNaN(maxLabelWidth)) {
@@ -161,7 +161,7 @@
161
161
  {@const tickClass_ = resolveProp(tickClass, tick)}
162
162
  {@const [textStyle, textClass] = resolveStyles(
163
163
  plot,
164
- { datum: tick },
164
+ toScaledDatum(tick),
165
165
  {
166
166
  fontVariant: isQuantitative ? 'tabular-nums' : 'normal',
167
167
  ...options,
@@ -169,7 +169,7 @@
169
169
  stroke: null
170
170
  },
171
171
  'fill',
172
- { y: true },
172
+ { y: true } as any,
173
173
  true
174
174
  )}
175
175
  <g
@@ -180,10 +180,10 @@
180
180
  {#if tickSize}
181
181
  {@const [tickLineStyle, tickLineClass] = resolveStyles(
182
182
  plot,
183
- { datum: tick },
183
+ toScaledDatum(tick),
184
184
  options,
185
185
  'stroke',
186
- { y: true },
186
+ { y: true } as any,
187
187
  true
188
188
  )}
189
189
  <line
@@ -1,25 +1,22 @@
1
- import type { ConstantAccessor, PlotState, RawValue, ScaleType } from '../../types/index.js';
1
+ import type { ConstantAccessor, PlotState, PlotScaleFunction, RawValue, ScaleType } from '../../types/index.js';
2
+ import type { BaseAxisYOptions } from '../../types/axes.js';
2
3
  type BaseAxisYProps = {
3
- scaleFn: (d: RawValue) => number;
4
+ scaleFn: PlotScaleFunction;
4
5
  scaleType: ScaleType;
5
6
  ticks: RawValue[];
6
7
  tickFormat: (d: RawValue, i: number, ticks: RawValue[]) => string | string[];
7
- anchor: 'left' | 'right';
8
- lineAnchor: 'top' | 'center' | 'bottom';
9
- tickSize: number;
10
- tickPadding: number;
11
- tickFontSize: ConstantAccessor<number>;
12
- tickClass: ConstantAccessor<number>;
8
+ anchor?: 'left' | 'right';
9
+ lineAnchor?: 'top' | 'center' | 'bottom';
10
+ tickSize?: number;
11
+ tickPadding?: number;
12
+ tickFontSize?: ConstantAccessor<number>;
13
+ tickClass?: ConstantAccessor<string>;
13
14
  marginLeft: number;
14
15
  width: number;
15
- title: string | null;
16
- options: {
17
- dx: ConstantAccessor<number>;
18
- dy: ConstantAccessor<number>;
19
- textAnchor: 'start' | 'middle' | 'end';
20
- };
16
+ title?: string | null;
17
+ options: BaseAxisYOptions;
21
18
  plot: PlotState;
22
- text: boolean | null;
19
+ text?: boolean | null;
23
20
  class: string | undefined;
24
21
  };
25
22
  declare const BaseAxisY: import("svelte").Component<BaseAxisYProps, {}, "">;
@@ -41,13 +41,13 @@
41
41
  import GroupMultiple from './GroupMultiple.svelte';
42
42
  import { groupX, groupY, BarY, TickY, RuleX, BarX, TickX, RuleY, Dot } from '../../index.js';
43
43
  import { resolveChannel } from '../../helpers/resolve.js';
44
- import type { BaseMarkProps, ChannelAccessor, DataRecord, RawValue } from '../../types';
45
- import { IS_SORTED } from '../../transforms/sort';
44
+ import type { BaseMarkProps, ChannelAccessor, DataRecord, RawValue } from '../../types/index.js';
45
+ import { IS_SORTED } from '../../transforms/sort.js';
46
46
 
47
47
  let markProps: BoxMarkProps = $props();
48
48
 
49
49
  const {
50
- data = [{}],
50
+ data = [] as Datum[],
51
51
  bar,
52
52
  rule,
53
53
  tickMedian,
@@ -89,7 +89,7 @@
89
89
  fy
90
90
  },
91
91
  { [xProp]: 'median', [x1Prop]: 'p25', [x2Prop]: 'p75', fill: (rows) => rows }
92
- )
92
+ ) as { data: any[]; [key: string]: any }
93
93
  );
94
94
 
95
95
  const X = Symbol('x'),
@@ -112,13 +112,15 @@
112
112
  const sortProps = { [IS_SORTED]: true };
113
113
 
114
114
  const compareValues = (a: RawValue, b: RawValue) =>
115
- (typeof a === 'string' && typeof b === 'string'
116
- ? a.localeCompare(b)
117
- : a > b
118
- ? 1
119
- : a < b
120
- ? -1
121
- : 0) || 0;
115
+ (typeof a === 'symbol' || typeof b === 'symbol'
116
+ ? 0
117
+ : typeof a === 'string' && typeof b === 'string'
118
+ ? a.localeCompare(b)
119
+ : (a as number) > (b as number)
120
+ ? 1
121
+ : (a as number) < (b as number)
122
+ ? -1
123
+ : 0) || 0;
122
124
 
123
125
  const boxData = $derived.by(() => {
124
126
  const boxes = grouped
@@ -128,11 +130,11 @@
128
130
  const p75Key = groupChannels[x2Prop];
129
131
  const groupKey = groupChannels[yProp];
130
132
 
131
- const iqr = row[p75Key] - row[p25Key];
133
+ const iqr = (row[p75Key] as number) - (row[p25Key] as number);
132
134
  const whisker = iqr * 1.5;
133
- const lower = row[p25Key] - whisker;
134
- const upper = row[p75Key] + whisker;
135
- const data = row[groupChannels.fill].map((d) => ({
135
+ const lower = (row[p25Key] as number) - whisker;
136
+ const upper = (row[p75Key] as number) + whisker;
137
+ const data = (row[groupChannels.fill] as any[]).map((d) => ({
136
138
  ...d,
137
139
  [orientation === 'y' ? Y : X]: resolveChannel(xProp, d, {
138
140
  x,
@@ -141,10 +143,12 @@
141
143
  }));
142
144
  const valueSym = orientation === 'y' ? Y : X;
143
145
  const groupSym = orientation === 'y' ? X : Y;
144
- const outliers = data.filter((d) => d[valueSym] < lower || d[valueSym] > upper);
146
+ const outliers = data.filter(
147
+ (d: any) => d[valueSym] < lower || d[valueSym] > upper
148
+ );
145
149
  const inside = data
146
- .filter((d) => d[valueSym] >= lower && d[valueSym] <= upper)
147
- .sort((a, b) => a[valueSym] - b[valueSym]);
150
+ .filter((d: any) => d[valueSym] >= lower && d[valueSym] <= upper)
151
+ .sort((a: any, b: any) => a[valueSym] - b[valueSym]);
148
152
 
149
153
  return {
150
154
  ...data[0],
@@ -154,15 +158,18 @@
154
158
  [MEDIAN]: row[medianKey],
155
159
  [P75]: row[p75Key],
156
160
  [MIN]: inside.length ? inside[0][valueSym] : null,
157
- [MAX]: inside.length ? inside.at(-1)[valueSym] : null,
158
- [FX]: resolveChannel('fx', data[0], { fx }, null),
159
- [FY]: resolveChannel('fy', data[0], { fy }, null),
161
+ [MAX]: inside.length ? (inside.at(-1) as any)[valueSym] : null,
162
+ [FX]: resolveChannel('fx', data[0], { fx }),
163
+ [FY]: resolveChannel('fy', data[0], { fy }),
160
164
  [OUTLIERS]: outliers
161
165
  };
162
166
  })
163
167
  .filter(Boolean);
164
168
 
165
- const stripSortRef = ({ [SORT_REF]: _, ...rest }) => rest;
169
+ const stripSortRef = (obj: any) => {
170
+ const { [SORT_REF]: _unused, ...rest } = obj;
171
+ return rest;
172
+ };
166
173
 
167
174
  if (!sort) return boxes.map(stripSortRef);
168
175
 
@@ -170,8 +177,8 @@
170
177
 
171
178
  const sortAccessor =
172
179
  typeof sort === 'function'
173
- ? (d) => sort(d[SORT_REF])
174
- : (d) => {
180
+ ? (d: any) => sort(d[SORT_REF])
181
+ : (d: any) => {
175
182
  switch (sort_) {
176
183
  case 'min':
177
184
  return d[MIN];
@@ -200,7 +207,7 @@
200
207
  function maybeSort(
201
208
  sort: string | ((d: Datum) => RawValue) | undefined
202
209
  ): [string | ((d: Datum) => RawValue), 1 | -1] {
203
- if (typeof sort !== 'string') return [sort, 1];
210
+ if (typeof sort !== 'string') return [sort as (d: Datum) => RawValue, 1];
204
211
  if (sort.startsWith('-')) {
205
212
  return [sort.slice(1), -1];
206
213
  }
@@ -249,18 +256,18 @@
249
256
  {...{ [yProp]: groupSymbol, [xProp]: MIN }}
250
257
  {stroke}
251
258
  {...facets}
252
- inset="20%"
259
+ {...{ inset: '20%' } as any}
253
260
  {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
254
261
  <TickMark
255
262
  data={boxData}
256
263
  {...{ [yProp]: groupSymbol, [xProp]: MAX }}
257
264
  {stroke}
258
265
  {...facets}
259
- inset="20%"
266
+ {...{ inset: '20%' } as any}
260
267
  {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
261
268
  {/if}
262
269
  <Dot
263
- data={boxData.map((d) => d[OUTLIERS]).flat()}
270
+ data={boxData.map((d) => (d as any)[OUTLIERS]).flat()}
264
271
  {x}
265
272
  {y}
266
273
  {fx}
@@ -1,68 +1,140 @@
1
- import type { ChannelAccessor, DataRecord, RawValue } from '../../types';
1
+ import type { ChannelAccessor, DataRecord, RawValue } from '../../types/index.js';
2
2
  declare function $$render<Datum extends DataRecord>(): {
3
3
  props: Pick<Partial<{
4
- filter: import("../../types").ConstantAccessor<boolean, Datum>;
4
+ filter: import("../../types/index.js").ConstantAccessor<boolean, Datum>;
5
5
  facet: "auto" | "include" | "exclude";
6
6
  fx: ChannelAccessor<Datum>;
7
7
  fy: ChannelAccessor<Datum>;
8
- dx: import("../../types").ConstantAccessor<number, Datum>;
9
- dy: import("../../types").ConstantAccessor<number, Datum>;
10
- dodgeX: import("../../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../../transforms/dodge").DodgeYOptions;
8
+ dx: import("../../types/index.js").ConstantAccessor<number, Datum>;
9
+ dy: import("../../types/index.js").ConstantAccessor<number, Datum>;
10
+ dodgeX: import("../../transforms/dodge.js").DodgeXOptions;
11
+ dodgeY: import("../../transforms/dodge.js").DodgeYOptions;
12
12
  fill: ChannelAccessor<Datum>;
13
- fillOpacity: import("../../types").ConstantAccessor<number, Datum>;
13
+ fillOpacity: import("../../types/index.js").ConstantAccessor<number, Datum>;
14
+ fontFamily: import("../../types/index.js").ConstantAccessor<import("csstype").Property.FontFamily, Datum>;
15
+ 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>;
16
+ fontStyle: import("../../types/index.js").ConstantAccessor<import("csstype").Property.FontStyle, Datum>;
17
+ fontVariant: import("../../types/index.js").ConstantAccessor<import("csstype").Property.FontVariant, Datum>;
18
+ fontWeight: import("../../types/index.js").ConstantAccessor<import("csstype").Property.FontWeight, Datum>;
19
+ letterSpacing: import("../../types/index.js").ConstantAccessor<import("csstype").Property.LetterSpacing<0 | (string & {})>, Datum>;
20
+ wordSpacing: import("../../types/index.js").ConstantAccessor<import("csstype").Property.WordSpacing<0 | (string & {})>, Datum>;
21
+ textAnchor: import("../../types/index.js").ConstantAccessor<import("csstype").Property.TextAnchor, Datum>;
22
+ textTransform: import("../../types/index.js").ConstantAccessor<import("csstype").Property.TextTransform, Datum>;
23
+ textDecoration: import("../../types/index.js").ConstantAccessor<import("csstype").Property.TextDecoration<0 | (string & {})>, Datum>;
14
24
  sort: ((a: RawValue, b: RawValue) => number) | {
15
25
  channel: string;
16
26
  order?: "ascending" | "descending";
17
- } | import("../../types").ConstantAccessor<RawValue, Datum>;
27
+ } | import("../../types/index.js").ConstantAccessor<RawValue, Datum>;
18
28
  stroke: ChannelAccessor<Datum>;
19
- strokeWidth: import("../../types").ConstantAccessor<number, Datum>;
20
- strokeOpacity: import("../../types").ConstantAccessor<number, Datum>;
21
- strokeLinejoin: import("../../types").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
22
- strokeLinecap: import("../../types").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
23
- strokeMiterlimit: import("../../types").ConstantAccessor<number, Datum>;
29
+ strokeWidth: import("../../types/index.js").ConstantAccessor<number, Datum>;
30
+ strokeOpacity: import("../../types/index.js").ConstantAccessor<number, Datum>;
31
+ strokeLinejoin: import("../../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
32
+ strokeLinecap: import("../../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
33
+ strokeMiterlimit: import("../../types/index.js").ConstantAccessor<number, Datum>;
24
34
  opacity: ChannelAccessor<Datum>;
25
- strokeDasharray: import("../../types").ConstantAccessor<string, Datum>;
26
- strokeDashoffset: import("../../types").ConstantAccessor<number, Datum>;
27
- mixBlendMode: import("../../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
35
+ strokeDasharray: import("../../types/index.js").ConstantAccessor<string, Datum>;
36
+ strokeDashoffset: import("../../types/index.js").ConstantAccessor<number, Datum>;
37
+ blend: import("../../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
38
+ mixBlendMode: import("../../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
39
  clipPath: string;
29
40
  mask: string;
30
- imageFilter: import("../../types").ConstantAccessor<string, Datum>;
31
- shapeRendering: import("../../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
32
- paintOrder: import("../../types").ConstantAccessor<string, Datum>;
33
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
+ imageFilter: import("../../types/index.js").ConstantAccessor<string, Datum>;
42
+ shapeRendering: import("../../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
43
+ paintOrder: import("../../types/index.js").ConstantAccessor<string, Datum>;
44
+ onclick: (event: Event & {
45
+ currentTarget: SVGPathElement;
46
+ }, datum: Datum, index: number) => void;
47
+ ondblclick: (event: Event & {
48
+ currentTarget: SVGPathElement;
49
+ }, datum: Datum, index: number) => void;
50
+ onmouseup: (event: Event & {
51
+ currentTarget: SVGPathElement;
52
+ }, datum: Datum, index: number) => void;
53
+ onmousedown: (event: Event & {
54
+ currentTarget: SVGPathElement;
55
+ }, datum: Datum, index: number) => void;
56
+ onmouseenter: (event: Event & {
57
+ currentTarget: SVGPathElement;
58
+ }, datum: Datum, index: number) => void;
59
+ onmousemove: (event: Event & {
60
+ currentTarget: SVGPathElement;
61
+ }, datum: Datum, index: number) => void;
62
+ onmouseleave: (event: Event & {
63
+ currentTarget: SVGPathElement;
64
+ }, datum: Datum, index: number) => void;
65
+ onmouseout: (event: Event & {
66
+ currentTarget: SVGPathElement;
67
+ }, datum: Datum, index: number) => void;
68
+ onmouseover: (event: Event & {
69
+ currentTarget: SVGPathElement;
70
+ }, datum: Datum, index: number) => void;
71
+ onpointercancel: (event: Event & {
72
+ currentTarget: SVGPathElement;
73
+ }, datum: Datum, index: number) => void;
74
+ onpointerdown: (event: Event & {
75
+ currentTarget: SVGPathElement;
76
+ }, datum: Datum, index: number) => void;
77
+ onpointerup: (event: Event & {
78
+ currentTarget: SVGPathElement;
79
+ }, datum: Datum, index: number) => void;
80
+ onpointerenter: (event: Event & {
81
+ currentTarget: SVGPathElement;
82
+ }, datum: Datum, index: number) => void;
83
+ onpointerleave: (event: Event & {
84
+ currentTarget: SVGPathElement;
85
+ }, datum: Datum, index: number) => void;
86
+ onpointermove: (event: Event & {
87
+ currentTarget: SVGPathElement;
88
+ }, datum: Datum, index: number) => void;
89
+ onpointerover: (event: Event & {
90
+ currentTarget: SVGPathElement;
91
+ }, datum: Datum, index: number) => void;
92
+ onpointerout: (event: Event & {
93
+ currentTarget: SVGPathElement;
94
+ }, datum: Datum, index: number) => void;
95
+ ondrag: (event: Event & {
96
+ currentTarget: SVGPathElement;
97
+ }, datum: Datum, index: number) => void;
98
+ ondrop: (event: Event & {
99
+ currentTarget: SVGPathElement;
100
+ }, datum: Datum, index: number) => void;
101
+ ondragstart: (event: Event & {
102
+ currentTarget: SVGPathElement;
103
+ }, datum: Datum, index: number) => void;
104
+ ondragenter: (event: Event & {
105
+ currentTarget: SVGPathElement;
106
+ }, datum: Datum, index: number) => void;
107
+ ondragleave: (event: Event & {
108
+ currentTarget: SVGPathElement;
109
+ }, datum: Datum, index: number) => void;
110
+ ondragover: (event: Event & {
111
+ currentTarget: SVGPathElement;
112
+ }, datum: Datum, index: number) => void;
113
+ ondragend: (event: Event & {
114
+ currentTarget: SVGPathElement;
115
+ }, datum: Datum, index: number) => void;
116
+ ontouchstart: (event: Event & {
117
+ currentTarget: SVGPathElement;
118
+ }, datum: Datum, index: number) => void;
119
+ ontouchmove: (event: Event & {
120
+ currentTarget: SVGPathElement;
121
+ }, datum: Datum, index: number) => void;
122
+ ontouchend: (event: Event & {
123
+ currentTarget: SVGPathElement;
124
+ }, datum: Datum, index: number) => void;
125
+ ontouchcancel: (event: Event & {
126
+ currentTarget: SVGPathElement;
127
+ }, datum: Datum, index: number) => void;
128
+ oncontextmenu: (event: Event & {
129
+ currentTarget: SVGPathElement;
130
+ }, datum: Datum, index: number) => void;
131
+ onwheel: (event: Event & {
132
+ currentTarget: SVGPathElement;
133
+ }, datum: Datum, index: number) => void;
63
134
  class: string;
64
135
  style: string;
65
- cursor: import("../../types").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
136
+ cursor: import("../../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
137
+ title: import("../../types/index.js").ConstantAccessor<string, Datum>;
66
138
  }>, "fx" | "fy" | "fill" | "stroke" | "class"> & {
67
139
  data: Datum[];
68
140
  x: ChannelAccessor;
@@ -25,14 +25,15 @@
25
25
  data: ScaledDataRecord[];
26
26
  } = $props();
27
27
 
28
- function drawSymbolPath(symbolType: string, size: number, context) {
28
+ function drawSymbolPath(symbolType: string, size: number, context: CanvasRenderingContext2D) {
29
29
  // maybeSymbol(symbolType).draw(context, size);
30
30
  return d3Symbol(maybeSymbol(symbolType), size).context(context)();
31
31
  }
32
32
 
33
33
  let _markOptions = $state(mark.options);
34
34
 
35
- const renderDots: Attachment = (canvas: HTMLCanvasElement) => {
35
+ const renderDots: Attachment = (canvasEl: Element) => {
36
+ const canvas = canvasEl as HTMLCanvasElement;
36
37
  const context = canvas.getContext('2d');
37
38
 
38
39
  $effect(() => {
@@ -44,8 +45,8 @@
44
45
  if (datum.valid) {
45
46
  let { fill, stroke } = datum;
46
47
 
47
- fill = resolveColor(fill, canvas);
48
- stroke = resolveColor(stroke, canvas);
48
+ fill = resolveColor(fill ?? 'none', canvas) as string;
49
+ stroke = resolveColor(stroke ?? 'none', canvas) as string;
49
50
 
50
51
  if (stroke && stroke !== 'none') {
51
52
  const strokeWidth = resolveProp(
@@ -53,17 +54,18 @@
53
54
  datum.datum,
54
55
  1.6
55
56
  );
56
- context.lineWidth = strokeWidth;
57
+ context.lineWidth = strokeWidth ?? 1.6;
57
58
  }
58
59
 
59
60
  context.fillStyle = fill ? fill : 'none';
60
61
  context.strokeStyle = stroke ? stroke : 'none';
61
- context.translate(datum.x, datum.y);
62
+ context.translate(datum.x ?? 0, datum.y ?? 0);
62
63
 
63
- const size = datum.r * datum.r * Math.PI;
64
+ const r = datum.r ?? 1;
65
+ const size = r * r * Math.PI;
64
66
 
65
67
  context.beginPath();
66
- drawSymbolPath(datum.symbol, size, context);
68
+ drawSymbolPath(datum.symbol ?? 'circle', size, context);
67
69
  context.closePath();
68
70
 
69
71
  const { opacity = 1, fillOpacity = 1, strokeOpacity = 1 } = datum;
@@ -74,7 +76,7 @@
74
76
  if (strokeOpacity != null)
75
77
  context.globalAlpha = (opacity ?? 1) * strokeOpacity;
76
78
  if (stroke && stroke !== 'none') context.stroke();
77
- context.translate(-datum.x, -datum.y);
79
+ context.translate(-(datum.x ?? 0), -(datum.y ?? 0));
78
80
  }
79
81
  }
80
82
  }
@@ -28,11 +28,12 @@
28
28
 
29
29
  const plot = usePlot();
30
30
 
31
- function maybeOpacity(value) {
31
+ function maybeOpacity(value: unknown) {
32
32
  return value == null ? 1 : +value;
33
33
  }
34
34
 
35
- const render: Attachment = (canvas: HTMLCanvasElement) => {
35
+ const render: Attachment = (canvasEl: Element) => {
36
+ const canvas = canvasEl as HTMLCanvasElement;
36
37
  const context = canvas.getContext('2d');
37
38
 
38
39
  $effect(() => {
@@ -44,7 +45,7 @@
44
45
 
45
46
  for (const d of data) {
46
47
  if (!d.valid) continue;
47
- const geometry = resolveProp(mark.options.geometry, d.datum, d.datum);
48
+ const geometry = resolveProp((mark.options as any).geometry, d.datum, d.datum);
48
49
  // untrack the filter test to avoid redrawing when not necessary
49
50
  let { stroke, fill, ...restStyles } = resolveScaledStyleProps(
50
51
  d.datum,
@@ -52,7 +53,7 @@
52
53
  usedScales,
53
54
  plot,
54
55
  GEOJSON_PREFER_STROKE.has(geometry.type) ? 'stroke' : 'fill'
55
- );
56
+ ) as { fill: string; stroke: string } & Record<string, unknown>;
56
57
 
57
58
  const opacity = maybeOpacity(restStyles['opacity']);
58
59
  const fillOpacity = maybeOpacity(restStyles['fill-opacity']);
@@ -62,13 +63,13 @@
62
63
  fill =
63
64
  currentColor ||
64
65
  (currentColor = getComputedStyle(
65
- canvas?.parentElement?.parentElement
66
+ canvas?.parentElement?.parentElement ?? canvas
66
67
  ).getPropertyValue('color'));
67
68
  if (`${stroke}`.toLowerCase() === 'currentcolor')
68
69
  stroke =
69
70
  currentColor ||
70
71
  (currentColor = getComputedStyle(
71
- canvas?.parentElement?.parentElement
72
+ canvas?.parentElement?.parentElement ?? canvas
72
73
  ).getPropertyValue('color'));
73
74
  if (CSS_VAR.test(fill))
74
75
  fill = getComputedStyle(canvas).getPropertyValue(fill.slice(4, -1));