svelteplot 0.4.2 → 0.4.3-pr-198.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Mark.svelte +4 -2
- package/dist/core/Plot.svelte +1 -2
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +3 -4
- package/dist/helpers/index.js +1 -6
- package/dist/helpers/resolve.js +4 -4
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +3 -3
- package/dist/marks/AreaX.svelte.d.ts +2 -1
- package/dist/marks/AreaY.svelte.d.ts +2 -1
- package/dist/marks/Arrow.svelte +16 -15
- package/dist/marks/Arrow.svelte.d.ts +1 -1
- package/dist/marks/AxisX.svelte +1 -1
- package/dist/marks/AxisX.svelte.d.ts +2 -2
- package/dist/marks/AxisY.svelte.d.ts +1 -1
- package/dist/marks/BarX.svelte.d.ts +1 -1
- package/dist/marks/BarY.svelte +0 -1
- package/dist/marks/BollingerX.svelte.d.ts +2 -73
- package/dist/marks/BollingerY.svelte.d.ts +2 -73
- package/dist/marks/BoxX.svelte +72 -28
- package/dist/marks/BoxY.svelte +88 -38
- package/dist/marks/BoxY.svelte.d.ts +6 -66
- package/dist/marks/CustomMark.svelte.d.ts +2 -80
- package/dist/marks/DifferenceY.svelte.d.ts +7 -66
- package/dist/marks/Dot.svelte +5 -5
- package/dist/marks/Geo.svelte +3 -3
- package/dist/marks/GridX.svelte +26 -8
- package/dist/marks/GridX.svelte.d.ts +8 -6
- package/dist/marks/GridY.svelte +16 -4
- package/dist/marks/GridY.svelte.d.ts +8 -6
- package/dist/marks/Line.svelte.d.ts +2 -2
- package/dist/marks/LineX.svelte.d.ts +2 -1
- package/dist/marks/LineY.svelte.d.ts +2 -1
- package/dist/marks/Link.svelte +7 -10
- package/dist/marks/Pointer.svelte +2 -2
- package/dist/marks/RuleX.svelte +1 -1
- package/dist/marks/RuleX.svelte.d.ts +1 -1
- package/dist/marks/Text.svelte +2 -1
- package/dist/marks/Vector.svelte +6 -5
- package/dist/marks/helpers/BaseAxisX.svelte +17 -12
- package/dist/marks/helpers/BaseAxisY.svelte +15 -10
- package/dist/marks/helpers/MarkerPath.svelte +10 -2
- package/dist/marks/helpers/RectPath.svelte +15 -15
- package/dist/marks/helpers/RectPath.svelte.d.ts +3 -1
- package/dist/marks/helpers/events.d.ts +5 -6
- package/dist/marks/helpers/events.js +47 -35
- package/dist/transforms/bollinger.d.ts +1 -66
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -122
- package/dist/transforms/recordize.d.ts +9 -7
- package/dist/transforms/recordize.js +23 -24
- package/dist/transforms/select.d.ts +7 -427
- package/dist/transforms/sort.d.ts +3 -242
- package/dist/transforms/stack.d.ts +3 -23
- package/dist/transforms/window.d.ts +2 -128
- package/dist/types/channel.d.ts +1 -1
- package/dist/types/data.d.ts +2 -0
- package/dist/types/index.d.ts +6 -6
- package/package.json +126 -125
|
@@ -28,18 +28,12 @@ Helper component for rendering rectangular marks in SVG
|
|
|
28
28
|
|
|
29
29
|
import { resolveProp, resolveStyles } from '../../helpers/resolve';
|
|
30
30
|
import { roundedRect } from '../../helpers/roundedRect';
|
|
31
|
-
import type {
|
|
32
|
-
BaseMarkProps,
|
|
33
|
-
BaseRectMarkProps,
|
|
34
|
-
BorderRadius,
|
|
35
|
-
ScaledDataRecord,
|
|
36
|
-
UsedScales,
|
|
37
|
-
PlotContext,
|
|
38
|
-
DataRecord
|
|
39
|
-
} from '../../index.js';
|
|
40
31
|
import { addEventHandlers } from './events.js';
|
|
41
32
|
import { getContext } from 'svelte';
|
|
42
33
|
import Anchor from './Anchor.svelte';
|
|
34
|
+
import type { BaseMarkProps, BaseRectMarkProps, BorderRadius } from '../../types/mark.js';
|
|
35
|
+
import type { DataRecord, ScaledDataRecord } from '../../types/data.js';
|
|
36
|
+
import type { PlotContext, UsedScales } from '../../types/index.js';
|
|
43
37
|
|
|
44
38
|
let {
|
|
45
39
|
datum,
|
|
@@ -52,7 +46,7 @@ Helper component for rendering rectangular marks in SVG
|
|
|
52
46
|
useInsetAsFallbackVertically = true,
|
|
53
47
|
useInsetAsFallbackHorizontally = true,
|
|
54
48
|
usedScales,
|
|
55
|
-
fallbackStyle
|
|
49
|
+
fallbackStyle
|
|
56
50
|
}: RectPathProps = $props();
|
|
57
51
|
|
|
58
52
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -99,7 +93,13 @@ Helper component for rendering rectangular marks in SVG
|
|
|
99
93
|
) > 0)
|
|
100
94
|
);
|
|
101
95
|
const [style, styleClass] = $derived(
|
|
102
|
-
resolveStyles(
|
|
96
|
+
resolveStyles(
|
|
97
|
+
plot,
|
|
98
|
+
datum,
|
|
99
|
+
options,
|
|
100
|
+
!fallbackStyle ? (options.stroke && !options.fill ? 'stroke' : 'fill') : fallbackStyle,
|
|
101
|
+
usedScales
|
|
102
|
+
)
|
|
103
103
|
);
|
|
104
104
|
</script>
|
|
105
105
|
|
|
@@ -116,11 +116,11 @@ Helper component for rendering rectangular marks in SVG
|
|
|
116
116
|
)}
|
|
117
117
|
class={[styleClass, className]}
|
|
118
118
|
{style}
|
|
119
|
-
|
|
119
|
+
{@attach addEventHandlers({
|
|
120
120
|
getPlotState,
|
|
121
121
|
options,
|
|
122
122
|
datum: datum?.datum
|
|
123
|
-
}} />
|
|
123
|
+
})} />
|
|
124
124
|
{:else}
|
|
125
125
|
<rect
|
|
126
126
|
transform="translate({x + insetLeft},{y + insetBottom})"
|
|
@@ -128,10 +128,10 @@ Helper component for rendering rectangular marks in SVG
|
|
|
128
128
|
height={height - insetTop - insetBottom}
|
|
129
129
|
class={[styleClass, className]}
|
|
130
130
|
{style}
|
|
131
|
-
|
|
131
|
+
{@attach addEventHandlers({
|
|
132
132
|
getPlotState,
|
|
133
133
|
options,
|
|
134
134
|
datum: datum?.datum
|
|
135
|
-
}} />
|
|
135
|
+
})} />
|
|
136
136
|
{/if}
|
|
137
137
|
</Anchor>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { BaseMarkProps, BaseRectMarkProps
|
|
1
|
+
import type { BaseMarkProps, BaseRectMarkProps } from '../../types/mark.js';
|
|
2
|
+
import type { DataRecord, ScaledDataRecord } from '../../types/data.js';
|
|
3
|
+
import type { UsedScales } from '../../types/index.js';
|
|
2
4
|
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
3
5
|
props(): {
|
|
4
6
|
datum: ScaledDataRecord<Datum_1>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BaseMarkProps, DataRecord, PlotState } from '../../types/index.js';
|
|
1
|
+
import type { BaseMarkProps, DataRecord, DataRow, PlotState } from '../../types/index.js';
|
|
2
|
+
import type { Attachment } from 'svelte/attachments';
|
|
2
3
|
declare global {
|
|
3
4
|
interface MouseEvent {
|
|
4
5
|
layerX?: number;
|
|
@@ -12,10 +13,8 @@ declare global {
|
|
|
12
13
|
* of the plot frame, regardless of which element triggered the event
|
|
13
14
|
*/
|
|
14
15
|
export declare function clientToLayerCoordinates(event: MouseEvent, plotBody: HTMLElement | null | undefined): [number, number];
|
|
15
|
-
export declare function addEventHandlers
|
|
16
|
-
options: BaseMarkProps
|
|
16
|
+
export declare function addEventHandlers<T extends DataRow>({ options, datum, getPlotState }: {
|
|
17
|
+
options: BaseMarkProps<T>;
|
|
17
18
|
datum: DataRecord;
|
|
18
19
|
getPlotState: () => PlotState;
|
|
19
|
-
}):
|
|
20
|
-
destroy(): void;
|
|
21
|
-
};
|
|
20
|
+
}): Attachment;
|
|
@@ -19,7 +19,7 @@ export function clientToLayerCoordinates(event, plotBody) {
|
|
|
19
19
|
// Calculate the coordinates relative to the plot body
|
|
20
20
|
return [event.clientX - plotBodyRect.left, event.clientY - plotBodyRect.top];
|
|
21
21
|
}
|
|
22
|
-
export function addEventHandlers(
|
|
22
|
+
export function addEventHandlers({ options, datum, getPlotState }) {
|
|
23
23
|
const events = pick(options, [
|
|
24
24
|
'onclick',
|
|
25
25
|
'oncontextmenu',
|
|
@@ -51,50 +51,62 @@ export function addEventHandlers(node, { options, datum, getPlotState }) {
|
|
|
51
51
|
'ontouchmove',
|
|
52
52
|
'onwheel'
|
|
53
53
|
]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
return (node) => {
|
|
55
|
+
const listeners = new Map();
|
|
56
|
+
// attach event handlers
|
|
57
|
+
for (const [eventName, eventHandler] of Object.entries(events)) {
|
|
58
|
+
if (eventHandler) {
|
|
59
|
+
const wrappedHandler = (origEvent) => {
|
|
60
|
+
const { scales, body, options } = getPlotState();
|
|
61
|
+
if (origEvent instanceof MouseEvent || origEvent instanceof PointerEvent) {
|
|
62
|
+
let facetEl = origEvent.target;
|
|
63
|
+
while (facetEl &&
|
|
64
|
+
!facetEl.classList.contains('facet') &&
|
|
65
|
+
facetEl.parentElement) {
|
|
66
|
+
// ensure that parentElement is SVGElement
|
|
67
|
+
if (!(facetEl.parentElement instanceof SVGElement))
|
|
68
|
+
break;
|
|
69
|
+
facetEl = facetEl.parentElement;
|
|
70
|
+
}
|
|
71
|
+
const facetRect = (facetEl?.firstElementChild ?? body).getBoundingClientRect();
|
|
72
|
+
const relativeX = origEvent.clientX - facetRect.left + (options.marginLeft ?? 0);
|
|
73
|
+
const relativeY = origEvent.clientY - facetRect.top + (options.marginTop ?? 0);
|
|
74
|
+
if (scales.projection) {
|
|
75
|
+
const [x, y] = scales.projection.invert([relativeX, relativeY]);
|
|
76
|
+
origEvent.dataX = x;
|
|
77
|
+
origEvent.dataY = y;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
origEvent.dataX = invertScale(scales.x, relativeX);
|
|
81
|
+
origEvent.dataY = invertScale(scales.y, relativeY);
|
|
82
|
+
}
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
eventHandler(origEvent, datum.hasOwnProperty(RAW_VALUE) ? datum[RAW_VALUE] : datum, datum[INDEX]);
|
|
75
|
-
};
|
|
76
|
-
listeners.set(eventName, wrappedHandler);
|
|
77
|
-
node.addEventListener(eventName.substring(2), wrappedHandler);
|
|
84
|
+
eventHandler(origEvent, datum.hasOwnProperty(RAW_VALUE) ? datum[RAW_VALUE] : datum, datum[INDEX]);
|
|
85
|
+
};
|
|
86
|
+
listeners.set(eventName, wrappedHandler);
|
|
87
|
+
node.addEventListener(eventName.substring(2), wrappedHandler);
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
destroy() {
|
|
90
|
+
if (events.onclick || events.onmousedown || events.onmouseup) {
|
|
91
|
+
// force role button
|
|
92
|
+
node.setAttribute('role', 'button');
|
|
93
|
+
}
|
|
94
|
+
return () => {
|
|
86
95
|
for (const [eventName, handler] of listeners.entries()) {
|
|
87
96
|
node.removeEventListener(eventName.substring(2), handler);
|
|
88
97
|
}
|
|
89
|
-
}
|
|
98
|
+
};
|
|
90
99
|
};
|
|
91
100
|
}
|
|
92
101
|
function invertScale(scale, position) {
|
|
93
102
|
if (scale.type === 'band') {
|
|
94
|
-
|
|
103
|
+
const range = scale.fn.range();
|
|
104
|
+
const domain = scale.fn.domain();
|
|
95
105
|
const eachBand = scale.fn.step();
|
|
96
|
-
const
|
|
97
|
-
|
|
106
|
+
const extent = range[1] - range[0];
|
|
107
|
+
const posInRange = (position - range[0]) * Math.sign(extent);
|
|
108
|
+
const index = Math.floor(posInRange / eachBand);
|
|
109
|
+
return domain[index];
|
|
98
110
|
}
|
|
99
111
|
return scale.fn.invert ? scale.fn.invert(position) : undefined;
|
|
100
112
|
}
|
|
@@ -11,69 +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
|
-
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
16
|
-
facet?: "auto" | "include" | "exclude" | undefined;
|
|
17
|
-
fx?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
18
|
-
fy?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
19
|
-
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
20
|
-
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
21
|
-
fill?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
22
|
-
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
23
|
-
sort?: {
|
|
24
|
-
channel: string;
|
|
25
|
-
order?: "ascending" | "descending";
|
|
26
|
-
} | ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
27
|
-
stroke?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
28
|
-
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
29
|
-
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
30
|
-
strokeLinejoin?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
31
|
-
strokeLinecap?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
32
|
-
strokeMiterlimit?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
33
|
-
opacity?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
34
|
-
strokeDasharray?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
35
|
-
strokeDashoffset?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
36
|
-
mixBlendMode?: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
37
|
-
clipPath?: string | undefined;
|
|
38
|
-
imageFilter?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
39
|
-
shapeRendering?: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
40
|
-
paintOrder?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
41
|
-
onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
42
|
-
ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
43
|
-
onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
44
|
-
onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
45
|
-
onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
46
|
-
onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
47
|
-
onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
48
|
-
onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
49
|
-
onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
50
|
-
onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
51
|
-
onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
52
|
-
onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
53
|
-
onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
54
|
-
onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
55
|
-
onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
56
|
-
onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
57
|
-
onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
58
|
-
ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
59
|
-
ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
60
|
-
ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
61
|
-
ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
62
|
-
ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
63
|
-
ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
64
|
-
ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
65
|
-
ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
66
|
-
ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
67
|
-
ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
68
|
-
ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
69
|
-
oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
70
|
-
onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
71
|
-
class?: string | null | undefined;
|
|
72
|
-
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
73
|
-
data: {
|
|
74
|
-
__x: import("../types/index.js").RawValue;
|
|
75
|
-
__lo: number;
|
|
76
|
-
__avg: number;
|
|
77
|
-
__hi: number;
|
|
78
|
-
}[];
|
|
79
|
-
};
|
|
14
|
+
export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): 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: Record<string | symbol, RawValue>[];
|
|
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: Record<string | symbol, RawValue>[];
|
|
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: Record<string | symbol, RawValue>[];
|
|
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: Record<string | symbol, RawValue>[];
|
|
65
|
-
};
|
|
57
|
+
export declare function groupZ(input: TransformArg<T, DataRecord>, options?: GroupZOptions): any;
|
|
66
58
|
export {};
|
|
@@ -1,127 +1,7 @@
|
|
|
1
1
|
import type { PlotState, TransformArg } from '../types/index.js';
|
|
2
2
|
export declare function intervalX<T>(args: TransformArg<T>, { plot }: {
|
|
3
3
|
plot: PlotState;
|
|
4
|
-
}):
|
|
5
|
-
filter?: import("../types/index.js").ConstantAccessor<boolean, T>;
|
|
6
|
-
facet?: "auto" | "include" | "exclude" | undefined;
|
|
7
|
-
fx?: import("../types/index.js").ChannelAccessor<T>;
|
|
8
|
-
fy?: import("../types/index.js").ChannelAccessor<T>;
|
|
9
|
-
dx?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
10
|
-
dy?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
11
|
-
fill?: import("../types/index.js").ChannelAccessor<T>;
|
|
12
|
-
fillOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
13
|
-
sort?: {
|
|
14
|
-
channel: string;
|
|
15
|
-
order?: "ascending" | "descending";
|
|
16
|
-
} | ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, T>;
|
|
17
|
-
stroke?: import("../types/index.js").ChannelAccessor<T>;
|
|
18
|
-
strokeWidth?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
19
|
-
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
20
|
-
strokeLinejoin?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, T>;
|
|
21
|
-
strokeLinecap?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, T>;
|
|
22
|
-
strokeMiterlimit?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
23
|
-
opacity?: import("../types/index.js").ChannelAccessor<T>;
|
|
24
|
-
strokeDasharray?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
25
|
-
strokeDashoffset?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
26
|
-
mixBlendMode?: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, T>;
|
|
27
|
-
clipPath?: string | undefined;
|
|
28
|
-
imageFilter?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
29
|
-
shapeRendering?: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, T>;
|
|
30
|
-
paintOrder?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
31
|
-
onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
32
|
-
ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
33
|
-
onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
34
|
-
onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
35
|
-
onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
36
|
-
onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
37
|
-
onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
38
|
-
onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
39
|
-
onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
40
|
-
onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
41
|
-
onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
42
|
-
onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
43
|
-
onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
44
|
-
onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
45
|
-
onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
46
|
-
onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
47
|
-
onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
48
|
-
ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
49
|
-
ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
50
|
-
ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
51
|
-
ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
52
|
-
ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
53
|
-
ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
54
|
-
ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
55
|
-
ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
56
|
-
ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
57
|
-
ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
58
|
-
ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
59
|
-
oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
60
|
-
onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
61
|
-
class?: string | null | undefined;
|
|
62
|
-
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, T>;
|
|
63
|
-
data: T[];
|
|
64
|
-
};
|
|
4
|
+
}): any;
|
|
65
5
|
export declare function intervalY<T>(args: TransformArg<T>, { plot }: {
|
|
66
6
|
plot: PlotState;
|
|
67
|
-
}):
|
|
68
|
-
filter?: import("../types/index.js").ConstantAccessor<boolean, T>;
|
|
69
|
-
facet?: "auto" | "include" | "exclude" | undefined;
|
|
70
|
-
fx?: import("../types/index.js").ChannelAccessor<T>;
|
|
71
|
-
fy?: import("../types/index.js").ChannelAccessor<T>;
|
|
72
|
-
dx?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
73
|
-
dy?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
74
|
-
fill?: import("../types/index.js").ChannelAccessor<T>;
|
|
75
|
-
fillOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
76
|
-
sort?: {
|
|
77
|
-
channel: string;
|
|
78
|
-
order?: "ascending" | "descending";
|
|
79
|
-
} | ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, T>;
|
|
80
|
-
stroke?: import("../types/index.js").ChannelAccessor<T>;
|
|
81
|
-
strokeWidth?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
82
|
-
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
83
|
-
strokeLinejoin?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, T>;
|
|
84
|
-
strokeLinecap?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, T>;
|
|
85
|
-
strokeMiterlimit?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
86
|
-
opacity?: import("../types/index.js").ChannelAccessor<T>;
|
|
87
|
-
strokeDasharray?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
88
|
-
strokeDashoffset?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
89
|
-
mixBlendMode?: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, T>;
|
|
90
|
-
clipPath?: string | undefined;
|
|
91
|
-
imageFilter?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
92
|
-
shapeRendering?: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, T>;
|
|
93
|
-
paintOrder?: import("../types/index.js").ConstantAccessor<string, T>;
|
|
94
|
-
onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
95
|
-
ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
96
|
-
onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
97
|
-
onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
98
|
-
onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
99
|
-
onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
100
|
-
onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
101
|
-
onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
102
|
-
onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
103
|
-
onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
104
|
-
onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
105
|
-
onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
106
|
-
onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
107
|
-
onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
108
|
-
onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
109
|
-
onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
110
|
-
onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
111
|
-
ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
112
|
-
ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
113
|
-
ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
114
|
-
ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
115
|
-
ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
116
|
-
ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
117
|
-
ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
118
|
-
ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
119
|
-
ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
120
|
-
ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
121
|
-
ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
122
|
-
oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
123
|
-
onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
|
|
124
|
-
class?: string | null | undefined;
|
|
125
|
-
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, T>;
|
|
126
|
-
data: T[];
|
|
127
|
-
};
|
|
7
|
+
}): any;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { TransformArgsRow, TransformArgsRecord } from '../types/index.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const X: unique symbol;
|
|
3
|
+
export declare const Y: unique symbol;
|
|
3
4
|
export declare const RAW_VALUE: unique symbol;
|
|
4
|
-
export declare function
|
|
5
|
+
export declare function indexData<T extends object>(data: T[]): (T & {})[];
|
|
6
|
+
export declare function recordizeX<T>({ data, ...channels }: TransformArgsRow<T>, { withIndex }?: {
|
|
5
7
|
withIndex: boolean;
|
|
6
|
-
}): TransformArgsRecord
|
|
7
|
-
export declare function recordizeY({ data, ...channels }: TransformArgsRow
|
|
8
|
+
}): TransformArgsRecord<T>;
|
|
9
|
+
export declare function recordizeY<T>({ data, ...channels }: TransformArgsRow<T>, { withIndex }?: {
|
|
8
10
|
withIndex: boolean;
|
|
9
|
-
}): TransformArgsRecord
|
|
11
|
+
}): TransformArgsRecord<T>;
|
|
10
12
|
/**
|
|
11
13
|
* This transform is used to allow users to pass an [[x0, y0], [x1, y1], ...] array
|
|
12
14
|
* as dataset to marks that support it. It transforms the arrays into records, so
|
|
13
15
|
* the rest of our code doesn't have to deal with this case anymore.
|
|
14
16
|
*/
|
|
15
|
-
export declare function recordizeXY({ data, ...channels }: TransformArgsRow): TransformArgsRecord
|
|
16
|
-
export declare function recordize({ data, ...channels }: TransformArgsRow): TransformArgsRecord
|
|
17
|
+
export declare function recordizeXY<T>({ data, ...channels }: TransformArgsRow<T>): TransformArgsRecord<T>;
|
|
18
|
+
export declare function recordize<T>({ data, ...channels }: TransformArgsRow<T>): TransformArgsRecord<T>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import isDataRecord from '../helpers/isDataRecord.js';
|
|
2
|
-
|
|
2
|
+
import { INDEX } from '../constants';
|
|
3
|
+
export const X = Symbol('x');
|
|
4
|
+
export const Y = Symbol('y');
|
|
3
5
|
export const RAW_VALUE = Symbol('originalValue');
|
|
6
|
+
export function indexData(data) {
|
|
7
|
+
return data.map((d, i) => ({ ...d, [INDEX]: i }));
|
|
8
|
+
}
|
|
4
9
|
/*
|
|
5
10
|
* This transform takes an array of raw values as input and returns data records
|
|
6
11
|
* in which the values are interpreted as x channel and their index as y
|
|
@@ -10,16 +15,15 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
10
15
|
if (dataIsRawValueArray) {
|
|
11
16
|
return {
|
|
12
17
|
data: data.map((value, index) => ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[RAW_VALUE]: value
|
|
18
|
+
[RAW_VALUE]: value,
|
|
19
|
+
[INDEX]: index
|
|
16
20
|
})),
|
|
17
21
|
...channels,
|
|
18
22
|
x: RAW_VALUE,
|
|
19
23
|
...(withIndex ? { y: INDEX } : {})
|
|
20
24
|
};
|
|
21
25
|
}
|
|
22
|
-
return { data: data, ...channels };
|
|
26
|
+
return { data: indexData(data), ...channels };
|
|
23
27
|
}
|
|
24
28
|
/*
|
|
25
29
|
* This transform takes an array of raw values as input and returns data records
|
|
@@ -32,22 +36,15 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
32
36
|
if (dataIsRawValueArray) {
|
|
33
37
|
return {
|
|
34
38
|
data: Array.from(data).map((value, index) => ({
|
|
35
|
-
|
|
39
|
+
[INDEX]: index,
|
|
36
40
|
[RAW_VALUE]: value
|
|
37
41
|
})),
|
|
38
42
|
...channels,
|
|
39
|
-
...(withIndex ? { x:
|
|
43
|
+
...(withIndex ? { x: INDEX } : {}),
|
|
40
44
|
y: RAW_VALUE
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
return {
|
|
44
|
-
data: Array.from(data).map((d, index) => ({
|
|
45
|
-
...d,
|
|
46
|
-
...(withIndex ? { __index: index } : {})
|
|
47
|
-
})),
|
|
48
|
-
x: '__index',
|
|
49
|
-
...channels
|
|
50
|
-
};
|
|
47
|
+
return { data: indexData(data), ...channels };
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
53
50
|
* This transform is used to allow users to pass an [[x0, y0], [x1, y1], ...] array
|
|
@@ -62,28 +59,30 @@ export function recordizeXY({ data, ...channels }) {
|
|
|
62
59
|
channels.x === undefined &&
|
|
63
60
|
channels.y === undefined) {
|
|
64
61
|
return {
|
|
65
|
-
data: data.map(([x, y, ...rest]) => ({
|
|
62
|
+
data: data.map(([x, y, ...rest], i) => ({
|
|
66
63
|
[RAW_VALUE]: [x, y, ...rest],
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
[INDEX]: i,
|
|
65
|
+
[X]: x,
|
|
66
|
+
[Y]: y
|
|
69
67
|
})),
|
|
70
68
|
...channels,
|
|
71
|
-
x:
|
|
72
|
-
y:
|
|
69
|
+
x: X,
|
|
70
|
+
y: Y
|
|
73
71
|
};
|
|
74
72
|
}
|
|
75
|
-
return { data, ...channels };
|
|
73
|
+
return { data: data, ...channels };
|
|
76
74
|
}
|
|
77
75
|
export function recordize({ data, ...channels }) {
|
|
78
76
|
if (!data)
|
|
79
77
|
return { data, ...channels };
|
|
80
78
|
if (!isDataRecord(data[0])) {
|
|
81
79
|
return {
|
|
82
|
-
data: data.map((d) => ({
|
|
83
|
-
[RAW_VALUE]: d
|
|
80
|
+
data: data.map((d, i) => ({
|
|
81
|
+
[RAW_VALUE]: d,
|
|
82
|
+
[INDEX]: i
|
|
84
83
|
})),
|
|
85
84
|
...channels
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
return { data, ...channels };
|
|
87
|
+
return { data: indexData(data), ...channels };
|
|
89
88
|
}
|