svelteplot 0.3.7-pr-131.0 → 0.3.7-pr-132.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Mark.svelte +1 -1
- package/dist/Mark.svelte.d.ts +1 -1
- package/dist/marks/Area.svelte +6 -0
- package/dist/marks/CustomMark.svelte +27 -46
- package/dist/types/channel.d.ts +0 -1
- package/dist/types/data.d.ts +2 -4
- package/dist/types/mark.d.ts +1 -1
- package/package.json +1 -1
package/dist/Mark.svelte
CHANGED
package/dist/Mark.svelte.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
71
71
|
children?: Snippet<[{
|
|
72
72
|
mark: any;
|
|
73
73
|
usedScales: ReturnType<typeof getUsedScales>;
|
|
74
|
-
scaledData: ScaledDataRecord
|
|
74
|
+
scaledData: ScaledDataRecord[];
|
|
75
75
|
}]> | undefined;
|
|
76
76
|
defaults?: Partial<Record<ScaledChannelName, RawValue>>;
|
|
77
77
|
};
|
package/dist/marks/Area.svelte
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
RawValue
|
|
42
42
|
} from '../types/index.js';
|
|
43
43
|
import type { StackOptions } from '../transforms/stack.js';
|
|
44
|
+
import { addEventHandlers } from './helpers/events';
|
|
44
45
|
|
|
45
46
|
let markProps: AreaMarkProps = $props();
|
|
46
47
|
|
|
@@ -135,6 +136,11 @@
|
|
|
135
136
|
class={['svelteplot-area', className, styleClass]}
|
|
136
137
|
clip-path={options.clipPath}
|
|
137
138
|
d={areaPath(areaData)}
|
|
139
|
+
use:addEventHandlers={{
|
|
140
|
+
getPlotState,
|
|
141
|
+
options,
|
|
142
|
+
datum: datum.datum
|
|
143
|
+
}}
|
|
138
144
|
{style}
|
|
139
145
|
>{#if title}<title>{title}</title>{/if}</path>
|
|
140
146
|
</Anchor>
|
|
@@ -4,18 +4,10 @@
|
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts" generics="Datum extends DataRecord">
|
|
6
6
|
interface CustomMarkProps extends BaseMarkProps<Datum> {
|
|
7
|
-
data
|
|
7
|
+
data: Datum[];
|
|
8
8
|
x?: ChannelAccessor<Datum>;
|
|
9
|
-
x1?: ChannelAccessor<Datum>;
|
|
10
|
-
x2?: ChannelAccessor<Datum>;
|
|
11
9
|
y?: ChannelAccessor<Datum>;
|
|
12
|
-
|
|
13
|
-
y2?: ChannelAccessor<Datum>;
|
|
14
|
-
r?: ChannelAccessor<Datum>;
|
|
15
|
-
mark?: Snippet<
|
|
16
|
-
[{ record: ScaledDataRecord<Datum>; index: number; usedScales: UsedScales }]
|
|
17
|
-
>;
|
|
18
|
-
marks?: Snippet<[{ records: ScaledDataRecord<Datum>[]; usedScales: UsedScales }]>;
|
|
10
|
+
children: Snippet<[{ datum: Datum; x: number; y: number }]>;
|
|
19
11
|
}
|
|
20
12
|
|
|
21
13
|
import { getContext } from 'svelte';
|
|
@@ -23,47 +15,36 @@
|
|
|
23
15
|
PlotContext,
|
|
24
16
|
DataRecord,
|
|
25
17
|
ChannelAccessor,
|
|
26
|
-
BaseMarkProps
|
|
27
|
-
ScaledDataRecord,
|
|
28
|
-
UsedScales,
|
|
29
|
-
ScaledChannelName
|
|
18
|
+
BaseMarkProps
|
|
30
19
|
} from '../types/index.js';
|
|
31
20
|
import type { Snippet } from 'svelte';
|
|
32
|
-
import { sort } from '../index.js';
|
|
33
21
|
|
|
34
|
-
|
|
22
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
23
|
+
let plot = $derived(getPlotState());
|
|
35
24
|
|
|
36
|
-
|
|
25
|
+
import { resolveChannel } from '../helpers/resolve.js';
|
|
26
|
+
import { projectXY } from '../helpers/scales.js';
|
|
27
|
+
import { isValid } from '../helpers/index.js';
|
|
28
|
+
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'y1',
|
|
46
|
-
'y2',
|
|
47
|
-
'r',
|
|
48
|
-
'fill',
|
|
49
|
-
'stroke',
|
|
50
|
-
'opacity',
|
|
51
|
-
'fillOpacity',
|
|
52
|
-
'strokeOpacity'
|
|
53
|
-
];
|
|
30
|
+
let {
|
|
31
|
+
data = [{} as Datum],
|
|
32
|
+
x,
|
|
33
|
+
y,
|
|
34
|
+
children,
|
|
35
|
+
class: className = null
|
|
36
|
+
}: CustomMarkProps = $props();
|
|
54
37
|
</script>
|
|
55
38
|
|
|
56
|
-
<
|
|
57
|
-
{#
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
{/if}
|
|
66
|
-
{/each}
|
|
39
|
+
<GroupMultiple class="g-custom-mark {className || ''}" length={className ? 2 : data.length}>
|
|
40
|
+
{#each data as datum, i (i)}
|
|
41
|
+
{@const x_ = resolveChannel<Datum>('x', datum, { x, y })}
|
|
42
|
+
{@const y_ = resolveChannel<Datum>('y', datum, { x, y })}
|
|
43
|
+
{#if isValid(x_) && isValid(y_)}
|
|
44
|
+
{@const [px, py] = projectXY(plot.scales, x_, y_)}
|
|
45
|
+
<g transform="translate({px}, {py})">
|
|
46
|
+
{@render children({ datum, x: px, y: py })}
|
|
47
|
+
</g>
|
|
67
48
|
{/if}
|
|
68
|
-
{/
|
|
69
|
-
</
|
|
49
|
+
{/each}
|
|
50
|
+
</GroupMultiple>
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -8,5 +8,4 @@ export type ChannelAccessor<T = Record<string | symbol, RawValue>> = ChannelValu
|
|
|
8
8
|
};
|
|
9
9
|
export type ChannelValue<T = Record<string | symbol, RawValue>> = RawValue | keyof T | ((d: T) => RawValue) | null | undefined;
|
|
10
10
|
export type ScaledChannelName = 'fill' | 'fillOpacity' | 'opacity' | 'r' | 'length' | 'stroke' | 'strokeOpacity' | 'symbol' | 'fx' | 'fy' | 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
|
|
11
|
-
export type ScaledChannelType<T extends ScaledChannelName> = T extends 'fill' | 'stroke' | 'symbol' ? string : number;
|
|
12
11
|
export type ChannelName = ScaledChannelName | 'z' | 'sort' | 'filter' | 'interval';
|
package/dist/types/data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScaledChannelName
|
|
1
|
+
import type { ScaledChannelName } from './channel.js';
|
|
2
2
|
export type RawValue = number | Date | boolean | string | symbol;
|
|
3
3
|
export type DataRecord<T = Record<string | symbol, RawValue>> = T & {
|
|
4
4
|
___orig___?: RawValue | [RawValue, RawValue];
|
|
@@ -6,9 +6,7 @@ export type DataRecord<T = Record<string | symbol, RawValue>> = T & {
|
|
|
6
6
|
export type ResolvedDataRecord<T = Record<string | symbol, RawValue>> = Partial<Record<ScaledChannelName, any>> & {
|
|
7
7
|
datum: DataRecord<T>;
|
|
8
8
|
};
|
|
9
|
-
export type ScaledDataRecord<T = Record<string | symbol, RawValue>> = Partial<{
|
|
10
|
-
[K in ScaledChannelName]?: ScaledChannelType<K>;
|
|
11
|
-
}> & {
|
|
9
|
+
export type ScaledDataRecord<T = Record<string | symbol, RawValue>> = Partial<Record<ScaledChannelName, number | string | boolean | undefined>> & {
|
|
12
10
|
datum: DataRecord<T>;
|
|
13
11
|
valid: Boolean;
|
|
14
12
|
};
|
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' | '
|
|
9
|
+
export type MarkType = 'area' | 'arrow' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
|
|
10
10
|
export type MarkStyleProps = 'strokeDasharray' | 'strokeLinejoin' | 'strokeLinecap' | 'opacity' | 'cursor' | 'pointerEvents' | 'blend' | 'fill' | 'fillOpacity' | 'fontWeight' | 'fontVariant' | 'fontSize' | 'fontStyle' | 'stroke' | 'strokeWidth' | 'strokeOpacity' | 'x' | 'y' | 'clipPath' | 'mask' | 'filter' | 'angle' | 'radius' | 'symbol' | 'textAnchor' | 'width';
|
|
11
11
|
import type { MouseEventHandler } from 'svelte/elements';
|
|
12
12
|
import type { ChannelAccessor, ConstantAccessor, DataRecord, RawValue } from './index.js';
|