svelteplot 0.4.2 → 0.4.3-pr-198.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 +4 -2
- package/dist/core/Plot.svelte +1 -2
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +3 -4
- package/dist/helpers/index.js +1 -6
- package/dist/helpers/resolve.js +4 -4
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +3 -3
- package/dist/marks/AreaX.svelte.d.ts +2 -1
- package/dist/marks/AreaY.svelte.d.ts +2 -1
- package/dist/marks/Arrow.svelte +16 -15
- package/dist/marks/Arrow.svelte.d.ts +1 -1
- package/dist/marks/AxisX.svelte +1 -1
- package/dist/marks/AxisX.svelte.d.ts +2 -2
- package/dist/marks/AxisY.svelte.d.ts +1 -1
- package/dist/marks/BarX.svelte.d.ts +1 -1
- package/dist/marks/BarY.svelte +0 -1
- package/dist/marks/BollingerX.svelte.d.ts +2 -73
- package/dist/marks/BollingerY.svelte.d.ts +2 -73
- package/dist/marks/BoxX.svelte +72 -28
- package/dist/marks/BoxY.svelte +88 -38
- package/dist/marks/BoxY.svelte.d.ts +6 -66
- package/dist/marks/CustomMark.svelte.d.ts +2 -80
- package/dist/marks/DifferenceY.svelte.d.ts +7 -66
- package/dist/marks/Dot.svelte +5 -5
- package/dist/marks/Geo.svelte +3 -3
- package/dist/marks/GridX.svelte +26 -8
- package/dist/marks/GridX.svelte.d.ts +8 -6
- package/dist/marks/GridY.svelte +16 -4
- package/dist/marks/GridY.svelte.d.ts +8 -6
- package/dist/marks/Line.svelte.d.ts +2 -2
- package/dist/marks/LineX.svelte.d.ts +2 -1
- package/dist/marks/LineY.svelte.d.ts +2 -1
- package/dist/marks/Link.svelte +7 -10
- package/dist/marks/Pointer.svelte +2 -2
- package/dist/marks/RuleX.svelte +1 -1
- package/dist/marks/RuleX.svelte.d.ts +1 -1
- package/dist/marks/Text.svelte +2 -1
- package/dist/marks/Vector.svelte +6 -5
- package/dist/marks/helpers/BaseAxisX.svelte +17 -12
- package/dist/marks/helpers/BaseAxisY.svelte +15 -10
- package/dist/marks/helpers/MarkerPath.svelte +10 -2
- package/dist/marks/helpers/RectPath.svelte +15 -15
- package/dist/marks/helpers/RectPath.svelte.d.ts +3 -1
- package/dist/marks/helpers/events.d.ts +5 -6
- package/dist/marks/helpers/events.js +47 -35
- package/dist/transforms/bollinger.d.ts +1 -66
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -122
- package/dist/transforms/recordize.d.ts +9 -7
- package/dist/transforms/recordize.js +23 -24
- package/dist/transforms/select.d.ts +7 -427
- package/dist/transforms/sort.d.ts +3 -242
- package/dist/transforms/stack.d.ts +3 -23
- package/dist/transforms/window.d.ts +2 -128
- package/dist/types/channel.d.ts +1 -1
- package/dist/types/data.d.ts +2 -0
- package/dist/types/index.d.ts +6 -6
- package/package.json +126 -125
package/dist/marks/Dot.svelte
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
import { sort } from '../index.js';
|
|
29
29
|
import Mark from '../Mark.svelte';
|
|
30
30
|
import DotCanvas from './helpers/DotCanvas.svelte';
|
|
31
|
-
import {
|
|
31
|
+
import { isValid } from '../helpers/index.js';
|
|
32
32
|
import { recordizeXY } from '../transforms/recordize.js';
|
|
33
33
|
import { addEventHandlers } from './helpers/events.js';
|
|
34
34
|
import Anchor from './helpers/Anchor.svelte';
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
// todo: move sorting to Mark
|
|
59
59
|
sort(
|
|
60
60
|
recordizeXY({
|
|
61
|
-
data
|
|
61
|
+
data,
|
|
62
62
|
// sort by descending radius by default
|
|
63
63
|
...(options.r ? { sort: { channel: '-r' } } : {}),
|
|
64
64
|
...options,
|
|
@@ -107,11 +107,11 @@
|
|
|
107
107
|
styleClass
|
|
108
108
|
]}
|
|
109
109
|
{style}
|
|
110
|
-
|
|
110
|
+
{@attach addEventHandlers({
|
|
111
111
|
getPlotState,
|
|
112
112
|
options: args,
|
|
113
|
-
datum: d
|
|
114
|
-
}} />
|
|
113
|
+
datum: d?.datum
|
|
114
|
+
})} />
|
|
115
115
|
</Anchor>
|
|
116
116
|
{/if}
|
|
117
117
|
{/each}
|
package/dist/marks/Geo.svelte
CHANGED
|
@@ -111,11 +111,11 @@
|
|
|
111
111
|
d={path(geometry)}
|
|
112
112
|
{style}
|
|
113
113
|
class={[styleClass]}
|
|
114
|
-
|
|
114
|
+
{@attach addEventHandlers({
|
|
115
115
|
getPlotState,
|
|
116
116
|
options: args,
|
|
117
|
-
datum: d
|
|
118
|
-
}}>
|
|
117
|
+
datum: d?.datum
|
|
118
|
+
})}>
|
|
119
119
|
{#if title}<title>{title}</title>{/if}
|
|
120
120
|
</path>
|
|
121
121
|
</Anchor>
|
package/dist/marks/GridX.svelte
CHANGED
|
@@ -5,14 +5,25 @@
|
|
|
5
5
|
interface GridXMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
|
|
6
6
|
data?: Datum[];
|
|
7
7
|
automatic?: boolean;
|
|
8
|
+
y1?: ChannelAccessor<Datum>;
|
|
9
|
+
y2?: ChannelAccessor<Datum>;
|
|
8
10
|
}
|
|
9
11
|
import { getContext } from 'svelte';
|
|
10
12
|
import Mark from '../Mark.svelte';
|
|
11
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
PlotContext,
|
|
15
|
+
BaseMarkProps,
|
|
16
|
+
RawValue,
|
|
17
|
+
PlotDefaults,
|
|
18
|
+
DataRecord,
|
|
19
|
+
ChannelAccessor
|
|
20
|
+
} from '../types/index.js';
|
|
12
21
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
13
22
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
14
23
|
import { testFilter } from '../helpers/index.js';
|
|
15
24
|
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
25
|
+
import isDataRecord from '../helpers/isDataRecord';
|
|
26
|
+
import { INDEX } from '../constants';
|
|
16
27
|
|
|
17
28
|
let markProps: GridXMarkProps = $props();
|
|
18
29
|
|
|
@@ -37,8 +48,8 @@
|
|
|
37
48
|
Math.max(3, Math.round(plot.facetWidth / plot.options.x.tickSpacing))
|
|
38
49
|
);
|
|
39
50
|
|
|
40
|
-
const ticks:
|
|
41
|
-
data.length > 0
|
|
51
|
+
const ticks: DataRecord[] = $derived(
|
|
52
|
+
(data.length > 0
|
|
42
53
|
? // use custom tick values if user passed any as prop
|
|
43
54
|
data
|
|
44
55
|
: // use custom scale tick values if user passed any as plot scale option
|
|
@@ -50,6 +61,9 @@
|
|
|
50
61
|
plot.scales.x.fn,
|
|
51
62
|
autoTickCount
|
|
52
63
|
)
|
|
64
|
+
).map((d, i) =>
|
|
65
|
+
isDataRecord(d) ? { ...d, [INDEX]: i } : { [RAW_VALUE]: d, [INDEX]: i }
|
|
66
|
+
) as DataRecord[]
|
|
53
67
|
);
|
|
54
68
|
</script>
|
|
55
69
|
|
|
@@ -64,17 +78,21 @@
|
|
|
64
78
|
{#each ticks as tick, t (t)}
|
|
65
79
|
{#if testFilter(tick, options)}
|
|
66
80
|
{@const x =
|
|
67
|
-
plot.scales.x.fn(tick) +
|
|
81
|
+
plot.scales.x.fn(tick[RAW_VALUE]) +
|
|
68
82
|
(plot.scales.x.type === 'band' ? plot.scales.x.fn.bandwidth() * 0.5 : 0)}
|
|
69
83
|
{@const y1_ = resolveChannel('y1', tick, options)}
|
|
70
84
|
{@const y2_ = resolveChannel('y2', tick, options)}
|
|
71
85
|
{@const dx = +resolveProp(options?.dx, tick, 0)}
|
|
72
86
|
{@const dy = +resolveProp(options?.dy, tick, 0)}
|
|
73
|
-
{@const y1 =
|
|
74
|
-
|
|
87
|
+
{@const y1 =
|
|
88
|
+
options.y1 != null ? plot.scales.y.fn(y1_) : plot.options.marginTop}
|
|
89
|
+
{@const y2 =
|
|
90
|
+
options.y2 != null
|
|
91
|
+
? plot.scales.y.fn(y2_)
|
|
92
|
+
: plot.options.marginTop + plot.facetHeight}
|
|
75
93
|
{@const [style, styleClass] = resolveStyles(
|
|
76
94
|
plot,
|
|
77
|
-
{ datum:
|
|
95
|
+
{ datum: tick },
|
|
78
96
|
options,
|
|
79
97
|
'stroke',
|
|
80
98
|
usedScales,
|
|
@@ -82,7 +100,7 @@
|
|
|
82
100
|
)}
|
|
83
101
|
<line
|
|
84
102
|
class={styleClass}
|
|
85
|
-
transform="translate({x + dx},{
|
|
103
|
+
transform="translate({x + dx},{dy})"
|
|
86
104
|
{style}
|
|
87
105
|
{y1}
|
|
88
106
|
{y2} />
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { RawValue } from '../types/index.js';
|
|
1
|
+
import type { RawValue, ChannelAccessor } from '../types/index.js';
|
|
2
2
|
declare class __sveltets_Render<Datum = RawValue> {
|
|
3
3
|
props(): Omit<Partial<{
|
|
4
4
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Datum>;
|
|
5
5
|
facet?: "auto" | "include" | "exclude";
|
|
6
|
-
fx:
|
|
7
|
-
fy:
|
|
6
|
+
fx: ChannelAccessor<Datum>;
|
|
7
|
+
fy: ChannelAccessor<Datum>;
|
|
8
8
|
dx: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
9
9
|
dy: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
10
|
-
fill:
|
|
10
|
+
fill: ChannelAccessor<Datum>;
|
|
11
11
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
12
12
|
sort: {
|
|
13
13
|
channel: string;
|
|
14
14
|
order?: "ascending" | "descending";
|
|
15
15
|
} | ((a: RawValue, b: RawValue) => number) | import("../types/index.js").ConstantAccessor<RawValue, Datum>;
|
|
16
|
-
stroke:
|
|
16
|
+
stroke: ChannelAccessor<Datum>;
|
|
17
17
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
18
18
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
19
19
|
strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
|
|
20
20
|
strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
|
|
21
21
|
strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
22
|
-
opacity:
|
|
22
|
+
opacity: ChannelAccessor<Datum>;
|
|
23
23
|
strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
24
24
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
25
25
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
@@ -62,6 +62,8 @@ declare class __sveltets_Render<Datum = RawValue> {
|
|
|
62
62
|
}>, "fill" | "fillOpacity"> & {
|
|
63
63
|
data?: Datum[] | undefined;
|
|
64
64
|
automatic?: boolean;
|
|
65
|
+
y1?: ChannelAccessor<Datum>;
|
|
66
|
+
y2?: ChannelAccessor<Datum>;
|
|
65
67
|
};
|
|
66
68
|
events(): {};
|
|
67
69
|
slots(): {};
|
package/dist/marks/GridY.svelte
CHANGED
|
@@ -5,10 +5,18 @@
|
|
|
5
5
|
interface GridYMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
|
|
6
6
|
data?: Datum[];
|
|
7
7
|
automatic?: boolean;
|
|
8
|
+
x1?: ChannelAccessor<Datum>;
|
|
9
|
+
x2?: ChannelAccessor<Datum>;
|
|
8
10
|
}
|
|
9
11
|
import { getContext } from 'svelte';
|
|
10
12
|
import Mark from '../Mark.svelte';
|
|
11
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
PlotContext,
|
|
15
|
+
BaseMarkProps,
|
|
16
|
+
RawValue,
|
|
17
|
+
PlotDefaults,
|
|
18
|
+
ChannelAccessor
|
|
19
|
+
} from '../types/index.js';
|
|
12
20
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
13
21
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
14
22
|
import { testFilter } from '../helpers/index.js';
|
|
@@ -68,8 +76,12 @@
|
|
|
68
76
|
(plot.scales.y.type === 'band' ? plot.scales.y.fn.bandwidth() * 0.5 : 0)}
|
|
69
77
|
{@const x1_ = resolveChannel('x1', tick, options)}
|
|
70
78
|
{@const x2_ = resolveChannel('x2', tick, options)}
|
|
71
|
-
{@const x1 =
|
|
72
|
-
|
|
79
|
+
{@const x1 =
|
|
80
|
+
options.x1 != null ? plot.scales.x.fn(x1_) : plot.options.marginLeft}
|
|
81
|
+
{@const x2 =
|
|
82
|
+
options.x2 != null
|
|
83
|
+
? plot.scales.x.fn(x2_)
|
|
84
|
+
: plot.options.marginLeft + plot.facetWidth}
|
|
73
85
|
{@const dx = +resolveProp(options?.dx, tick, 0)}
|
|
74
86
|
{@const dy = +resolveProp(options?.dy, tick, 0)}
|
|
75
87
|
{@const [style, styleClass] = resolveStyles(
|
|
@@ -83,7 +95,7 @@
|
|
|
83
95
|
<line
|
|
84
96
|
{style}
|
|
85
97
|
class={styleClass}
|
|
86
|
-
transform="translate({
|
|
98
|
+
transform="translate({dx},{y + dy})"
|
|
87
99
|
{x1}
|
|
88
100
|
{x2} />
|
|
89
101
|
{/if}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { RawValue } from '../types/index.js';
|
|
1
|
+
import type { RawValue, ChannelAccessor } from '../types/index.js';
|
|
2
2
|
declare class __sveltets_Render<Datum = RawValue> {
|
|
3
3
|
props(): Omit<Partial<{
|
|
4
4
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Datum>;
|
|
5
5
|
facet?: "auto" | "include" | "exclude";
|
|
6
|
-
fx:
|
|
7
|
-
fy:
|
|
6
|
+
fx: ChannelAccessor<Datum>;
|
|
7
|
+
fy: ChannelAccessor<Datum>;
|
|
8
8
|
dx: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
9
9
|
dy: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
10
|
-
fill:
|
|
10
|
+
fill: ChannelAccessor<Datum>;
|
|
11
11
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
12
12
|
sort: {
|
|
13
13
|
channel: string;
|
|
14
14
|
order?: "ascending" | "descending";
|
|
15
15
|
} | ((a: RawValue, b: RawValue) => number) | import("../types/index.js").ConstantAccessor<RawValue, Datum>;
|
|
16
|
-
stroke:
|
|
16
|
+
stroke: ChannelAccessor<Datum>;
|
|
17
17
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
18
18
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
19
19
|
strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
|
|
20
20
|
strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
|
|
21
21
|
strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
22
|
-
opacity:
|
|
22
|
+
opacity: ChannelAccessor<Datum>;
|
|
23
23
|
strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
24
24
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
25
25
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
@@ -62,6 +62,8 @@ declare class __sveltets_Render<Datum = RawValue> {
|
|
|
62
62
|
}>, "fill" | "fillOpacity"> & {
|
|
63
63
|
data?: Datum[] | undefined;
|
|
64
64
|
automatic?: boolean;
|
|
65
|
+
x1?: ChannelAccessor<Datum>;
|
|
66
|
+
x2?: ChannelAccessor<Datum>;
|
|
65
67
|
};
|
|
66
68
|
events(): {};
|
|
67
69
|
slots(): {};
|
|
@@ -14,7 +14,7 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
14
14
|
sort: {
|
|
15
15
|
channel: string;
|
|
16
16
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
|
|
17
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | ConstantAccessor<import("../types/data.js").RawValue, Datum>;
|
|
18
18
|
stroke: ChannelAccessor<Datum>;
|
|
19
19
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
20
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -71,7 +71,7 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
71
71
|
outlineStrokeOpacity?: number;
|
|
72
72
|
curve?: CurveName | CurveFactory | "auto";
|
|
73
73
|
tension?: number;
|
|
74
|
-
sort?: ConstantAccessor<RawValue,
|
|
74
|
+
sort?: ConstantAccessor<RawValue, Datum_1> | {
|
|
75
75
|
channel: "stroke" | "fill";
|
|
76
76
|
};
|
|
77
77
|
text?: ConstantAccessor<string, Datum>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordizeX } from '../index.js';
|
|
1
2
|
import type { DataRow } from '../index.js';
|
|
2
3
|
declare class __sveltets_Render<Datum extends DataRow> {
|
|
3
4
|
props(): Omit<import("../types").MarkerOptions & Partial<{
|
|
@@ -69,7 +70,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
|
|
|
69
70
|
outlineStrokeOpacity?: number;
|
|
70
71
|
curve?: import("../types").CurveName | import("d3-shape").CurveFactory | "auto";
|
|
71
72
|
tension?: number;
|
|
72
|
-
sort?: import("../types").ConstantAccessor<
|
|
73
|
+
sort?: import("../types").ConstantAccessor<recordizeX, Datum_1> | {
|
|
73
74
|
channel: "stroke" | "fill";
|
|
74
75
|
};
|
|
75
76
|
text?: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordizeY } from '../index.js';
|
|
1
2
|
import type { DataRow } from '../index.js';
|
|
2
3
|
declare class __sveltets_Render<Datum extends DataRow> {
|
|
3
4
|
props(): Omit<import("../types").MarkerOptions & Partial<{
|
|
@@ -69,7 +70,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
|
|
|
69
70
|
outlineStrokeOpacity?: number;
|
|
70
71
|
curve?: import("../types").CurveName | import("d3-shape").CurveFactory | "auto";
|
|
71
72
|
tension?: number;
|
|
72
|
-
sort?: import("../types").ConstantAccessor<
|
|
73
|
+
sort?: import("../types").ConstantAccessor<recordizeY, Datum_1> | {
|
|
73
74
|
channel: "stroke" | "fill";
|
|
74
75
|
};
|
|
75
76
|
text?: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
package/dist/marks/Link.svelte
CHANGED
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
PlotDefaults
|
|
49
49
|
} from '../types/index.js';
|
|
50
50
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
51
|
-
import { maybeData } from '../helpers/index.js';
|
|
52
51
|
import Mark from '../Mark.svelte';
|
|
53
52
|
import MarkerPath from './helpers/MarkerPath.svelte';
|
|
54
53
|
import { replaceChannels } from '../transforms/rename.js';
|
|
@@ -57,6 +56,8 @@
|
|
|
57
56
|
import { maybeCurve } from '../helpers/curves.js';
|
|
58
57
|
import { geoPath } from 'd3-geo';
|
|
59
58
|
import { pick } from 'es-toolkit';
|
|
59
|
+
import { sort } from '../transforms/sort.js';
|
|
60
|
+
import { indexData } from '../transforms/recordize.js';
|
|
60
61
|
|
|
61
62
|
let markProps: LinkMarkProps = $props();
|
|
62
63
|
const DEFAULTS = {
|
|
@@ -77,17 +78,13 @@
|
|
|
77
78
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
78
79
|
let plot = $derived(getPlotState());
|
|
79
80
|
|
|
80
|
-
const sorted = $derived(
|
|
81
|
-
options.sort
|
|
82
|
-
? maybeData(data).toSorted((a, b) =>
|
|
83
|
-
resolveChannel('sort', a, options) > resolveChannel('sort', b, options) ? 1 : -1
|
|
84
|
-
)
|
|
85
|
-
: maybeData(data)
|
|
86
|
-
);
|
|
87
|
-
|
|
88
81
|
const args = $derived(
|
|
89
82
|
replaceChannels(
|
|
90
|
-
{
|
|
83
|
+
sort({
|
|
84
|
+
data: indexData(data),
|
|
85
|
+
stroke: 'currentColor',
|
|
86
|
+
...options
|
|
87
|
+
}),
|
|
91
88
|
{ y: ['y1', 'y2'], x: ['x1', 'x2'] }
|
|
92
89
|
)
|
|
93
90
|
);
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import { quadtree } from 'd3-quadtree';
|
|
31
31
|
import { projectXY } from '../helpers/scales.js';
|
|
32
32
|
import isDataRecord from '../helpers/isDataRecord.js';
|
|
33
|
-
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
33
|
+
import { indexData, RAW_VALUE } from '../transforms/recordize.js';
|
|
34
34
|
import { groupFacetsAndZ } from '../helpers/group.js';
|
|
35
35
|
|
|
36
36
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
|
|
117
117
|
const groups = $derived.by(() => {
|
|
118
118
|
const groups = [];
|
|
119
|
-
groupFacetsAndZ(data, { x, y, z, fx, fy }, (d) => groups.push(d));
|
|
119
|
+
groupFacetsAndZ(indexData(data), { x, y, z, fx, fy }, (d) => groups.push(d));
|
|
120
120
|
return groups;
|
|
121
121
|
});
|
|
122
122
|
|
package/dist/marks/RuleX.svelte
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
-->
|
|
4
4
|
<script lang="ts" generics="Datum = DataRecord | RawValue">
|
|
5
5
|
interface RuleXMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
|
|
6
|
-
data
|
|
6
|
+
data?: Datum[];
|
|
7
7
|
x?: ChannelAccessor<Datum>;
|
|
8
8
|
y1?: ChannelAccessor<Datum>;
|
|
9
9
|
y2?: ChannelAccessor<Datum>;
|
|
@@ -60,7 +60,7 @@ declare class __sveltets_Render<Datum = DataRecord | RawValue> {
|
|
|
60
60
|
class: string | null;
|
|
61
61
|
cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
|
|
62
62
|
}>, "fill" | "fillOpacity"> & {
|
|
63
|
-
data
|
|
63
|
+
data?: Datum[] | undefined;
|
|
64
64
|
x?: ChannelAccessor<Datum>;
|
|
65
65
|
y1?: ChannelAccessor<Datum>;
|
|
66
66
|
y2?: ChannelAccessor<Datum>;
|
package/dist/marks/Text.svelte
CHANGED
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
import { sort } from '../index.js';
|
|
72
72
|
|
|
73
73
|
import MultilineText from './helpers/MultilineText.svelte';
|
|
74
|
+
import { indexData } from '../transforms/recordize';
|
|
74
75
|
|
|
75
76
|
const DEFAULTS = {
|
|
76
77
|
fontSize: 12,
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
|
|
96
97
|
const args = $derived(
|
|
97
98
|
sort({
|
|
98
|
-
data,
|
|
99
|
+
data: indexData(data),
|
|
99
100
|
...options
|
|
100
101
|
})
|
|
101
102
|
) as TextMarkProps;
|
package/dist/marks/Vector.svelte
CHANGED
|
@@ -44,8 +44,9 @@
|
|
|
44
44
|
import { sort } from '../index.js';
|
|
45
45
|
import Mark from '../Mark.svelte';
|
|
46
46
|
//import DotCanvas from './helpers/DotCanvas.svelte';
|
|
47
|
-
import {
|
|
47
|
+
import { isValid } from '../helpers/index.js';
|
|
48
48
|
import { addEventHandlers } from './helpers/events.js';
|
|
49
|
+
import { indexData } from '../transforms/recordize.js';
|
|
49
50
|
|
|
50
51
|
const defaultRadius = 3.5;
|
|
51
52
|
|
|
@@ -145,7 +146,7 @@
|
|
|
145
146
|
|
|
146
147
|
const args = $derived(
|
|
147
148
|
sort({
|
|
148
|
-
data:
|
|
149
|
+
data: indexData(data),
|
|
149
150
|
// sort by descending radius by default
|
|
150
151
|
...options
|
|
151
152
|
})
|
|
@@ -201,11 +202,11 @@
|
|
|
201
202
|
? `translate(0, ${d.length})`
|
|
202
203
|
: `translate(0, ${d.length / 2})`}"
|
|
203
204
|
{style}
|
|
204
|
-
|
|
205
|
+
{@attach addEventHandlers({
|
|
205
206
|
getPlotState,
|
|
206
207
|
options: args,
|
|
207
|
-
datum: d
|
|
208
|
-
}}
|
|
208
|
+
datum: d?.datum
|
|
209
|
+
})}
|
|
209
210
|
class={[styleClass]} />
|
|
210
211
|
{/if}
|
|
211
212
|
{/each}
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
ConstantAccessor,
|
|
10
10
|
PlotState,
|
|
11
11
|
RawValue,
|
|
12
|
+
ScaledDataRecord,
|
|
12
13
|
ScaleType
|
|
13
14
|
} from '../../types/index.js';
|
|
14
15
|
import { resolveProp, resolveStyles } from '../../helpers/resolve.js';
|
|
15
16
|
import { max } from 'd3-array';
|
|
16
17
|
import { randomId, testFilter } from '../../helpers/index.js';
|
|
18
|
+
import { INDEX } from '../../constants';
|
|
19
|
+
import { RAW_VALUE } from '../../transforms/recordize';
|
|
17
20
|
|
|
18
21
|
type BaseAxisXProps = {
|
|
19
22
|
scaleFn: (d: RawValue) => number;
|
|
@@ -76,11 +79,12 @@
|
|
|
76
79
|
const positionedTicks = $derived.by(() => {
|
|
77
80
|
let tickObjects = removeIdenticalLines(
|
|
78
81
|
ticks.map((tick, i) => {
|
|
82
|
+
const datum = { [RAW_VALUE]: tick, [INDEX]: i };
|
|
79
83
|
return {
|
|
80
|
-
|
|
84
|
+
...datum,
|
|
81
85
|
hidden: false,
|
|
82
|
-
dx: +resolveProp(options.dx,
|
|
83
|
-
dy: +resolveProp(options.dy,
|
|
86
|
+
dx: +resolveProp(options.dx, datum, 0),
|
|
87
|
+
dy: +resolveProp(options.dy, datum, 0),
|
|
84
88
|
x: scaleFn(tick) + (scaleType === 'band' ? scaleFn.bandwidth() * 0.5 : 0),
|
|
85
89
|
text: splitTick(tickFormat(tick, i)),
|
|
86
90
|
element: null as SVGTextElement | null
|
|
@@ -101,7 +105,7 @@
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
return tickObjects;
|
|
108
|
+
return tickObjects as ScaledDataRecord[];
|
|
105
109
|
});
|
|
106
110
|
|
|
107
111
|
$effect(() => {
|
|
@@ -114,11 +118,11 @@
|
|
|
114
118
|
max(
|
|
115
119
|
positionedTicks.map((tick, i) => {
|
|
116
120
|
if (
|
|
117
|
-
resolveProp(options.anchor, tick
|
|
121
|
+
resolveProp(options.anchor, tick, outsideTextAnchor) !==
|
|
118
122
|
outsideTextAnchor
|
|
119
123
|
)
|
|
120
124
|
return 0;
|
|
121
|
-
if (tick.hidden || !testFilter(tick
|
|
125
|
+
if (tick.hidden || !testFilter(tick, options)) return 0;
|
|
122
126
|
if (tickTextElements[i])
|
|
123
127
|
return tickTextElements[i].getBoundingClientRect().height;
|
|
124
128
|
return 0;
|
|
@@ -148,8 +152,9 @@
|
|
|
148
152
|
|
|
149
153
|
<g class="axis-x">
|
|
150
154
|
{#each positionedTicks as tick, t (t)}
|
|
151
|
-
{#if testFilter(tick
|
|
152
|
-
{@const tickClass_ = resolveProp(tickClass, tick
|
|
155
|
+
{#if testFilter(tick, options) && !tick.hidden}
|
|
156
|
+
{@const tickClass_ = resolveProp(tickClass, tick)}
|
|
157
|
+
{@const tickFontSize_ = +resolveProp(tickFontSize, tick, 10)}
|
|
153
158
|
<g
|
|
154
159
|
class="tick {tickClass_ || ''}"
|
|
155
160
|
transform="translate({tick.x + tick.dx}, {tickY + tick.dy})"
|
|
@@ -157,7 +162,7 @@
|
|
|
157
162
|
{#if tickSize}
|
|
158
163
|
{@const [tickLineStyle, tickLineClass] = resolveStyles(
|
|
159
164
|
plot,
|
|
160
|
-
tick,
|
|
165
|
+
{ datum: tick },
|
|
161
166
|
options,
|
|
162
167
|
'stroke',
|
|
163
168
|
{ x: true },
|
|
@@ -174,15 +179,15 @@
|
|
|
174
179
|
{@const prevTextLines = t && positionedTicks[t - 1].text}
|
|
175
180
|
|
|
176
181
|
{@const moveDown =
|
|
177
|
-
(tickSize + tickPadding + (tickRotate !== 0 ?
|
|
182
|
+
(tickSize + tickPadding + (tickRotate !== 0 ? tickFontSize_ * 0.35 : 0)) *
|
|
178
183
|
(anchor === 'bottom' ? 1 : -1)}
|
|
179
184
|
{@const [textStyle, textClass] = resolveStyles(
|
|
180
185
|
plot,
|
|
181
|
-
tick,
|
|
186
|
+
{ datum: tick },
|
|
182
187
|
{
|
|
183
188
|
fontVariant: isQuantitative ? 'tabular-nums' : 'normal',
|
|
184
189
|
...options,
|
|
185
|
-
fontSize:
|
|
190
|
+
fontSize: tickFontSize_,
|
|
186
191
|
stroke: null
|
|
187
192
|
},
|
|
188
193
|
'fill',
|
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
import type {
|
|
7
7
|
AutoMarginStores,
|
|
8
8
|
ConstantAccessor,
|
|
9
|
+
DataRecord,
|
|
9
10
|
PlotState,
|
|
10
11
|
RawValue,
|
|
12
|
+
ScaledDataRecord,
|
|
11
13
|
ScaleType
|
|
12
14
|
} from '../../types/index.js';
|
|
15
|
+
import { RAW_VALUE } from '../../transforms/recordize';
|
|
16
|
+
import { INDEX } from '../../constants';
|
|
13
17
|
|
|
14
18
|
type BaseAxisYProps = {
|
|
15
19
|
scaleFn: (d: RawValue) => number;
|
|
@@ -61,13 +65,14 @@
|
|
|
61
65
|
|
|
62
66
|
const positionedTicks = $derived.by(() => {
|
|
63
67
|
let tickObjects = ticks.map((tick, i) => {
|
|
68
|
+
const datum = { [RAW_VALUE]: tick, [INDEX]: i };
|
|
64
69
|
return {
|
|
65
|
-
|
|
70
|
+
...datum,
|
|
66
71
|
hidden: false,
|
|
67
|
-
dx: +resolveProp(options.dx,
|
|
68
|
-
dy: +resolveProp(options.dy,
|
|
72
|
+
dx: +resolveProp(options.dx, datum, 0),
|
|
73
|
+
dy: +resolveProp(options.dy, datum, 0),
|
|
69
74
|
y: scaleFn(tick) + (scaleType === 'band' ? scaleFn.bandwidth() * 0.5 : 0),
|
|
70
|
-
text: tickFormat(tick),
|
|
75
|
+
text: tickFormat(tick, i),
|
|
71
76
|
element: null as SVGTextElement | null
|
|
72
77
|
};
|
|
73
78
|
});
|
|
@@ -107,11 +112,11 @@
|
|
|
107
112
|
max(
|
|
108
113
|
positionedTicks.map((tick, i) => {
|
|
109
114
|
if (
|
|
110
|
-
resolveProp(options.textAnchor, tick
|
|
115
|
+
resolveProp(options.textAnchor, tick, outsideTextAnchor) !==
|
|
111
116
|
outsideTextAnchor
|
|
112
117
|
)
|
|
113
118
|
return 0;
|
|
114
|
-
if (tick.hidden || !testFilter(tick
|
|
119
|
+
if (tick.hidden || !testFilter(tick, options)) return 0;
|
|
115
120
|
if (tickTexts[i]) return tickTexts[i].getBoundingClientRect().width;
|
|
116
121
|
return 0;
|
|
117
122
|
}) as number[]
|
|
@@ -150,11 +155,11 @@
|
|
|
150
155
|
|
|
151
156
|
<g class="axis-y">
|
|
152
157
|
{#each positionedTicks as tick, t (t)}
|
|
153
|
-
{#if testFilter(tick
|
|
154
|
-
{@const tickClass_ = resolveProp(tickClass, tick
|
|
158
|
+
{#if testFilter(tick, options) && !tick.hidden}
|
|
159
|
+
{@const tickClass_ = resolveProp(tickClass, tick)}
|
|
155
160
|
{@const [textStyle, textClass] = resolveStyles(
|
|
156
161
|
plot,
|
|
157
|
-
tick,
|
|
162
|
+
{ datum: tick },
|
|
158
163
|
{
|
|
159
164
|
fontVariant: isQuantitative ? 'tabular-nums' : 'normal',
|
|
160
165
|
...options,
|
|
@@ -173,7 +178,7 @@
|
|
|
173
178
|
{#if tickSize}
|
|
174
179
|
{@const [tickLineStyle, tickLineClass] = resolveStyles(
|
|
175
180
|
plot,
|
|
176
|
-
tick,
|
|
181
|
+
{ datum: tick },
|
|
177
182
|
options,
|
|
178
183
|
'stroke',
|
|
179
184
|
{ y: true },
|
|
@@ -95,7 +95,11 @@
|
|
|
95
95
|
{transform}
|
|
96
96
|
class={className}
|
|
97
97
|
stroke-width={strokeWidth_}
|
|
98
|
-
|
|
98
|
+
{@attach addEventHandlers({
|
|
99
|
+
getPlotState,
|
|
100
|
+
options: mark.options,
|
|
101
|
+
datum: datum
|
|
102
|
+
})}>
|
|
99
103
|
{#each Object.entries( { start: markerStart, mid: markerMid, end: markerEnd, all: marker } ) as [key, marker] (key)}
|
|
100
104
|
{@const markerId = `marker-${key === 'all' ? '' : `${key}-`}${id}`}
|
|
101
105
|
{#if isSnippet(marker)}
|
|
@@ -122,7 +126,11 @@
|
|
|
122
126
|
marker-end={markerEnd || marker ? `url(#marker-${markerEnd ? 'end-' : ''}${id})` : null}
|
|
123
127
|
{d}
|
|
124
128
|
{style}
|
|
125
|
-
|
|
129
|
+
{@attach addEventHandlers({
|
|
130
|
+
getPlotState,
|
|
131
|
+
options: mark.options,
|
|
132
|
+
datum: datum
|
|
133
|
+
})} />
|
|
126
134
|
{#if text}
|
|
127
135
|
<!-- since textPath.side is not yet supported, we have to use an invisible
|
|
128
136
|
path in order to keep the text from turning upside down -->
|