svelteplot 0.8.1-pr-298.0 → 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/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/helpers/projection.js +7 -2
- package/dist/marks/Area.svelte.d.ts +1 -0
- package/dist/marks/AreaX.svelte.d.ts +1 -0
- package/dist/marks/Arrow.svelte.d.ts +1 -0
- package/dist/marks/AxisX.svelte.d.ts +1 -0
- package/dist/marks/AxisY.svelte +1 -1
- package/dist/marks/AxisY.svelte.d.ts +1 -0
- package/dist/marks/BarX.svelte.d.ts +1 -0
- package/dist/marks/BarY.svelte.d.ts +1 -0
- package/dist/marks/BoxX.svelte +1 -0
- package/dist/marks/BoxY.svelte +1 -0
- package/dist/marks/Cell.svelte.d.ts +1 -0
- 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.d.ts +1 -0
- package/dist/marks/Geo.svelte +2 -0
- package/dist/marks/Geo.svelte.d.ts +2 -0
- package/dist/marks/GridX.svelte.d.ts +1 -0
- package/dist/marks/GridY.svelte.d.ts +1 -0
- package/dist/marks/Line.svelte +5 -2
- 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.d.ts +1 -0
- package/dist/marks/Rect.svelte.d.ts +1 -0
- package/dist/marks/RuleX.svelte.d.ts +1 -0
- package/dist/marks/RuleY.svelte.d.ts +1 -0
- package/dist/marks/Spike.svelte.d.ts +1 -0
- package/dist/marks/Text.svelte.d.ts +1 -0
- package/dist/marks/TickX.svelte.d.ts +1 -0
- package/dist/marks/TickY.svelte.d.ts +1 -0
- package/dist/marks/Trail.svelte +163 -0
- package/dist/marks/Trail.svelte.d.ts +44 -0
- package/dist/marks/Vector.svelte.d.ts +1 -0
- package/dist/marks/helpers/Box.svelte +42 -39
- package/dist/marks/helpers/TrailCanvas.svelte +140 -0
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
- 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/types/mark.d.ts +2 -1
- package/dist/types/plot.d.ts +5 -1
- package/package.json +16 -15
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, index);
|
|
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,6 +29,7 @@ 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;
|
|
32
33
|
imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
|
|
33
34
|
shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
35
|
paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -117,6 +117,8 @@ 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;
|
|
120
122
|
// export const CHANNEL_MAP: Record<ScaleName, ValueOf<typeof SCALE_TYPES>> = {
|
|
121
123
|
// x: SCALE_TYPES.x,
|
|
122
124
|
// 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 && dx > 0 && dy > 0) {
|
|
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,9 +66,14 @@ 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
|
-
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
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
|
+
}
|
|
72
77
|
transform ??=
|
|
73
78
|
tx === 0 && ty === 0
|
|
74
79
|
? identity()
|
|
@@ -29,6 +29,7 @@ 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;
|
|
32
33
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
34
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
35
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -28,6 +28,7 @@ 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;
|
|
31
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -28,6 +28,7 @@ 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;
|
|
31
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
33
34
|
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.options.y.reverse ? '↑' : '↓'} ${plot.scales.y.autoTitle}${plot.options.y.percent ? ' (%)' : ''}`
|
|
174
174
|
: ''
|
|
175
175
|
);
|
|
176
176
|
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -29,6 +29,7 @@ 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;
|
|
32
33
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
33
34
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
35
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -28,6 +28,7 @@ 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;
|
|
31
32
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/marks/BoxX.svelte
CHANGED
package/dist/marks/BoxY.svelte
CHANGED
|
@@ -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>;
|
|
@@ -28,6 +28,7 @@ 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;
|
|
31
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -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/Geo.svelte
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* radius for point features
|
|
22
22
|
*/
|
|
23
23
|
r?: ChannelAccessor<Datum>;
|
|
24
|
+
svgFilter?: ConstantAccessor<string | undefined, Datum>;
|
|
24
25
|
}
|
|
25
26
|
import { getContext } from 'svelte';
|
|
26
27
|
import type {
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
d={path(geometry)}
|
|
112
113
|
{style}
|
|
113
114
|
class={[styleClass]}
|
|
115
|
+
filter={resolveProp(args.svgFilter, d.datum, undefined)}
|
|
114
116
|
{@attach addEventHandlers({
|
|
115
117
|
getPlotState,
|
|
116
118
|
options: args,
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -84,6 +85,7 @@ declare function $$render<Datum = DataRecord | GeoJSON.GeoJsonObject>(): {
|
|
|
84
85
|
* radius for point features
|
|
85
86
|
*/
|
|
86
87
|
r?: ChannelAccessor<Datum>;
|
|
88
|
+
svgFilter?: ConstantAccessor<string | undefined, Datum>;
|
|
87
89
|
};
|
|
88
90
|
exports: {};
|
|
89
91
|
bindings: "";
|
|
@@ -27,6 +27,7 @@ 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;
|
|
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>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
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/Line.svelte
CHANGED
|
@@ -76,7 +76,10 @@
|
|
|
76
76
|
|
|
77
77
|
const args = $derived(sort(recordizeXY({ data, ...options })));
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Groups the data by the specified key
|
|
81
|
+
*/
|
|
82
|
+
function groupIndex(data: ScaledDataRecord[], groupByKey: ChannelAccessor<Datum> | null) {
|
|
80
83
|
if (!groupByKey) return [data];
|
|
81
84
|
let group = [];
|
|
82
85
|
const groups = [group];
|
|
@@ -95,7 +98,7 @@
|
|
|
95
98
|
return groups;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
const groupByKey = $derived(args.z || args.stroke);
|
|
101
|
+
const groupByKey = $derived(args.z || args.stroke) as ChannelAccessor<Datum> | null;
|
|
99
102
|
|
|
100
103
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
101
104
|
const plot = $derived(getPlotState());
|
|
@@ -29,6 +29,7 @@ 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;
|
|
32
33
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
34
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
35
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
|
|
32
33
|
paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
@@ -27,6 +27,7 @@ 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;
|
|
30
31
|
imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
|
|
32
33
|
paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
|
|
@@ -28,6 +28,7 @@ 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;
|
|
31
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -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>;
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum = DataRecord | RawValue>(): {
|
|
|
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>;
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum = 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>;
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
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;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -29,6 +29,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
29
29
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
30
30
|
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
|
|
31
31
|
clipPath: string;
|
|
32
|
+
mask: string;
|
|
32
33
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
34
|
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
34
35
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
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>;
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
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>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<script lang="ts" generics="Datum extends DataRecord">
|
|
2
|
+
interface TrailMarkProps extends Omit<
|
|
3
|
+
BaseMarkProps<Datum>,
|
|
4
|
+
'stroke' | 'strokeWidth' | 'strokeDasharray'
|
|
5
|
+
> {
|
|
6
|
+
data?: Datum[];
|
|
7
|
+
x?: ChannelAccessor<Datum>;
|
|
8
|
+
y?: ChannelAccessor<Datum>;
|
|
9
|
+
z?: ChannelAccessor<Datum>;
|
|
10
|
+
r?: ChannelAccessor<Datum>;
|
|
11
|
+
curve?: CurveName | CurveFactory;
|
|
12
|
+
tension?: number;
|
|
13
|
+
sort?: ConstantAccessor<RawValue, Datum> | { channel: 'stroke' | 'fill' };
|
|
14
|
+
defined?: ConstantAccessor<boolean, Datum>;
|
|
15
|
+
canvas?: boolean;
|
|
16
|
+
cap?: 'butt' | 'round';
|
|
17
|
+
/**
|
|
18
|
+
* Samples per segment for curve interpolation
|
|
19
|
+
*/
|
|
20
|
+
resolution?: number | 'auto';
|
|
21
|
+
}
|
|
22
|
+
import type {
|
|
23
|
+
DataRecord,
|
|
24
|
+
ChannelAccessor,
|
|
25
|
+
BaseMarkProps,
|
|
26
|
+
ConstantAccessor,
|
|
27
|
+
RawValue,
|
|
28
|
+
PlotContext,
|
|
29
|
+
ScaledDataRecord,
|
|
30
|
+
CurveName
|
|
31
|
+
} from '../types';
|
|
32
|
+
import Mark from '../Mark.svelte';
|
|
33
|
+
import { getContext } from 'svelte';
|
|
34
|
+
import { path as d3Path } from 'd3-path';
|
|
35
|
+
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
36
|
+
import { getPlotDefaults } from '../hooks/plotDefaults';
|
|
37
|
+
import { sort } from '../transforms';
|
|
38
|
+
import trailPath, { type TrailSample } from './helpers/trail.js';
|
|
39
|
+
import TrailCanvas from './helpers/TrailCanvas.svelte';
|
|
40
|
+
import { addEventHandlers } from './helpers/events';
|
|
41
|
+
import type { CurveFactory } from 'd3-shape';
|
|
42
|
+
|
|
43
|
+
let markProps: TrailMarkProps = $props();
|
|
44
|
+
|
|
45
|
+
const DEFAULTS: TrailMarkProps = {
|
|
46
|
+
curve: 'linear',
|
|
47
|
+
r: 3,
|
|
48
|
+
canvas: false,
|
|
49
|
+
resolution: 'auto',
|
|
50
|
+
cap: 'round',
|
|
51
|
+
tension: 0,
|
|
52
|
+
...getPlotDefaults().trail
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
data = [{} as Datum],
|
|
57
|
+
curve,
|
|
58
|
+
resolution,
|
|
59
|
+
tension,
|
|
60
|
+
canvas,
|
|
61
|
+
cap,
|
|
62
|
+
class: className,
|
|
63
|
+
...options
|
|
64
|
+
}: TrailMarkProps = $derived({
|
|
65
|
+
...DEFAULTS,
|
|
66
|
+
...markProps
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const args = $derived(sort({ data, ...options })) as TrailMarkProps;
|
|
70
|
+
|
|
71
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
72
|
+
const plot = $derived(getPlotState());
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Groups the data by the specified key
|
|
76
|
+
*/
|
|
77
|
+
function groupIndex(data: ScaledDataRecord[], groupByKey: ChannelAccessor<Datum> | null) {
|
|
78
|
+
if (!groupByKey) return [data];
|
|
79
|
+
let group: ScaledDataRecord[] = [];
|
|
80
|
+
const groups = [group];
|
|
81
|
+
let lastGroupValue;
|
|
82
|
+
for (const d of data) {
|
|
83
|
+
const groupValue = resolveProp(groupByKey, d.datum);
|
|
84
|
+
if (groupValue === lastGroupValue || group.length === 0) {
|
|
85
|
+
group.push(d);
|
|
86
|
+
lastGroupValue = groupValue;
|
|
87
|
+
} else {
|
|
88
|
+
// new group
|
|
89
|
+
group = [d];
|
|
90
|
+
groups.push(group);
|
|
91
|
+
lastGroupValue = groupValue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return groups.filter((d) => d.length > 0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const groupByKey = $derived(args.z || args.fill) as ChannelAccessor<Datum> | null;
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<Mark
|
|
101
|
+
type="trail"
|
|
102
|
+
channels={['x', 'y', 'opacity', 'fill', 'fillOpacity', 'r']}
|
|
103
|
+
required={['x', 'y']}
|
|
104
|
+
{...args}>
|
|
105
|
+
{#snippet children({ mark, usedScales, scaledData })}
|
|
106
|
+
{#if scaledData.length > 0}
|
|
107
|
+
{@const groupedTrailData = groupIndex(scaledData, groupByKey)}
|
|
108
|
+
{#if canvas}
|
|
109
|
+
<!-- todo -->
|
|
110
|
+
<TrailCanvas
|
|
111
|
+
{curve}
|
|
112
|
+
{cap}
|
|
113
|
+
{tension}
|
|
114
|
+
{resolution}
|
|
115
|
+
{usedScales}
|
|
116
|
+
data={groupedTrailData}
|
|
117
|
+
options={args} />
|
|
118
|
+
{:else}
|
|
119
|
+
<g class={['trail', className]}>
|
|
120
|
+
{#each groupedTrailData as trailData, i (i)}
|
|
121
|
+
{@const samples = trailData.map((d) => ({
|
|
122
|
+
x: Number(d.x),
|
|
123
|
+
y: Number(d.y),
|
|
124
|
+
r: Number(d.r ?? 0)
|
|
125
|
+
})) satisfies TrailSample[]}
|
|
126
|
+
{@const defined = trailData.map(
|
|
127
|
+
(d) =>
|
|
128
|
+
d.valid &&
|
|
129
|
+
d.r >= 0 &&
|
|
130
|
+
(resolveProp(options.defined, d.datum, true) ?? true)
|
|
131
|
+
)}
|
|
132
|
+
{@const pathString = trailPath(samples, defined, d3Path(), {
|
|
133
|
+
curve,
|
|
134
|
+
cap,
|
|
135
|
+
tension,
|
|
136
|
+
...(typeof resolution === 'number'
|
|
137
|
+
? { samplesPerSegment: resolution }
|
|
138
|
+
: {})
|
|
139
|
+
})}
|
|
140
|
+
{@const [style, styleClass] = resolveStyles(
|
|
141
|
+
plot,
|
|
142
|
+
trailData[0],
|
|
143
|
+
{
|
|
144
|
+
...args
|
|
145
|
+
},
|
|
146
|
+
'fill',
|
|
147
|
+
usedScales
|
|
148
|
+
)}
|
|
149
|
+
<path
|
|
150
|
+
d={pathString}
|
|
151
|
+
{style}
|
|
152
|
+
class={styleClass}
|
|
153
|
+
{@attach addEventHandlers({
|
|
154
|
+
getPlotState,
|
|
155
|
+
options: mark.options,
|
|
156
|
+
datum: trailData[0].datum
|
|
157
|
+
})} />
|
|
158
|
+
{/each}
|
|
159
|
+
</g>
|
|
160
|
+
{/if}
|
|
161
|
+
{/if}
|
|
162
|
+
{/snippet}
|
|
163
|
+
</Mark>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DataRecord, ChannelAccessor, ConstantAccessor, RawValue, CurveName } from '../types';
|
|
2
|
+
import type { CurveFactory } from 'd3-shape';
|
|
3
|
+
declare function $$render<Datum extends DataRecord>(): {
|
|
4
|
+
props: Omit<BaseMarkProps<Datum>, "stroke" | "strokeDasharray" | "strokeWidth"> & {
|
|
5
|
+
data?: Datum[];
|
|
6
|
+
x?: ChannelAccessor<Datum>;
|
|
7
|
+
y?: ChannelAccessor<Datum>;
|
|
8
|
+
z?: ChannelAccessor<Datum>;
|
|
9
|
+
r?: ChannelAccessor<Datum>;
|
|
10
|
+
curve?: CurveName | CurveFactory;
|
|
11
|
+
tension?: number;
|
|
12
|
+
sort?: ConstantAccessor<RawValue, Datum> | {
|
|
13
|
+
channel: "stroke" | "fill";
|
|
14
|
+
};
|
|
15
|
+
defined?: ConstantAccessor<boolean, Datum>;
|
|
16
|
+
canvas?: boolean;
|
|
17
|
+
cap?: "butt" | "round";
|
|
18
|
+
/**
|
|
19
|
+
* Samples per segment for curve interpolation
|
|
20
|
+
*/
|
|
21
|
+
resolution?: number | "auto";
|
|
22
|
+
};
|
|
23
|
+
exports: {};
|
|
24
|
+
bindings: "";
|
|
25
|
+
slots: {};
|
|
26
|
+
events: {};
|
|
27
|
+
};
|
|
28
|
+
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
29
|
+
props(): ReturnType<typeof $$render<Datum>>['props'];
|
|
30
|
+
events(): ReturnType<typeof $$render<Datum>>['events'];
|
|
31
|
+
slots(): ReturnType<typeof $$render<Datum>>['slots'];
|
|
32
|
+
bindings(): "";
|
|
33
|
+
exports(): {};
|
|
34
|
+
}
|
|
35
|
+
interface $$IsomorphicComponent {
|
|
36
|
+
new <Datum extends DataRecord>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
|
|
37
|
+
$$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
|
|
38
|
+
} & ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
39
|
+
<Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
40
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
41
|
+
}
|
|
42
|
+
declare const Trail: $$IsomorphicComponent;
|
|
43
|
+
type Trail<Datum extends DataRecord> = InstanceType<typeof Trail<Datum>>;
|
|
44
|
+
export default Trail;
|
|
@@ -32,6 +32,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
32
32
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
33
33
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
34
34
|
clipPath: string;
|
|
35
|
+
mask: string;
|
|
35
36
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
36
37
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
37
38
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|