svelteplot 0.8.1 → 0.9.0-pr-311.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 (131) hide show
  1. package/README.md +4 -3
  2. package/dist/Mark.svelte +1 -1
  3. package/dist/Mark.svelte.d.ts +6 -4
  4. package/dist/constants.d.ts +3 -1
  5. package/dist/constants.js +11 -2
  6. package/dist/core/Plot.svelte +4 -4
  7. package/dist/helpers/autoScales.d.ts +1 -1
  8. package/dist/helpers/callWithProps.d.ts +1 -3
  9. package/dist/helpers/callWithProps.js +5 -3
  10. package/dist/helpers/colors.d.ts +9 -12
  11. package/dist/helpers/facets.d.ts +1 -1
  12. package/dist/helpers/getBaseStyles.d.ts +2 -4
  13. package/dist/helpers/index.d.ts +3 -3
  14. package/dist/helpers/projection.js +7 -2
  15. package/dist/helpers/reduce.d.ts +1 -1
  16. package/dist/helpers/scales.d.ts +7 -7
  17. package/dist/helpers/symbols.d.ts +2 -2
  18. package/dist/helpers/time.d.ts +3 -3
  19. package/dist/helpers/typeChecks.d.ts +8 -8
  20. package/dist/hooks/usePlot.svelte.d.ts +51 -0
  21. package/dist/hooks/usePlot.svelte.js +90 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/marks/Area.svelte +3 -5
  25. package/dist/marks/Area.svelte.d.ts +6 -4
  26. package/dist/marks/AreaX.svelte.d.ts +7 -5
  27. package/dist/marks/Arrow.svelte +3 -5
  28. package/dist/marks/Arrow.svelte.d.ts +6 -4
  29. package/dist/marks/AxisX.svelte +2 -3
  30. package/dist/marks/AxisX.svelte.d.ts +7 -5
  31. package/dist/marks/AxisY.svelte +3 -4
  32. package/dist/marks/AxisY.svelte.d.ts +7 -5
  33. package/dist/marks/BarX.svelte +2 -4
  34. package/dist/marks/BarX.svelte.d.ts +6 -4
  35. package/dist/marks/BarY.svelte +2 -4
  36. package/dist/marks/BarY.svelte.d.ts +6 -4
  37. package/dist/marks/BollingerX.svelte.d.ts +2 -76
  38. package/dist/marks/BollingerY.svelte.d.ts +2 -76
  39. package/dist/marks/BoxX.svelte +4 -138
  40. package/dist/marks/BoxY.svelte +20 -137
  41. package/dist/marks/BoxY.svelte.d.ts +6 -64
  42. package/dist/marks/Brush.svelte +3 -3
  43. package/dist/marks/Brush.svelte.d.ts +1 -63
  44. package/dist/marks/Cell.svelte +2 -4
  45. package/dist/marks/Cell.svelte.d.ts +6 -4
  46. package/dist/marks/ColorLegend.svelte +2 -4
  47. package/dist/marks/CustomMark.svelte.d.ts +2 -84
  48. package/dist/marks/CustomMarkHTML.svelte +5 -10
  49. package/dist/marks/DifferenceY.svelte +3 -5
  50. package/dist/marks/DifferenceY.svelte.d.ts +1 -63
  51. package/dist/marks/Dot.svelte +4 -5
  52. package/dist/marks/Dot.svelte.d.ts +6 -4
  53. package/dist/marks/DotX.svelte.d.ts +7 -5
  54. package/dist/marks/DotY.svelte.d.ts +7 -5
  55. package/dist/marks/Frame.svelte +3 -9
  56. package/dist/marks/Frame.svelte.d.ts +7 -5
  57. package/dist/marks/Geo.svelte +5 -5
  58. package/dist/marks/Geo.svelte.d.ts +7 -4
  59. package/dist/marks/GridX.svelte +3 -10
  60. package/dist/marks/GridX.svelte.d.ts +6 -4
  61. package/dist/marks/GridY.svelte +3 -4
  62. package/dist/marks/GridY.svelte.d.ts +6 -4
  63. package/dist/marks/HTMLTooltip.svelte +5 -5
  64. package/dist/marks/Image.svelte.d.ts +2 -75
  65. package/dist/marks/Line.svelte +7 -6
  66. package/dist/marks/Line.svelte.d.ts +6 -4
  67. package/dist/marks/LineX.svelte.d.ts +8 -6
  68. package/dist/marks/LineY.svelte.d.ts +8 -6
  69. package/dist/marks/Link.svelte +2 -4
  70. package/dist/marks/Link.svelte.d.ts +6 -4
  71. package/dist/marks/Pointer.svelte +4 -4
  72. package/dist/marks/Rect.svelte +2 -4
  73. package/dist/marks/Rect.svelte.d.ts +6 -4
  74. package/dist/marks/RectX.svelte +4 -4
  75. package/dist/marks/RectY.svelte +4 -4
  76. package/dist/marks/RuleX.svelte +2 -4
  77. package/dist/marks/RuleX.svelte.d.ts +6 -4
  78. package/dist/marks/RuleY.svelte +2 -4
  79. package/dist/marks/RuleY.svelte.d.ts +6 -4
  80. package/dist/marks/Spike.svelte.d.ts +7 -5
  81. package/dist/marks/SymbolLegend.svelte +2 -4
  82. package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
  83. package/dist/marks/Text.svelte.d.ts +6 -4
  84. package/dist/marks/TickX.svelte +2 -3
  85. package/dist/marks/TickX.svelte.d.ts +6 -4
  86. package/dist/marks/TickY.svelte +2 -3
  87. package/dist/marks/TickY.svelte.d.ts +6 -4
  88. package/dist/marks/Trail.svelte +161 -0
  89. package/dist/marks/Trail.svelte.d.ts +44 -0
  90. package/dist/marks/Vector.svelte +3 -4
  91. package/dist/marks/Vector.svelte.d.ts +6 -4
  92. package/dist/marks/WaffleX.svelte +3 -4
  93. package/dist/marks/WaffleX.svelte.d.ts +2 -85
  94. package/dist/marks/WaffleY.svelte +2 -4
  95. package/dist/marks/WaffleY.svelte.d.ts +2 -83
  96. package/dist/marks/helpers/AreaCanvas.svelte +2 -4
  97. package/dist/marks/helpers/Box.svelte +271 -0
  98. package/dist/marks/helpers/Box.svelte.d.ts +55 -0
  99. package/dist/marks/helpers/CanvasLayer.svelte +2 -4
  100. package/dist/marks/helpers/DotCanvas.svelte +3 -5
  101. package/dist/marks/helpers/GeoCanvas.svelte +2 -4
  102. package/dist/marks/helpers/LineCanvas.svelte +2 -4
  103. package/dist/marks/helpers/LinearGradientX.svelte +3 -4
  104. package/dist/marks/helpers/LinearGradientY.svelte +3 -4
  105. package/dist/marks/helpers/MarkerPath.svelte +4 -5
  106. package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -102
  107. package/dist/marks/helpers/MultilineText.svelte +4 -4
  108. package/dist/marks/helpers/RectPath.svelte +5 -6
  109. package/dist/marks/helpers/Regression.svelte +4 -8
  110. package/dist/marks/helpers/TrailCanvas.svelte +138 -0
  111. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
  112. package/dist/marks/helpers/events.d.ts +2 -2
  113. package/dist/marks/helpers/events.js +4 -4
  114. package/dist/marks/helpers/trail.d.ts +23 -0
  115. package/dist/marks/helpers/trail.js +372 -0
  116. package/dist/marks/index.d.ts +1 -0
  117. package/dist/marks/index.js +1 -0
  118. package/dist/transforms/bollinger.d.ts +1 -69
  119. package/dist/transforms/centroid.d.ts +1 -4
  120. package/dist/transforms/group.d.ts +4 -12
  121. package/dist/transforms/interval.d.ts +2 -128
  122. package/dist/transforms/normalize.d.ts +23 -0
  123. package/dist/transforms/recordize.d.ts +4 -7
  124. package/dist/transforms/select.d.ts +7 -448
  125. package/dist/transforms/sort.d.ts +5 -253
  126. package/dist/transforms/stack.d.ts +3 -23
  127. package/dist/transforms/window.d.ts +2 -134
  128. package/dist/types/mark.d.ts +2 -1
  129. package/dist/types/plot.d.ts +6 -1
  130. package/dist/ui/Spiral.svelte +4 -0
  131. package/package.json +25 -23
