svelteplot 0.2.6-next.5 → 0.2.7-pr-65.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 +1 -1
- package/dist/Plot.svelte +1 -1
- package/dist/core/FacetGrid.svelte +2 -2
- package/dist/core/Plot.svelte +1 -0
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/resolve.js +7 -4
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/scales.js +2 -1
- package/dist/helpers/time.d.ts +4 -3
- package/dist/helpers/time.js +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +17 -23
- package/dist/marks/Area.svelte.d.ts +9 -17
- package/dist/marks/AreaX.svelte +7 -6
- package/dist/marks/AreaX.svelte.d.ts +7 -6
- package/dist/marks/AreaY.svelte +7 -15
- package/dist/marks/AreaY.svelte.d.ts +7 -10
- package/dist/marks/Arrow.svelte +25 -25
- package/dist/marks/Arrow.svelte.d.ts +5 -8
- package/dist/marks/AxisX.svelte +50 -44
- package/dist/marks/AxisX.svelte.d.ts +4 -3
- package/dist/marks/AxisY.svelte +39 -31
- package/dist/marks/AxisY.svelte.d.ts +7 -4
- package/dist/marks/BarX.svelte +27 -12
- package/dist/marks/BarX.svelte.d.ts +17 -1
- package/dist/marks/BarY.svelte +21 -11
- package/dist/marks/BarY.svelte.d.ts +4 -4
- package/dist/marks/BollingerX.svelte +15 -7
- package/dist/marks/BollingerX.svelte.d.ts +3 -3
- package/dist/marks/BollingerY.svelte +9 -7
- package/dist/marks/BollingerY.svelte.d.ts +3 -3
- package/dist/marks/BoxX.svelte +3 -0
- package/dist/marks/BoxX.svelte.d.ts +1 -0
- package/dist/marks/BoxY.svelte +3 -0
- package/dist/marks/BoxY.svelte.d.ts +1 -0
- package/dist/marks/BrushX.svelte +5 -1
- package/dist/marks/BrushX.svelte.d.ts +2 -1
- package/dist/marks/BrushY.svelte +5 -1
- package/dist/marks/BrushY.svelte.d.ts +2 -1
- package/dist/marks/Cell.svelte +18 -21
- package/dist/marks/Cell.svelte.d.ts +3 -9
- package/dist/marks/CellX.svelte +7 -12
- package/dist/marks/CellX.svelte.d.ts +3 -1
- package/dist/marks/CellY.svelte +7 -12
- package/dist/marks/CellY.svelte.d.ts +3 -1
- package/dist/marks/ColorLegend.svelte +10 -8
- package/dist/marks/ColorLegend.svelte.d.ts +3 -5
- package/dist/marks/CustomMark.svelte +1 -1
- package/dist/marks/CustomMarkHTML.svelte +1 -1
- package/dist/marks/DifferenceY.svelte +22 -20
- package/dist/marks/DifferenceY.svelte.d.ts +5 -5
- package/dist/marks/Dot.svelte +17 -27
- package/dist/marks/Dot.svelte.d.ts +5 -15
- package/dist/marks/DotX.svelte +10 -9
- package/dist/marks/DotX.svelte.d.ts +4 -7
- package/dist/marks/DotY.svelte +9 -2
- package/dist/marks/DotY.svelte.d.ts +4 -3
- package/dist/marks/Frame.svelte +42 -31
- package/dist/marks/Frame.svelte.d.ts +8 -3
- package/dist/marks/Geo.svelte +18 -11
- package/dist/marks/Geo.svelte.d.ts +4 -3
- package/dist/marks/Graticule.svelte +15 -8
- package/dist/marks/Graticule.svelte.d.ts +2 -1
- package/dist/marks/GridX.svelte +11 -6
- package/dist/marks/GridX.svelte.d.ts +3 -2
- package/dist/marks/GridY.svelte +11 -3
- package/dist/marks/GridY.svelte.d.ts +3 -2
- package/dist/marks/HTMLTooltip.svelte +2 -1
- package/dist/marks/HTMLTooltip.svelte.d.ts +4 -0
- package/dist/marks/Line.svelte +8 -14
- package/dist/marks/Line.svelte.d.ts +5 -10
- package/dist/marks/LineX.svelte +5 -2
- package/dist/marks/LineX.svelte.d.ts +3 -2
- package/dist/marks/LineY.svelte +5 -2
- package/dist/marks/LineY.svelte.d.ts +3 -2
- package/dist/marks/Link.svelte +20 -19
- package/dist/marks/Link.svelte.d.ts +6 -6
- package/dist/marks/Rect.svelte +15 -12
- package/dist/marks/Rect.svelte.d.ts +3 -3
- package/dist/marks/RectX.svelte +10 -20
- package/dist/marks/RectX.svelte.d.ts +6 -12
- package/dist/marks/RectY.svelte +10 -20
- package/dist/marks/RectY.svelte.d.ts +6 -12
- package/dist/marks/RegressionX.svelte +10 -2
- package/dist/marks/RegressionX.svelte.d.ts +2 -0
- package/dist/marks/RegressionY.svelte +9 -2
- package/dist/marks/RegressionY.svelte.d.ts +2 -0
- package/dist/marks/RuleX.svelte +16 -13
- package/dist/marks/RuleX.svelte.d.ts +3 -4
- package/dist/marks/RuleY.svelte +16 -13
- package/dist/marks/RuleY.svelte.d.ts +3 -4
- package/dist/marks/Sphere.svelte +9 -2
- package/dist/marks/Sphere.svelte.d.ts +4 -59
- package/dist/marks/Spike.svelte +9 -1
- package/dist/marks/Spike.svelte.d.ts +2 -0
- package/dist/marks/SymbolLegend.svelte +1 -1
- package/dist/marks/Text.svelte +34 -35
- package/dist/marks/Text.svelte.d.ts +4 -7
- package/dist/marks/TickX.svelte +25 -20
- package/dist/marks/TickX.svelte.d.ts +3 -3
- package/dist/marks/TickY.svelte +25 -20
- package/dist/marks/TickY.svelte.d.ts +3 -3
- package/dist/marks/Vector.svelte +5 -5
- package/dist/marks/Vector.svelte.d.ts +2 -5
- package/dist/marks/helpers/BaseAxisX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/RectPath.svelte +17 -13
- package/dist/marks/helpers/RectPath.svelte.d.ts +1 -0
- package/dist/marks/helpers/events.js +3 -6
- 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/index.d.ts +1 -0
- package/dist/transforms/index.js +1 -0
- package/dist/transforms/interval.d.ts +2 -6
- package/dist/transforms/jitter.d.ts +17 -0
- package/dist/transforms/jitter.js +60 -1
- package/dist/transforms/map.d.ts +4 -10
- package/dist/transforms/normalize.d.ts +2 -6
- package/dist/transforms/recordize.js +4 -4
- package/dist/transforms/select.d.ts +7 -21
- package/dist/transforms/sort.d.ts +3 -16
- package/dist/transforms/window.d.ts +2 -14
- package/dist/types.d.ts +13 -11
- package/dist/ui/RadioInput.svelte +1 -1
- package/dist/ui/Select.svelte +1 -1
- package/package.json +8 -8
|
@@ -25,7 +25,8 @@ Helper component for rendering rectangular marks in SVG
|
|
|
25
25
|
height,
|
|
26
26
|
useInsetAsFallbackVertically = true,
|
|
27
27
|
useInsetAsFallbackHorizontally = true,
|
|
28
|
-
usedScales
|
|
28
|
+
usedScales,
|
|
29
|
+
fallbackStyle = 'fill'
|
|
29
30
|
}: {
|
|
30
31
|
datum: ScaledDataRecord;
|
|
31
32
|
class: string | null;
|
|
@@ -47,39 +48,40 @@ Helper component for rendering rectangular marks in SVG
|
|
|
47
48
|
*/
|
|
48
49
|
useInsetAsFallbackHorizontally?: boolean;
|
|
49
50
|
usedScales: UsedScales;
|
|
51
|
+
fallbackStyle?: 'fill' | 'stroke';
|
|
50
52
|
} = $props();
|
|
51
53
|
|
|
52
54
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
53
55
|
const plot = $derived(getPlotState());
|
|
54
56
|
|
|
55
|
-
const dx = $derived(+(resolveProp(options.dx, datum
|
|
56
|
-
const dy = $derived(+(resolveProp(options.dy, datum
|
|
57
|
-
const inset = $derived(+(resolveProp(options.inset, datum
|
|
57
|
+
const dx = $derived(+(resolveProp(options.dx, datum?.datum, 0) as number));
|
|
58
|
+
const dy = $derived(+(resolveProp(options.dy, datum?.datum, 0) as number));
|
|
59
|
+
const inset = $derived(+(resolveProp(options.inset, datum?.datum, 0) as number));
|
|
58
60
|
const insetLeft = $derived(
|
|
59
61
|
+(resolveProp(
|
|
60
62
|
options.insetLeft,
|
|
61
|
-
datum
|
|
63
|
+
datum?.datum,
|
|
62
64
|
useInsetAsFallbackHorizontally ? inset : 0
|
|
63
65
|
) as number)
|
|
64
66
|
);
|
|
65
67
|
const insetRight = $derived(
|
|
66
68
|
+(resolveProp(
|
|
67
69
|
options.insetRight,
|
|
68
|
-
datum
|
|
70
|
+
datum?.datum,
|
|
69
71
|
useInsetAsFallbackHorizontally ? inset : 0
|
|
70
72
|
) as number)
|
|
71
73
|
);
|
|
72
74
|
const insetTop = $derived(
|
|
73
75
|
+(resolveProp(
|
|
74
76
|
options.insetTop,
|
|
75
|
-
datum
|
|
77
|
+
datum?.datum,
|
|
76
78
|
useInsetAsFallbackVertically ? inset : 0
|
|
77
79
|
) as number)
|
|
78
80
|
);
|
|
79
81
|
const insetBottom = $derived(
|
|
80
82
|
+(resolveProp(
|
|
81
83
|
options.insetBottom,
|
|
82
|
-
datum
|
|
84
|
+
datum?.datum,
|
|
83
85
|
useInsetAsFallbackVertically ? inset : 0
|
|
84
86
|
) as number)
|
|
85
87
|
);
|
|
@@ -94,12 +96,14 @@ Helper component for rendering rectangular marks in SVG
|
|
|
94
96
|
borderRadius.bottomLeft ?? 0
|
|
95
97
|
) > 0)
|
|
96
98
|
);
|
|
97
|
-
const [style, styleClass] = $derived(
|
|
99
|
+
const [style, styleClass] = $derived(
|
|
100
|
+
resolveStyles(plot, datum, options, fallbackStyle, usedScales)
|
|
101
|
+
);
|
|
98
102
|
</script>
|
|
99
103
|
|
|
100
104
|
{#if hasBorderRadius}
|
|
101
105
|
<path
|
|
102
|
-
transform="translate({
|
|
106
|
+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
|
|
103
107
|
d={roundedRect(
|
|
104
108
|
0,
|
|
105
109
|
0,
|
|
@@ -112,11 +116,11 @@ Helper component for rendering rectangular marks in SVG
|
|
|
112
116
|
use:addEventHandlers={{
|
|
113
117
|
getPlotState,
|
|
114
118
|
options,
|
|
115
|
-
datum: datum
|
|
119
|
+
datum: datum?.datum
|
|
116
120
|
}} />
|
|
117
121
|
{:else}
|
|
118
122
|
<rect
|
|
119
|
-
transform="translate({
|
|
123
|
+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
|
|
120
124
|
width={width - insetLeft - insetRight}
|
|
121
125
|
height={height - insetTop - insetBottom}
|
|
122
126
|
class={[styleClass, className]}
|
|
@@ -124,6 +128,6 @@ Helper component for rendering rectangular marks in SVG
|
|
|
124
128
|
use:addEventHandlers={{
|
|
125
129
|
getPlotState,
|
|
126
130
|
options,
|
|
127
|
-
datum: datum
|
|
131
|
+
datum: datum?.datum
|
|
128
132
|
}} />
|
|
129
133
|
{/if}
|
|
@@ -20,6 +20,7 @@ type $$ComponentProps = {
|
|
|
20
20
|
*/
|
|
21
21
|
useInsetAsFallbackHorizontally?: boolean;
|
|
22
22
|
usedScales: UsedScales;
|
|
23
|
+
fallbackStyle?: 'fill' | 'stroke';
|
|
23
24
|
};
|
|
24
25
|
/** Helper component for rendering rectangular marks in SVG */
|
|
25
26
|
declare const RectPath: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
@@ -6,7 +6,7 @@ import { INDEX } from '../../constants.js';
|
|
|
6
6
|
* of the plot frame, regardless of which element triggered the event
|
|
7
7
|
*/
|
|
8
8
|
export function clientToLayerCoordinates(event, plotBody) {
|
|
9
|
-
// If layerX/Y already exist and the target is the plot frame (rect element),
|
|
9
|
+
// If layerX/Y already exist and the target is the plot frame (rect element),
|
|
10
10
|
// we can use them directly
|
|
11
11
|
// if (event.layerX !== undefined && (event.target as SVGElement).tagName === 'rect') {
|
|
12
12
|
// return [event.layerX, event.layerY];
|
|
@@ -17,10 +17,7 @@ export function clientToLayerCoordinates(event, plotBody) {
|
|
|
17
17
|
return [0, 0];
|
|
18
18
|
const plotBodyRect = plotBody.getBoundingClientRect();
|
|
19
19
|
// Calculate the coordinates relative to the plot body
|
|
20
|
-
return [
|
|
21
|
-
event.clientX - plotBodyRect.left,
|
|
22
|
-
event.clientY - plotBodyRect.top
|
|
23
|
-
];
|
|
20
|
+
return [event.clientX - plotBodyRect.left, event.clientY - plotBodyRect.top];
|
|
24
21
|
}
|
|
25
22
|
export function addEventHandlers(node, { options, datum, getPlotState }) {
|
|
26
23
|
const events = pick(options, [
|
|
@@ -52,7 +49,7 @@ export function addEventHandlers(node, { options, datum, getPlotState }) {
|
|
|
52
49
|
'ontouchcancel',
|
|
53
50
|
'ontouchend',
|
|
54
51
|
'ontouchmove',
|
|
55
|
-
'onwheel'
|
|
52
|
+
'onwheel'
|
|
56
53
|
]);
|
|
57
54
|
const listeners = new Map();
|
|
58
55
|
// attach event handlers
|
|
@@ -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 {};
|
|
@@ -6,6 +6,7 @@ export { map, mapX, mapY } from './map.js';
|
|
|
6
6
|
export { normalizeX, normalizeY } from './normalize.js';
|
|
7
7
|
export { group, groupX, groupY, groupZ } from './group.js';
|
|
8
8
|
export { intervalX, intervalY } from './interval.js';
|
|
9
|
+
export { jitterX, jitterY } from './jitter.js';
|
|
9
10
|
export { recordizeX, recordizeY } from './recordize.js';
|
|
10
11
|
export { renameChannels, replaceChannels } from './rename.js';
|
|
11
12
|
export { select, selectFirst, selectLast, selectMaxX, selectMaxY, selectMinX, selectMinY } from './select.js';
|
package/dist/transforms/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { map, mapX, mapY } from './map.js';
|
|
|
6
6
|
export { normalizeX, normalizeY } from './normalize.js';
|
|
7
7
|
export { group, groupX, groupY, groupZ } from './group.js';
|
|
8
8
|
export { intervalX, intervalY } from './interval.js';
|
|
9
|
+
export { jitterX, jitterY } from './jitter.js';
|
|
9
10
|
export { recordizeX, recordizeY } from './recordize.js';
|
|
10
11
|
export { renameChannels, replaceChannels } from './rename.js';
|
|
11
12
|
export { select, selectFirst, selectLast, selectMaxX, selectMaxY, selectMinX, selectMinY } from './select.js';
|
|
@@ -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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Channels, DataRecord, TransformArg } from '../types.js';
|
|
2
|
+
type JitterOptions = {
|
|
3
|
+
type: 'uniform' | 'normal';
|
|
4
|
+
/** width for uniform jittering */
|
|
5
|
+
width: number;
|
|
6
|
+
/** standard deviation for normal jittering */
|
|
7
|
+
std: number;
|
|
8
|
+
/**
|
|
9
|
+
* optional random number source that produces values in range [0,1)
|
|
10
|
+
* useful for testing with a deterministic source
|
|
11
|
+
*/
|
|
12
|
+
source?: () => number;
|
|
13
|
+
};
|
|
14
|
+
export declare function jitterX({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord>;
|
|
15
|
+
export declare function jitterY({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord>;
|
|
16
|
+
export declare function jitter(channel: 'x' | 'y', data: DataRecord[], channels: Channels, options: JitterOptions): TransformArg<DataRecord>;
|
|
17
|
+
export {};
|
|
@@ -1 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolveChannel } from '../helpers/resolve';
|
|
2
|
+
import { randomUniform, randomNormal } from 'd3-random';
|
|
3
|
+
import { isDate } from '../helpers/typeChecks';
|
|
4
|
+
import { durations, maybeTimeInterval, parseTimeInterval } from '../helpers/time';
|
|
5
|
+
const JITTER_X = Symbol('jitterX');
|
|
6
|
+
const JITTER_Y = Symbol('jitterY');
|
|
7
|
+
export function jitterX({ data, ...channels }, options) {
|
|
8
|
+
return jitter('x', data, channels, options);
|
|
9
|
+
}
|
|
10
|
+
export function jitterY({ data, ...channels }, options) {
|
|
11
|
+
return jitter('y', data, channels, options);
|
|
12
|
+
}
|
|
13
|
+
export function jitter(channel, data, channels, options) {
|
|
14
|
+
if (channels[channel]) {
|
|
15
|
+
const type = options?.type ?? 'uniform';
|
|
16
|
+
const width = parseNumber(options?.width ?? 0.35);
|
|
17
|
+
const std = parseNumber(options?.std ?? 0.15);
|
|
18
|
+
// @todo support time interval strings as width/std parameters
|
|
19
|
+
// Use the provided source or default to Math.random
|
|
20
|
+
const rng = options?.source ?? Math.random;
|
|
21
|
+
const random = type === 'uniform'
|
|
22
|
+
? randomUniform.source(rng)(-width, width)
|
|
23
|
+
: randomNormal.source(rng)(0, std);
|
|
24
|
+
const accKey = channel === 'x' ? JITTER_X : JITTER_Y;
|
|
25
|
+
return {
|
|
26
|
+
data: data.map((row) => {
|
|
27
|
+
const value = resolveChannel(channel, row, channels);
|
|
28
|
+
return {
|
|
29
|
+
...row,
|
|
30
|
+
[accKey]: typeof value === 'number'
|
|
31
|
+
? value + random()
|
|
32
|
+
: isDate(value)
|
|
33
|
+
? new Date(value.getTime() + random())
|
|
34
|
+
: value
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
...channels,
|
|
38
|
+
// point channel to new accessor symbol
|
|
39
|
+
[channel]: accKey
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
data,
|
|
44
|
+
...channels
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function parseNumber(value) {
|
|
48
|
+
if (typeof value === 'number')
|
|
49
|
+
return value;
|
|
50
|
+
if (typeof value === 'string') {
|
|
51
|
+
try {
|
|
52
|
+
const [name, period] = parseTimeInterval(value);
|
|
53
|
+
return durations.get(name) * period;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
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 {};
|
|
@@ -12,7 +12,7 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
12
12
|
data: data.map((value, index) => ({
|
|
13
13
|
__value: value,
|
|
14
14
|
...(withIndex ? { [INDEX]: index } : {}),
|
|
15
|
-
[RAW_VALUE]: value
|
|
15
|
+
[RAW_VALUE]: value
|
|
16
16
|
})),
|
|
17
17
|
...channels,
|
|
18
18
|
x: RAW_VALUE,
|
|
@@ -33,7 +33,7 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
33
33
|
return {
|
|
34
34
|
data: Array.from(data).map((value, index) => ({
|
|
35
35
|
...(withIndex ? { __index: index } : {}),
|
|
36
|
-
[RAW_VALUE]: value
|
|
36
|
+
[RAW_VALUE]: value
|
|
37
37
|
})),
|
|
38
38
|
...channels,
|
|
39
39
|
...(withIndex ? { x: '__index' } : {}),
|
|
@@ -80,9 +80,9 @@ export function recordize({ data, ...channels }) {
|
|
|
80
80
|
if (!isDataRecord(data[0])) {
|
|
81
81
|
return {
|
|
82
82
|
data: data.map((d) => ({
|
|
83
|
-
[RAW_VALUE]: d
|
|
83
|
+
[RAW_VALUE]: d
|
|
84
84
|
})),
|
|
85
|
-
...channels
|
|
85
|
+
...channels
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
return { data, ...channels };
|
|
@@ -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 {};
|
|
@@ -2,27 +2,14 @@ import type { DataRecord, DataRow, TransformArg } from '../types.js';
|
|
|
2
2
|
export declare const SORT_KEY: unique symbol;
|
|
3
3
|
export declare function sort({ data, ...channels }: TransformArg<DataRecord>, options?: {
|
|
4
4
|
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
|
-
};
|
|
5
|
+
}): any;
|
|
13
6
|
/**
|
|
14
7
|
* reverses the data row order
|
|
15
8
|
*/
|
|
16
9
|
export declare function shuffle({ data, ...channels }: TransformArg<DataRow[]>, options?: {
|
|
17
10
|
seed?: number;
|
|
18
|
-
}):
|
|
19
|
-
sort: null;
|
|
20
|
-
data: DataRow[][];
|
|
21
|
-
};
|
|
11
|
+
}): any;
|
|
22
12
|
/**
|
|
23
13
|
* reverses the data row order
|
|
24
14
|
*/
|
|
25
|
-
export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>):
|
|
26
|
-
sort: null;
|
|
27
|
-
data: DataRow[][];
|
|
28
|
-
};
|
|
15
|
+
export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>): any;
|
|
@@ -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
|
@@ -488,6 +488,18 @@ export type FacetContext = {
|
|
|
488
488
|
getTestFacet: () => TestFacetFunction;
|
|
489
489
|
getFacetState: () => FacetState;
|
|
490
490
|
};
|
|
491
|
+
export type LinkableMarkProps = {
|
|
492
|
+
/**
|
|
493
|
+
* simple browser tooltip to be displayed on mouseover
|
|
494
|
+
*/
|
|
495
|
+
title: ConstantAccessor<string>;
|
|
496
|
+
/**
|
|
497
|
+
* if set, the mark element will be wrapped in a <a> link
|
|
498
|
+
* element
|
|
499
|
+
*/
|
|
500
|
+
href: ConstantAccessor<string>;
|
|
501
|
+
target: ConstantAccessor<'_self' | '_blank' | string>;
|
|
502
|
+
};
|
|
491
503
|
export type BaseMarkProps = Partial<{
|
|
492
504
|
/**
|
|
493
505
|
* Filter the data without modifying the inferred scales
|
|
@@ -544,20 +556,10 @@ export type BaseMarkProps = Partial<{
|
|
|
544
556
|
ontouchcancel?: MouseEventHandler<SVGPathElement>;
|
|
545
557
|
oncontextmenu?: MouseEventHandler<SVGPathElement>;
|
|
546
558
|
onwheel?: MouseEventHandler<SVGPathElement>;
|
|
547
|
-
/**
|
|
548
|
-
* simple browser tooltip to be displayed on mouseover
|
|
549
|
-
*/
|
|
550
|
-
title: ConstantAccessor<string>;
|
|
551
|
-
/**
|
|
552
|
-
* if set, the mark element will be wrapped in a <a> link
|
|
553
|
-
* element
|
|
554
|
-
*/
|
|
555
|
-
href: ConstantAccessor<string>;
|
|
556
|
-
target: ConstantAccessor<'_self' | '_blank' | string>;
|
|
557
559
|
/**
|
|
558
560
|
* if you want to give your mark element an extra CSS class
|
|
559
561
|
*/
|
|
560
|
-
class: string;
|
|
562
|
+
class: string | null;
|
|
561
563
|
cursor: ConstantAccessor<CSS.Property.Cursor>;
|
|
562
564
|
}>;
|
|
563
565
|
export type BorderRadius = number | {
|
package/dist/ui/Select.svelte
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7-pr-65.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gregor Aisch",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
54
54
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
55
55
|
"@sveltejs/eslint-config": "^8.2.0",
|
|
56
|
-
"@sveltejs/kit": "^2.21.
|
|
56
|
+
"@sveltejs/kit": "^2.21.1",
|
|
57
57
|
"@sveltejs/package": "^2.3.11",
|
|
58
58
|
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
|
59
59
|
"@sveltepress/theme-default": "^6.0.3",
|
|
60
60
|
"@sveltepress/twoslash": "^1.2.2",
|
|
61
61
|
"@sveltepress/vite": "^1.2.2",
|
|
62
|
-
"@testing-library/svelte": "^5.2.
|
|
62
|
+
"@testing-library/svelte": "^5.2.8",
|
|
63
63
|
"@testing-library/user-event": "^14.6.1",
|
|
64
64
|
"@types/d3-array": "^3.2.1",
|
|
65
65
|
"@types/d3-color": "^3.1.3",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"d3-dsv": "^3.0.1",
|
|
78
78
|
"d3-fetch": "^3.0.1",
|
|
79
79
|
"d3-force": "^3.0.0",
|
|
80
|
-
"eslint": "^9.
|
|
80
|
+
"eslint": "^9.27.0",
|
|
81
81
|
"eslint-config-prettier": "^10.1.5",
|
|
82
|
-
"eslint-plugin-svelte": "3.
|
|
82
|
+
"eslint-plugin-svelte": "3.9.0",
|
|
83
83
|
"jsdom": "^26.1.0",
|
|
84
84
|
"prettier": "^3.5.3",
|
|
85
85
|
"prettier-plugin-svelte": "^3.4.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
98
98
|
"typescript": "^5.8.3",
|
|
99
99
|
"vite": "^6.3.5",
|
|
100
|
-
"vitest": "^3.1.
|
|
100
|
+
"vitest": "^3.1.4",
|
|
101
101
|
"vitest-matchmedia-mock": "^2.0.3"
|
|
102
102
|
},
|
|
103
103
|
"types": "./dist/index.d.ts",
|
|
@@ -116,9 +116,9 @@
|
|
|
116
116
|
"d3-scale-chromatic": "^3.1.0",
|
|
117
117
|
"d3-shape": "^3.2.0",
|
|
118
118
|
"d3-time": "^3.1.0",
|
|
119
|
-
"es-toolkit": "^1.
|
|
119
|
+
"es-toolkit": "^1.38.0",
|
|
120
120
|
"fast-equals": "^5.2.2",
|
|
121
121
|
"merge-deep": "^3.0.3",
|
|
122
|
-
"svelte": "5.
|
|
122
|
+
"svelte": "5.33.2"
|
|
123
123
|
}
|
|
124
124
|
}
|