svelteplot 0.8.1 → 0.9.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.
- package/README.md +1 -1
- package/dist/Mark.svelte +1 -1
- package/dist/Mark.svelte.d.ts +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/core/Plot.svelte +4 -4
- package/dist/helpers/projection.js +7 -2
- package/dist/hooks/usePlot.svelte.d.ts +51 -0
- package/dist/hooks/usePlot.svelte.js +90 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/marks/Area.svelte +3 -5
- package/dist/marks/Area.svelte.d.ts +1 -0
- package/dist/marks/AreaX.svelte.d.ts +1 -0
- package/dist/marks/Arrow.svelte +3 -5
- package/dist/marks/Arrow.svelte.d.ts +1 -0
- package/dist/marks/AxisX.svelte +2 -3
- package/dist/marks/AxisX.svelte.d.ts +1 -0
- package/dist/marks/AxisY.svelte +3 -4
- package/dist/marks/AxisY.svelte.d.ts +1 -0
- package/dist/marks/BarX.svelte +2 -4
- package/dist/marks/BarX.svelte.d.ts +1 -0
- package/dist/marks/BarY.svelte +2 -4
- package/dist/marks/BarY.svelte.d.ts +1 -0
- package/dist/marks/BollingerX.svelte.d.ts +1 -0
- package/dist/marks/BollingerY.svelte.d.ts +1 -0
- package/dist/marks/BoxX.svelte +4 -138
- package/dist/marks/BoxY.svelte +20 -137
- package/dist/marks/BoxY.svelte.d.ts +8 -3
- package/dist/marks/Brush.svelte +3 -3
- package/dist/marks/Brush.svelte.d.ts +1 -0
- package/dist/marks/Cell.svelte +2 -4
- package/dist/marks/Cell.svelte.d.ts +1 -0
- package/dist/marks/ColorLegend.svelte +2 -4
- package/dist/marks/CustomMark.svelte.d.ts +1 -0
- package/dist/marks/CustomMarkHTML.svelte +5 -10
- package/dist/marks/DifferenceY.svelte +3 -5
- package/dist/marks/DifferenceY.svelte.d.ts +1 -0
- package/dist/marks/Dot.svelte +4 -5
- package/dist/marks/Dot.svelte.d.ts +1 -0
- package/dist/marks/DotX.svelte.d.ts +1 -0
- package/dist/marks/DotY.svelte.d.ts +1 -0
- package/dist/marks/Frame.svelte +3 -9
- package/dist/marks/Frame.svelte.d.ts +1 -0
- package/dist/marks/Geo.svelte +5 -5
- package/dist/marks/Geo.svelte.d.ts +2 -0
- package/dist/marks/GridX.svelte +3 -10
- package/dist/marks/GridX.svelte.d.ts +1 -0
- package/dist/marks/GridY.svelte +3 -4
- package/dist/marks/GridY.svelte.d.ts +1 -0
- package/dist/marks/HTMLTooltip.svelte +5 -5
- package/dist/marks/Image.svelte.d.ts +1 -0
- package/dist/marks/Line.svelte +7 -6
- package/dist/marks/Line.svelte.d.ts +1 -0
- package/dist/marks/LineX.svelte.d.ts +1 -0
- package/dist/marks/LineY.svelte.d.ts +1 -0
- package/dist/marks/Link.svelte +2 -4
- package/dist/marks/Link.svelte.d.ts +1 -0
- package/dist/marks/Pointer.svelte +4 -4
- package/dist/marks/Rect.svelte +2 -4
- package/dist/marks/Rect.svelte.d.ts +1 -0
- package/dist/marks/RectX.svelte +4 -4
- package/dist/marks/RectY.svelte +4 -4
- package/dist/marks/RuleX.svelte +2 -4
- package/dist/marks/RuleX.svelte.d.ts +1 -0
- package/dist/marks/RuleY.svelte +2 -4
- package/dist/marks/RuleY.svelte.d.ts +1 -0
- package/dist/marks/Spike.svelte.d.ts +1 -0
- package/dist/marks/SymbolLegend.svelte +2 -4
- package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
- package/dist/marks/Text.svelte.d.ts +1 -0
- package/dist/marks/TickX.svelte +2 -3
- package/dist/marks/TickX.svelte.d.ts +1 -0
- package/dist/marks/TickY.svelte +2 -3
- package/dist/marks/TickY.svelte.d.ts +1 -0
- package/dist/marks/Trail.svelte +161 -0
- package/dist/marks/Trail.svelte.d.ts +107 -0
- package/dist/marks/Vector.svelte +3 -4
- package/dist/marks/Vector.svelte.d.ts +1 -0
- package/dist/marks/WaffleX.svelte +2 -3
- package/dist/marks/WaffleX.svelte.d.ts +1 -0
- package/dist/marks/WaffleY.svelte +2 -4
- package/dist/marks/WaffleY.svelte.d.ts +1 -0
- package/dist/marks/helpers/AreaCanvas.svelte +2 -4
- package/dist/marks/helpers/Box.svelte +271 -0
- package/dist/marks/helpers/Box.svelte.d.ts +118 -0
- package/dist/marks/helpers/CanvasLayer.svelte +2 -4
- package/dist/marks/helpers/DotCanvas.svelte +3 -5
- package/dist/marks/helpers/GeoCanvas.svelte +2 -4
- package/dist/marks/helpers/LineCanvas.svelte +2 -4
- package/dist/marks/helpers/LinearGradientX.svelte +3 -4
- package/dist/marks/helpers/LinearGradientY.svelte +3 -4
- package/dist/marks/helpers/MarkerPath.svelte +4 -5
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -0
- package/dist/marks/helpers/MultilineText.svelte +4 -4
- package/dist/marks/helpers/RectPath.svelte +5 -6
- package/dist/marks/helpers/Regression.svelte +4 -8
- package/dist/marks/helpers/TrailCanvas.svelte +138 -0
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
- package/dist/marks/helpers/events.d.ts +2 -2
- package/dist/marks/helpers/events.js +4 -4
- package/dist/marks/helpers/trail.d.ts +23 -0
- package/dist/marks/helpers/trail.js +372 -0
- package/dist/marks/index.d.ts +1 -0
- package/dist/marks/index.js +1 -0
- package/dist/transforms/bollinger.d.ts +1 -0
- package/dist/transforms/interval.d.ts +2 -0
- package/dist/transforms/select.d.ts +7 -0
- package/dist/transforms/sort.d.ts +4 -0
- package/dist/transforms/window.d.ts +2 -0
- package/dist/types/mark.d.ts +2 -1
- package/dist/types/plot.d.ts +6 -1
- package/dist/ui/Spiral.svelte +4 -0
- package/package.json +24 -23
package/dist/marks/BoxX.svelte
CHANGED
|
@@ -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
|
-
<
|
|
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" />
|
package/dist/marks/BoxY.svelte
CHANGED
|
@@ -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
|
|
38
|
-
import {
|
|
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
|
-
<
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import type { ChannelAccessor, DataRecord } from '../types';
|
|
1
|
+
import type { ChannelAccessor, DataRecord, RawValue } from '../types';
|
|
2
2
|
declare function $$render<Datum extends DataRecord>(): {
|
|
3
3
|
props: Pick<Partial<{
|
|
4
4
|
filter: import("../types").ConstantAccessor<boolean, Datum>;
|
|
@@ -11,10 +11,10 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
11
11
|
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
12
12
|
fill: ChannelAccessor<Datum>;
|
|
13
13
|
fillOpacity: import("../types").ConstantAccessor<number, Datum>;
|
|
14
|
-
sort: ((a:
|
|
14
|
+
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
15
15
|
channel: string;
|
|
16
16
|
order?: "ascending" | "descending";
|
|
17
|
-
} | import("../types").ConstantAccessor<
|
|
17
|
+
} | import("../types").ConstantAccessor<RawValue, Datum>;
|
|
18
18
|
stroke: ChannelAccessor<Datum>;
|
|
19
19
|
strokeWidth: import("../types").ConstantAccessor<number, Datum>;
|
|
20
20
|
strokeOpacity: import("../types").ConstantAccessor<number, Datum>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: import("../types").ConstantAccessor<string, Datum>;
|
|
@@ -66,6 +67,10 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
66
67
|
data: Datum[];
|
|
67
68
|
x: ChannelAccessor;
|
|
68
69
|
y: ChannelAccessor;
|
|
70
|
+
/**
|
|
71
|
+
* Custom sort order for grouped box plot data
|
|
72
|
+
*/
|
|
73
|
+
sort?: "min" | "max" | "median" | "p25" | "p75" | "-min" | "-max" | "-median" | "-p25" | "-p75" | ((d: Datum) => RawValue);
|
|
69
74
|
/**
|
|
70
75
|
* Options for the rule marks that represent the min/max range
|
|
71
76
|
*/
|
package/dist/marks/Brush.svelte
CHANGED
|
@@ -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
|
|
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
|
|
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);
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/Cell.svelte
CHANGED
|
@@ -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
|
|
45
|
-
const plot = $derived(getPlotState());
|
|
43
|
+
const plot = usePlot();
|
|
46
44
|
|
|
47
45
|
const args = $derived(
|
|
48
46
|
options.sort !== undefined
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
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
|
|
19
|
-
const plot = $derived(getPlotState());
|
|
17
|
+
const plot = usePlot();
|
|
20
18
|
|
|
21
19
|
const DEFAULTS = getPlotDefaults();
|
|
22
20
|
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -23,21 +23,16 @@
|
|
|
23
23
|
class: string | null;
|
|
24
24
|
children: Snippet<{ datum: Datum; x: number; y: number }>;
|
|
25
25
|
}
|
|
26
|
-
import {
|
|
27
|
-
import type {
|
|
28
|
-
|
|
29
|
-
ConstantAccessor,
|
|
30
|
-
DataRecord,
|
|
31
|
-
PlotContext
|
|
32
|
-
} from '../types/index.js';
|
|
33
|
-
|
|
34
|
-
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
35
|
-
const plot = $derived(getPlotState());
|
|
26
|
+
import { type Snippet } from 'svelte';
|
|
27
|
+
import type { ChannelAccessor, ConstantAccessor, DataRecord } from '../types/index.js';
|
|
28
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
36
29
|
|
|
37
30
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
38
31
|
import { projectX, projectY, projectXY } from '../helpers/scales.js';
|
|
39
32
|
import { isValid } from '../helpers/index.js';
|
|
40
33
|
|
|
34
|
+
const plot = usePlot();
|
|
35
|
+
|
|
41
36
|
let {
|
|
42
37
|
data = [{} as Datum],
|
|
43
38
|
x,
|
|
@@ -49,19 +49,17 @@
|
|
|
49
49
|
BaseMarkProps,
|
|
50
50
|
ChannelAccessor,
|
|
51
51
|
CurveName,
|
|
52
|
-
DataRecord
|
|
53
|
-
PlotContext
|
|
52
|
+
DataRecord
|
|
54
53
|
} from '../types/index.js';
|
|
55
54
|
import { Line, Area } from './index.js';
|
|
56
55
|
import { randomId, coalesce } from '../helpers/index.js';
|
|
57
|
-
import { getContext } from 'svelte';
|
|
58
56
|
import { extent, max, min } from 'd3-array';
|
|
59
57
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
60
58
|
import type { CurveFactory } from 'd3-shape';
|
|
61
59
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
60
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
62
61
|
|
|
63
|
-
const
|
|
64
|
-
let plot = $derived(getPlotState());
|
|
62
|
+
const plot = usePlot();
|
|
65
63
|
|
|
66
64
|
let markProps: DifferenceYMarkProps = $props();
|
|
67
65
|
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/Dot.svelte
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
dotClass?: ConstantAccessor<string, Datum>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { type Snippet } from 'svelte';
|
|
16
16
|
import type {
|
|
17
|
-
PlotContext,
|
|
18
17
|
DataRecord,
|
|
19
18
|
BaseMarkProps,
|
|
20
19
|
ConstantAccessor,
|
|
@@ -33,6 +32,7 @@
|
|
|
33
32
|
import Anchor from './helpers/Anchor.svelte';
|
|
34
33
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
35
34
|
import { isOrdinalScale } from '../helpers/scales.js';
|
|
35
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
36
36
|
|
|
37
37
|
const DEFAULTS = {
|
|
38
38
|
...getPlotDefaults().dot
|
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
...options
|
|
49
49
|
}: DotMarkProps = $derived({ ...DEFAULTS, ...markProps });
|
|
50
50
|
|
|
51
|
-
const
|
|
52
|
-
const plot = $derived(getPlotState());
|
|
51
|
+
const plot = usePlot();
|
|
53
52
|
|
|
54
53
|
function getSymbolPath(symbolType, size) {
|
|
55
54
|
return d3Symbol(maybeSymbol(symbolType), size)();
|
|
@@ -113,7 +112,7 @@
|
|
|
113
112
|
]}
|
|
114
113
|
{style}
|
|
115
114
|
{@attach addEventHandlers({
|
|
116
|
-
|
|
115
|
+
plot,
|
|
117
116
|
options: args,
|
|
118
117
|
datum: d?.datum
|
|
119
118
|
})} />
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
27
27
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
package/dist/marks/Frame.svelte
CHANGED
|
@@ -21,17 +21,12 @@
|
|
|
21
21
|
insetBottom?: number;
|
|
22
22
|
}
|
|
23
23
|
import Mark from '../Mark.svelte';
|
|
24
|
-
import {
|
|
25
|
-
import type {
|
|
26
|
-
PlotContext,
|
|
27
|
-
BaseRectMarkProps,
|
|
28
|
-
LinkableMarkProps,
|
|
29
|
-
DataRecord
|
|
30
|
-
} from '../types/index.js';
|
|
24
|
+
import type { BaseRectMarkProps, LinkableMarkProps, DataRecord } from '../types/index.js';
|
|
31
25
|
import type { BaseMarkProps } from '../types/index.js';
|
|
32
26
|
import RectPath from './helpers/RectPath.svelte';
|
|
33
27
|
import { resolveProp } from '../helpers/resolve';
|
|
34
28
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
29
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
35
30
|
|
|
36
31
|
let markProps: FrameMarkProps = $props();
|
|
37
32
|
|
|
@@ -61,8 +56,7 @@
|
|
|
61
56
|
const dx = $derived(resolveProp(options.dx, null, 0) || 0);
|
|
62
57
|
const dy = $derived(resolveProp(options.dy, null, 0) || 0);
|
|
63
58
|
|
|
64
|
-
const
|
|
65
|
-
const plot = $derived(getPlotState());
|
|
59
|
+
const plot = usePlot();
|
|
66
60
|
</script>
|
|
67
61
|
|
|
68
62
|
<Mark type="frame" {automatic}>
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|