@@ -4,159 +4,25 @@
4
4
 
5
5
  <script lang="ts">
6
6
  interface BoxXMarkProps extends ComponentProps<typeof BoxY> {}
7
- import GroupMultiple from './helpers/GroupMultiple.svelte';
8
- import { BarX, TickX, RuleY, Dot, groupY } from '../index.js';
9
- import { resolveChannel } from '../helpers/resolve.js';
10
7
  import { type ComponentProps } from 'svelte';
8
+ import Box from './helpers/Box.svelte';
11
9
  import type BoxY from './BoxY.svelte';
12
10
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
13
- import { IS_SORTED } from '../transforms/sort';
14
- import { sort } from 'd3-array';
15
11
 
16
12
  let markProps: BoxXMarkProps = $props();
17
13
 
18
14
  const DEFAULTS = {
19
15
  tickMedian: true,
20
16
  tickMinMax: false,
17
+ sort: 'median',
21
18
  ...getPlotDefaults().box,
22
19
  ...getPlotDefaults().boxX
23
20
  };
24
21
 
25
- const {
26
- data = [{}],
27
- bar,
28
- rule,
29
- tickMedian,
30
- tickMinMax,
31
- dot,
32
- x,
33
- y,
34
- fx,
35
- fy,
36
- fill,
37
- stroke,
38
- class: className = ''
39
- }: BoxXMarkProps = $derived({
22
+ const props: BoxXMarkProps & { class?: string } = $derived({
40
23
  ...DEFAULTS,
41
24
  ...markProps
42
25
  });
43
-
44
- const { data: grouped, ...groupChannels } = $derived(
45
- groupY(
46
- {
47
- data: data.filter((d) => resolveChannel('x', d, { x, y }) != null),
48
- x,
49
- y,
50
- x1: x,
51
- x2: x,
52
- fx,
53
- fy
54
- },
55
- { x: 'median', x1: 'p25', x2: 'p75', fill: (rows) => rows }
56
- )
57
- );
58
-
59
- const X = Symbol('x'),
60
- Y = Symbol('y'),
61
- FX = Symbol('fx'),
62
- FY = Symbol('fy'),
63
- P25 = Symbol('p25'),
64
- P75 = Symbol('p75'),
65
- MEDIAN = Symbol('median'),
66
- MIN = Symbol('min'),
67
- MAX = Symbol('max'),
68
- OUTLIERS = Symbol('outliers');
69
-
70
- const facets = $derived({
71
- ...(fx != null && { fx: FX }),
72
- ...(fy != null && { fy: FY })
73
- });
74
-
75
- const sortProps = { [IS_SORTED]: true };
76
-
77
- const boxData = $derived(
78
- grouped
79
- .map((row) => {
80
- const { x: median, x1: p25, x2: p75, fill: fill, y: ry } = groupChannels;
81
-
82
- const iqr = row[p75] - row[p25];
83
- const whisker = iqr * 1.5;
84
- const lower = row[p25] - whisker;
85
- const upper = row[p75] + whisker;
86
- const data = row[fill].map((d) => ({
87
- ...d,
88
- [X]: resolveChannel('x', d, { x, y })
89
- }));
90
- const outliers = data.filter((d) => d[X] < lower || d[X] > upper);
91
- const inside = data
92
- .filter((d) => d[X] >= lower && d[X] <= upper)
93
- .sort((a, b) => a[X] - b[X]);
94
-
95
- // if (inside.length === 0) console.log('No data inside boxplot', data, row, lower, upper);
96
- return {
97
- ...data[0],
98
- [Y]: row[ry],
99
- [P25]: row[p25],
100
- [MEDIAN]: row[median],
101
- [P75]: row[p75],
102
- [MIN]: inside[0][X],
103
- [MAX]: inside.at(-1)[X],
104
- [FX]: resolveChannel('fx', data[0], { fx }, null),
105
- [FY]: resolveChannel('fy', data[0], { fy }, null),
106
- [OUTLIERS]: outliers
107
- };
108
- })
109
- .sort((a, b) => b[MEDIAN] - a[MEDIAN])
110
- );
111
26
  </script>
112
27
 
113
- <GroupMultiple class="box-x {className || ''}" length={className ? 2 : grouped.length}>
114
- <RuleY
115
- data={boxData}
116
- y={Y}
117
- x1={MIN}
118
- x2={P25}
119
- {stroke}
120
- {...rule || {}}
121
- {...facets}
122
- {...sortProps} />
123
- <RuleY data={boxData} y={Y} x1={P75} x2={MAX} {stroke} {...rule || {}} {...facets} />
124
- <BarX data={boxData} y={Y} x1={P25} x2={P75} {fill} {stroke} {...facets} {...bar || {}} />
125
- {#if tickMedian}
126
- <TickX
127
- data={boxData}
128
- y={Y}
129
- x={MEDIAN}
130
- {...facets}
131
- {stroke}
132
- strokeWidth={2}
133
- {...typeof tickMedian === 'object' ? tickMedian : {}} />
134
- {/if}
135
- {#if tickMinMax}
136
- <TickX
137
- data={boxData}
138
- x={MIN}
139
- y={Y}
140
- {stroke}
141
- {...facets}
142
- inset="20%"
143
- {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
144
- <TickX
145
- data={boxData}
146
- x={MAX}
147
- y={Y}
148
- {stroke}
149
- {...facets}
150
- inset="20%"
151
- {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
152
- {/if}
153
- <Dot
154
- data={boxData.map((d) => d[OUTLIERS]).flat()}
155
- {x}
156
- {y}
157
- {fx}
158
- {fy}
159
- {fill}
160
- {stroke}
161
- {...dot || {}} />
162
- </GroupMultiple>
28
+ <Box {...props} orientation="x" />
@@ -9,6 +9,21 @@
9
9
  data: Datum[];
10
10
  x: ChannelAccessor;
11
11
  y: ChannelAccessor;
12
+ /**
13
+ * Custom sort order for grouped box plot data
14
+ */
15
+ sort?:
16
+ | 'min'
17
+ | 'max'
18
+ | 'median'
19
+ | 'p25'
20
+ | 'p75'
21
+ | '-min'
22
+ | '-max'
23
+ | '-median'
24
+ | '-p25'
25
+ | '-p75'
26
+ | ((d: Datum) => RawValue);
12
27
  /**
13
28
  * Options for the rule marks that represent the min/max range
14
29
  */
@@ -30,156 +45,24 @@
30
45
  */
31
46
  dot: Record<string, ChannelAccessor<Datum>>;
32
47
  }
33
- import GroupMultiple from './helpers/GroupMultiple.svelte';
34
- import { groupX, BarY, TickY, RuleX, Dot } from '../index.js';
35
- import { resolveChannel } from '../helpers/resolve.js';
36
48
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
37
- import type { BaseMarkProps, ChannelAccessor, DataRecord } from '../types';
38
- import { IS_SORTED } from '../transforms/sort';
49
+ import Box from './helpers/Box.svelte';
50
+ import type { BaseMarkProps, ChannelAccessor, DataRecord, RawValue } from '../types';
39
51
 
40
52
  let markProps: BoxYMarkProps = $props();
41
53
 
42
54
  const DEFAULTS = {
43
55
  tickMedian: true,
44
56
  tickMinMax: false,
57
+ sort: 'median',
45
58
  ...getPlotDefaults().box,
46
59
  ...getPlotDefaults().boxY
47
60
  };
48
61
 
49
- const {
50
- data = [{}],
51
- bar,
52
- rule,
53
- tickMedian,
54
- tickMinMax,
55
- dot,
56
- x,
57
- y,
58
- fx,
59
- fy,
60
- fill,
61
- stroke,
62
- class: className = ''
63
- }: BoxYMarkProps = $derived({
62
+ const props: BoxYMarkProps & { class?: string } = $derived({
64
63
  ...DEFAULTS,
65
64
  ...markProps
66
65
  });
67
-
68
- const { data: grouped, ...groupChannels } = $derived(
69
- groupX(
70
- {
71
- data: data.filter((d) => resolveChannel('x', d, { x, y }) != null),
72
- x,
73
- y,
74
- y1: y,
75
- y2: y,
76
- fx,
77
- fy
78
- },
79
- { y: 'median', y1: 'p25', y2: 'p75', fill: (rows) => rows }
80
- )
81
- );
82
-
83
- const X = Symbol('x'),
84
- Y = Symbol('y'),
85
- FX = Symbol('fx'),
86
- FY = Symbol('fy'),
87
- P25 = Symbol('p25'),
88
- P75 = Symbol('p75'),
89
- MEDIAN = Symbol('median'),
90
- MIN = Symbol('min'),
91
- MAX = Symbol('max'),
92
- OUTLIERS = Symbol('outliers');
93
-
94
- const facets = $derived({
95
- ...(fx != null && { fx: FX }),
96
- ...(fy != null && { fy: FY })
97
- });
98
-
99
- const sortProps = { [IS_SORTED]: true };
100
-
101
- const boxData = $derived(
102
- grouped
103
- .map((row) => {
104
- const { y: median, y1: p25, y2: p75, fill: fill, x: rx } = groupChannels;
105
-
106
- const iqr = row[p75] - row[p25];
107
- const whisker = iqr * 1.5;
108
- const lower = row[p25] - whisker;
109
- const upper = row[p75] + whisker;
110
- const data = row[fill].map((d) => ({
111
- ...d,
112
- [Y]: resolveChannel('y', d, { x, y })
113
- }));
114
- const outliers = data.filter((d) => d[Y] < lower || d[Y] > upper);
115
- const inside = data
116
- .filter((d) => d[Y] >= lower && d[Y] <= upper)
117
- .sort((a, b) => a[Y] - b[Y]);
118
-
119
- return {
120
- ...data[0],
121
- [X]: row[rx],
122
- [P25]: row[p25],
123
- [MEDIAN]: row[median],
124
- [P75]: row[p75],
125
- [MIN]: inside[0][Y],
126
- [MAX]: inside.at(-1)[Y],
127
- [FX]: resolveChannel('fx', data[0], { fx }, null),
128
- [FY]: resolveChannel('fy', data[0], { fy }, null),
129
- [OUTLIERS]: outliers
130
- };
131
- })
132
- .sort((a, b) => b[MEDIAN] - a[MEDIAN])
133
- );
134
66
  </script>
135
67
 
136
- <GroupMultiple class="box-y {className || ''}" length={className ? 2 : grouped.length}>
137
- <RuleX
138
- data={boxData}
139
- x={X}
140
- y1={MIN}
141
- y2={P25}
142
- {stroke}
143
- {...sortProps}
144
- {...rule || {}}
145
- {...facets} />
146
- <RuleX data={boxData} x={X} y1={P75} y2={MAX} {stroke} {...rule || {}} {...facets} />
147
- <BarY data={boxData} x={X} y1={P25} y2={P75} {fill} {stroke} {...facets} {...bar || {}} />
148
- {#if tickMedian}
149
- <TickY
150
- data={boxData}
151
- x={X}
152
- y={MEDIAN}
153
- {...facets}
154
- {stroke}
155
- strokeWidth={2}
156
- {...typeof tickMedian === 'object' ? tickMedian : {}} />
157
- {/if}
158
- {#if tickMinMax}
159
- <TickY
160
- data={boxData}
161
- x={X}
162
- y={MIN}
163
- {stroke}
164
- {...facets}
165
- inset="20%"
166
- {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
167
- <TickY
168
- data={boxData}
169
- x={X}
170
- y={MAX}
171
- {stroke}
172
- {...facets}
173
- inset="20%"
174
- {...typeof tickMinMax === 'object' ? tickMinMax : {}} />
175
- {/if}
176
- <Dot
177
- data={boxData.map((d) => d[OUTLIERS]).flat()}
178
- {x}
179
- {y}
180
- {fx}
181
- {fy}
182
- {fill}
183
- {stroke}
184
- {...dot || {}} />
185
- </GroupMultiple>
68
+ <Box {...props} orientation="y" />
@@ -1,71 +1,13 @@
1
- import type { ChannelAccessor, DataRecord } from '../types';
1
+ import type { ChannelAccessor, DataRecord, RawValue } from '../types';
2
2
  declare function $$render<Datum extends DataRecord>(): {
3
- props: Pick<Partial<{
4
- filter: import("../types").ConstantAccessor<boolean, Datum>;
5
- facet: "auto" | "include" | "exclude";
6
- fx: ChannelAccessor<Datum>;
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;
12
- fill: ChannelAccessor<Datum>;
13
- fillOpacity: import("../types").ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types").RawValue, b: import("../types").RawValue) => number) | {
15
- channel: string;
16
- order?: "ascending" | "descending";
17
- } | import("../types").ConstantAccessor<import("../types").RawValue, Datum>;
18
- 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>;
24
- 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>;
28
- clipPath: string;
29
- imageFilter: import("../types").ConstantAccessor<string, Datum>;
30
- shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
- paintOrder: import("../types").ConstantAccessor<string, Datum>;
32
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- class: string;
63
- style: string;
64
- cursor: import("../types").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
65
- }>, "fx" | "fy" | "fill" | "stroke" | "class"> & {
3
+ props: Pick<BaseMarkProps<Datum>, "fill" | "stroke" | "fx" | "fy" | "class"> & {
66
4
  data: Datum[];
67
5
  x: ChannelAccessor;
68
6
  y: ChannelAccessor;
7
+ /**
8
+ * Custom sort order for grouped box plot data
9
+ */
10
+ sort?: "min" | "max" | "median" | "p25" | "p75" | "-min" | "-max" | "-median" | "-p25" | "-p75" | ((d: Datum) => RawValue);
69
11
  /**
70
12
  * Options for the rule marks that represent the min/max range
71
13
  */
@@ -34,10 +34,11 @@
34
34
  }
35
35
  import { getContext, untrack } from 'svelte';
36
36
  import Rect from './Rect.svelte';
37
- import type { BaseMarkProps, DataRecord, PlotContext } from '../types/index.js';
37
+ import type { BaseMarkProps, DataRecord } from '../types/index.js';
38
38
  import { clientToLayerCoordinates } from './helpers/events.js';
39
39
  import Frame from './Frame.svelte';
40
40
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
41
+ import { usePlot } from '../hooks/usePlot.svelte.js';
41
42
 
42
43
  let { brush: brushExternal = $bindable({ enabled: false }), ...markProps }: BrushMarkProps =
43
44
  $props();
@@ -85,8 +86,7 @@
85
86
  ...markProps
86
87
  });
87
88
 
88
- const { getPlotState } = getContext<PlotContext>('svelteplot');
89
- const plot = $derived(getPlotState());
89
+ const plot = usePlot();
90
90
 
91
91
  const xScaleFn = $derived(plot.scales.x.fn);
92
92
  const yScaleFn = $derived(plot.scales.y.fn);
@@ -1,68 +1,6 @@
1
1
  import type { DataRecord } from '../types/index.js';
2
2
  declare function $$render<Datum extends DataRecord>(): {
3
- props: Pick<Partial<{
4
- filter: import("../types/index.js").ConstantAccessor<boolean, Datum>;
5
- facet: "auto" | "include" | "exclude";
6
- fx: import("../types/index.js").ChannelAccessor<Datum>;
7
- fy: import("../types/index.js").ChannelAccessor<Datum>;
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
- fill: import("../types/index.js").ChannelAccessor<Datum>;
13
- fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
15
- channel: string;
16
- order?: "ascending" | "descending";
17
- } | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Datum>;
18
- stroke: import("../types/index.js").ChannelAccessor<Datum>;
19
- strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
20
- strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
21
- strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
22
- strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
23
- strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Datum>;
24
- opacity: import("../types/index.js").ChannelAccessor<Datum>;
25
- strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
26
- strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
27
- mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
- clipPath: string;
29
- imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
30
- shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
- paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
32
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- class: string;
63
- style: string;
64
- cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
65
- }>, "stroke" | "strokeWidth" | "strokeOpacity" | "strokeLinejoin" | "strokeLinecap" | "strokeMiterlimit" | "strokeDasharray" | "strokeDashoffset" | "cursor"> & {
3
+ props: Pick<BaseMarkProps<Datum>, "stroke" | "strokeOpacity" | "strokeDasharray" | "strokeLinejoin" | "strokeLinecap" | "cursor" | "strokeWidth" | "strokeMiterlimit" | "strokeDashoffset"> & {
66
4
  brush: {
67
5
  x1?: number | Date;
68
6
  x2?: number | Date;
@@ -10,7 +10,6 @@
10
10
  y?: ChannelAccessor<Datum>;
11
11
  }
12
12
  import type {
13
- PlotContext,
14
13
  DataRecord,
15
14
  BaseMarkProps,
16
15
  BaseRectMarkProps,
@@ -18,13 +17,13 @@
18
17
  LinkableMarkProps
19
18
  } from '../types/index.js';
20
19
  import Mark from '../Mark.svelte';
21
- import { getContext } from 'svelte';
22
20
  import { recordizeY, sort } from '../index.js';
23
21
  import { resolveChannel } from '../helpers/resolve.js';
24
22
 
25
23
  import { isValid } from '../helpers/index.js';
26
24
  import RectPath from './helpers/RectPath.svelte';
27
25
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
26
+ import { usePlot } from '../hooks/usePlot.svelte.js';
28
27
 
29
28
  let markProps: CellMarkProps = $props();
30
29
 
@@ -41,8 +40,7 @@
41
40
  ...markProps
42
41
  });
43
42
 
44
- const { getPlotState } = getContext<PlotContext>('svelteplot');
45
- const plot = $derived(getPlotState());
43
+ const plot = usePlot();
46
44
 
47
45
  const args = $derived(
48
46
  options.sort !== undefined
@@ -1,4 +1,5 @@
1
1
  import type { DataRecord, BaseRectMarkProps, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
2
+ import { recordizeY } from '../index.js';
2
3
  declare function $$render<Datum extends DataRecord>(): {
3
4
  props: Partial<{
4
5
  filter: import("../types/index.js").ConstantAccessor<boolean, Datum>;
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRecord>(): {
7
8
  fy: ChannelAccessor<Datum>;
8
9
  dx: import("../types/index.js").ConstantAccessor<number, Datum>;
9
10
  dy: import("../types/index.js").ConstantAccessor<number, Datum>;
10
- dodgeX: import("../transforms/dodge.js").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge.js").DodgeYOptions;
11
+ dodgeX: recordizeY;
12
+ dodgeY: recordizeY;
12
13
  fill: ChannelAccessor<Datum>;
13
14
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
18
+ } | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
18
19
  stroke: ChannelAccessor<Datum>;
19
20
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
20
21
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
26
27
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
27
28
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
30
32
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
33
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -2,7 +2,6 @@
2
2
  interface ColorLegendMarkProps {
3
3
  class: string | null;
4
4
  }
5
- import { getContext } from 'svelte';
6
5
  import Plot from '../Plot.svelte';
7
6
  import AxisX from './AxisX.svelte';
8
7
  import Frame from './Frame.svelte';
@@ -10,13 +9,12 @@
10
9
  import { range as d3Range, extent } from 'd3-array';
11
10
  import { maybeSymbol } from '../helpers/symbols.js';
12
11
 
13
- import type { PlotContext } from '../types/plot.js';
14
12
  import { getPlotDefaults } from '../hooks/plotDefaults';
13
+ import { usePlot } from '../hooks/usePlot.svelte.js';
15
14
 
16
15
  let { class: className = null }: ColorLegendMarkProps = $props();
17
16
 
18
- const { getPlotState } = getContext<PlotContext>('svelteplot');
19
- const plot = $derived(getPlotState());
17
+ const plot = usePlot();
20
18
 
21
19
  const DEFAULTS = getPlotDefaults();
22
20