svelteplot 0.4.4-pr-105.0 → 0.4.4-pr-105.1
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/AreaY.svelte
CHANGED
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
import Area from './Area.svelte';
|
|
11
11
|
import { renameChannels } from '../transforms/rename.js';
|
|
12
12
|
import { stackY } from '../transforms/stack.js';
|
|
13
|
-
import { recordizeY } from '../transforms/recordize.js';
|
|
13
|
+
import { RAW_VALUE, recordizeY } from '../transforms/recordize.js';
|
|
14
14
|
import type { ChannelAccessor, DataRow, PlotDefaults } from '../types/index.js';
|
|
15
15
|
import { getContext, type Component, type ComponentProps } from 'svelte';
|
|
16
|
+
import { area } from 'd3-shape';
|
|
16
17
|
|
|
17
18
|
let markProps: AreaYMarkProps = $props();
|
|
18
19
|
|
|
@@ -13,12 +13,15 @@ export function indexData(data) {
|
|
|
13
13
|
export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: true }) {
|
|
14
14
|
const dataIsRawValueArray = !isDataRecord(data[0]) && !Array.isArray(data[0]) && channels.x == null;
|
|
15
15
|
if (dataIsRawValueArray) {
|
|
16
|
+
// we remove x, x1 and x2 from the channels since they make no sense when
|
|
17
|
+
// the data is a raw value array
|
|
18
|
+
const { x, x1, x2, ...nonXChannels } = channels;
|
|
16
19
|
return {
|
|
17
20
|
data: data.map((value, index) => ({
|
|
18
21
|
[RAW_VALUE]: value,
|
|
19
22
|
[INDEX]: index
|
|
20
23
|
})),
|
|
21
|
-
...
|
|
24
|
+
...nonXChannels,
|
|
22
25
|
x: RAW_VALUE,
|
|
23
26
|
...(withIndex ? { y: INDEX } : {})
|
|
24
27
|
};
|
|
@@ -34,12 +37,15 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
34
37
|
return { data, ...channels };
|
|
35
38
|
const dataIsRawValueArray = !isDataRecord(data[0]) && !Array.isArray(data[0]) && channels.y == null;
|
|
36
39
|
if (dataIsRawValueArray) {
|
|
40
|
+
// we remove y, y1 and y2 from the channels since they make no sense when
|
|
41
|
+
// the data is a raw value array
|
|
42
|
+
const { y, y1, y2, ...nonYChannels } = channels;
|
|
37
43
|
return {
|
|
38
44
|
data: Array.from(data).map((value, index) => ({
|
|
39
45
|
[INDEX]: index,
|
|
40
46
|
[RAW_VALUE]: value
|
|
41
47
|
})),
|
|
42
|
-
...
|
|
48
|
+
...nonYChannels,
|
|
43
49
|
...(withIndex ? { x: INDEX } : {}),
|
|
44
50
|
y: RAW_VALUE
|
|
45
51
|
};
|