svelteplot 0.2.9 → 0.2.10-pr-110.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/README.md +1 -1
- package/dist/Mark.svelte +5 -4
- package/dist/Plot.svelte +3 -2
- package/dist/core/Plot.svelte +37 -20
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/scales.js +9 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +31 -29
- package/dist/marks/AreaX.svelte +7 -3
- package/dist/marks/AreaX.svelte.d.ts +1 -6
- package/dist/marks/AreaY.svelte +7 -2
- package/dist/marks/AreaY.svelte.d.ts +1 -9
- package/dist/marks/Arrow.svelte +24 -7
- package/dist/marks/AxisX.svelte +24 -21
- package/dist/marks/AxisX.svelte.d.ts +3 -4
- package/dist/marks/AxisY.svelte +23 -20
- package/dist/marks/AxisY.svelte.d.ts +3 -4
- package/dist/marks/BarX.svelte +18 -2
- package/dist/marks/BarX.svelte.d.ts +2 -2
- package/dist/marks/BarY.svelte +18 -3
- package/dist/marks/BarY.svelte.d.ts +2 -2
- package/dist/marks/BollingerX.svelte.d.ts +1 -1
- package/dist/marks/BollingerY.svelte.d.ts +1 -1
- package/dist/marks/BoxX.svelte +23 -9
- package/dist/marks/BoxX.svelte.d.ts +3 -2
- package/dist/marks/BoxY.svelte +20 -10
- package/dist/marks/BoxY.svelte.d.ts +3 -3
- package/dist/marks/Brush.svelte +30 -10
- package/dist/marks/BrushX.svelte +9 -3
- package/dist/marks/BrushX.svelte.d.ts +1 -1
- package/dist/marks/BrushY.svelte +9 -3
- package/dist/marks/BrushY.svelte.d.ts +1 -1
- package/dist/marks/Cell.svelte +17 -2
- package/dist/marks/Cell.svelte.d.ts +2 -2
- package/dist/marks/ColorLegend.svelte +3 -2
- package/dist/marks/Dot.svelte +29 -24
- package/dist/marks/Dot.svelte.d.ts +2 -2
- package/dist/marks/Frame.svelte +24 -4
- package/dist/marks/Frame.svelte.d.ts +2 -2
- package/dist/marks/Geo.svelte +41 -37
- package/dist/marks/Geo.svelte.d.ts +4 -2
- package/dist/marks/Graticule.svelte +14 -5
- package/dist/marks/GridX.svelte +16 -2
- package/dist/marks/GridY.svelte +16 -2
- package/dist/marks/Line.svelte +22 -8
- package/dist/marks/Link.svelte +12 -4
- package/dist/marks/Pointer.svelte +12 -3
- package/dist/marks/Rect.svelte +17 -2
- package/dist/marks/Rect.svelte.d.ts +2 -2
- package/dist/marks/RectX.svelte +16 -2
- package/dist/marks/RectY.svelte +16 -2
- package/dist/marks/RuleX.svelte +15 -2
- package/dist/marks/RuleY.svelte +15 -2
- package/dist/marks/Sphere.svelte +17 -4
- package/dist/marks/Sphere.svelte.d.ts +3 -58
- package/dist/marks/Text.svelte +22 -4
- package/dist/marks/TickX.svelte +15 -2
- package/dist/marks/TickY.svelte +15 -2
- package/dist/marks/Vector.svelte +13 -5
- package/dist/marks/helpers/Anchor.svelte +37 -0
- package/dist/marks/helpers/Anchor.svelte.d.ts +15 -0
- package/dist/marks/helpers/BaseAxisX.svelte +59 -53
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
- package/dist/marks/helpers/BaseAxisY.svelte +24 -18
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/RectPath.svelte +33 -30
- package/dist/marks/helpers/Regression.svelte +1 -1
- package/dist/transforms/bollinger.d.ts +1 -8
- package/dist/transforms/centroid.d.ts +1 -8
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -6
- package/dist/transforms/map.d.ts +4 -10
- package/dist/transforms/normalize.d.ts +2 -6
- package/dist/transforms/select.d.ts +7 -21
- package/dist/transforms/sort.d.ts +5 -17
- package/dist/transforms/sort.js +23 -13
- package/dist/transforms/window.d.ts +2 -14
- package/dist/types.d.ts +251 -78
- package/dist/ui/ExamplesGrid.svelte +1 -1
- package/package.json +121 -120
|
@@ -11,11 +11,4 @@ export type BollingerOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function bollingerX(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
|
|
13
13
|
export declare function bollingerY(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
|
|
14
|
-
export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions):
|
|
15
|
-
data: {
|
|
16
|
-
__x: import("../types.js").RawValue;
|
|
17
|
-
__lo: number;
|
|
18
|
-
__avg: number;
|
|
19
|
-
__hi: number;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
14
|
+
export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): any;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import type { DataRecord, TransformArg } from '../types.js';
|
|
2
|
-
export declare function geoCentroid({ data, ...options }: TransformArg<DataRecord>):
|
|
3
|
-
x: (d: any) => any;
|
|
4
|
-
y: (d: any) => any;
|
|
5
|
-
data: {
|
|
6
|
-
__centroid__: [number, number];
|
|
7
|
-
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
8
|
-
}[];
|
|
9
|
-
};
|
|
2
|
+
export declare function geoCentroid({ data, ...options }: TransformArg<DataRecord>): any;
|
|
@@ -38,29 +38,21 @@ type GroupZOptions = GroupXOptions | GroupYOptions;
|
|
|
38
38
|
* groups the dataset by x and y channel and optionally reduces the group items
|
|
39
39
|
* to output channels fill, stroke, r, opacity, fillOpacity, or strokeOpacity
|
|
40
40
|
*/
|
|
41
|
-
export declare function group({ data, ...channels }: TransformArg<T, DataRecord>, options?: GroupXOptions):
|
|
42
|
-
data: DataRecord[];
|
|
43
|
-
};
|
|
41
|
+
export declare function group({ data, ...channels }: TransformArg<T, DataRecord>, options?: GroupXOptions): any;
|
|
44
42
|
/**
|
|
45
43
|
* groups the dataset by the x channel and optionally reduces the group items
|
|
46
44
|
* to output channels y, y1, y2, fill, stroke, r, opacity, fillOpacity, or strokeOpacity
|
|
47
45
|
*/
|
|
48
|
-
export declare function groupX(input: TransformArg<T, DataRecord>, options?: GroupXOptions):
|
|
49
|
-
data: DataRecord[];
|
|
50
|
-
};
|
|
46
|
+
export declare function groupX(input: TransformArg<T, DataRecord>, options?: GroupXOptions): any;
|
|
51
47
|
/**
|
|
52
48
|
* groups the dataset by the y channel and optionally reduces the group items
|
|
53
49
|
* to output channels x, x1, x2, fill, stroke, r, opacity, fillOpacity, or strokeOpacity
|
|
54
50
|
*/
|
|
55
|
-
export declare function groupY(input: TransformArg<T, DataRecord>, options?: GroupYOptions):
|
|
56
|
-
data: DataRecord[];
|
|
57
|
-
};
|
|
51
|
+
export declare function groupY(input: TransformArg<T, DataRecord>, options?: GroupYOptions): any;
|
|
58
52
|
/**
|
|
59
53
|
* groups the dataset by the z channel and optionally reduces the group items
|
|
60
54
|
* to output channels x, x1, x2, y, y1, y2, fill, stroke, r, opacity, fillOpacity,
|
|
61
55
|
* or strokeOpacity
|
|
62
56
|
*/
|
|
63
|
-
export declare function groupZ(input: TransformArg<T, DataRecord>, options?: GroupZOptions):
|
|
64
|
-
data: DataRecord[];
|
|
65
|
-
};
|
|
57
|
+
export declare function groupZ(input: TransformArg<T, DataRecord>, options?: GroupZOptions): any;
|
|
66
58
|
export {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { PlotState, TransformArg } from '../types.js';
|
|
2
2
|
export declare function intervalX<T>(args: TransformArg<T>, { plot }: {
|
|
3
3
|
plot: PlotState;
|
|
4
|
-
}):
|
|
5
|
-
data: T[];
|
|
6
|
-
};
|
|
4
|
+
}): any;
|
|
7
5
|
export declare function intervalY<T>(args: TransformArg<T>, { plot }: {
|
|
8
6
|
plot: PlotState;
|
|
9
|
-
}):
|
|
10
|
-
data: T[];
|
|
11
|
-
};
|
|
7
|
+
}): any;
|
package/dist/transforms/map.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type { TransformArg, MapOptions, MapMethod
|
|
2
|
-
export declare function map<T>(args: TransformArg<T>, options: MapOptions):
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function mapX<T>(args: TransformArg<T>, mapper: MapMethod): {
|
|
6
|
-
data: DataRecord[];
|
|
7
|
-
};
|
|
8
|
-
export declare function mapY<T>(args: TransformArg<T>, mapper: MapMethod): {
|
|
9
|
-
data: DataRecord[];
|
|
10
|
-
};
|
|
1
|
+
import type { TransformArg, MapOptions, MapMethod } from '../types.js';
|
|
2
|
+
export declare function map<T>(args: TransformArg<T>, options: MapOptions): any;
|
|
3
|
+
export declare function mapX<T>(args: TransformArg<T>, mapper: MapMethod): any;
|
|
4
|
+
export declare function mapY<T>(args: TransformArg<T>, mapper: MapMethod): any;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { TransformArg, MapIndexObject } from '../types.js';
|
|
2
2
|
type NormalizeBasis = 'deviation' | 'first' | 'last' | 'min' | 'max' | 'mean' | 'median' | 'sum' | 'extent' | MapIndexObject;
|
|
3
|
-
export declare function normalizeX<T>(args: TransformArg<T>, basis: NormalizeBasis):
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export declare function normalizeY<T>(args: TransformArg<T>, basis: NormalizeBasis): {
|
|
7
|
-
data: import("../types.js").DataRecord[];
|
|
8
|
-
};
|
|
3
|
+
export declare function normalizeX<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
|
|
4
|
+
export declare function normalizeY<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
|
|
9
5
|
export {};
|
|
@@ -5,31 +5,17 @@ type AtLeastOne<T, U = {
|
|
|
5
5
|
type SelectOptions = 'first' | 'last' | AtLeastOne<{
|
|
6
6
|
[k in ChannelName]: 'min' | 'max';
|
|
7
7
|
}>;
|
|
8
|
-
export declare function select({ data, ...channels }: TransformArg<DataRecord>, options: SelectOptions):
|
|
9
|
-
data: DataRecord[];
|
|
10
|
-
};
|
|
8
|
+
export declare function select({ data, ...channels }: TransformArg<DataRecord>, options: SelectOptions): any;
|
|
11
9
|
/**
|
|
12
10
|
* Keeps only the first item of each group
|
|
13
11
|
*/
|
|
14
|
-
export declare function selectFirst(args: TransformArg<DataRecord>):
|
|
15
|
-
data: DataRecord[];
|
|
16
|
-
};
|
|
12
|
+
export declare function selectFirst(args: TransformArg<DataRecord>): any;
|
|
17
13
|
/**
|
|
18
14
|
* Keeps only the last item of each group
|
|
19
15
|
*/
|
|
20
|
-
export declare function selectLast(args: TransformArg<DataRecord>):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export declare function
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
export declare function selectMaxX(args: TransformArg<DataRecord>): {
|
|
27
|
-
data: DataRecord[];
|
|
28
|
-
};
|
|
29
|
-
export declare function selectMinY(args: TransformArg<DataRecord>): {
|
|
30
|
-
data: DataRecord[];
|
|
31
|
-
};
|
|
32
|
-
export declare function selectMaxY(args: TransformArg<DataRecord>): {
|
|
33
|
-
data: DataRecord[];
|
|
34
|
-
};
|
|
16
|
+
export declare function selectLast(args: TransformArg<DataRecord>): any;
|
|
17
|
+
export declare function selectMinX(args: TransformArg<DataRecord>): any;
|
|
18
|
+
export declare function selectMaxX(args: TransformArg<DataRecord>): any;
|
|
19
|
+
export declare function selectMinY(args: TransformArg<DataRecord>): any;
|
|
20
|
+
export declare function selectMaxY(args: TransformArg<DataRecord>): any;
|
|
35
21
|
export {};
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import type { DataRecord, DataRow, TransformArg } from '../types.js';
|
|
2
2
|
export declare const SORT_KEY: unique symbol;
|
|
3
|
+
export declare const IS_SORTED: unique symbol;
|
|
3
4
|
export declare function sort({ data, ...channels }: TransformArg<DataRecord>, options?: {
|
|
4
5
|
reverse?: boolean;
|
|
5
|
-
}):
|
|
6
|
-
sort: null;
|
|
7
|
-
data: {
|
|
8
|
-
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
9
|
-
}[];
|
|
10
|
-
} | {
|
|
11
|
-
data: DataRecord[];
|
|
12
|
-
};
|
|
6
|
+
}): any;
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
8
|
+
* shuffles the data row order
|
|
15
9
|
*/
|
|
16
10
|
export declare function shuffle({ data, ...channels }: TransformArg<DataRow[]>, options?: {
|
|
17
11
|
seed?: number;
|
|
18
|
-
}):
|
|
19
|
-
sort: null;
|
|
20
|
-
data: DataRow[][];
|
|
21
|
-
};
|
|
12
|
+
}): any;
|
|
22
13
|
/**
|
|
23
14
|
* reverses the data row order
|
|
24
15
|
*/
|
|
25
|
-
export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>):
|
|
26
|
-
sort: null;
|
|
27
|
-
data: DataRow[][];
|
|
28
|
-
};
|
|
16
|
+
export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>): any;
|
package/dist/transforms/sort.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolveChannel } from '../helpers/resolve.js';
|
|
|
3
3
|
import { shuffler } from 'd3-array';
|
|
4
4
|
import { randomLcg } from 'd3-random';
|
|
5
5
|
export const SORT_KEY = Symbol('sortKey');
|
|
6
|
+
export const IS_SORTED = Symbol('isSorted');
|
|
6
7
|
export function sort({ data, ...channels }, options = {}) {
|
|
7
8
|
if (!Array.isArray(data))
|
|
8
9
|
return { data, ...channels };
|
|
@@ -14,19 +15,26 @@ export function sort({ data, ...channels }, options = {}) {
|
|
|
14
15
|
sort.channel = sort.channel.substring(1);
|
|
15
16
|
sort.order = 'descending';
|
|
16
17
|
}
|
|
18
|
+
// if sort is a function that does not take exactly one argument, we treat it
|
|
19
|
+
// as comparator function, as you would pass to array.sort
|
|
20
|
+
const isComparator = typeof channels.sort === 'function' && channels.sort.length !== 1;
|
|
17
21
|
// sort data
|
|
18
22
|
return {
|
|
19
|
-
data:
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
? -1
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
data: isComparator
|
|
24
|
+
? data.toSorted(channels.sort)
|
|
25
|
+
: data
|
|
26
|
+
.map((d) => ({
|
|
27
|
+
...d,
|
|
28
|
+
[SORT_KEY]: resolveChannel('sort', d, { ...channels, sort })
|
|
29
|
+
}))
|
|
30
|
+
.toSorted((a, b) => (a[SORT_KEY] > b[SORT_KEY] ? 1 : a[SORT_KEY] < b[SORT_KEY] ? -1 : 0) *
|
|
31
|
+
(options.reverse ||
|
|
32
|
+
(isDataRecord(sort) && sort?.order === 'descending')
|
|
33
|
+
? -1
|
|
34
|
+
: 1))
|
|
35
|
+
.map(({ [SORT_KEY]: a, ...rest }) => rest),
|
|
29
36
|
...channels,
|
|
37
|
+
[IS_SORTED]: sort,
|
|
30
38
|
// set the sort channel to null to disable the implicit alphabetical
|
|
31
39
|
// ordering of ordinal domains, and also to avoid double sorting in case
|
|
32
40
|
// this transform is used "outside" a mark
|
|
@@ -39,7 +47,7 @@ export function sort({ data, ...channels }, options = {}) {
|
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
|
-
*
|
|
50
|
+
* shuffles the data row order
|
|
43
51
|
*/
|
|
44
52
|
export function shuffle({ data, ...channels }, options = {}) {
|
|
45
53
|
const random = randomLcg(options.seed);
|
|
@@ -49,7 +57,8 @@ export function shuffle({ data, ...channels }, options = {}) {
|
|
|
49
57
|
...channels,
|
|
50
58
|
// set the sort channel to null to disable the implicit
|
|
51
59
|
// alphabetical ordering of ordinal domains
|
|
52
|
-
sort: null
|
|
60
|
+
sort: null,
|
|
61
|
+
[IS_SORTED]: true
|
|
53
62
|
};
|
|
54
63
|
}
|
|
55
64
|
/**
|
|
@@ -61,6 +70,7 @@ export function reverse({ data, ...channels }) {
|
|
|
61
70
|
...channels,
|
|
62
71
|
// set the sort channel to null to disable the implicit
|
|
63
72
|
// alphabetical ordering of ordinal domains
|
|
64
|
-
sort: null
|
|
73
|
+
sort: null,
|
|
74
|
+
[IS_SORTED]: true
|
|
65
75
|
};
|
|
66
76
|
}
|
|
@@ -7,18 +7,6 @@ type WindowOptions = {
|
|
|
7
7
|
reduce: ReducerName;
|
|
8
8
|
strict: boolean;
|
|
9
9
|
};
|
|
10
|
-
export declare function windowX(args: TransformArg<DataRecord>, options: WindowOptions):
|
|
11
|
-
|
|
12
|
-
[x: string]: import("../types.js").RawValue;
|
|
13
|
-
[x: symbol]: import("../types.js").RawValue;
|
|
14
|
-
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
export declare function windowY(args: TransformArg<DataRecord>, options: WindowOptions): {
|
|
18
|
-
data: {
|
|
19
|
-
[x: string]: import("../types.js").RawValue;
|
|
20
|
-
[x: symbol]: import("../types.js").RawValue;
|
|
21
|
-
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
22
|
-
}[];
|
|
23
|
-
};
|
|
10
|
+
export declare function windowX(args: TransformArg<DataRecord>, options: WindowOptions): any;
|
|
11
|
+
export declare function windowY(args: TransformArg<DataRecord>, options: WindowOptions): any;
|
|
24
12
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,37 @@ import type { MouseEventHandler } from 'svelte/elements';
|
|
|
4
4
|
import type { MarkerShape } from './marks/helpers/Marker.svelte';
|
|
5
5
|
import type { Writable } from 'svelte/store';
|
|
6
6
|
import type * as CSS from 'csstype';
|
|
7
|
+
import type { AreaMarkProps } from './marks/Area.svelte';
|
|
8
|
+
import type { ArrowMarkProps } from './marks/Arrow.svelte';
|
|
9
|
+
import type { AxisXMarkProps } from './marks/AxisX.svelte';
|
|
10
|
+
import type { AxisYMarkProps } from './marks/AxisY.svelte';
|
|
11
|
+
import type { BarXMarkProps } from './marks/BarX.svelte';
|
|
12
|
+
import type { CellMarkProps } from './marks/Cell.svelte';
|
|
13
|
+
import type { DotMarkProps } from './marks/Dot.svelte';
|
|
14
|
+
import type { FrameMarkProps } from './marks/Frame.svelte';
|
|
15
|
+
import type { GeoMarkProps } from './marks/Geo.svelte';
|
|
16
|
+
import type { GraticuleMarkProps } from './marks/Graticule.svelte';
|
|
17
|
+
import type { LineMarkProps } from './marks/Line.svelte';
|
|
18
|
+
import type { LinkMarkProps } from './marks/Link.svelte';
|
|
19
|
+
import type { RectMarkProps } from './marks/Rect.svelte';
|
|
20
|
+
import type { RuleXMarkProps } from './marks/RuleX.svelte';
|
|
21
|
+
import type { SphereMarkProps } from './marks/Sphere.svelte';
|
|
22
|
+
import type { SpikeMarkProps } from './marks/Spike.svelte';
|
|
23
|
+
import type { TextMarkProps } from './marks/Text.svelte';
|
|
24
|
+
import type { TickXMarkProps } from './marks/TickX.svelte';
|
|
25
|
+
import type { VectorMarkProps } from './marks/Vector.svelte';
|
|
26
|
+
import type { BrushMarkProps } from './marks/Brush.svelte';
|
|
27
|
+
import type { BrushXMarkProps } from './marks/BrushX.svelte';
|
|
28
|
+
import type { BrushYMarkProps } from './marks/BrushY.svelte';
|
|
29
|
+
import type { RectXMarkProps } from './marks/RectX.svelte';
|
|
30
|
+
import type { RectYMarkProps } from './marks/RectY.svelte';
|
|
31
|
+
import type { RuleYMarkProps } from './marks/RuleY.svelte';
|
|
32
|
+
import type { TickYMarkProps } from './marks/TickY.svelte';
|
|
33
|
+
import type { GridYMarkProps } from './marks/GridY.svelte';
|
|
34
|
+
import type { GridXMarkProps } from './marks/GridX.svelte';
|
|
35
|
+
import type { PointerMarkProps } from './marks/Pointer.svelte';
|
|
36
|
+
import type { BoxXMarkProps } from './marks/BoxX.svelte';
|
|
37
|
+
import type { BoxYMarkProps } from './marks/BoxY.svelte';
|
|
7
38
|
export type MarkType = 'area' | 'arrow' | 'axisX' | 'axisY' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
|
|
8
39
|
export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
|
|
9
40
|
export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
|
|
@@ -300,52 +331,7 @@ export type PlotOptions = {
|
|
|
300
331
|
*/
|
|
301
332
|
css: (d: string) => string | undefined;
|
|
302
333
|
};
|
|
303
|
-
export type
|
|
304
|
-
axisXAnchor: AxisXAnchor;
|
|
305
|
-
axisYAnchor: AxisYAnchor;
|
|
306
|
-
xTickSpacing: number;
|
|
307
|
-
yTickSpacing: number;
|
|
308
|
-
height: number;
|
|
309
|
-
inset: number;
|
|
310
|
-
colorScheme: ColorScheme | string[];
|
|
311
|
-
categoricalColorScheme: ColorScheme | string[];
|
|
312
|
-
dotRadius: number;
|
|
313
|
-
/**
|
|
314
|
-
* for computing the automatic height based on the number of
|
|
315
|
-
* domain items in a point scale
|
|
316
|
-
*/
|
|
317
|
-
pointScaleHeight: number;
|
|
318
|
-
/**
|
|
319
|
-
* for computing the automatic height based on the number of
|
|
320
|
-
* domain items in a band scale
|
|
321
|
-
*/
|
|
322
|
-
bandScaleHeight: number;
|
|
323
|
-
/**
|
|
324
|
-
* add frame to plots by default
|
|
325
|
-
*/
|
|
326
|
-
frame: boolean;
|
|
327
|
-
grid: boolean;
|
|
328
|
-
axes: boolean;
|
|
329
|
-
/**
|
|
330
|
-
* initial width of the plot before measuring the actual width
|
|
331
|
-
*/
|
|
332
|
-
initialWidth: number;
|
|
333
|
-
/**
|
|
334
|
-
* locale, used for automatic axis ticks
|
|
335
|
-
*/
|
|
336
|
-
locale: string;
|
|
337
|
-
/**
|
|
338
|
-
* default number format for axis ticks
|
|
339
|
-
*/
|
|
340
|
-
numberFormat: Intl.NumberFormatOptions;
|
|
341
|
-
markerDotRadius: number;
|
|
342
|
-
/**
|
|
343
|
-
* fallback color to be used for null/NA
|
|
344
|
-
*/
|
|
345
|
-
unknown: string;
|
|
346
|
-
css: (d: string) => string | undefined;
|
|
347
|
-
};
|
|
348
|
-
export type GenericMarkOptions = Record<string, any>;
|
|
334
|
+
export type GenericMarkOptions = Record<string | symbol, any>;
|
|
349
335
|
export type DataRecord = Record<string | symbol, RawValue> & {
|
|
350
336
|
___orig___?: RawValue | [RawValue, RawValue];
|
|
351
337
|
};
|
|
@@ -490,15 +476,30 @@ export type FacetContext = {
|
|
|
490
476
|
};
|
|
491
477
|
export type LinkableMarkProps = {
|
|
492
478
|
/**
|
|
493
|
-
*
|
|
479
|
+
* if set, the mark element will be wrapped in a <a> link element
|
|
480
|
+
*/
|
|
481
|
+
href?: ConstantAccessor<string>;
|
|
482
|
+
/**
|
|
483
|
+
* the relationship of the target object to the link object (e.g. "noopener")
|
|
484
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#rel
|
|
485
|
+
*/
|
|
486
|
+
rel?: ConstantAccessor<string>;
|
|
487
|
+
/**
|
|
488
|
+
* the link target mime type, e.g. "text/csv"
|
|
489
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#type
|
|
490
|
+
*/
|
|
491
|
+
type?: ConstantAccessor<string>;
|
|
492
|
+
/**
|
|
493
|
+
* the target of the link, e.g. "_blank" or "_self"
|
|
494
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#target
|
|
494
495
|
*/
|
|
495
|
-
|
|
496
|
+
target?: ConstantAccessor<'_self' | '_blank' | '_parent' | '_top' | string>;
|
|
496
497
|
/**
|
|
497
|
-
* if set, the
|
|
498
|
-
*
|
|
498
|
+
* if set to true, the link will be downloaded instead of navigating to it
|
|
499
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download
|
|
499
500
|
*/
|
|
500
|
-
|
|
501
|
-
|
|
501
|
+
download?: ConstantAccessor<boolean>;
|
|
502
|
+
[key: `data-sveltekit-${string}`]: string | boolean;
|
|
502
503
|
};
|
|
503
504
|
export type BaseMarkProps = Partial<{
|
|
504
505
|
/**
|
|
@@ -512,6 +513,12 @@ export type BaseMarkProps = Partial<{
|
|
|
512
513
|
dy: ConstantAccessor<number>;
|
|
513
514
|
fill: ConstantAccessor<string>;
|
|
514
515
|
fillOpacity: ConstantAccessor<number>;
|
|
516
|
+
sort: string | ConstantAccessor<RawValue> | ((a: RawValue, b: RawValue) => number) | {
|
|
517
|
+
/** sort data using an already defined channel */
|
|
518
|
+
channel: string;
|
|
519
|
+
/** sort order */
|
|
520
|
+
order?: 'ascending' | 'descending';
|
|
521
|
+
};
|
|
515
522
|
stroke: ConstantAccessor<string>;
|
|
516
523
|
strokeWidth: ConstantAccessor<number>;
|
|
517
524
|
strokeOpacity: ConstantAccessor<number>;
|
|
@@ -577,7 +584,7 @@ export type BaseRectMarkProps = {
|
|
|
577
584
|
borderRadius?: BorderRadius;
|
|
578
585
|
};
|
|
579
586
|
export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean | symbol>>;
|
|
580
|
-
export type TransformArg<K> = Channels & {
|
|
587
|
+
export type TransformArg<K> = Channels & BaseMarkProps & {
|
|
581
588
|
data: K[];
|
|
582
589
|
};
|
|
583
590
|
export type MapArg<K> = Channels & {
|
|
@@ -597,11 +604,12 @@ export type AutoMarginStores = {
|
|
|
597
604
|
autoMarginRight: Writable<Map<string, number>>;
|
|
598
605
|
autoMarginBottom: Writable<Map<string, number>>;
|
|
599
606
|
};
|
|
607
|
+
type IgnoreDefaults = 'data' | 'facet' | ChannelName | 'title' | 'automatic' | 'children';
|
|
600
608
|
/**
|
|
601
609
|
* these are the default options for the plot marks that can be set using
|
|
602
610
|
* the 'svelteplot/defaults' context.
|
|
603
611
|
*/
|
|
604
|
-
export type
|
|
612
|
+
export type PlotDefaults = {
|
|
605
613
|
/**
|
|
606
614
|
* default plot height
|
|
607
615
|
*/
|
|
@@ -611,41 +619,32 @@ export type DefaultOptions = {
|
|
|
611
619
|
*/
|
|
612
620
|
inset: number;
|
|
613
621
|
/**
|
|
614
|
-
* default
|
|
615
|
-
*/
|
|
616
|
-
tickSize: number;
|
|
617
|
-
/**
|
|
618
|
-
* default padding between tick line and tick label
|
|
619
|
-
*/
|
|
620
|
-
tickPadding: number;
|
|
621
|
-
/**
|
|
622
|
-
* default font size for tick labels
|
|
623
|
-
*/
|
|
624
|
-
tickFontSize: number;
|
|
625
|
-
/**
|
|
626
|
-
* default anchor for x axis
|
|
622
|
+
* default color scheme
|
|
627
623
|
*/
|
|
628
|
-
|
|
624
|
+
colorScheme: ColorScheme;
|
|
625
|
+
categoricalColorScheme: ColorScheme | string[];
|
|
629
626
|
/**
|
|
630
|
-
*
|
|
627
|
+
* fallback color to be used for null/NA
|
|
631
628
|
*/
|
|
632
|
-
|
|
629
|
+
unknown: string;
|
|
633
630
|
/**
|
|
634
|
-
*
|
|
631
|
+
* optional @emotion/css function to style the plot
|
|
635
632
|
*/
|
|
636
|
-
|
|
633
|
+
css: (d: string) => string | undefined;
|
|
637
634
|
/**
|
|
638
|
-
*
|
|
635
|
+
* for computing the automatic height based on the number of
|
|
636
|
+
* domain items in a point scale
|
|
639
637
|
*/
|
|
640
|
-
|
|
638
|
+
pointScaleHeight: number;
|
|
641
639
|
/**
|
|
642
|
-
*
|
|
640
|
+
* for computing the automatic height based on the number of
|
|
641
|
+
* domain items in a band scale
|
|
643
642
|
*/
|
|
644
|
-
|
|
643
|
+
bandScaleHeight: number;
|
|
645
644
|
/**
|
|
646
|
-
*
|
|
645
|
+
* initial width of the plot before measuring the actual width
|
|
647
646
|
*/
|
|
648
|
-
|
|
647
|
+
initialWidth: number;
|
|
649
648
|
/**
|
|
650
649
|
* locale, used for automatic axis ticks
|
|
651
650
|
*/
|
|
@@ -658,6 +657,180 @@ export type DefaultOptions = {
|
|
|
658
657
|
* default dot radius for line markers, used in dot, circle, and circle-stroke markers
|
|
659
658
|
*/
|
|
660
659
|
markerDotRadius: number;
|
|
660
|
+
/**
|
|
661
|
+
* default props for area marks, applied to area, areaX, and areaY marks
|
|
662
|
+
*/
|
|
663
|
+
area: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
|
|
664
|
+
/**
|
|
665
|
+
* default props for areaX marks
|
|
666
|
+
*/
|
|
667
|
+
areaX: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
|
|
668
|
+
/**
|
|
669
|
+
* default props for areaY marks
|
|
670
|
+
*/
|
|
671
|
+
areaY: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
|
|
672
|
+
/**
|
|
673
|
+
* default props for arrow marks
|
|
674
|
+
*/
|
|
675
|
+
arrow: Partial<Omit<ArrowMarkProps, IgnoreDefaults>>;
|
|
676
|
+
/**
|
|
677
|
+
* default props for axis marks, applied to both axisX and axisY marks
|
|
678
|
+
*/
|
|
679
|
+
axis: Partial<Omit<AxisXMarkProps, 'data' | 'facet' | ChannelName | 'facetAnchor' | 'labelAnchor' | 'anchor'> & {
|
|
680
|
+
implicit: boolean;
|
|
681
|
+
}>;
|
|
682
|
+
/**
|
|
683
|
+
* default props for axisX marks
|
|
684
|
+
*/
|
|
685
|
+
axisX: Partial<Omit<AxisXMarkProps, IgnoreDefaults> & {
|
|
686
|
+
implicit: boolean;
|
|
687
|
+
}>;
|
|
688
|
+
/**
|
|
689
|
+
* default props for axisY marks
|
|
690
|
+
*/
|
|
691
|
+
axisY: Partial<Omit<AxisYMarkProps, IgnoreDefaults> & {
|
|
692
|
+
implicit: boolean;
|
|
693
|
+
}>;
|
|
694
|
+
/**
|
|
695
|
+
* default props for bar marks, applied to both barX and barY marks
|
|
696
|
+
*/
|
|
697
|
+
bar: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
|
|
698
|
+
/**
|
|
699
|
+
* default props for barX marks
|
|
700
|
+
*/
|
|
701
|
+
barX: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
|
|
702
|
+
/**
|
|
703
|
+
* default props for barY marks
|
|
704
|
+
*/
|
|
705
|
+
barY: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
|
|
706
|
+
/**
|
|
707
|
+
* default props for box marks, applied to boxX and boxY marks
|
|
708
|
+
*/
|
|
709
|
+
box: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
|
|
710
|
+
/**
|
|
711
|
+
* default props for boxX marks
|
|
712
|
+
*/
|
|
713
|
+
boxX: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
|
|
714
|
+
/**
|
|
715
|
+
* default props for boxY marks
|
|
716
|
+
*/
|
|
717
|
+
boxY: Partial<Omit<BoxYMarkProps, IgnoreDefaults>>;
|
|
718
|
+
/**
|
|
719
|
+
* default props for brush marks, applied to brush, brushX and brushY marks
|
|
720
|
+
*/
|
|
721
|
+
brush: Partial<Omit<BrushMarkProps, IgnoreDefaults | 'limitDimension'>>;
|
|
722
|
+
/**
|
|
723
|
+
* default props for brushX marks
|
|
724
|
+
*/
|
|
725
|
+
brushX: Partial<Omit<BrushXMarkProps, IgnoreDefaults>>;
|
|
726
|
+
/**
|
|
727
|
+
* default props for brushY marks
|
|
728
|
+
*/
|
|
729
|
+
brushY: Partial<Omit<BrushYMarkProps, IgnoreDefaults>>;
|
|
730
|
+
/**
|
|
731
|
+
* default props for cell marks
|
|
732
|
+
*/
|
|
733
|
+
cell: Partial<Omit<CellMarkProps, IgnoreDefaults>>;
|
|
734
|
+
/**
|
|
735
|
+
* default props for dot marks
|
|
736
|
+
*/
|
|
737
|
+
dot: Partial<Omit<DotMarkProps, IgnoreDefaults>>;
|
|
738
|
+
/**
|
|
739
|
+
* default props for frame marks
|
|
740
|
+
*/
|
|
741
|
+
frame: Partial<FrameMarkProps & {
|
|
742
|
+
implicit: boolean;
|
|
743
|
+
}>;
|
|
744
|
+
/**
|
|
745
|
+
* default props for geo marks
|
|
746
|
+
*/
|
|
747
|
+
geo: Partial<Omit<GeoMarkProps, IgnoreDefaults>>;
|
|
748
|
+
/**
|
|
749
|
+
* default props for graticule marks
|
|
750
|
+
*/
|
|
751
|
+
graticule: Partial<Omit<GraticuleMarkProps, IgnoreDefaults>>;
|
|
752
|
+
/**
|
|
753
|
+
* default props for grid marks, applied to both gridX and gridY marks
|
|
754
|
+
*/
|
|
755
|
+
grid: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
|
|
756
|
+
implicit: boolean;
|
|
757
|
+
}>;
|
|
758
|
+
/**
|
|
759
|
+
* default props for gridX marks
|
|
760
|
+
*/
|
|
761
|
+
gridX: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
|
|
762
|
+
implicit: boolean;
|
|
763
|
+
}>;
|
|
764
|
+
/**
|
|
765
|
+
* default props for gridY marks
|
|
766
|
+
*/
|
|
767
|
+
gridY: Partial<Omit<GridYMarkProps, IgnoreDefaults> & {
|
|
768
|
+
implicit: boolean;
|
|
769
|
+
}>;
|
|
770
|
+
/**
|
|
771
|
+
* default props for line marks
|
|
772
|
+
*/
|
|
773
|
+
line: Partial<Omit<LineMarkProps, IgnoreDefaults>>;
|
|
774
|
+
/**
|
|
775
|
+
* default props for link marks
|
|
776
|
+
*/
|
|
777
|
+
link: Partial<Omit<LinkMarkProps, IgnoreDefaults>>;
|
|
778
|
+
/**
|
|
779
|
+
* default props for pointer marks
|
|
780
|
+
*/
|
|
781
|
+
pointer: Partial<Omit<PointerMarkProps, IgnoreDefaults>>;
|
|
782
|
+
/**
|
|
783
|
+
* default props for rect marks, applied to rect and rectX marks
|
|
784
|
+
*/
|
|
785
|
+
rect: Partial<Omit<RectMarkProps, IgnoreDefaults>>;
|
|
786
|
+
/**
|
|
787
|
+
* default props for rectX marks
|
|
788
|
+
*/
|
|
789
|
+
rectX: Partial<Omit<RectXMarkProps, IgnoreDefaults>>;
|
|
790
|
+
/**
|
|
791
|
+
* default props for rectY marks
|
|
792
|
+
*/
|
|
793
|
+
rectY: Partial<Omit<RectYMarkProps, IgnoreDefaults>>;
|
|
794
|
+
/**
|
|
795
|
+
* default props for rule marks
|
|
796
|
+
*/
|
|
797
|
+
rule: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
|
|
798
|
+
/**
|
|
799
|
+
* default props for rule marks
|
|
800
|
+
*/
|
|
801
|
+
ruleX: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
|
|
802
|
+
/**
|
|
803
|
+
* default props for rule marks
|
|
804
|
+
*/
|
|
805
|
+
ruleY: Partial<Omit<RuleYMarkProps, IgnoreDefaults>>;
|
|
806
|
+
/**
|
|
807
|
+
* default props for sphere marks
|
|
808
|
+
*/
|
|
809
|
+
sphere: Partial<SphereMarkProps>;
|
|
810
|
+
/**
|
|
811
|
+
* default props for spike marks
|
|
812
|
+
*/
|
|
813
|
+
spike: Partial<Omit<SpikeMarkProps, IgnoreDefaults>>;
|
|
814
|
+
/**
|
|
815
|
+
* default props for text marks
|
|
816
|
+
*/
|
|
817
|
+
text: Partial<Omit<TextMarkProps, IgnoreDefaults>>;
|
|
818
|
+
/**
|
|
819
|
+
* default props for tick marks, applied to tickX and tickY marks
|
|
820
|
+
*/
|
|
821
|
+
tick: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
|
|
822
|
+
/**
|
|
823
|
+
* default props for tickX marks
|
|
824
|
+
*/
|
|
825
|
+
tickX: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
|
|
826
|
+
/**
|
|
827
|
+
* default props for tickY marks
|
|
828
|
+
*/
|
|
829
|
+
tickY: Partial<Omit<TickYMarkProps, IgnoreDefaults>>;
|
|
830
|
+
/**
|
|
831
|
+
* default props for vector marks
|
|
832
|
+
*/
|
|
833
|
+
vector: Partial<Omit<VectorMarkProps, IgnoreDefaults>>;
|
|
661
834
|
};
|
|
662
835
|
export type MapIndexObject = {
|
|
663
836
|
mapIndex: (I: number[], S: RawValue[], T: RawValue[]) => void;
|