svelteplot 0.8.1-pr-283.11 → 0.8.1-pr-298.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/dist/Mark.svelte +1 -1
- package/dist/Mark.svelte.d.ts +0 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/helpers/projection.js +2 -7
- package/dist/marks/Area.svelte.d.ts +0 -1
- package/dist/marks/AreaX.svelte.d.ts +0 -1
- package/dist/marks/Arrow.svelte.d.ts +0 -1
- package/dist/marks/AxisX.svelte.d.ts +0 -1
- package/dist/marks/AxisY.svelte +1 -1
- package/dist/marks/AxisY.svelte.d.ts +0 -1
- package/dist/marks/BarX.svelte.d.ts +0 -1
- package/dist/marks/BarY.svelte.d.ts +0 -1
- package/dist/marks/BoxX.svelte +3 -138
- package/dist/marks/BoxY.svelte +8 -137
- package/dist/marks/BoxY.svelte.d.ts +5 -1
- package/dist/marks/Cell.svelte.d.ts +0 -1
- package/dist/marks/Dot.svelte.d.ts +0 -1
- package/dist/marks/DotX.svelte.d.ts +0 -1
- package/dist/marks/DotY.svelte.d.ts +0 -1
- package/dist/marks/Frame.svelte.d.ts +0 -1
- package/dist/marks/Geo.svelte +0 -2
- package/dist/marks/Geo.svelte.d.ts +0 -2
- package/dist/marks/GridX.svelte.d.ts +0 -1
- package/dist/marks/GridY.svelte.d.ts +0 -1
- package/dist/marks/Line.svelte +2 -5
- package/dist/marks/Line.svelte.d.ts +0 -1
- package/dist/marks/LineX.svelte.d.ts +0 -1
- package/dist/marks/LineY.svelte.d.ts +0 -1
- package/dist/marks/Link.svelte.d.ts +0 -1
- package/dist/marks/Rect.svelte.d.ts +0 -1
- package/dist/marks/RuleX.svelte.d.ts +0 -1
- package/dist/marks/RuleY.svelte.d.ts +0 -1
- package/dist/marks/Spike.svelte.d.ts +0 -1
- package/dist/marks/Text.svelte.d.ts +0 -1
- package/dist/marks/TickX.svelte.d.ts +0 -1
- package/dist/marks/TickY.svelte.d.ts +0 -1
- package/dist/marks/Vector.svelte.d.ts +0 -1
- package/dist/marks/helpers/Box.svelte +254 -0
- package/dist/marks/helpers/Box.svelte.d.ts +55 -0
- package/dist/marks/index.d.ts +0 -1
- package/dist/marks/index.js +0 -1
- package/dist/types/mark.d.ts +1 -2
- package/dist/types/plot.d.ts +1 -5
- package/package.json +15 -16
- package/dist/marks/Trail.svelte +0 -163
- package/dist/marks/Trail.svelte.d.ts +0 -44
- package/dist/marks/helpers/TrailCanvas.svelte +0 -140
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +0 -40
- package/dist/marks/helpers/trail.d.ts +0 -23
- package/dist/marks/helpers/trail.js +0 -372
package/dist/Mark.svelte
CHANGED
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
// check if the mark has defined an accessor for this channel
|
|
152
152
|
if (options?.[channel] !== undefined && out[channel] === undefined) {
|
|
153
153
|
// resolve value
|
|
154
|
-
out[channel] = resolveChannel(channel, row, options
|
|
154
|
+
out[channel] = resolveChannel(channel, row, options);
|
|
155
155
|
if (options[channel] === INDEX) {
|
|
156
156
|
const scale = plot.scales[CHANNEL_SCALE[channel]];
|
|
157
157
|
if (scale.type === 'band' || scale.type === 'point') {
|
package/dist/Mark.svelte.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
29
29
|
strokeDashoffset: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
30
30
|
mixBlendMode: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
31
31
|
clipPath: string;
|
|
32
|
-
mask: string;
|
|
33
32
|
imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
|
|
34
33
|
shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
35
34
|
paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -117,8 +117,6 @@ export const CSS_COLOR_CONTRAST = /^color-contrast\(/; // just check for prefix
|
|
|
117
117
|
export const CSS_RGBA = /^rgba\(/; // just check for prefix
|
|
118
118
|
export const CSS_URL = /^url\(#/; // just check for prefix
|
|
119
119
|
export const INDEX = Symbol('index');
|
|
120
|
-
export const PI = Math.PI;
|
|
121
|
-
export const TAU = PI * 2;
|
|
122
120
|
// export const CHANNEL_MAP: Record<ScaleName, ValueOf<typeof SCALE_TYPES>> = {
|
|
123
121
|
// x: SCALE_TYPES.x,
|
|
124
122
|
// y: SCALE_TYPES.y,
|
|
@@ -50,7 +50,7 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
|
|
|
50
50
|
let transform;
|
|
51
51
|
let invertTransform = (d) => d;
|
|
52
52
|
// If a domain is specified, fit the projection to the frame.
|
|
53
|
-
if (domain != null
|
|
53
|
+
if (domain != null) {
|
|
54
54
|
const [[x0, y0], [x1, y1]] = geoPath(projInstance).bounds(domain);
|
|
55
55
|
const k = Math.min(dx / (x1 - x0), dy / (y1 - y0));
|
|
56
56
|
aspectRatio = (y1 - y0) / (x1 - x0);
|
|
@@ -66,14 +66,9 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
|
|
|
66
66
|
invertTransform = ([x, y]) => [(x - tx) / k, (y - ty) / k];
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
|
|
70
|
-
console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
69
|
+
throw new Error(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
|
-
else if (domain != null) {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
76
|
-
}
|
|
77
72
|
transform ??=
|
|
78
73
|
tx === 0 && ty === 0
|
|
79
74
|
? identity()
|
|
@@ -29,7 +29,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
29
29
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
30
30
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
31
31
|
clipPath: string;
|
|
32
|
-
mask: string;
|
|
33
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
34
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
35
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -28,7 +28,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
28
28
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
-
mask: string;
|
|
32
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -28,7 +28,6 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
28
28
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
-
mask: string;
|
|
32
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
32
|
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
34
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
package/dist/marks/AxisY.svelte
CHANGED
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
: optionsLabel !== undefined
|
|
171
171
|
? optionsLabel
|
|
172
172
|
: plot.scales.y.autoTitle
|
|
173
|
-
?
|
|
173
|
+
? `↑ ${plot.scales.y.autoTitle}${plot.options.y.percent ? ' (%)' : ''}`
|
|
174
174
|
: ''
|
|
175
175
|
);
|
|
176
176
|
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
27
27
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -29,7 +29,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
29
29
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
30
30
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
31
31
|
clipPath: string;
|
|
32
|
-
mask: string;
|
|
33
32
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
34
33
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
35
34
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -28,7 +28,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
28
28
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
-
mask: string;
|
|
32
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
33
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/BoxX.svelte
CHANGED
|
@@ -4,14 +4,10 @@
|
|
|
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
|
|
|
@@ -22,141 +18,10 @@
|
|
|
22
18
|
...getPlotDefaults().boxX
|
|
23
19
|
};
|
|
24
20
|
|
|
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({
|
|
21
|
+
const props: BoxXMarkProps & { class?: string } = $derived({
|
|
40
22
|
...DEFAULTS,
|
|
41
23
|
...markProps
|
|
42
24
|
});
|
|
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
25
|
</script>
|
|
112
26
|
|
|
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>
|
|
27
|
+
<Box {...props} orientation="x" />
|
package/dist/marks/BoxY.svelte
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
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?: 'min' | 'max' | 'median' | 'p25' | 'p75' | ((d: Datum) => RawValue);
|
|
12
16
|
/**
|
|
13
17
|
* Options for the rule marks that represent the min/max range
|
|
14
18
|
*/
|
|
@@ -30,12 +34,9 @@
|
|
|
30
34
|
*/
|
|
31
35
|
dot: Record<string, ChannelAccessor<Datum>>;
|
|
32
36
|
}
|
|
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
37
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
37
|
-
import
|
|
38
|
-
import {
|
|
38
|
+
import Box from './helpers/Box.svelte';
|
|
39
|
+
import type { BaseMarkProps, ChannelAccessor, DataRecord, RawValue } from '../types';
|
|
39
40
|
|
|
40
41
|
let markProps: BoxYMarkProps = $props();
|
|
41
42
|
|
|
@@ -46,140 +47,10 @@
|
|
|
46
47
|
...getPlotDefaults().boxY
|
|
47
48
|
};
|
|
48
49
|
|
|
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({
|
|
50
|
+
const props: BoxYMarkProps & { class?: string } = $derived({
|
|
64
51
|
...DEFAULTS,
|
|
65
52
|
...markProps
|
|
66
53
|
});
|
|
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
54
|
</script>
|
|
135
55
|
|
|
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>
|
|
56
|
+
<Box {...props} orientation="y" />
|
|
@@ -1,9 +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
3
|
props: Pick<BaseMarkProps<Datum>, "fill" | "stroke" | "fx" | "fy" | "class"> & {
|
|
4
4
|
data: Datum[];
|
|
5
5
|
x: ChannelAccessor;
|
|
6
6
|
y: ChannelAccessor;
|
|
7
|
+
/**
|
|
8
|
+
* Custom sort order for grouped box plot data
|
|
9
|
+
*/
|
|
10
|
+
sort?: "min" | "max" | "median" | "p25" | "p75" | ((d: Datum) => RawValue);
|
|
7
11
|
/**
|
|
8
12
|
* Options for the rule marks that represent the min/max range
|
|
9
13
|
*/
|
|
@@ -27,7 +27,6 @@ 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;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -28,7 +28,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
28
28
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
-
mask: string;
|
|
32
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -27,7 +27,6 @@ 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;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/Geo.svelte
CHANGED
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
* radius for point features
|
|
22
22
|
*/
|
|
23
23
|
r?: ChannelAccessor<Datum>;
|
|
24
|
-
svgFilter?: ConstantAccessor<string | undefined, Datum>;
|
|
25
24
|
}
|
|
26
25
|
import { getContext } from 'svelte';
|
|
27
26
|
import type {
|
|
@@ -112,7 +111,6 @@
|
|
|
112
111
|
d={path(geometry)}
|
|
113
112
|
{style}
|
|
114
113
|
class={[styleClass]}
|
|
115
|
-
filter={resolveProp(args.svgFilter, d.datum, undefined)}
|
|
116
114
|
{@attach addEventHandlers({
|
|
117
115
|
getPlotState,
|
|
118
116
|
options: args,
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum = DataRecord | GeoJSON.GeoJsonObject>(): {
|
|
|
27
27
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -85,7 +84,6 @@ declare function $$render<Datum = DataRecord | GeoJSON.GeoJsonObject>(): {
|
|
|
85
84
|
* radius for point features
|
|
86
85
|
*/
|
|
87
86
|
r?: ChannelAccessor<Datum>;
|
|
88
|
-
svgFilter?: ConstantAccessor<string | undefined, Datum>;
|
|
89
87
|
};
|
|
90
88
|
exports: {};
|
|
91
89
|
bindings: "";
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum = RawValue>(): {
|
|
|
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;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum = RawValue>(): {
|
|
|
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;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/Line.svelte
CHANGED
|
@@ -76,10 +76,7 @@
|
|
|
76
76
|
|
|
77
77
|
const args = $derived(sort(recordizeXY({ data, ...options })));
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
* Groups the data by the specified key
|
|
81
|
-
*/
|
|
82
|
-
function groupIndex(data: ScaledDataRecord[], groupByKey: ChannelAccessor<Datum> | null) {
|
|
79
|
+
function groupIndex(data: ScaledDataRecord[], groupByKey) {
|
|
83
80
|
if (!groupByKey) return [data];
|
|
84
81
|
let group = [];
|
|
85
82
|
const groups = [group];
|
|
@@ -98,7 +95,7 @@
|
|
|
98
95
|
return groups;
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
const groupByKey = $derived(args.z || args.stroke)
|
|
98
|
+
const groupByKey = $derived(args.z || args.stroke);
|
|
102
99
|
|
|
103
100
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
104
101
|
const plot = $derived(getPlotState());
|
|
@@ -29,7 +29,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
29
29
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
30
30
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
31
31
|
clipPath: string;
|
|
32
|
-
mask: string;
|
|
33
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
34
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
35
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types").ConstantAccessor<number, Record<string | symbol, import("../types").RawValue>>;
|
|
28
28
|
mixBlendMode: import("../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types").RawValue>>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
32
31
|
shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
|
|
33
32
|
paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
@@ -27,7 +27,6 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types").ConstantAccessor<number, Record<string | symbol, import("../types").RawValue>>;
|
|
28
28
|
mixBlendMode: import("../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types").RawValue>>;
|
|
29
29
|
clipPath: string;
|
|
30
|
-
mask: string;
|
|
31
30
|
imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
32
31
|
shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
|
|
33
32
|
paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
@@ -28,7 +28,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
28
28
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
-
mask: string;
|
|
32
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,7 +27,6 @@ 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;
|
|
31
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|