svelteplot 0.8.1-pr-298.1 → 0.8.1-pr-298.2
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/marks/BoxX.svelte
CHANGED
package/dist/marks/BoxY.svelte
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
import { resolveChannel } from '../../helpers/resolve.js';
|
|
44
44
|
import type { BaseMarkProps, ChannelAccessor, DataRecord, RawValue } from '../../types';
|
|
45
45
|
import { IS_SORTED } from '../../transforms/sort';
|
|
46
|
+
import Up from '../../../theme/components/icons/Up.svelte';
|
|
46
47
|
|
|
47
48
|
let markProps: BoxMarkProps = $props();
|
|
48
49
|
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
const { data: grouped, ...groupChannels } = $derived(
|
|
81
82
|
groupFn(
|
|
82
83
|
{
|
|
83
|
-
data: data.filter((d) => resolveChannel(
|
|
84
|
+
data: data.filter((d) => resolveChannel(xProp, d, { x, y }) != null),
|
|
84
85
|
x,
|
|
85
86
|
y,
|
|
86
87
|
[x1Prop]: xChannel,
|
|
@@ -121,44 +122,46 @@
|
|
|
121
122
|
: 0) || 0;
|
|
122
123
|
|
|
123
124
|
const boxData = $derived.by(() => {
|
|
124
|
-
const boxes = grouped
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
125
|
+
const boxes = grouped
|
|
126
|
+
.map((row) => {
|
|
127
|
+
const medianKey = groupChannels[xProp];
|
|
128
|
+
const p25Key = groupChannels[x1Prop];
|
|
129
|
+
const p75Key = groupChannels[x2Prop];
|
|
130
|
+
const groupKey = groupChannels[yProp];
|
|
131
|
+
|
|
132
|
+
const iqr = row[p75Key] - row[p25Key];
|
|
133
|
+
const whisker = iqr * 1.5;
|
|
134
|
+
const lower = row[p25Key] - whisker;
|
|
135
|
+
const upper = row[p75Key] + whisker;
|
|
136
|
+
const data = row[groupChannels.fill].map((d) => ({
|
|
137
|
+
...d,
|
|
138
|
+
[orientation === 'y' ? Y : X]: resolveChannel(xProp, d, {
|
|
139
|
+
x,
|
|
140
|
+
y
|
|
141
|
+
})
|
|
142
|
+
}));
|
|
143
|
+
const valueSym = orientation === 'y' ? Y : X;
|
|
144
|
+
const groupSym = orientation === 'y' ? X : Y;
|
|
145
|
+
const outliers = data.filter((d) => d[valueSym] < lower || d[valueSym] > upper);
|
|
146
|
+
const inside = data
|
|
147
|
+
.filter((d) => d[valueSym] >= lower && d[valueSym] <= upper)
|
|
148
|
+
.sort((a, b) => a[valueSym] - b[valueSym]);
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
...data[0],
|
|
152
|
+
[SORT_REF]: row[groupChannels.fill]?.[0],
|
|
153
|
+
[groupSym]: row[groupKey],
|
|
154
|
+
[P25]: row[p25Key],
|
|
155
|
+
[MEDIAN]: row[medianKey],
|
|
156
|
+
[P75]: row[p75Key],
|
|
157
|
+
[MIN]: inside.length ? inside[0][valueSym] : null,
|
|
158
|
+
[MAX]: inside.length ? inside.at(-1)[valueSym] : null,
|
|
159
|
+
[FX]: resolveChannel('fx', data[0], { fx }, null),
|
|
160
|
+
[FY]: resolveChannel('fy', data[0], { fy }, null),
|
|
161
|
+
[OUTLIERS]: outliers
|
|
162
|
+
};
|
|
163
|
+
})
|
|
164
|
+
.filter(Boolean);
|
|
162
165
|
|
|
163
166
|
const stripSortRef = ({ [SORT_REF]: _, ...rest }) => rest;
|
|
164
167
|
|