svelteplot 0.9.2 → 0.10.0-pr-356.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/README.md +9 -2
- package/dist/Mark.svelte.d.ts +5 -4
- package/dist/constants.d.ts +1 -1
- package/dist/helpers/colors.d.ts +8 -11
- package/dist/helpers/curves.d.ts +2 -2
- package/dist/helpers/facets.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +2 -4
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/reduce.d.ts +1 -1
- package/dist/helpers/scales.d.ts +7 -7
- package/dist/helpers/symbols.d.ts +1 -1
- package/dist/helpers/time.d.ts +3 -3
- package/dist/helpers/typeChecks.d.ts +8 -8
- package/dist/marks/Area.svelte.d.ts +5 -4
- package/dist/marks/AreaX.svelte.d.ts +6 -5
- package/dist/marks/Arrow.svelte.d.ts +5 -4
- package/dist/marks/AxisX.svelte.d.ts +6 -5
- package/dist/marks/AxisY.svelte.d.ts +6 -5
- package/dist/marks/BarX.svelte.d.ts +5 -4
- package/dist/marks/BarY.svelte.d.ts +5 -4
- package/dist/marks/BollingerX.svelte.d.ts +2 -77
- package/dist/marks/BollingerY.svelte.d.ts +2 -77
- package/dist/marks/BoxY.svelte.d.ts +1 -64
- package/dist/marks/Brush.svelte.d.ts +1 -64
- package/dist/marks/Cell.svelte.d.ts +5 -4
- package/dist/marks/CellX.svelte.d.ts +31 -30
- package/dist/marks/CellY.svelte.d.ts +31 -30
- package/dist/marks/CustomMark.svelte.d.ts +2 -85
- package/dist/marks/DifferenceY.svelte.d.ts +1 -64
- package/dist/marks/Dot.svelte.d.ts +5 -4
- package/dist/marks/DotX.svelte.d.ts +6 -5
- package/dist/marks/DotY.svelte.d.ts +6 -5
- package/dist/marks/Frame.svelte.d.ts +6 -5
- package/dist/marks/Geo.svelte.d.ts +5 -4
- package/dist/marks/GridX.svelte.d.ts +5 -4
- package/dist/marks/GridY.svelte.d.ts +5 -4
- package/dist/marks/Image.svelte.d.ts +2 -76
- package/dist/marks/Line.svelte +2 -0
- package/dist/marks/Line.svelte.d.ts +5 -4
- package/dist/marks/LineX.svelte.d.ts +7 -6
- package/dist/marks/LineY.svelte.d.ts +7 -6
- package/dist/marks/Link.svelte +2 -0
- package/dist/marks/Link.svelte.d.ts +5 -4
- package/dist/marks/Rect.svelte.d.ts +5 -4
- package/dist/marks/RuleX.svelte +39 -15
- package/dist/marks/RuleX.svelte.d.ts +6 -4
- package/dist/marks/RuleY.svelte +39 -16
- package/dist/marks/RuleY.svelte.d.ts +6 -4
- package/dist/marks/Spike.svelte.d.ts +6 -5
- package/dist/marks/Text.svelte +49 -20
- package/dist/marks/Text.svelte.d.ts +119 -7
- package/dist/marks/TickX.svelte +40 -33
- package/dist/marks/TickX.svelte.d.ts +6 -4
- package/dist/marks/TickY.svelte +40 -33
- package/dist/marks/TickY.svelte.d.ts +6 -4
- package/dist/marks/Trail.svelte.d.ts +1 -64
- package/dist/marks/Vector.svelte +6 -10
- package/dist/marks/Vector.svelte.d.ts +5 -4
- package/dist/marks/WaffleX.svelte.d.ts +2 -86
- package/dist/marks/WaffleY.svelte.d.ts +2 -84
- package/dist/marks/helpers/Box.svelte.d.ts +1 -64
- package/dist/marks/helpers/Marker.svelte +5 -4
- package/dist/marks/helpers/Marker.svelte.d.ts +1 -0
- package/dist/marks/helpers/MarkerPath.svelte +8 -1
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -103
- package/dist/marks/helpers/RuleCanvas.svelte +175 -0
- package/dist/marks/helpers/RuleCanvas.svelte.d.ts +41 -0
- package/dist/marks/helpers/TextCanvas.svelte +332 -0
- package/dist/marks/helpers/TextCanvas.svelte.d.ts +50 -0
- package/dist/marks/helpers/TickCanvas.svelte +214 -0
- package/dist/marks/helpers/TickCanvas.svelte.d.ts +36 -0
- package/dist/transforms/centroid.d.ts +1 -4
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -130
- package/dist/transforms/normalize.d.ts +33 -0
- package/dist/transforms/recordize.d.ts +4 -7
- package/dist/transforms/rename.d.ts +1 -1
- package/dist/transforms/select.d.ts +7 -455
- package/dist/transforms/sort.d.ts +5 -257
- package/dist/transforms/stack.d.ts +3 -23
- package/dist/transforms/window.d.ts +2 -136
- package/dist/types/index.d.ts +4 -0
- package/package.json +87 -71
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordizeY } from '../transforms/recordize.js';
|
|
1
2
|
import type { DataRecord, ConstantAccessor, ChannelAccessor } from '../types/index.js';
|
|
2
3
|
declare function $$render<Datum = DataRecord>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum = DataRecord>(): {
|
|
|
7
8
|
fy: ChannelAccessor<Datum>;
|
|
8
9
|
dx: ConstantAccessor<number, Datum>;
|
|
9
10
|
dy: ConstantAccessor<number, Datum>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: recordizeY;
|
|
12
|
+
dodgeY: recordizeY;
|
|
12
13
|
fill: ChannelAccessor<Datum>;
|
|
13
14
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
19
|
stroke: ChannelAccessor<Datum>;
|
|
19
20
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
21
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -71,6 +72,7 @@ declare function $$render<Datum = DataRecord>(): {
|
|
|
71
72
|
inset?: ConstantAccessor<number, Datum>;
|
|
72
73
|
insetLeft?: ConstantAccessor<number, Datum>;
|
|
73
74
|
insetRight?: ConstantAccessor<number, Datum>;
|
|
75
|
+
canvas?: boolean;
|
|
74
76
|
};
|
|
75
77
|
exports: {};
|
|
76
78
|
bindings: "";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChannelAccessor, DataRecord } from '../types/index.js';
|
|
2
|
+
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
2
3
|
declare function $$render<Datum extends DataRecord>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
4
5
|
filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
7
8
|
fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
8
9
|
dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
9
10
|
dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: getPlotDefaults;
|
|
12
|
+
dodgeY: getPlotDefaults;
|
|
12
13
|
fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
13
14
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
|
|
18
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
|
|
18
19
|
stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
19
20
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
20
21
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -74,7 +75,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
74
75
|
shape?: "arrow" | "spike" | "arrow-filled" | import("./Vector.svelte").ShapeRenderer;
|
|
75
76
|
children?: import("svelte").Snippet;
|
|
76
77
|
canvas?: boolean;
|
|
77
|
-
}, "
|
|
78
|
+
}, "r" | "length" | "x" | "y" | "data" | "rotate"> & {
|
|
78
79
|
data: Datum[];
|
|
79
80
|
x: ChannelAccessor<Datum>;
|
|
80
81
|
y: ChannelAccessor<Datum>;
|
package/dist/marks/Text.svelte
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<script lang="ts" generics="Datum extends DataRecord">
|
|
7
7
|
import type * as CSS from 'csstype';
|
|
8
8
|
|
|
9
|
-
interface
|
|
9
|
+
interface TextCommonMarkProps extends BaseMarkProps<Datum>, LinkableMarkProps<Datum> {
|
|
10
10
|
data?: Datum[];
|
|
11
11
|
x?: ChannelAccessor<Datum>;
|
|
12
12
|
y?: ChannelAccessor<Datum>;
|
|
@@ -29,10 +29,6 @@
|
|
|
29
29
|
* the horizontal text anchor; start, end, or middle
|
|
30
30
|
*/
|
|
31
31
|
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor, Datum>;
|
|
32
|
-
/**
|
|
33
|
-
* if you want to apply class names to individual text elements
|
|
34
|
-
*/
|
|
35
|
-
textClass?: ConstantAccessor<string, Datum>;
|
|
36
32
|
/**
|
|
37
33
|
* the line anchor for vertical position; top, bottom, or middle
|
|
38
34
|
*/
|
|
@@ -60,6 +56,27 @@
|
|
|
60
56
|
rotate?: ConstantAccessor<number, Datum>;
|
|
61
57
|
}
|
|
62
58
|
|
|
59
|
+
type CanvasTextMarkProps = TextCommonMarkProps & {
|
|
60
|
+
/**
|
|
61
|
+
* renders texts as canvas instead of SVG
|
|
62
|
+
*/
|
|
63
|
+
canvas: true;
|
|
64
|
+
textClass?: never;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type SvgTextMarkProps = TextCommonMarkProps & {
|
|
68
|
+
/**
|
|
69
|
+
* renders texts as canvas instead of SVG
|
|
70
|
+
*/
|
|
71
|
+
canvas?: false | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* if you want to apply class names to individual text elements. Only supported in SVG rendering.
|
|
74
|
+
*/
|
|
75
|
+
textClass?: ConstantAccessor<string, Datum>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type TextMarkProps = SvgTextMarkProps | CanvasTextMarkProps;
|
|
79
|
+
|
|
63
80
|
import { type Snippet } from 'svelte';
|
|
64
81
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
65
82
|
import type {
|
|
@@ -74,6 +91,7 @@
|
|
|
74
91
|
import { sort } from '../index.js';
|
|
75
92
|
|
|
76
93
|
import MultilineText from './helpers/MultilineText.svelte';
|
|
94
|
+
import TextCanvas from './helpers/TextCanvas.svelte';
|
|
77
95
|
import { indexData } from '../transforms/recordize';
|
|
78
96
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
79
97
|
|
|
@@ -89,14 +107,17 @@
|
|
|
89
107
|
|
|
90
108
|
let markProps: TextMarkProps = $props();
|
|
91
109
|
|
|
110
|
+
const mergedProps = $derived({
|
|
111
|
+
...DEFAULTS,
|
|
112
|
+
...markProps
|
|
113
|
+
}) as TextMarkProps;
|
|
114
|
+
|
|
92
115
|
const {
|
|
93
116
|
data = [{} as Datum],
|
|
117
|
+
canvas = false,
|
|
94
118
|
class: className = '',
|
|
95
119
|
...options
|
|
96
|
-
}
|
|
97
|
-
...DEFAULTS,
|
|
98
|
-
...markProps
|
|
99
|
-
});
|
|
120
|
+
} = $derived(mergedProps);
|
|
100
121
|
|
|
101
122
|
const args = $derived(
|
|
102
123
|
sort({
|
|
@@ -107,7 +128,8 @@
|
|
|
107
128
|
</script>
|
|
108
129
|
|
|
109
130
|
<Mark
|
|
110
|
-
|
|
131
|
+
{...args}
|
|
132
|
+
type={'text' as const}
|
|
111
133
|
channels={[
|
|
112
134
|
'x',
|
|
113
135
|
'y',
|
|
@@ -119,17 +141,24 @@
|
|
|
119
141
|
'strokeOpacity',
|
|
120
142
|
'fillOpacity'
|
|
121
143
|
]}
|
|
122
|
-
required={[]}
|
|
123
|
-
{...args}>
|
|
144
|
+
required={[]}>
|
|
124
145
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
146
|
+
{#if canvas}
|
|
147
|
+
<g class="text {className || ''}">
|
|
148
|
+
<TextCanvas data={scaledData} options={args as CanvasTextMarkProps} {usedScales} />
|
|
149
|
+
</g>
|
|
150
|
+
{:else}
|
|
151
|
+
<GroupMultiple
|
|
152
|
+
class="text {className}"
|
|
153
|
+
length={className ? 2 : (args.data?.length ?? 0)}>
|
|
154
|
+
{#each scaledData as d, i (i)}
|
|
155
|
+
{#if d.valid}
|
|
156
|
+
{@const textLines = String(resolveProp(args.text, d.datum, '')).split('\n')}
|
|
129
157
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
158
|
+
<MultilineText {textLines} {d} args={args as any} {usedScales} />
|
|
159
|
+
{/if}
|
|
160
|
+
{/each}
|
|
161
|
+
</GroupMultiple>
|
|
162
|
+
{/if}
|
|
134
163
|
{/snippet}
|
|
135
164
|
</Mark>
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import type * as CSS from 'csstype';
|
|
2
2
|
import { type Snippet } from 'svelte';
|
|
3
3
|
import type { DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
|
|
4
|
+
import { sort } from '../index.js';
|
|
4
5
|
declare function $$render<Datum extends DataRecord>(): {
|
|
5
|
-
props: Partial<{
|
|
6
|
+
props: (Partial<{
|
|
6
7
|
filter: ConstantAccessor<boolean, Datum>;
|
|
7
8
|
facet: "auto" | "include" | "exclude";
|
|
8
9
|
fx: ChannelAccessor<Datum>;
|
|
9
10
|
fy: ChannelAccessor<Datum>;
|
|
10
11
|
dx: ConstantAccessor<number, Datum>;
|
|
11
12
|
dy: ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX:
|
|
13
|
-
dodgeY:
|
|
13
|
+
dodgeX: sort;
|
|
14
|
+
dodgeY: sort;
|
|
14
15
|
fill: ChannelAccessor<Datum>;
|
|
15
16
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
16
|
-
sort:
|
|
17
|
+
sort: {
|
|
17
18
|
channel: string;
|
|
18
19
|
order?: "ascending" | "descending";
|
|
19
|
-
} | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
20
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
20
21
|
stroke: ChannelAccessor<Datum>;
|
|
21
22
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
22
23
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -89,9 +90,114 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
89
90
|
*/
|
|
90
91
|
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor, Datum>;
|
|
91
92
|
/**
|
|
92
|
-
*
|
|
93
|
+
* the line anchor for vertical position; top, bottom, or middle
|
|
94
|
+
*/
|
|
95
|
+
lineAnchor?: ConstantAccessor<"bottom" | "top" | "middle">;
|
|
96
|
+
/**
|
|
97
|
+
* line height as multiplier of font size
|
|
98
|
+
* @default 1.2
|
|
99
|
+
*/
|
|
100
|
+
lineHeight?: ConstantAccessor<number, Datum>;
|
|
101
|
+
frameAnchor?: ConstantAccessor<"bottom" | "top" | "left" | "right" | "top-left" | "bottom-left" | "top-right" | "bottom-right" | "middle", Datum>;
|
|
102
|
+
/**
|
|
103
|
+
* rotate text by angle in degrees
|
|
104
|
+
*/
|
|
105
|
+
rotate?: ConstantAccessor<number, Datum>;
|
|
106
|
+
} & {
|
|
107
|
+
/**
|
|
108
|
+
* renders texts as canvas instead of SVG
|
|
109
|
+
*/
|
|
110
|
+
canvas?: false | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* if you want to apply class names to individual text elements. Only supported in SVG rendering.
|
|
93
113
|
*/
|
|
94
114
|
textClass?: ConstantAccessor<string, Datum>;
|
|
115
|
+
}) | (Partial<{
|
|
116
|
+
filter: ConstantAccessor<boolean, Datum>;
|
|
117
|
+
facet: "auto" | "include" | "exclude";
|
|
118
|
+
fx: ChannelAccessor<Datum>;
|
|
119
|
+
fy: ChannelAccessor<Datum>;
|
|
120
|
+
dx: ConstantAccessor<number, Datum>;
|
|
121
|
+
dy: ConstantAccessor<number, Datum>;
|
|
122
|
+
dodgeX: sort;
|
|
123
|
+
dodgeY: sort;
|
|
124
|
+
fill: ChannelAccessor<Datum>;
|
|
125
|
+
fillOpacity: ConstantAccessor<number, Datum>;
|
|
126
|
+
sort: {
|
|
127
|
+
channel: string;
|
|
128
|
+
order?: "ascending" | "descending";
|
|
129
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
130
|
+
stroke: ChannelAccessor<Datum>;
|
|
131
|
+
strokeWidth: ConstantAccessor<number, Datum>;
|
|
132
|
+
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
133
|
+
strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin, Datum>;
|
|
134
|
+
strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap, Datum>;
|
|
135
|
+
strokeMiterlimit: ConstantAccessor<number, Datum>;
|
|
136
|
+
opacity: ChannelAccessor<Datum>;
|
|
137
|
+
strokeDasharray: ConstantAccessor<string, Datum>;
|
|
138
|
+
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
139
|
+
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
|
|
140
|
+
clipPath: string;
|
|
141
|
+
mask: string;
|
|
142
|
+
imageFilter: ConstantAccessor<string, Datum>;
|
|
143
|
+
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
144
|
+
paintOrder: ConstantAccessor<string, Datum>;
|
|
145
|
+
onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
146
|
+
ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
147
|
+
onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
148
|
+
onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
149
|
+
onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
150
|
+
onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
151
|
+
onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
152
|
+
onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
153
|
+
onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
154
|
+
onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
155
|
+
onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
156
|
+
onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
157
|
+
onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
158
|
+
onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
159
|
+
onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
160
|
+
onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
161
|
+
onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
162
|
+
ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
163
|
+
ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
164
|
+
ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
165
|
+
ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
166
|
+
ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
167
|
+
ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
168
|
+
ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
169
|
+
ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
170
|
+
ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
171
|
+
ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
172
|
+
ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
173
|
+
oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
174
|
+
onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
175
|
+
class: string;
|
|
176
|
+
style: string;
|
|
177
|
+
cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
|
|
178
|
+
}> & LinkableMarkProps<Datum> & {
|
|
179
|
+
data?: Datum[];
|
|
180
|
+
x?: ChannelAccessor<Datum>;
|
|
181
|
+
y?: ChannelAccessor<Datum>;
|
|
182
|
+
children?: Snippet;
|
|
183
|
+
text: ConstantAccessor<string | null | false | undefined, Datum>;
|
|
184
|
+
title?: ConstantAccessor<string, Datum>;
|
|
185
|
+
/**
|
|
186
|
+
* the font size of the text
|
|
187
|
+
*/
|
|
188
|
+
fontFamily?: ConstantAccessor<CSS.Property.FontFamily, Datum>;
|
|
189
|
+
fontSize?: ConstantAccessor<CSS.Property.FontSize | number, Datum>;
|
|
190
|
+
fontWeight?: ConstantAccessor<CSS.Property.FontWeight, Datum>;
|
|
191
|
+
fontStyle?: ConstantAccessor<CSS.Property.FontStyle, Datum>;
|
|
192
|
+
fontVariant?: ConstantAccessor<CSS.Property.FontVariant, Datum>;
|
|
193
|
+
letterSpacing?: ConstantAccessor<CSS.Property.LetterSpacing, Datum>;
|
|
194
|
+
wordSpacing?: ConstantAccessor<CSS.Property.WordSpacing, Datum>;
|
|
195
|
+
textTransform?: ConstantAccessor<CSS.Property.TextTransform, Datum>;
|
|
196
|
+
textDecoration?: ConstantAccessor<CSS.Property.TextDecoration, Datum>;
|
|
197
|
+
/**
|
|
198
|
+
* the horizontal text anchor; start, end, or middle
|
|
199
|
+
*/
|
|
200
|
+
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor, Datum>;
|
|
95
201
|
/**
|
|
96
202
|
* the line anchor for vertical position; top, bottom, or middle
|
|
97
203
|
*/
|
|
@@ -106,7 +212,13 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
106
212
|
* rotate text by angle in degrees
|
|
107
213
|
*/
|
|
108
214
|
rotate?: ConstantAccessor<number, Datum>;
|
|
109
|
-
}
|
|
215
|
+
} & {
|
|
216
|
+
/**
|
|
217
|
+
* renders texts as canvas instead of SVG
|
|
218
|
+
*/
|
|
219
|
+
canvas: true;
|
|
220
|
+
textClass?: never;
|
|
221
|
+
});
|
|
110
222
|
exports: {};
|
|
111
223
|
bindings: "";
|
|
112
224
|
slots: {};
|
package/dist/marks/TickX.svelte
CHANGED
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
* length of the tick. Defaults to 10 pixel
|
|
21
21
|
*/
|
|
22
22
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
23
|
+
canvas?: boolean;
|
|
23
24
|
}
|
|
24
25
|
import Mark from '../Mark.svelte';
|
|
26
|
+
import TickCanvas from './helpers/TickCanvas.svelte';
|
|
25
27
|
import { getContext } from 'svelte';
|
|
26
28
|
import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
27
29
|
import type {
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
const {
|
|
49
51
|
data = [{}],
|
|
50
52
|
class: className = '',
|
|
53
|
+
canvas = false,
|
|
51
54
|
...options
|
|
52
55
|
}: TickXMarkProps = $derived({
|
|
53
56
|
...DEFAULTS,
|
|
@@ -65,40 +68,44 @@
|
|
|
65
68
|
channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']}
|
|
66
69
|
{...markProps}
|
|
67
70
|
{...args}>
|
|
68
|
-
{#snippet children({ mark, usedScales })}
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{@const
|
|
80
|
-
{@const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
71
|
+
{#snippet children({ mark, usedScales, scaledData })}
|
|
72
|
+
{#if canvas}
|
|
73
|
+
<TickCanvas data={scaledData} options={args} {usedScales} orientation="vertical" />
|
|
74
|
+
{:else}
|
|
75
|
+
<g class="tick-x">
|
|
76
|
+
{#each args.data as datum, i (i)}
|
|
77
|
+
{#if testFacet(datum, mark.options) && testFilter(datum, args)}
|
|
78
|
+
{@const x_ = resolveChannel('x', datum, args)}
|
|
79
|
+
{@const y_ = resolveChannel('y', datum, args)}
|
|
80
|
+
{@const inset_ = resolveProp(args.inset, datum, 0)}
|
|
81
|
+
{@const tickLength_ = resolveProp(args.tickLength, datum, 10)}
|
|
82
|
+
{@const dx_ = resolveProp(args.dx, datum, 0)}
|
|
83
|
+
{@const dy_ = resolveProp(args.dy, datum, 0)}
|
|
84
|
+
{#if isValid(x_) && (isValid(y_) || args.y == null) && (args.filter == null || resolveProp(args.filter, datum))}
|
|
85
|
+
{@const x = usedScales.x ? projectX('x', plot.scales, x_) : x_}
|
|
86
|
+
{@const y1 =
|
|
87
|
+
args.y != null
|
|
88
|
+
? usedScales.y
|
|
89
|
+
? projectY('y1', plot.scales, y_)
|
|
90
|
+
: y_
|
|
91
|
+
: plot.options.marginTop}
|
|
92
|
+
{@const y2 =
|
|
93
|
+
args.y != null
|
|
94
|
+
? usedScales.y
|
|
95
|
+
? Number(projectY('y2', plot.scales, y_))
|
|
96
|
+
: y_
|
|
97
|
+
: plot.options.marginTop + plot.plotHeight}
|
|
98
|
+
{@const inset = parseInset(inset_, Math.abs(y2 - y1))}
|
|
99
|
+
<line
|
|
100
|
+
transform="translate({x + dx_}, {dy_})"
|
|
101
|
+
style={resolveScaledStyles(datum, args, usedScales, plot, 'stroke')}
|
|
102
|
+
y1={y1 + inset + (y1 === y2 ? tickLength_ * 0.5 : 0)}
|
|
103
|
+
y2={y2 - inset - (y1 === y2 ? tickLength_ * 0.5 : 0)} />
|
|
104
|
+
{/if}
|
|
98
105
|
{/if}
|
|
99
|
-
{/
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
{/each}
|
|
107
|
+
</g>
|
|
108
|
+
{/if}
|
|
102
109
|
{/snippet}
|
|
103
110
|
</Mark>
|
|
104
111
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChannelAccessor, DataRow, ConstantAccessor } from '../types/index.js';
|
|
2
|
+
import { recordizeX } from '../index.js';
|
|
2
3
|
declare function $$render<Datum extends DataRow>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
4
5
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
7
8
|
fy: ChannelAccessor<Datum>;
|
|
8
9
|
dx: ConstantAccessor<number, Datum>;
|
|
9
10
|
dy: ConstantAccessor<number, Datum>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: recordizeX;
|
|
12
|
+
dodgeY: recordizeX;
|
|
12
13
|
fill: ChannelAccessor<Datum>;
|
|
13
14
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
19
|
stroke: ChannelAccessor<Datum>;
|
|
19
20
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
21
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -79,6 +80,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
79
80
|
* length of the tick. Defaults to 10 pixel
|
|
80
81
|
*/
|
|
81
82
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
83
|
+
canvas?: boolean;
|
|
82
84
|
};
|
|
83
85
|
exports: {};
|
|
84
86
|
bindings: "";
|
package/dist/marks/TickY.svelte
CHANGED
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
* length of the tick. Defaults to 10 pixel
|
|
20
20
|
*/
|
|
21
21
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
22
|
+
canvas?: boolean;
|
|
22
23
|
}
|
|
23
24
|
import Mark from '../Mark.svelte';
|
|
25
|
+
import TickCanvas from './helpers/TickCanvas.svelte';
|
|
24
26
|
import { getContext } from 'svelte';
|
|
25
27
|
import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
26
28
|
import type {
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
const {
|
|
48
50
|
data = [{}],
|
|
49
51
|
class: className = '',
|
|
52
|
+
canvas = false,
|
|
50
53
|
...options
|
|
51
54
|
}: TickYMarkProps = $derived({
|
|
52
55
|
...DEFAULTS,
|
|
@@ -64,40 +67,44 @@
|
|
|
64
67
|
channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']}
|
|
65
68
|
{...markProps}
|
|
66
69
|
{...args}>
|
|
67
|
-
{#snippet children({ mark, usedScales })}
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{@const
|
|
79
|
-
{@const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
{#snippet children({ mark, usedScales, scaledData })}
|
|
71
|
+
{#if canvas}
|
|
72
|
+
<TickCanvas data={scaledData} options={args} {usedScales} orientation="horizontal" />
|
|
73
|
+
{:else}
|
|
74
|
+
<g class="tick-y">
|
|
75
|
+
{#each args.data as datum, i (i)}
|
|
76
|
+
{#if testFacet(datum, mark.options) && testFilter(datum, args)}
|
|
77
|
+
{@const y_ = resolveChannel('y', datum, args)}
|
|
78
|
+
{@const x_ = resolveChannel('x', datum, args)}
|
|
79
|
+
{@const inset_ = resolveProp(args.inset, datum, 0)}
|
|
80
|
+
{@const tickLength_ = resolveProp(args.tickLength, datum, 10)}
|
|
81
|
+
{@const dx_ = resolveProp(args.dx, datum, 0)}
|
|
82
|
+
{@const dy_ = resolveProp(args.dy, datum, 0)}
|
|
83
|
+
{#if isValid(y_) && (isValid(x_) || args.x == null)}
|
|
84
|
+
{@const y = usedScales.y ? projectY('y', plot.scales, y_) : y_}
|
|
85
|
+
{@const x1 =
|
|
86
|
+
args.x != null
|
|
87
|
+
? usedScales.x
|
|
88
|
+
? projectX('x1', plot.scales, x_)
|
|
89
|
+
: x_
|
|
90
|
+
: plot.options.marginLeft}
|
|
91
|
+
{@const x2 =
|
|
92
|
+
args.x != null
|
|
93
|
+
? usedScales.x
|
|
94
|
+
? projectX('x2', plot.scales, x_)
|
|
95
|
+
: x_
|
|
96
|
+
: plot.options.marginLeft + plot.facetWidth}
|
|
97
|
+
{@const inset = parseInset(inset_, Math.abs(x2 - x1))}
|
|
98
|
+
<line
|
|
99
|
+
transform="translate({dx_}, {y + dy_})"
|
|
100
|
+
style={resolveScaledStyles(datum, args, usedScales, plot, 'stroke')}
|
|
101
|
+
x1={x1 + inset + (x1 === x2 ? tickLength_ * 0.5 : 0)}
|
|
102
|
+
x2={x2 - inset - (x1 === x2 ? tickLength_ * 0.5 : 0)} />
|
|
103
|
+
{/if}
|
|
97
104
|
{/if}
|
|
98
|
-
{/
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
{/each}
|
|
106
|
+
</g>
|
|
107
|
+
{/if}
|
|
101
108
|
{/snippet}
|
|
102
109
|
</Mark>
|
|
103
110
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChannelAccessor, DataRow, ConstantAccessor } from '../types/index.js';
|
|
2
|
+
import { recordizeY } from '../index.js';
|
|
2
3
|
declare function $$render<Datum extends DataRow>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
4
5
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
7
8
|
fy: ChannelAccessor<Datum>;
|
|
8
9
|
dx: ConstantAccessor<number, Datum>;
|
|
9
10
|
dy: ConstantAccessor<number, Datum>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: recordizeY;
|
|
12
|
+
dodgeY: recordizeY;
|
|
12
13
|
fill: ChannelAccessor<Datum>;
|
|
13
14
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
18
19
|
stroke: ChannelAccessor<Datum>;
|
|
19
20
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
21
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -79,6 +80,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
79
80
|
* length of the tick. Defaults to 10 pixel
|
|
80
81
|
*/
|
|
81
82
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
83
|
+
canvas?: boolean;
|
|
82
84
|
};
|
|
83
85
|
exports: {};
|
|
84
86
|
bindings: "";
|