svelteplot 0.9.2 → 0.10.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/marks/Line.svelte +2 -0
- package/dist/marks/Link.svelte +2 -0
- package/dist/marks/RuleX.svelte +39 -15
- package/dist/marks/RuleX.svelte.d.ts +1 -0
- package/dist/marks/RuleY.svelte +39 -16
- package/dist/marks/RuleY.svelte.d.ts +1 -0
- package/dist/marks/Text.svelte +49 -20
- package/dist/marks/Text.svelte.d.ts +114 -3
- package/dist/marks/TickX.svelte +40 -33
- package/dist/marks/TickX.svelte.d.ts +1 -0
- package/dist/marks/TickY.svelte +40 -33
- package/dist/marks/TickY.svelte.d.ts +1 -0
- package/dist/marks/Vector.svelte +6 -10
- 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 +4 -0
- 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/types/index.d.ts +4 -0
- package/package.json +151 -152
package/dist/marks/Line.svelte
CHANGED
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
curve: 'auto',
|
|
55
55
|
tension: 0,
|
|
56
56
|
canvas: false,
|
|
57
|
+
markerScale: 1,
|
|
57
58
|
class: null,
|
|
58
59
|
lineClass: null,
|
|
59
60
|
...getPlotDefaults().line
|
|
@@ -216,6 +217,7 @@
|
|
|
216
217
|
markerMid={args.markerMid}
|
|
217
218
|
markerEnd={args.markerEnd}
|
|
218
219
|
marker={args.marker}
|
|
220
|
+
markerScale={args.markerScale}
|
|
219
221
|
strokeWidth={args.strokeWidth}
|
|
220
222
|
datum={lineData[0].datum}
|
|
221
223
|
d={pathString}
|
package/dist/marks/Link.svelte
CHANGED
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
|
|
61
61
|
let markProps: LinkMarkProps = $props();
|
|
62
62
|
const DEFAULTS = {
|
|
63
|
+
markerScale: 1,
|
|
63
64
|
...getPlotDefaults().link
|
|
64
65
|
};
|
|
65
66
|
const {
|
|
@@ -179,6 +180,7 @@
|
|
|
179
180
|
markerStart={args.markerStart}
|
|
180
181
|
markerEnd={args.markerEnd}
|
|
181
182
|
marker={args.marker}
|
|
183
|
+
markerScale={args.markerScale}
|
|
182
184
|
class={styleClass}
|
|
183
185
|
strokeWidth={args.strokeWidth}
|
|
184
186
|
datum={d.datum}
|
package/dist/marks/RuleX.svelte
CHANGED
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
inset?: ConstantAccessor<number, Datum>;
|
|
11
11
|
insetTop?: ConstantAccessor<number, Datum>;
|
|
12
12
|
insetBottom?: ConstantAccessor<number, Datum>;
|
|
13
|
+
canvas?: boolean;
|
|
13
14
|
}
|
|
14
15
|
import Mark from '../Mark.svelte';
|
|
15
16
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
17
|
+
import RuleCanvas from './helpers/RuleCanvas.svelte';
|
|
16
18
|
import { recordizeX } from '../transforms/recordize.js';
|
|
17
19
|
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
18
20
|
import type {
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
const {
|
|
34
36
|
data = [{} as Datum],
|
|
35
37
|
class: className = '',
|
|
38
|
+
canvas = false,
|
|
36
39
|
...options
|
|
37
40
|
}: RuleXMarkProps = $derived({
|
|
38
41
|
...DEFAULTS,
|
|
@@ -49,20 +52,41 @@
|
|
|
49
52
|
{...markProps}
|
|
50
53
|
{...args}>
|
|
51
54
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
{
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
{#if canvas}
|
|
56
|
+
<RuleCanvas
|
|
57
|
+
data={scaledData}
|
|
58
|
+
options={args}
|
|
59
|
+
{usedScales}
|
|
60
|
+
orientation="vertical"
|
|
61
|
+
marginTop={plot.options.marginTop}
|
|
62
|
+
facetHeight={plot.facetHeight} />
|
|
63
|
+
{:else}
|
|
64
|
+
<GroupMultiple
|
|
65
|
+
class="rule-x {className || ''}"
|
|
66
|
+
length={className ? 2 : scaledData.length}>
|
|
67
|
+
{#each scaledData as d, i (i)}
|
|
68
|
+
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
69
|
+
{@const insetTop = resolveProp(args.insetTop, d.datum, 0)}
|
|
70
|
+
{@const insetBottom = resolveProp(args.insetBottom, d.datum, 0)}
|
|
71
|
+
{@const [style, styleClass] = resolveStyles(
|
|
72
|
+
plot,
|
|
73
|
+
d,
|
|
74
|
+
args,
|
|
75
|
+
'stroke',
|
|
76
|
+
usedScales
|
|
77
|
+
)}
|
|
78
|
+
<line
|
|
79
|
+
transform="translate({d.x}, 0)"
|
|
80
|
+
{style}
|
|
81
|
+
class={[styleClass]}
|
|
82
|
+
y1={(inset || insetTop) +
|
|
83
|
+
(d.y1 != null ? d.y1 : plot.options.marginTop + d.dy)}
|
|
84
|
+
y2={(d.y2 != null
|
|
85
|
+
? d.y2
|
|
86
|
+
: plot.facetHeight + plot.options.marginTop + d.dy) -
|
|
87
|
+
(inset || insetBottom)} />
|
|
88
|
+
{/each}
|
|
89
|
+
</GroupMultiple>
|
|
90
|
+
{/if}
|
|
67
91
|
{/snippet}
|
|
68
92
|
</Mark>
|
|
@@ -71,6 +71,7 @@ declare function $$render<Datum = DataRecord | RawValue>(): {
|
|
|
71
71
|
inset?: ConstantAccessor<number, Datum>;
|
|
72
72
|
insetTop?: ConstantAccessor<number, Datum>;
|
|
73
73
|
insetBottom?: ConstantAccessor<number, Datum>;
|
|
74
|
+
canvas?: boolean;
|
|
74
75
|
};
|
|
75
76
|
exports: {};
|
|
76
77
|
bindings: "";
|
package/dist/marks/RuleY.svelte
CHANGED
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
inset?: ConstantAccessor<number, Datum>;
|
|
11
11
|
insetLeft?: ConstantAccessor<number, Datum>;
|
|
12
12
|
insetRight?: ConstantAccessor<number, Datum>;
|
|
13
|
+
canvas?: boolean;
|
|
13
14
|
}
|
|
14
15
|
import Mark from '../Mark.svelte';
|
|
15
16
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
17
|
+
import RuleCanvas from './helpers/RuleCanvas.svelte';
|
|
16
18
|
import { recordizeY } from '../transforms/recordize.js';
|
|
17
19
|
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
18
20
|
import type {
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
const {
|
|
34
36
|
data = [{} as Datum],
|
|
35
37
|
class: className = '',
|
|
38
|
+
canvas = false,
|
|
36
39
|
...options
|
|
37
40
|
}: RuleYMarkProps = $derived({
|
|
38
41
|
...DEFAULTS,
|
|
@@ -49,21 +52,41 @@
|
|
|
49
52
|
{...markProps}
|
|
50
53
|
{...args}>
|
|
51
54
|
{#snippet children({ scaledData, usedScales })}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
{
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
{#if canvas}
|
|
56
|
+
<RuleCanvas
|
|
57
|
+
data={scaledData}
|
|
58
|
+
options={args}
|
|
59
|
+
{usedScales}
|
|
60
|
+
orientation="horizontal"
|
|
61
|
+
marginLeft={plot.options.marginLeft}
|
|
62
|
+
facetWidth={plot.facetWidth} />
|
|
63
|
+
{:else}
|
|
64
|
+
<GroupMultiple
|
|
65
|
+
class="rule-y {className || ''}"
|
|
66
|
+
length={className ? 2 : args.data.length}>
|
|
67
|
+
{#each scaledData as d, i (i)}
|
|
68
|
+
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
69
|
+
{@const insetLeft = resolveProp(args.insetLeft, d.datum, 0)}
|
|
70
|
+
{@const insetRight = resolveProp(args.insetRight, d.datum, 0)}
|
|
71
|
+
{@const [style, styleClass] = resolveStyles(
|
|
72
|
+
plot,
|
|
73
|
+
d,
|
|
74
|
+
args,
|
|
75
|
+
'stroke',
|
|
76
|
+
usedScales
|
|
77
|
+
)}
|
|
78
|
+
<line
|
|
79
|
+
transform="translate(0, {d.y})"
|
|
80
|
+
{style}
|
|
81
|
+
class={[styleClass]}
|
|
82
|
+
x1={(inset || insetLeft) +
|
|
83
|
+
(d.x1 != null ? d.x1 : plot.options.marginLeft + d.dx)}
|
|
84
|
+
x2={(d.x2 != null
|
|
85
|
+
? d.x2
|
|
86
|
+
: plot.facetWidth + plot.options.marginLeft + d.dx) -
|
|
87
|
+
(inset || insetRight)} />
|
|
88
|
+
{/each}
|
|
89
|
+
</GroupMultiple>
|
|
90
|
+
{/if}
|
|
68
91
|
{/snippet}
|
|
69
92
|
</Mark>
|
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>
|
|
@@ -2,7 +2,7 @@ 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
4
|
declare function $$render<Datum extends DataRecord>(): {
|
|
5
|
-
props: Partial<{
|
|
5
|
+
props: (Partial<{
|
|
6
6
|
filter: ConstantAccessor<boolean, Datum>;
|
|
7
7
|
facet: "auto" | "include" | "exclude";
|
|
8
8
|
fx: ChannelAccessor<Datum>;
|
|
@@ -89,9 +89,114 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
89
89
|
*/
|
|
90
90
|
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor, Datum>;
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* the line anchor for vertical position; top, bottom, or middle
|
|
93
|
+
*/
|
|
94
|
+
lineAnchor?: ConstantAccessor<"bottom" | "top" | "middle">;
|
|
95
|
+
/**
|
|
96
|
+
* line height as multiplier of font size
|
|
97
|
+
* @default 1.2
|
|
98
|
+
*/
|
|
99
|
+
lineHeight?: ConstantAccessor<number, Datum>;
|
|
100
|
+
frameAnchor?: ConstantAccessor<"bottom" | "top" | "left" | "right" | "top-left" | "bottom-left" | "top-right" | "bottom-right" | "middle", Datum>;
|
|
101
|
+
/**
|
|
102
|
+
* rotate text by angle in degrees
|
|
103
|
+
*/
|
|
104
|
+
rotate?: ConstantAccessor<number, Datum>;
|
|
105
|
+
} & {
|
|
106
|
+
/**
|
|
107
|
+
* renders texts as canvas instead of SVG
|
|
108
|
+
*/
|
|
109
|
+
canvas?: false | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* if you want to apply class names to individual text elements. Only supported in SVG rendering.
|
|
93
112
|
*/
|
|
94
113
|
textClass?: ConstantAccessor<string, Datum>;
|
|
114
|
+
}) | (Partial<{
|
|
115
|
+
filter: ConstantAccessor<boolean, Datum>;
|
|
116
|
+
facet: "auto" | "include" | "exclude";
|
|
117
|
+
fx: ChannelAccessor<Datum>;
|
|
118
|
+
fy: ChannelAccessor<Datum>;
|
|
119
|
+
dx: ConstantAccessor<number, Datum>;
|
|
120
|
+
dy: ConstantAccessor<number, Datum>;
|
|
121
|
+
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
122
|
+
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
123
|
+
fill: ChannelAccessor<Datum>;
|
|
124
|
+
fillOpacity: ConstantAccessor<number, Datum>;
|
|
125
|
+
sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
|
|
126
|
+
channel: string;
|
|
127
|
+
order?: "ascending" | "descending";
|
|
128
|
+
} | ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
129
|
+
stroke: ChannelAccessor<Datum>;
|
|
130
|
+
strokeWidth: ConstantAccessor<number, Datum>;
|
|
131
|
+
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
132
|
+
strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin, Datum>;
|
|
133
|
+
strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap, Datum>;
|
|
134
|
+
strokeMiterlimit: ConstantAccessor<number, Datum>;
|
|
135
|
+
opacity: ChannelAccessor<Datum>;
|
|
136
|
+
strokeDasharray: ConstantAccessor<string, Datum>;
|
|
137
|
+
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
138
|
+
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
|
|
139
|
+
clipPath: string;
|
|
140
|
+
mask: string;
|
|
141
|
+
imageFilter: ConstantAccessor<string, Datum>;
|
|
142
|
+
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
143
|
+
paintOrder: ConstantAccessor<string, Datum>;
|
|
144
|
+
onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
145
|
+
ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
146
|
+
onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
147
|
+
onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
148
|
+
onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
149
|
+
onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
150
|
+
onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
151
|
+
onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
152
|
+
onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
153
|
+
onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
154
|
+
onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
155
|
+
onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
156
|
+
onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
157
|
+
onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
158
|
+
onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
159
|
+
onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
160
|
+
onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
161
|
+
ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
162
|
+
ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
163
|
+
ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
164
|
+
ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
165
|
+
ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
166
|
+
ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
167
|
+
ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
168
|
+
ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
169
|
+
ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
170
|
+
ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
171
|
+
ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
172
|
+
oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
173
|
+
onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
174
|
+
class: string;
|
|
175
|
+
style: string;
|
|
176
|
+
cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
|
|
177
|
+
}> & LinkableMarkProps<Datum> & {
|
|
178
|
+
data?: Datum[];
|
|
179
|
+
x?: ChannelAccessor<Datum>;
|
|
180
|
+
y?: ChannelAccessor<Datum>;
|
|
181
|
+
children?: Snippet;
|
|
182
|
+
text: ConstantAccessor<string | null | false | undefined, Datum>;
|
|
183
|
+
title?: ConstantAccessor<string, Datum>;
|
|
184
|
+
/**
|
|
185
|
+
* the font size of the text
|
|
186
|
+
*/
|
|
187
|
+
fontFamily?: ConstantAccessor<CSS.Property.FontFamily, Datum>;
|
|
188
|
+
fontSize?: ConstantAccessor<CSS.Property.FontSize | number, Datum>;
|
|
189
|
+
fontWeight?: ConstantAccessor<CSS.Property.FontWeight, Datum>;
|
|
190
|
+
fontStyle?: ConstantAccessor<CSS.Property.FontStyle, Datum>;
|
|
191
|
+
fontVariant?: ConstantAccessor<CSS.Property.FontVariant, Datum>;
|
|
192
|
+
letterSpacing?: ConstantAccessor<CSS.Property.LetterSpacing, Datum>;
|
|
193
|
+
wordSpacing?: ConstantAccessor<CSS.Property.WordSpacing, Datum>;
|
|
194
|
+
textTransform?: ConstantAccessor<CSS.Property.TextTransform, Datum>;
|
|
195
|
+
textDecoration?: ConstantAccessor<CSS.Property.TextDecoration, Datum>;
|
|
196
|
+
/**
|
|
197
|
+
* the horizontal text anchor; start, end, or middle
|
|
198
|
+
*/
|
|
199
|
+
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor, Datum>;
|
|
95
200
|
/**
|
|
96
201
|
* the line anchor for vertical position; top, bottom, or middle
|
|
97
202
|
*/
|
|
@@ -106,7 +211,13 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
106
211
|
* rotate text by angle in degrees
|
|
107
212
|
*/
|
|
108
213
|
rotate?: ConstantAccessor<number, Datum>;
|
|
109
|
-
}
|
|
214
|
+
} & {
|
|
215
|
+
/**
|
|
216
|
+
* renders texts as canvas instead of SVG
|
|
217
|
+
*/
|
|
218
|
+
canvas: true;
|
|
219
|
+
textClass?: never;
|
|
220
|
+
});
|
|
110
221
|
exports: {};
|
|
111
222
|
bindings: "";
|
|
112
223
|
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
|
|