svelteplot 0.3.2 → 0.3.3-pr-115.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +2 -0
- package/dist/helpers/getBaseStyles.js +8 -0
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/BollingerX.svelte.d.ts +1 -1
- package/dist/marks/BollingerY.svelte.d.ts +1 -1
- package/dist/marks/Sphere.svelte.d.ts +1 -1
- package/dist/marks/Text.svelte +12 -103
- package/dist/marks/Text.svelte.d.ts +5 -0
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/MultilineText.svelte +158 -0
- package/dist/marks/helpers/MultilineText.svelte.d.ts +12 -0
- package/dist/transforms/bollinger.d.ts +1 -66
- package/dist/transforms/centroid.d.ts +1 -66
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -122
- package/dist/transforms/map.d.ts +4 -184
- package/dist/transforms/normalize.d.ts +3 -123
- package/dist/transforms/select.d.ts +7 -427
- package/dist/transforms/sort.d.ts +3 -242
- package/dist/transforms/window.d.ts +2 -130
- package/package.json +121 -120
package/dist/helpers/colors.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type SchemeGetter = (n: number) => readonly string[];
|
|
|
6
6
|
export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
|
|
7
7
|
export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
|
|
8
8
|
export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
|
|
9
|
-
export declare function maybeBooleanRange(domain: boolean[], scheme?: string):
|
|
9
|
+
export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
|
|
10
10
|
export declare function isQuantitativeScheme(scheme: string): boolean;
|
|
11
11
|
export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
|
|
12
12
|
export declare function isDivergingScheme(scheme: string): boolean;
|
|
@@ -5,3 +5,5 @@ export declare function getBaseStylesObject(datum: DataRow, props: Partial<Chann
|
|
|
5
5
|
};
|
|
6
6
|
export default function (datum: DataRow, props: Partial<Channels>): string;
|
|
7
7
|
export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
|
|
8
|
+
export declare function maybeFromPixel(value: string | number): string | number;
|
|
9
|
+
export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
|
|
@@ -41,3 +41,11 @@ export function maybeToPixel(cssKey, value) {
|
|
|
41
41
|
}
|
|
42
42
|
return value;
|
|
43
43
|
}
|
|
44
|
+
export function maybeFromPixel(value) {
|
|
45
|
+
return typeof value === 'string' && value.endsWith('px') ? +value.slice(0, -2) : value;
|
|
46
|
+
}
|
|
47
|
+
export function maybeFromRem(value, rootFontSize = 16) {
|
|
48
|
+
return typeof value === 'string' && value.endsWith('rem')
|
|
49
|
+
? +value.slice(0, -3) * rootFontSize
|
|
50
|
+
: value;
|
|
51
|
+
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { Snippet } from 'svelte';
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns first argument that is not null or undefined
|
|
5
5
|
*/
|
|
6
|
-
export declare function coalesce(...args: (RawValue | undefined | null)[]):
|
|
7
|
-
export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>):
|
|
6
|
+
export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
|
|
7
|
+
export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): any;
|
|
8
8
|
export declare function randomId(): string;
|
|
9
9
|
export declare function isSnippet(value: unknown): value is Snippet;
|
|
10
10
|
export declare function isValid(value: RawValue | undefined): value is number | Date | string;
|
package/dist/helpers/scales.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
|
|
|
15
15
|
autoTitle?: undefined;
|
|
16
16
|
} | {
|
|
17
17
|
type: ScaleType;
|
|
18
|
-
domain:
|
|
18
|
+
domain: any;
|
|
19
19
|
range: any;
|
|
20
20
|
fn: any;
|
|
21
21
|
skip: Map<ScaledChannelName, Set<symbol>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { RawValue } from '../types.js';
|
|
2
|
-
export declare function isBooleanOrNull(v: RawValue):
|
|
2
|
+
export declare function isBooleanOrNull(v: RawValue): boolean;
|
|
3
3
|
export declare function isDate(v: RawValue): v is Date;
|
|
4
|
-
export declare function isDateOrNull(v: RawValue | null | undefined):
|
|
4
|
+
export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
|
|
5
5
|
export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
|
|
6
6
|
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
|
|
7
|
-
export declare function isStringOrNull(v: RawValue | null | undefined):
|
|
7
|
+
export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
|
|
8
8
|
export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
|
|
9
|
-
export declare function isColorOrNull(v: RawValue | null | undefined):
|
|
9
|
+
export declare function isColorOrNull(v: RawValue | null | undefined): any;
|
|
10
10
|
export declare function isOpacityOrNull(v: RawValue): boolean;
|
|
@@ -13,6 +13,6 @@ export type BollingerXMarkProps = BaseMarkProps & {
|
|
|
13
13
|
};
|
|
14
14
|
import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
|
|
15
15
|
/** line representing a moving average and an area representing volatility as a band */
|
|
16
|
-
declare const BollingerX: import("svelte").Component<
|
|
16
|
+
declare const BollingerX: import("svelte").Component<any, {}, "">;
|
|
17
17
|
type BollingerX = ReturnType<typeof BollingerX>;
|
|
18
18
|
export default BollingerX;
|
|
@@ -13,6 +13,6 @@ export type BollingerYMarkProps = BaseMarkProps & {
|
|
|
13
13
|
};
|
|
14
14
|
import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
|
|
15
15
|
/** line representing a moving average and an area representing volatility as a band */
|
|
16
|
-
declare const BollingerY: import("svelte").Component<
|
|
16
|
+
declare const BollingerY: import("svelte").Component<any, {}, "">;
|
|
17
17
|
type BollingerY = ReturnType<typeof BollingerY>;
|
|
18
18
|
export default BollingerY;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BaseMarkProps, type LinkableMarkProps } from '../types.js';
|
|
2
2
|
export type SphereMarkProps = BaseMarkProps & LinkableMarkProps;
|
|
3
3
|
/** Geo mark with Sphere geometry object */
|
|
4
|
-
declare const Sphere: import("svelte").Component<
|
|
4
|
+
declare const Sphere: import("svelte").Component<any, {}, "">;
|
|
5
5
|
type Sphere = ReturnType<typeof Sphere>;
|
|
6
6
|
export default Sphere;
|
package/dist/marks/Text.svelte
CHANGED
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
* the line anchor for vertical position; top, bottom, or middle
|
|
19
19
|
*/
|
|
20
20
|
lineAnchor?: ConstantAccessor<'bottom' | 'top' | 'middle'>;
|
|
21
|
+
/**
|
|
22
|
+
* line height as multiplier of font size
|
|
23
|
+
* @default 1.2
|
|
24
|
+
*/
|
|
25
|
+
lineHeight?: ConstantAccessor<number>;
|
|
21
26
|
frameAnchor?: ConstantAccessor<
|
|
22
27
|
| 'bottom'
|
|
23
28
|
| 'top'
|
|
@@ -35,7 +40,6 @@
|
|
|
35
40
|
import { getContext, type Snippet } from 'svelte';
|
|
36
41
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
37
42
|
import type {
|
|
38
|
-
PlotContext,
|
|
39
43
|
DataRecord,
|
|
40
44
|
BaseMarkProps,
|
|
41
45
|
ConstantAccessor,
|
|
@@ -46,10 +50,14 @@
|
|
|
46
50
|
import Mark from '../Mark.svelte';
|
|
47
51
|
import { sort } from '../index.js';
|
|
48
52
|
|
|
53
|
+
import MultilineText from './helpers/MultilineText.svelte';
|
|
54
|
+
|
|
49
55
|
const DEFAULTS = {
|
|
50
56
|
fontSize: 12,
|
|
51
57
|
fontWeight: 500,
|
|
52
58
|
strokeWidth: 1.6,
|
|
59
|
+
frameAnchor: 'center',
|
|
60
|
+
lineHeight: 1.1,
|
|
53
61
|
...getContext<PlotDefaults>('svelteplot/_defaults').text
|
|
54
62
|
};
|
|
55
63
|
|
|
@@ -64,21 +72,12 @@
|
|
|
64
72
|
...markProps
|
|
65
73
|
});
|
|
66
74
|
|
|
67
|
-
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
68
|
-
let plot = $derived(getPlotState());
|
|
69
|
-
|
|
70
|
-
const LINE_ANCHOR = {
|
|
71
|
-
bottom: 'auto',
|
|
72
|
-
middle: 'central',
|
|
73
|
-
top: 'hanging'
|
|
74
|
-
} as const;
|
|
75
|
-
|
|
76
75
|
const args = $derived(
|
|
77
76
|
sort({
|
|
78
77
|
data,
|
|
79
78
|
...options
|
|
80
79
|
})
|
|
81
|
-
);
|
|
80
|
+
) as TextMarkProps;
|
|
82
81
|
</script>
|
|
83
82
|
|
|
84
83
|
<Mark
|
|
@@ -94,105 +93,15 @@
|
|
|
94
93
|
'strokeOpacity',
|
|
95
94
|
'fillOpacity'
|
|
96
95
|
]}
|
|
97
|
-
required={[
|
|
96
|
+
required={[]}
|
|
98
97
|
{...args}>
|
|
99
98
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
100
99
|
<GroupMultiple class="text {className}" length={className ? 2 : args.data.length}>
|
|
101
100
|
{#each scaledData as d, i (i)}
|
|
102
101
|
{#if d.valid}
|
|
103
|
-
{@const title = resolveProp(args.title, d.datum, '')}
|
|
104
|
-
{@const frameAnchor = resolveProp(args.frameAnchor, d.datum)}
|
|
105
|
-
{@const isLeft =
|
|
106
|
-
frameAnchor === 'left' ||
|
|
107
|
-
frameAnchor === 'top-left' ||
|
|
108
|
-
frameAnchor === 'bottom-left'}
|
|
109
|
-
{@const isRight =
|
|
110
|
-
frameAnchor === 'right' ||
|
|
111
|
-
frameAnchor === 'top-right' ||
|
|
112
|
-
frameAnchor === 'bottom-right'}
|
|
113
|
-
{@const isTop =
|
|
114
|
-
frameAnchor === 'top' ||
|
|
115
|
-
frameAnchor === 'top-left' ||
|
|
116
|
-
frameAnchor === 'top-right'}
|
|
117
|
-
{@const isBottom =
|
|
118
|
-
frameAnchor === 'bottom' ||
|
|
119
|
-
frameAnchor === 'bottom-left' ||
|
|
120
|
-
frameAnchor === 'bottom-right'}
|
|
121
|
-
{@const [x, y] =
|
|
122
|
-
args.x != null && args.y != null
|
|
123
|
-
? [d.x, d.y]
|
|
124
|
-
: [
|
|
125
|
-
args.x != null
|
|
126
|
-
? d.x
|
|
127
|
-
: isLeft
|
|
128
|
-
? plot.options.marginLeft
|
|
129
|
-
: isRight
|
|
130
|
-
? plot.options.marginLeft + plot.facetWidth
|
|
131
|
-
: plot.options.marginLeft + plot.facetWidth * 0.5,
|
|
132
|
-
args.y != null
|
|
133
|
-
? d.y
|
|
134
|
-
: isTop
|
|
135
|
-
? plot.options.marginTop
|
|
136
|
-
: isBottom
|
|
137
|
-
? plot.options.marginTop + plot.facetHeight
|
|
138
|
-
: plot.options.marginTop + plot.facetHeight * 0.5
|
|
139
|
-
]}
|
|
140
|
-
|
|
141
|
-
{@const dx = +resolveProp(args.dx, d.datum, 0)}
|
|
142
|
-
{@const dy = +resolveProp(args.dy, d.datum, 0)}
|
|
143
102
|
{@const textLines = String(resolveProp(args.text, d.datum, '')).split('\n')}
|
|
144
|
-
{@const lineAnchor = resolveProp(
|
|
145
|
-
args.lineAnchor,
|
|
146
|
-
d.datum,
|
|
147
|
-
args.y != null ? 'middle' : isTop ? 'top' : isBottom ? 'bottom' : 'middle'
|
|
148
|
-
)}
|
|
149
|
-
{@const textClassName = resolveProp(args.textClass, d.datum, null)}
|
|
150
|
-
|
|
151
|
-
{@const [style, styleClass] = resolveStyles(
|
|
152
|
-
plot,
|
|
153
|
-
{ ...d, __tspanIndex: 0 },
|
|
154
|
-
{
|
|
155
|
-
fontSize: 12,
|
|
156
|
-
fontWeight: 500,
|
|
157
|
-
strokeWidth: 1.6,
|
|
158
|
-
textAnchor: isLeft ? 'start' : isRight ? 'end' : 'middle',
|
|
159
|
-
...args
|
|
160
|
-
},
|
|
161
|
-
'fill',
|
|
162
|
-
usedScales
|
|
163
|
-
)}
|
|
164
103
|
|
|
165
|
-
{
|
|
166
|
-
<!-- multiline text-->
|
|
167
|
-
{@const fontSize = resolveProp(args.fontSize, d.datum) || 12}
|
|
168
|
-
<text
|
|
169
|
-
class={[textClassName]}
|
|
170
|
-
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
171
|
-
transform="translate({Math.round(x + dx)},{Math.round(
|
|
172
|
-
y +
|
|
173
|
-
dy -
|
|
174
|
-
(lineAnchor === 'bottom'
|
|
175
|
-
? textLines.length - 1
|
|
176
|
-
: lineAnchor === 'middle'
|
|
177
|
-
? (textLines.length - 1) * 0.5
|
|
178
|
-
: 0) *
|
|
179
|
-
fontSize
|
|
180
|
-
)})"
|
|
181
|
-
>{#each textLines as line, l (l)}<tspan
|
|
182
|
-
x="0"
|
|
183
|
-
dy={l ? fontSize : 0}
|
|
184
|
-
class={styleClass}
|
|
185
|
-
{style}>{line}</tspan
|
|
186
|
-
>{/each}{#if title}<title>{title}</title>{/if}</text>
|
|
187
|
-
{:else}
|
|
188
|
-
<!-- singleline text-->
|
|
189
|
-
<text
|
|
190
|
-
class={[textClassName, styleClass]}
|
|
191
|
-
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
192
|
-
transform="translate({Math.round(x + dx)},{Math.round(y + dy)})"
|
|
193
|
-
{style}
|
|
194
|
-
>{textLines[0]}{#if title}<title>{title}</title>{/if}</text>
|
|
195
|
-
{/if}
|
|
104
|
+
<MultilineText {textLines} {d} {args} {usedScales} />
|
|
196
105
|
{/if}
|
|
197
106
|
{/each}
|
|
198
107
|
</GroupMultiple>
|
|
@@ -13,6 +13,11 @@ export type TextMarkProps = BaseMarkProps & {
|
|
|
13
13
|
* the line anchor for vertical position; top, bottom, or middle
|
|
14
14
|
*/
|
|
15
15
|
lineAnchor?: ConstantAccessor<'bottom' | 'top' | 'middle'>;
|
|
16
|
+
/**
|
|
17
|
+
* line height as multiplier of font size
|
|
18
|
+
* @default 1.2
|
|
19
|
+
*/
|
|
20
|
+
lineHeight?: ConstantAccessor<number>;
|
|
16
21
|
frameAnchor?: ConstantAccessor<'bottom' | 'top' | 'left' | 'right' | 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right'>;
|
|
17
22
|
};
|
|
18
23
|
import { type Snippet } from 'svelte';
|
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
import { type MarkerShape } from './Marker.svelte';
|
|
2
|
-
import type { BaseMarkProps, ConstantAccessor, DataRecord, Mark, PlotScales } from '../../types.js';
|
|
3
|
-
type MarkerPathProps = BaseMarkProps & {
|
|
4
|
-
/**
|
|
5
|
-
* the datum associated with this path, usually the first
|
|
6
|
-
* element of the data array group
|
|
7
|
-
*/
|
|
8
|
-
datum: DataRecord;
|
|
9
|
-
/**
|
|
10
|
-
* the marker shape to use at the start of the path, defaults to
|
|
11
|
-
* circle
|
|
12
|
-
*/
|
|
13
|
-
markerStart?: boolean | MarkerShape;
|
|
14
|
-
/**
|
|
15
|
-
* the marker shape to use at the middle of the path, defaults to circle
|
|
16
|
-
*/
|
|
17
|
-
markerMid?: boolean | MarkerShape;
|
|
18
|
-
/**
|
|
19
|
-
* the marker shape to use at the end of the path, defaults to circle
|
|
20
|
-
*/
|
|
21
|
-
markerEnd?: boolean | MarkerShape;
|
|
22
|
-
/**
|
|
23
|
-
* shorthand for setting all markers
|
|
24
|
-
*/
|
|
25
|
-
marker?: boolean | MarkerShape;
|
|
26
|
-
/**
|
|
27
|
-
* path string
|
|
28
|
-
*/
|
|
29
|
-
d: string;
|
|
30
|
-
style: string;
|
|
31
|
-
startOffset: string;
|
|
32
|
-
textStyle: string;
|
|
33
|
-
textStyleClass?: string | null;
|
|
34
|
-
text: string;
|
|
35
|
-
transform: string;
|
|
36
|
-
color: string;
|
|
37
|
-
strokeWidth: ConstantAccessor<number>;
|
|
38
|
-
mark: Mark<BaseMarkProps>;
|
|
39
|
-
scales: PlotScales;
|
|
40
|
-
};
|
|
41
1
|
/** Helper component for paths with markers and optional text along the path. */
|
|
42
|
-
declare const MarkerPath: import("svelte").Component<
|
|
2
|
+
declare const MarkerPath: import("svelte").Component<any, {}, "">;
|
|
43
3
|
type MarkerPath = ReturnType<typeof MarkerPath>;
|
|
44
4
|
export default MarkerPath;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { resolveProp, resolveStyles } from '../../helpers/resolve';
|
|
3
|
+
import { getContext, type ComponentProps } from 'svelte';
|
|
4
|
+
import type { PlotContext, ScaledDataRecord, UsedScales } from '../../types';
|
|
5
|
+
import type Text from '../Text.svelte';
|
|
6
|
+
import { CSS_VAR } from '../../constants';
|
|
7
|
+
import { maybeFromPixel, maybeFromRem } from '../../helpers/getBaseStyles';
|
|
8
|
+
|
|
9
|
+
const LINE_ANCHOR = {
|
|
10
|
+
bottom: 'auto',
|
|
11
|
+
middle: 'central',
|
|
12
|
+
top: 'hanging'
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
16
|
+
const plot = $derived(getPlotState());
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
textLines,
|
|
20
|
+
d,
|
|
21
|
+
args,
|
|
22
|
+
usedScales
|
|
23
|
+
}: {
|
|
24
|
+
textLines: string[];
|
|
25
|
+
d: ScaledDataRecord;
|
|
26
|
+
args: ComponentProps<typeof Text>;
|
|
27
|
+
usedScales: UsedScales;
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
const title = $derived(resolveProp(args.title, d.datum, ''));
|
|
31
|
+
const frameAnchor = $derived(resolveProp(args.frameAnchor, d.datum));
|
|
32
|
+
const isLeft = $derived(
|
|
33
|
+
frameAnchor === 'left' || frameAnchor === 'top-left' || frameAnchor === 'bottom-left'
|
|
34
|
+
);
|
|
35
|
+
const isRight = $derived(
|
|
36
|
+
frameAnchor === 'right' || frameAnchor === 'top-right' || frameAnchor === 'bottom-right'
|
|
37
|
+
);
|
|
38
|
+
const isTop = $derived(
|
|
39
|
+
frameAnchor === 'top' || frameAnchor === 'top-left' || frameAnchor === 'top-right'
|
|
40
|
+
);
|
|
41
|
+
const isBottom = $derived(
|
|
42
|
+
frameAnchor === 'bottom' || frameAnchor === 'bottom-left' || frameAnchor === 'bottom-right'
|
|
43
|
+
);
|
|
44
|
+
const lineAnchor = $derived(
|
|
45
|
+
resolveProp(
|
|
46
|
+
args.lineAnchor,
|
|
47
|
+
d.datum,
|
|
48
|
+
args.y != null ? 'middle' : isTop ? 'top' : isBottom ? 'bottom' : 'middle'
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
const textClassName = $derived(resolveProp(args.textClass, d.datum, null));
|
|
52
|
+
const [x, y] = $derived(
|
|
53
|
+
args.x != null && args.y != null
|
|
54
|
+
? [d.x, d.y]
|
|
55
|
+
: [
|
|
56
|
+
args.x != null
|
|
57
|
+
? d.x
|
|
58
|
+
: isLeft
|
|
59
|
+
? plot.options.marginLeft
|
|
60
|
+
: isRight
|
|
61
|
+
? plot.options.marginLeft + plot.facetWidth
|
|
62
|
+
: plot.options.marginLeft + plot.facetWidth * 0.5,
|
|
63
|
+
args.y != null
|
|
64
|
+
? d.y
|
|
65
|
+
: isTop
|
|
66
|
+
? plot.options.marginTop
|
|
67
|
+
: isBottom
|
|
68
|
+
? plot.options.marginTop + plot.facetHeight
|
|
69
|
+
: plot.options.marginTop + plot.facetHeight * 0.5
|
|
70
|
+
]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const dx = $derived(+resolveProp(args.dx, d.datum, 0));
|
|
74
|
+
const dy = $derived(+resolveProp(args.dy, d.datum, 0));
|
|
75
|
+
|
|
76
|
+
const [style, styleClass] = $derived(
|
|
77
|
+
resolveStyles(
|
|
78
|
+
plot,
|
|
79
|
+
{ ...d, __tspanIndex: 0 },
|
|
80
|
+
{
|
|
81
|
+
fontSize: 12,
|
|
82
|
+
fontWeight: 500,
|
|
83
|
+
strokeWidth: 1.6,
|
|
84
|
+
textAnchor: isLeft ? 'start' : isRight ? 'end' : 'middle',
|
|
85
|
+
...args
|
|
86
|
+
},
|
|
87
|
+
'fill',
|
|
88
|
+
usedScales
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const fontSize = $derived(
|
|
93
|
+
textLines.length > 1 ? (resolveProp(args.fontSize, d.datum) ?? 12) : 0
|
|
94
|
+
);
|
|
95
|
+
let textElement: SVGTextElement | null = $state(null);
|
|
96
|
+
|
|
97
|
+
const rootFontSize = $derived(
|
|
98
|
+
textElement?.ownerDocument?.documentElement && textLines.length > 1
|
|
99
|
+
? maybeFromPixel(getComputedStyle(textElement.ownerDocument.documentElement).fontSize)
|
|
100
|
+
: 14
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const computedFontSize = $derived(
|
|
104
|
+
textElement && textLines.length > 1 && CSS_VAR.test(fontSize)
|
|
105
|
+
? maybeFromRem(
|
|
106
|
+
maybeFromPixel(
|
|
107
|
+
getComputedStyle(textElement).getPropertyValue(
|
|
108
|
+
`--${fontSize.match(CSS_VAR)[1]}`
|
|
109
|
+
)
|
|
110
|
+
),
|
|
111
|
+
rootFontSize
|
|
112
|
+
)
|
|
113
|
+
: fontSize
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const lineHeight = $derived(
|
|
117
|
+
textLines.length > 1 ? (resolveProp(args.lineHeight, d.datum) ?? 1.2) : 0
|
|
118
|
+
);
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
{#if textLines.length > 1}
|
|
122
|
+
<!-- multiline text-->
|
|
123
|
+
<text
|
|
124
|
+
bind:this={textElement}
|
|
125
|
+
class={[textClassName]}
|
|
126
|
+
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
127
|
+
transform="translate({Math.round(x + dx)},{Math.round(
|
|
128
|
+
y +
|
|
129
|
+
dy -
|
|
130
|
+
(lineAnchor === 'bottom'
|
|
131
|
+
? textLines.length - 1
|
|
132
|
+
: lineAnchor === 'middle'
|
|
133
|
+
? (textLines.length - 1) * 0.5
|
|
134
|
+
: 0) *
|
|
135
|
+
computedFontSize *
|
|
136
|
+
lineHeight
|
|
137
|
+
)})"
|
|
138
|
+
>{#each textLines as line, l (l)}<tspan
|
|
139
|
+
x="0"
|
|
140
|
+
dy={l ? computedFontSize * lineHeight : 0}
|
|
141
|
+
class={styleClass}
|
|
142
|
+
{style}>{line}</tspan
|
|
143
|
+
>{/each}{#if title}<title>{title}</title>{/if}</text>
|
|
144
|
+
{:else}
|
|
145
|
+
<!-- singleline text-->
|
|
146
|
+
<text
|
|
147
|
+
class={[textClassName, styleClass]}
|
|
148
|
+
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
149
|
+
transform="translate({Math.round(x + dx)},{Math.round(y + dy)})"
|
|
150
|
+
{style}
|
|
151
|
+
>{textLines[0]}{#if title}<title>{title}</title>{/if}</text>
|
|
152
|
+
{/if}
|
|
153
|
+
|
|
154
|
+
<style>
|
|
155
|
+
text {
|
|
156
|
+
paint-order: stroke fill;
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ComponentProps } from 'svelte';
|
|
2
|
+
import type { ScaledDataRecord, UsedScales } from '../../types';
|
|
3
|
+
import type Text from '../Text.svelte';
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
textLines: string[];
|
|
6
|
+
d: ScaledDataRecord;
|
|
7
|
+
args: ComponentProps<typeof Text>;
|
|
8
|
+
usedScales: UsedScales;
|
|
9
|
+
};
|
|
10
|
+
declare const MultilineText: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type MultilineText = ReturnType<typeof MultilineText>;
|
|
12
|
+
export default MultilineText;
|
|
@@ -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.js").ConstantAccessor<boolean>;
|
|
16
|
-
facet?: "auto" | "include" | "exclude" | undefined;
|
|
17
|
-
fx?: import("../types.js").ChannelAccessor;
|
|
18
|
-
fy?: import("../types.js").ChannelAccessor;
|
|
19
|
-
dx?: import("../types.js").ConstantAccessor<number>;
|
|
20
|
-
dy?: import("../types.js").ConstantAccessor<number>;
|
|
21
|
-
fill?: import("../types.js").ConstantAccessor<string>;
|
|
22
|
-
fillOpacity?: import("../types.js").ConstantAccessor<number>;
|
|
23
|
-
sort?: string | import("../types.js").ConstantAccessor<import("../types.js").RawValue> | ((a: import("../types.js").RawValue, b: import("../types.js").RawValue) => number) | {
|
|
24
|
-
channel: string;
|
|
25
|
-
order?: "ascending" | "descending";
|
|
26
|
-
};
|
|
27
|
-
stroke?: import("../types.js").ConstantAccessor<string>;
|
|
28
|
-
strokeWidth?: import("../types.js").ConstantAccessor<number>;
|
|
29
|
-
strokeOpacity?: import("../types.js").ConstantAccessor<number>;
|
|
30
|
-
strokeLinejoin?: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin>;
|
|
31
|
-
strokeLinecap?: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinecap>;
|
|
32
|
-
strokeMiterlimit?: import("../types.js").ConstantAccessor<number>;
|
|
33
|
-
opacity?: import("../types.js").ConstantAccessor<number>;
|
|
34
|
-
strokeDasharray?: import("../types.js").ConstantAccessor<string>;
|
|
35
|
-
strokeDashoffset?: import("../types.js").ConstantAccessor<number>;
|
|
36
|
-
mixBlendMode?: import("../types.js").ConstantAccessor<import("csstype").Property.MixBlendMode>;
|
|
37
|
-
clipPath?: string | undefined;
|
|
38
|
-
imageFilter?: import("../types.js").ConstantAccessor<string>;
|
|
39
|
-
shapeRendering?: import("../types.js").ConstantAccessor<import("csstype").Property.ShapeRendering>;
|
|
40
|
-
paintOrder?: import("../types.js").ConstantAccessor<string>;
|
|
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.js").ConstantAccessor<import("csstype").Property.Cursor>;
|
|
73
|
-
data: {
|
|
74
|
-
__x: import("../types.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;
|
|
@@ -1,67 +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
|
-
filter?: import("../types.js").ConstantAccessor<boolean>;
|
|
6
|
-
facet?: "auto" | "include" | "exclude" | undefined;
|
|
7
|
-
fx?: import("../types.js").ChannelAccessor;
|
|
8
|
-
fy?: import("../types.js").ChannelAccessor;
|
|
9
|
-
dx?: import("../types.js").ConstantAccessor<number>;
|
|
10
|
-
dy?: import("../types.js").ConstantAccessor<number>;
|
|
11
|
-
fill?: import("../types.js").ConstantAccessor<string>;
|
|
12
|
-
fillOpacity?: import("../types.js").ConstantAccessor<number>;
|
|
13
|
-
sort?: string | import("../types.js").ConstantAccessor<import("../types.js").RawValue> | ((a: import("../types.js").RawValue, b: import("../types.js").RawValue) => number) | {
|
|
14
|
-
channel: string;
|
|
15
|
-
order?: "ascending" | "descending";
|
|
16
|
-
};
|
|
17
|
-
stroke?: import("../types.js").ConstantAccessor<string>;
|
|
18
|
-
strokeWidth?: import("../types.js").ConstantAccessor<number>;
|
|
19
|
-
strokeOpacity?: import("../types.js").ConstantAccessor<number>;
|
|
20
|
-
strokeLinejoin?: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin>;
|
|
21
|
-
strokeLinecap?: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinecap>;
|
|
22
|
-
strokeMiterlimit?: import("../types.js").ConstantAccessor<number>;
|
|
23
|
-
opacity?: import("../types.js").ConstantAccessor<number>;
|
|
24
|
-
strokeDasharray?: import("../types.js").ConstantAccessor<string>;
|
|
25
|
-
strokeDashoffset?: import("../types.js").ConstantAccessor<number>;
|
|
26
|
-
mixBlendMode?: import("../types.js").ConstantAccessor<import("csstype").Property.MixBlendMode>;
|
|
27
|
-
clipPath?: string | undefined;
|
|
28
|
-
imageFilter?: import("../types.js").ConstantAccessor<string>;
|
|
29
|
-
shapeRendering?: import("../types.js").ConstantAccessor<import("csstype").Property.ShapeRendering>;
|
|
30
|
-
paintOrder?: import("../types.js").ConstantAccessor<string>;
|
|
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.js").ConstantAccessor<import("csstype").Property.Cursor>;
|
|
63
|
-
data: {
|
|
64
|
-
__centroid__: [number, number];
|
|
65
|
-
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
66
|
-
}[];
|
|
67
|
-
};
|
|
2
|
+
export declare function geoCentroid({ data, ...options }: TransformArg<DataRecord>): any;
|