svelteplot 0.10.3-pr-472.0 → 0.10.3-pr-474.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/BollingerX.svelte +1 -7
- package/dist/marks/CustomMark.svelte +3 -4
- package/dist/marks/CustomMark.svelte.d.ts +0 -2
- package/dist/marks/Image.svelte +36 -21
- package/dist/marks/helpers/Anchor.svelte +15 -0
- package/dist/marks/helpers/Anchor.svelte.d.ts +15 -0
- package/dist/types/mark.d.ts +2 -2
- package/package.json +1 -1
|
@@ -29,13 +29,7 @@
|
|
|
29
29
|
k?: number;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
let {
|
|
33
|
-
data,
|
|
34
|
-
class: className = '',
|
|
35
|
-
n = 20,
|
|
36
|
-
k = 2,
|
|
37
|
-
...options
|
|
38
|
-
}: BollingerXMarkProps = $props();
|
|
32
|
+
let { data, class: className = '', n = 20, k = 2, ...options }: BollingerXMarkProps = $props();
|
|
39
33
|
|
|
40
34
|
let args = $derived(
|
|
41
35
|
bollingerX(recordizeX({ data, ...options } as TransformArg<DataRecord>), { n, k })
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
interface CustomMarkProps extends BaseMarkProps<Datum> {
|
|
7
7
|
/** the input data array */
|
|
8
8
|
data?: Datum[];
|
|
9
|
-
/** a custom mark type identifier for debugging */
|
|
10
|
-
type?: string;
|
|
11
9
|
/** the horizontal position channel; bound to the x scale */
|
|
12
10
|
x?: ChannelAccessor<Datum>;
|
|
13
11
|
/** the starting horizontal position; bound to the x scale */
|
|
@@ -37,7 +35,8 @@
|
|
|
37
35
|
BaseMarkProps,
|
|
38
36
|
ScaledDataRecord,
|
|
39
37
|
UsedScales,
|
|
40
|
-
ScaledChannelName
|
|
38
|
+
ScaledChannelName,
|
|
39
|
+
MarkType
|
|
41
40
|
} from '../types/index.js';
|
|
42
41
|
import type { Snippet } from 'svelte';
|
|
43
42
|
import { sort } from '../index.js';
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
];
|
|
71
70
|
</script>
|
|
72
71
|
|
|
73
|
-
<Mark
|
|
72
|
+
<Mark type="custom" required={[]} channels={channels.filter((d) => !!options[d])} {...args}>
|
|
74
73
|
{#snippet children({ scaledData, usedScales })}
|
|
75
74
|
{#if marks}
|
|
76
75
|
{@render marks({ records: scaledData.filter((d) => d.valid), usedScales })}
|
|
@@ -138,8 +138,6 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
138
138
|
}> & {
|
|
139
139
|
/** the input data array */
|
|
140
140
|
data?: Datum[];
|
|
141
|
-
/** a custom mark type identifier for debugging */
|
|
142
|
-
type?: string;
|
|
143
141
|
/** the horizontal position channel; bound to the x scale */
|
|
144
142
|
x?: ChannelAccessor<Datum>;
|
|
145
143
|
/** the starting horizontal position; bound to the x scale */
|
package/dist/marks/Image.svelte
CHANGED
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
ChannelAccessor,
|
|
33
33
|
ConstantAccessor,
|
|
34
34
|
DataRecord,
|
|
35
|
-
LinkableMarkProps
|
|
35
|
+
LinkableMarkProps,
|
|
36
|
+
TransformArg
|
|
36
37
|
} from '../types';
|
|
37
38
|
import { resolveProp } from '../helpers/resolve';
|
|
38
|
-
import CustomMark from './CustomMark.svelte';
|
|
39
39
|
import { getPlotDefaults } from '../hooks/plotDefaults';
|
|
40
40
|
import { sort } from '../transforms';
|
|
41
41
|
import Anchor from './helpers/Anchor.svelte';
|
|
42
|
+
import Mark from '../Mark.svelte';
|
|
42
43
|
|
|
43
44
|
let markProps: ImageMarkProps = $props();
|
|
44
45
|
|
|
@@ -62,25 +63,39 @@
|
|
|
62
63
|
...markProps
|
|
63
64
|
});
|
|
64
65
|
|
|
65
|
-
const args = $derived(sort({ data, ...options }));
|
|
66
|
+
const args = $derived(sort({ data, ...options } as TransformArg<Datum>) as ImageMarkProps);
|
|
66
67
|
</script>
|
|
67
68
|
|
|
68
|
-
<
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
<Mark
|
|
70
|
+
required={['x', 'y']}
|
|
71
|
+
channels={['x', 'y', 'r', 'fill', 'opacity', 'stroke', 'fillOpacity', 'strokeOpacity']}
|
|
72
|
+
{...args}
|
|
73
|
+
type="image">
|
|
74
|
+
{#snippet children({ scaledData })}
|
|
75
|
+
{#each scaledData as record, i (i)}
|
|
76
|
+
{#if record.valid}
|
|
77
|
+
{@const w =
|
|
78
|
+
record.r !== undefined
|
|
79
|
+
? record.r * 2
|
|
80
|
+
: Number(resolveProp(width, record.datum, 20) ?? 20)}
|
|
81
|
+
{@const h =
|
|
82
|
+
record.r !== undefined
|
|
83
|
+
? record.r * 2
|
|
84
|
+
: Number(resolveProp(height || width, record.datum, 20) ?? 20)}
|
|
85
|
+
<Anchor {options} datum={record.datum}>
|
|
86
|
+
<image
|
|
87
|
+
class={resolveProp(imageClass, record.datum, null)}
|
|
88
|
+
href={resolveProp(src, record.datum, '')}
|
|
89
|
+
x={record.x! - w * 0.5}
|
|
90
|
+
y={record.y! - h * 0.5}
|
|
91
|
+
{preserveAspectRatio}
|
|
92
|
+
clip-path={record.r !== undefined ? `circle(${record.r}px)` : null}
|
|
93
|
+
width={w}
|
|
94
|
+
height={h}
|
|
95
|
+
>{#if title}<title>{resolveProp(title, record.datum, '')}</title
|
|
96
|
+
>{/if}</image>
|
|
97
|
+
</Anchor>
|
|
98
|
+
{/if}
|
|
99
|
+
{/each}
|
|
85
100
|
{/snippet}
|
|
86
|
-
</
|
|
101
|
+
</Mark>
|
|
@@ -5,10 +5,25 @@
|
|
|
5
5
|
interface AnchorProps {
|
|
6
6
|
datum?: Datum;
|
|
7
7
|
options?: {
|
|
8
|
+
/**
|
|
9
|
+
* The URL or URL fragment the hyperlink points to.
|
|
10
|
+
*/
|
|
8
11
|
href?: ConstantAccessor<string, Datum>;
|
|
12
|
+
/**
|
|
13
|
+
* Where to display the linked URL, e.g. _self, _blank
|
|
14
|
+
*/
|
|
9
15
|
target?: ConstantAccessor<string, Datum>;
|
|
16
|
+
/**
|
|
17
|
+
* The relationship of the target object to the link object.
|
|
18
|
+
*/
|
|
10
19
|
rel?: ConstantAccessor<string, Datum>;
|
|
20
|
+
/**
|
|
21
|
+
* A MIME type for the linked URL.
|
|
22
|
+
*/
|
|
11
23
|
type?: ConstantAccessor<string, Datum>;
|
|
24
|
+
/**
|
|
25
|
+
* Instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file.
|
|
26
|
+
*/
|
|
12
27
|
download?: ConstantAccessor<string, Datum>;
|
|
13
28
|
[key: string]: any;
|
|
14
29
|
};
|
|
@@ -3,10 +3,25 @@ declare function $$render<Datum extends Record<string, any>>(): {
|
|
|
3
3
|
props: {
|
|
4
4
|
datum?: Datum;
|
|
5
5
|
options?: {
|
|
6
|
+
/**
|
|
7
|
+
* The URL or URL fragment the hyperlink points to.
|
|
8
|
+
*/
|
|
6
9
|
href?: ConstantAccessor<string, Datum>;
|
|
10
|
+
/**
|
|
11
|
+
* Where to display the linked URL, e.g. _self, _blank
|
|
12
|
+
*/
|
|
7
13
|
target?: ConstantAccessor<string, Datum>;
|
|
14
|
+
/**
|
|
15
|
+
* The relationship of the target object to the link object.
|
|
16
|
+
*/
|
|
8
17
|
rel?: ConstantAccessor<string, Datum>;
|
|
18
|
+
/**
|
|
19
|
+
* A MIME type for the linked URL.
|
|
20
|
+
*/
|
|
9
21
|
type?: ConstantAccessor<string, Datum>;
|
|
22
|
+
/**
|
|
23
|
+
* Instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file.
|
|
24
|
+
*/
|
|
10
25
|
download?: ConstantAccessor<string, Datum>;
|
|
11
26
|
[key: string]: any;
|
|
12
27
|
};
|
package/dist/types/mark.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type Mark<T> = {
|
|
|
6
6
|
data: DataRecord<T>[];
|
|
7
7
|
options: T;
|
|
8
8
|
};
|
|
9
|
-
export type MarkType = 'area' | 'arrow' | 'barX' | 'barY' | 'cell' | 'custom' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY' | 'trail' | 'waffleX' | 'waffleY';
|
|
9
|
+
export type MarkType = 'area' | 'arrow' | 'barX' | 'barY' | 'cell' | 'custom' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'image' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY' | 'trail' | 'waffleX' | 'waffleY';
|
|
10
10
|
export type MarkStyleProps = 'strokeDasharray' | 'strokeLinejoin' | 'strokeLinecap' | 'opacity' | 'cursor' | 'pointerEvents' | 'blend' | 'fill' | 'fillOpacity' | 'fontFamily' | 'fontWeight' | 'fontVariant' | 'fontSize' | 'fontStyle' | 'letterSpacing' | 'wordSpacing' | 'stroke' | 'strokeWidth' | 'strokeOpacity' | 'x' | 'y' | 'clipPath' | 'mask' | 'filter' | 'angle' | 'radius' | 'symbol' | 'textAnchor' | 'textTransform' | 'textDecoration' | 'width';
|
|
11
11
|
import type { ChannelAccessor, ConstantAccessor, DataRecord, RawValue } from './index.js';
|
|
12
12
|
import type * as CSS from 'csstype';
|
|
@@ -193,7 +193,7 @@ export type LinkableMarkProps<T> = {
|
|
|
193
193
|
* if set to true, the link will be downloaded instead of navigating to it
|
|
194
194
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download
|
|
195
195
|
*/
|
|
196
|
-
download?: ConstantAccessor<
|
|
196
|
+
download?: ConstantAccessor<string, T>;
|
|
197
197
|
[key: `data-sveltekit-${string}`]: unknown;
|
|
198
198
|
};
|
|
199
199
|
export type BorderRadius = number | {
|