svelteplot 0.1.3-next.9 → 0.2.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 +4 -2
- package/dist/Mark.svelte +6 -1
- package/dist/Plot.svelte +45 -29
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/resolve.js +1 -1
- package/dist/helpers/scales.js +3 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/marks/BarX.svelte +15 -5
- package/dist/marks/BarY.svelte +20 -12
- package/dist/marks/BarY.svelte.d.ts +22 -1
- package/dist/marks/Brush.svelte +364 -0
- package/dist/marks/Brush.svelte.d.ts +32 -0
- package/dist/marks/BrushX.svelte +7 -0
- package/dist/marks/BrushX.svelte.d.ts +4 -0
- package/dist/marks/BrushY.svelte +7 -0
- package/dist/marks/BrushY.svelte.d.ts +4 -0
- package/dist/marks/Cell.svelte +0 -7
- package/dist/marks/Dot.svelte +9 -18
- package/dist/marks/Dot.svelte.d.ts +8 -8
- package/dist/marks/Frame.svelte +10 -5
- package/dist/marks/Frame.svelte.d.ts +6 -1
- package/dist/marks/GridX.svelte +15 -6
- package/dist/marks/GridY.svelte +15 -6
- package/dist/marks/Pointer.svelte +2 -2
- package/dist/marks/Pointer.svelte.d.ts +2 -2
- package/dist/marks/Rect.svelte +12 -19
- package/dist/marks/Sphere.svelte.d.ts +14 -4
- package/dist/marks/Text.svelte +2 -2
- package/dist/marks/Text.svelte.d.ts +2 -2
- package/dist/marks/helpers/events.d.ts +13 -0
- package/dist/marks/helpers/events.js +32 -3
- package/dist/transforms/bin.d.ts +7 -7
- package/dist/transforms/recordize.d.ts +1 -0
- package/dist/transforms/recordize.js +4 -5
- package/dist/transforms/window.d.ts +2 -0
- package/dist/types.d.ts +29 -9
- package/package.json +9 -7
package/dist/marks/Rect.svelte
CHANGED
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import Mark from '../Mark.svelte';
|
|
7
7
|
import { getContext } from 'svelte';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
resolveProp,
|
|
12
|
-
resolveScaledStyles,
|
|
13
|
-
resolveStyles
|
|
14
|
-
} from '../helpers/resolve.js';
|
|
15
|
-
import { getUsedScales, projectX, projectY } from '../helpers/scales.js';
|
|
16
|
-
import { coalesce, testFilter, maybeNumber } from '../helpers/index.js';
|
|
8
|
+
import { intervalX, intervalY } from '../index.js';
|
|
9
|
+
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
10
|
+
import { coalesce, maybeNumber } from '../helpers/index.js';
|
|
17
11
|
import type {
|
|
18
12
|
PlotContext,
|
|
19
13
|
DataRecord,
|
|
@@ -21,7 +15,6 @@
|
|
|
21
15
|
BaseRectMarkProps,
|
|
22
16
|
ChannelAccessor
|
|
23
17
|
} from '../types.js';
|
|
24
|
-
import { isValid } from '../helpers/isValid.js';
|
|
25
18
|
import { addEventHandlers } from './helpers/events.js';
|
|
26
19
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
27
20
|
|
|
@@ -36,7 +29,7 @@
|
|
|
36
29
|
interval?: number | string;
|
|
37
30
|
} & BaseRectMarkProps;
|
|
38
31
|
|
|
39
|
-
let { data = [{}], class: className =
|
|
32
|
+
let { data = [{}], class: className = 'rect', ...options }: RectMarkProps = $props();
|
|
40
33
|
|
|
41
34
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
42
35
|
let plot = $derived(getPlotState());
|
|
@@ -51,8 +44,8 @@
|
|
|
51
44
|
required={[]}
|
|
52
45
|
channels={['x1', 'x2', 'y1', 'y2', 'fill', 'stroke', 'opacity', 'fillOpacity', 'strokeOpacity']}
|
|
53
46
|
{...args}>
|
|
54
|
-
{#snippet children({
|
|
55
|
-
<
|
|
47
|
+
{#snippet children({ usedScales, scaledData })}
|
|
48
|
+
<GroupMultiple class={scaledData.length > 1 ? className : null} length={scaledData.length}>
|
|
56
49
|
{#each scaledData as d}
|
|
57
50
|
{#if d.valid}
|
|
58
51
|
{@const x1 = d.x1 == null ? plot.options.marginLeft : d.x1}
|
|
@@ -69,14 +62,14 @@
|
|
|
69
62
|
{@const insetRight = resolveProp(args.insetRight, d.datum)}
|
|
70
63
|
{@const insetTop = resolveProp(args.insetTop, d.datum)}
|
|
71
64
|
{@const insetBottom = resolveProp(args.insetBottom, d.datum)}
|
|
72
|
-
{@const insetL = maybeNumber(coalesce(insetLeft, inset, 0))}
|
|
73
|
-
{@const insetT = maybeNumber(coalesce(insetTop, inset, 0))}
|
|
74
|
-
{@const insetR = maybeNumber(coalesce(insetRight, inset, 0))}
|
|
75
|
-
{@const insetB = maybeNumber(coalesce(insetBottom, inset, 0))}
|
|
65
|
+
{@const insetL = maybeNumber(coalesce(insetLeft, inset, 0)) ?? 0}
|
|
66
|
+
{@const insetT = maybeNumber(coalesce(insetTop, inset, 0)) ?? 0}
|
|
67
|
+
{@const insetR = maybeNumber(coalesce(insetRight, inset, 0)) ?? 0}
|
|
68
|
+
{@const insetB = maybeNumber(coalesce(insetBottom, inset, 0)) ?? 0}
|
|
76
69
|
|
|
77
70
|
{@const [style, styleClass] = resolveStyles(plot, d, args, 'fill', usedScales)}
|
|
78
71
|
<rect
|
|
79
|
-
class={[styleClass]}
|
|
72
|
+
class={[scaledData.length === 1 && className, styleClass]}
|
|
80
73
|
{style}
|
|
81
74
|
x={minx + insetL}
|
|
82
75
|
y={miny + insetT}
|
|
@@ -91,7 +84,7 @@
|
|
|
91
84
|
}} />
|
|
92
85
|
{/if}
|
|
93
86
|
{/each}
|
|
94
|
-
</
|
|
87
|
+
</GroupMultiple>
|
|
95
88
|
{/snippet}
|
|
96
89
|
</Mark>
|
|
97
90
|
|
|
@@ -10,16 +10,16 @@ declare const Sphere: import("svelte").Component<Partial<{
|
|
|
10
10
|
stroke: import("../types.js").ConstantAccessor<string>;
|
|
11
11
|
strokeWidth: import("../types.js").ConstantAccessor<number>;
|
|
12
12
|
strokeOpacity: import("../types.js").ConstantAccessor<number>;
|
|
13
|
-
strokeLinejoin: import("../types.js").ConstantAccessor<"
|
|
14
|
-
strokeLinecap: import("../types.js").ConstantAccessor<"
|
|
13
|
+
strokeLinejoin: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin>;
|
|
14
|
+
strokeLinecap: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinecap>;
|
|
15
15
|
strokeMiterlimit: import("../types.js").ConstantAccessor<number>;
|
|
16
16
|
opacity: import("../types.js").ConstantAccessor<number>;
|
|
17
17
|
strokeDasharray: import("../types.js").ConstantAccessor<string>;
|
|
18
18
|
strokeDashoffset: import("../types.js").ConstantAccessor<number>;
|
|
19
|
-
mixBlendMode: import("../types.js").ConstantAccessor<"
|
|
19
|
+
mixBlendMode: import("../types.js").ConstantAccessor<import("csstype").Property.MixBlendMode>;
|
|
20
20
|
clipPath: string;
|
|
21
21
|
imageFilter: import("../types.js").ConstantAccessor<string>;
|
|
22
|
-
shapeRendering: import("../types.js").ConstantAccessor<"
|
|
22
|
+
shapeRendering: import("../types.js").ConstantAccessor<import("csstype").Property.ShapeRendering>;
|
|
23
23
|
paintOrder: import("../types.js").ConstantAccessor<string>;
|
|
24
24
|
onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
25
25
|
ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
@@ -29,6 +29,15 @@ declare const Sphere: import("svelte").Component<Partial<{
|
|
|
29
29
|
onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
30
30
|
onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
31
31
|
onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
32
|
+
onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
33
|
+
onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
34
|
+
onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
35
|
+
onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
36
|
+
onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
37
|
+
onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
38
|
+
onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
39
|
+
onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
40
|
+
onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
32
41
|
ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
33
42
|
ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
34
43
|
ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
@@ -46,6 +55,7 @@ declare const Sphere: import("svelte").Component<Partial<{
|
|
|
46
55
|
href: import("../types.js").ConstantAccessor<string>;
|
|
47
56
|
target: import("../types.js").ConstantAccessor<"_self" | "_blank" | string>;
|
|
48
57
|
class: string;
|
|
58
|
+
cursor: import("../types.js").ConstantAccessor<import("csstype").Property.Cursor>;
|
|
49
59
|
}>, {}, "">;
|
|
50
60
|
type Sphere = ReturnType<typeof Sphere>;
|
|
51
61
|
export default Sphere;
|
package/dist/marks/Text.svelte
CHANGED
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
dx?: ConstantAccessor<number>;
|
|
23
23
|
dy?: ConstantAccessor<number>;
|
|
24
24
|
text: ConstantAccessor<string>;
|
|
25
|
-
title
|
|
25
|
+
title?: ConstantAccessor<string>;
|
|
26
26
|
/**
|
|
27
27
|
* if you want to apply class names to individual text elements
|
|
28
28
|
*/
|
|
29
|
-
textClass
|
|
29
|
+
textClass?: ConstantAccessor<string>;
|
|
30
30
|
/**
|
|
31
31
|
* the line anchor for vertical position; top, bottom, or middle
|
|
32
32
|
*/
|
|
@@ -10,11 +10,11 @@ type TextMarkProps = BaseMarkProps & {
|
|
|
10
10
|
dx?: ConstantAccessor<number>;
|
|
11
11
|
dy?: ConstantAccessor<number>;
|
|
12
12
|
text: ConstantAccessor<string>;
|
|
13
|
-
title
|
|
13
|
+
title?: ConstantAccessor<string>;
|
|
14
14
|
/**
|
|
15
15
|
* if you want to apply class names to individual text elements
|
|
16
16
|
*/
|
|
17
|
-
textClass
|
|
17
|
+
textClass?: ConstantAccessor<string>;
|
|
18
18
|
/**
|
|
19
19
|
* the line anchor for vertical position; top, bottom, or middle
|
|
20
20
|
*/
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { BaseMarkProps, DataRecord, PlotState } from '../../types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface MouseEvent {
|
|
4
|
+
layerX?: number;
|
|
5
|
+
layerY?: number;
|
|
6
|
+
dataX?: number | string | Date;
|
|
7
|
+
dataY?: number | string | Date;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Translates client coordinates (clientX, clientY) to the layer coordinates
|
|
12
|
+
* of the plot frame, regardless of which element triggered the event
|
|
13
|
+
*/
|
|
14
|
+
export declare function clientToLayerCoordinates(event: MouseEvent, plotBody: HTMLElement | null | undefined): [number, number];
|
|
2
15
|
export declare function addEventHandlers(node: SVGElement, { options, datum, getPlotState }: {
|
|
3
16
|
options: BaseMarkProps;
|
|
4
17
|
datum: DataRecord;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { invert, pick } from 'es-toolkit';
|
|
2
2
|
import { RAW_VALUE } from '../../transforms/recordize.js';
|
|
3
3
|
import { INDEX } from '../../constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Translates client coordinates (clientX, clientY) to the layer coordinates
|
|
6
|
+
* of the plot frame, regardless of which element triggered the event
|
|
7
|
+
*/
|
|
8
|
+
export function clientToLayerCoordinates(event, plotBody) {
|
|
9
|
+
// If layerX/Y already exist and the target is the plot frame (rect element),
|
|
10
|
+
// we can use them directly
|
|
11
|
+
// if (event.layerX !== undefined && (event.target as SVGElement).tagName === 'rect') {
|
|
12
|
+
// return [event.layerX, event.layerY];
|
|
13
|
+
// }
|
|
14
|
+
// Otherwise, transform from client coordinates to layer coordinates
|
|
15
|
+
// by getting the bounds of the plot body element and calculating the offset
|
|
16
|
+
if (!plotBody)
|
|
17
|
+
return [0, 0];
|
|
18
|
+
const plotBodyRect = plotBody.getBoundingClientRect();
|
|
19
|
+
// Calculate the coordinates relative to the plot body
|
|
20
|
+
return [
|
|
21
|
+
event.clientX - plotBodyRect.left,
|
|
22
|
+
event.clientY - plotBodyRect.top
|
|
23
|
+
];
|
|
24
|
+
}
|
|
4
25
|
export function addEventHandlers(node, { options, datum, getPlotState }) {
|
|
5
26
|
const events = pick(options, [
|
|
6
27
|
'onclick',
|
|
@@ -18,11 +39,20 @@ export function addEventHandlers(node, { options, datum, getPlotState }) {
|
|
|
18
39
|
'onmouseleave',
|
|
19
40
|
'onmousemove',
|
|
20
41
|
'onmouseout',
|
|
42
|
+
'onmouseover',
|
|
21
43
|
'onmouseup',
|
|
22
|
-
'
|
|
44
|
+
'onpointercancel',
|
|
45
|
+
'onpointerdown',
|
|
46
|
+
'onpointerenter',
|
|
47
|
+
'onpointerleave',
|
|
48
|
+
'onpointermove',
|
|
49
|
+
'onpointerout',
|
|
50
|
+
'onpointerover',
|
|
51
|
+
'onpointerup',
|
|
23
52
|
'ontouchcancel',
|
|
24
53
|
'ontouchend',
|
|
25
|
-
'ontouchmove'
|
|
54
|
+
'ontouchmove',
|
|
55
|
+
'onwheel',
|
|
26
56
|
]);
|
|
27
57
|
const listeners = new Map();
|
|
28
58
|
// attach event handlers
|
|
@@ -66,7 +96,6 @@ function invertScale(scale, position) {
|
|
|
66
96
|
if (scale.type === 'band') {
|
|
67
97
|
// invert band scale since scaleBand doesn't have an invert function
|
|
68
98
|
const eachBand = scale.fn.step();
|
|
69
|
-
console.log({ eachBand, position });
|
|
70
99
|
const index = Math.floor(position / eachBand);
|
|
71
100
|
return scale.fn.domain()[index];
|
|
72
101
|
}
|
package/dist/transforms/bin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataRecord, RawValue } from '../types.js';
|
|
2
2
|
import type { TransformArg } from '../types.js';
|
|
3
3
|
import { type ThresholdCountGenerator } from 'd3-array';
|
|
4
|
-
import {
|
|
4
|
+
import { type ReducerName } from '../helpers/reduce.js';
|
|
5
5
|
type NamedThresholdsGenerator = 'auto' | 'scott' | 'sturges' | 'freedman-diaconis';
|
|
6
6
|
type BinBaseOptions = {
|
|
7
7
|
domain?: [number, number];
|
|
@@ -20,14 +20,14 @@ type AdditionalOutputChannels = Partial<{
|
|
|
20
20
|
strokeOpacity: ReducerOption;
|
|
21
21
|
}>;
|
|
22
22
|
export type BinXOptions = BinBaseOptions & AdditionalOutputChannels & Partial<{
|
|
23
|
-
y:
|
|
24
|
-
y1:
|
|
25
|
-
y2:
|
|
23
|
+
y: ReducerOption;
|
|
24
|
+
y1: ReducerOption;
|
|
25
|
+
y2: ReducerOption;
|
|
26
26
|
}>;
|
|
27
27
|
export type BinYOptions = BinBaseOptions & AdditionalOutputChannels & Partial<{
|
|
28
|
-
x:
|
|
29
|
-
x1:
|
|
30
|
-
x2:
|
|
28
|
+
x: ReducerOption;
|
|
29
|
+
x1: ReducerOption;
|
|
30
|
+
x2: ReducerOption;
|
|
31
31
|
}>;
|
|
32
32
|
type BinOptions = BinBaseOptions & AdditionalOutputChannels;
|
|
33
33
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TransformArgsRow, TransformArgsRecord } from '../types.js';
|
|
2
|
+
export declare const INDEX: unique symbol;
|
|
2
3
|
export declare const RAW_VALUE: unique symbol;
|
|
3
4
|
export declare function recordizeX({ data, ...channels }: TransformArgsRow, { withIndex }?: {
|
|
4
5
|
withIndex: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import isDataRecord from '../helpers/isDataRecord.js';
|
|
2
|
-
export const
|
|
2
|
+
export const INDEX = Symbol('index');
|
|
3
|
+
export const RAW_VALUE = Symbol('originalValue');
|
|
3
4
|
/*
|
|
4
5
|
* This transform takes an array of raw values as input and returns data records
|
|
5
6
|
* in which the values are interpreted as x channel and their index as y
|
|
@@ -12,7 +13,6 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
12
13
|
__value: value,
|
|
13
14
|
...(withIndex ? { __index: index } : {}),
|
|
14
15
|
[RAW_VALUE]: value,
|
|
15
|
-
// TODO: remove ___orig___ references
|
|
16
16
|
___orig___: value
|
|
17
17
|
})),
|
|
18
18
|
...channels,
|
|
@@ -33,14 +33,13 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
33
33
|
if (dataIsRawValueArray) {
|
|
34
34
|
return {
|
|
35
35
|
data: Array.from(data).map((value, index) => ({
|
|
36
|
-
__value: value,
|
|
37
36
|
...(withIndex ? { __index: index } : {}),
|
|
38
37
|
[RAW_VALUE]: value,
|
|
39
38
|
___orig___: value
|
|
40
39
|
})),
|
|
41
40
|
...channels,
|
|
42
41
|
...(withIndex ? { x: '__index' } : {}),
|
|
43
|
-
y:
|
|
42
|
+
y: RAW_VALUE
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
return {
|
|
@@ -66,7 +65,7 @@ export function recordizeXY({ data, ...channels }) {
|
|
|
66
65
|
channels.y === undefined) {
|
|
67
66
|
return {
|
|
68
67
|
data: data.map(([x, y, ...rest]) => ({
|
|
69
|
-
|
|
68
|
+
[RAW_VALUE]: [x, y, ...rest],
|
|
70
69
|
__x: x,
|
|
71
70
|
__y: y
|
|
72
71
|
})),
|
|
@@ -10,12 +10,14 @@ type WindowOptions = {
|
|
|
10
10
|
export declare function windowX(args: TransformArg<DataRecord>, options: WindowOptions): {
|
|
11
11
|
data: {
|
|
12
12
|
[x: string]: import("../types.js").RawValue;
|
|
13
|
+
[x: symbol]: import("../types.js").RawValue;
|
|
13
14
|
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
14
15
|
}[];
|
|
15
16
|
};
|
|
16
17
|
export declare function windowY(args: TransformArg<DataRecord>, options: WindowOptions): {
|
|
17
18
|
data: {
|
|
18
19
|
[x: string]: import("../types.js").RawValue;
|
|
20
|
+
[x: symbol]: import("../types.js").RawValue;
|
|
19
21
|
___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
|
|
20
22
|
}[];
|
|
21
23
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Snippet } from 'svelte';
|
|
|
3
3
|
import type { MouseEventHandler } from 'svelte/elements';
|
|
4
4
|
import type { MarkerShape } from './marks/helpers/Marker.svelte';
|
|
5
5
|
import type { Writable } from 'svelte/store';
|
|
6
|
+
import type * as CSS from 'csstype';
|
|
6
7
|
export type MarkType = 'area' | 'arrow' | 'axisX' | 'axisY' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
|
|
7
8
|
export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
|
|
8
9
|
export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
|
|
@@ -16,7 +17,7 @@ export type Mark<T> = {
|
|
|
16
17
|
};
|
|
17
18
|
export type ScaledChannelName = 'fill' | 'fillOpacity' | 'opacity' | 'r' | 'length' | 'stroke' | 'strokeOpacity' | 'symbol' | 'fx' | 'fy' | 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
|
|
18
19
|
export type ChannelName = ScaledChannelName | 'z' | 'sort' | 'filter' | 'interval';
|
|
19
|
-
export type RawValue = number | Date | boolean | string;
|
|
20
|
+
export type RawValue = number | Date | boolean | string | symbol;
|
|
20
21
|
export type ScaleOptions = {
|
|
21
22
|
/**
|
|
22
23
|
* Override the automatic scale type detection.
|
|
@@ -159,6 +160,10 @@ export type PlotOptions = {
|
|
|
159
160
|
* setting the maxWidth style property you can limit the width of your plot.
|
|
160
161
|
*/
|
|
161
162
|
maxWidth?: string;
|
|
163
|
+
/**
|
|
164
|
+
* force the plot into a fixed width
|
|
165
|
+
*/
|
|
166
|
+
width?: number;
|
|
162
167
|
/**
|
|
163
168
|
* force the plot into a fixed height
|
|
164
169
|
*/
|
|
@@ -166,7 +171,12 @@ export type PlotOptions = {
|
|
|
166
171
|
/**
|
|
167
172
|
* Convenience option for setting all four margins at once, in px.
|
|
168
173
|
*/
|
|
169
|
-
margin: number
|
|
174
|
+
margin: number | {
|
|
175
|
+
top?: number;
|
|
176
|
+
right?: number;
|
|
177
|
+
bottom?: number;
|
|
178
|
+
left?: number;
|
|
179
|
+
};
|
|
170
180
|
/**
|
|
171
181
|
* Left margin of the plot, in px.
|
|
172
182
|
*/
|
|
@@ -237,7 +247,7 @@ export type PlotOptions = {
|
|
|
237
247
|
* Options for the shared radius scale
|
|
238
248
|
*/
|
|
239
249
|
r: ScaleOptions;
|
|
240
|
-
color: ColorScaleOptions
|
|
250
|
+
color: Partial<ColorScaleOptions>;
|
|
241
251
|
opacity: ScaleOptions;
|
|
242
252
|
symbol: LegendScaleOptions;
|
|
243
253
|
length: ScaleOptions;
|
|
@@ -331,7 +341,7 @@ export type PlotDefaults = {
|
|
|
331
341
|
markerDotRadius: number;
|
|
332
342
|
};
|
|
333
343
|
export type GenericMarkOptions = Record<string, any>;
|
|
334
|
-
export type DataRecord = Record<string, RawValue> & {
|
|
344
|
+
export type DataRecord = Record<string | symbol, RawValue> & {
|
|
335
345
|
___orig___?: RawValue | [RawValue, RawValue];
|
|
336
346
|
};
|
|
337
347
|
export type ResolvedDataRecord = Partial<Record<ScaledChannelName, any>> & {
|
|
@@ -488,16 +498,16 @@ export type BaseMarkProps = Partial<{
|
|
|
488
498
|
stroke: ConstantAccessor<string>;
|
|
489
499
|
strokeWidth: ConstantAccessor<number>;
|
|
490
500
|
strokeOpacity: ConstantAccessor<number>;
|
|
491
|
-
strokeLinejoin: ConstantAccessor<
|
|
492
|
-
strokeLinecap: ConstantAccessor<
|
|
501
|
+
strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin>;
|
|
502
|
+
strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap>;
|
|
493
503
|
strokeMiterlimit: ConstantAccessor<number>;
|
|
494
504
|
opacity: ConstantAccessor<number>;
|
|
495
505
|
strokeDasharray: ConstantAccessor<string>;
|
|
496
506
|
strokeDashoffset: ConstantAccessor<number>;
|
|
497
|
-
mixBlendMode: ConstantAccessor<
|
|
507
|
+
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode>;
|
|
498
508
|
clipPath: string;
|
|
499
509
|
imageFilter: ConstantAccessor<string>;
|
|
500
|
-
shapeRendering: ConstantAccessor<
|
|
510
|
+
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering>;
|
|
501
511
|
paintOrder: ConstantAccessor<string>;
|
|
502
512
|
onclick?: MouseEventHandler<SVGPathElement>;
|
|
503
513
|
ondblclick?: MouseEventHandler<SVGPathElement>;
|
|
@@ -507,6 +517,15 @@ export type BaseMarkProps = Partial<{
|
|
|
507
517
|
onmousemove?: MouseEventHandler<SVGPathElement>;
|
|
508
518
|
onmouseleave?: MouseEventHandler<SVGPathElement>;
|
|
509
519
|
onmouseout?: MouseEventHandler<SVGPathElement>;
|
|
520
|
+
onmouseover?: MouseEventHandler<SVGPathElement>;
|
|
521
|
+
onpointercancel?: MouseEventHandler<SVGPathElement>;
|
|
522
|
+
onpointerdown?: MouseEventHandler<SVGPathElement>;
|
|
523
|
+
onpointerup?: MouseEventHandler<SVGPathElement>;
|
|
524
|
+
onpointerenter?: MouseEventHandler<SVGPathElement>;
|
|
525
|
+
onpointerleave?: MouseEventHandler<SVGPathElement>;
|
|
526
|
+
onpointermove?: MouseEventHandler<SVGPathElement>;
|
|
527
|
+
onpointerover?: MouseEventHandler<SVGPathElement>;
|
|
528
|
+
onpointerout?: MouseEventHandler<SVGPathElement>;
|
|
510
529
|
ondrag?: MouseEventHandler<SVGPathElement>;
|
|
511
530
|
ondrop?: MouseEventHandler<SVGPathElement>;
|
|
512
531
|
ondragstart?: MouseEventHandler<SVGPathElement>;
|
|
@@ -534,6 +553,7 @@ export type BaseMarkProps = Partial<{
|
|
|
534
553
|
* if you want to give your mark element an extra CSS class
|
|
535
554
|
*/
|
|
536
555
|
class: string;
|
|
556
|
+
cursor: ConstantAccessor<CSS.Property.Cursor>;
|
|
537
557
|
}>;
|
|
538
558
|
export type BaseRectMarkProps = {
|
|
539
559
|
rx?: ConstantAccessor<number>;
|
|
@@ -544,7 +564,7 @@ export type BaseRectMarkProps = {
|
|
|
544
564
|
insetRight?: ConstantAccessor<number>;
|
|
545
565
|
insetBottom?: ConstantAccessor<number>;
|
|
546
566
|
};
|
|
547
|
-
export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean>>;
|
|
567
|
+
export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean | symbol>>;
|
|
548
568
|
export type TransformArg<K> = Channels & {
|
|
549
569
|
data: K[];
|
|
550
570
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gregor Aisch",
|
|
@@ -50,13 +50,14 @@
|
|
|
50
50
|
"@sveltejs/adapter-auto": "^6.0.0",
|
|
51
51
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
52
52
|
"@sveltejs/eslint-config": "^8.2.0",
|
|
53
|
-
"@sveltejs/kit": "^2.20.
|
|
53
|
+
"@sveltejs/kit": "^2.20.8",
|
|
54
54
|
"@sveltejs/package": "^2.3.11",
|
|
55
55
|
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
|
56
56
|
"@sveltepress/theme-default": "^6.0.2",
|
|
57
57
|
"@sveltepress/twoslash": "^1.2.1",
|
|
58
58
|
"@sveltepress/vite": "^1.2.1",
|
|
59
59
|
"@testing-library/svelte": "^5.2.7",
|
|
60
|
+
"@testing-library/user-event": "^14.6.1",
|
|
60
61
|
"@types/d3-array": "^3.2.1",
|
|
61
62
|
"@types/d3-color": "^3.1.3",
|
|
62
63
|
"@types/d3-dsv": "^3.0.7",
|
|
@@ -69,10 +70,11 @@
|
|
|
69
70
|
"@types/d3-shape": "^3.1.7",
|
|
70
71
|
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
|
71
72
|
"@typescript-eslint/parser": "^8.31.1",
|
|
73
|
+
"csstype": "^3.1.3",
|
|
72
74
|
"d3-dsv": "^3.0.1",
|
|
73
75
|
"d3-fetch": "^3.0.1",
|
|
74
76
|
"d3-force": "^3.0.0",
|
|
75
|
-
"eslint": "^9.
|
|
77
|
+
"eslint": "^9.26.0",
|
|
76
78
|
"eslint-config-prettier": "^10.1.2",
|
|
77
79
|
"eslint-plugin-svelte": "3.5.1",
|
|
78
80
|
"jsdom": "^26.1.0",
|
|
@@ -82,15 +84,15 @@
|
|
|
82
84
|
"remark-code-frontmatter": "^1.0.0",
|
|
83
85
|
"resize-observer-polyfill": "^1.5.1",
|
|
84
86
|
"sass": "^1.87.0",
|
|
85
|
-
"svelte-check": "^4.1.
|
|
87
|
+
"svelte-check": "^4.1.7",
|
|
86
88
|
"svelte-eslint-parser": "1.1.3",
|
|
87
89
|
"svelte-highlight": "^7.8.3",
|
|
88
90
|
"topojson-client": "^3.1.0",
|
|
89
91
|
"tslib": "^2.8.1",
|
|
90
|
-
"typedoc": "^0.28.
|
|
92
|
+
"typedoc": "^0.28.4",
|
|
91
93
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
92
94
|
"typescript": "^5.8.3",
|
|
93
|
-
"vite": "^6.3.
|
|
95
|
+
"vite": "^6.3.4",
|
|
94
96
|
"vitest": "^3.1.2"
|
|
95
97
|
},
|
|
96
98
|
"types": "./dist/index.d.ts",
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
"d3-scale-chromatic": "^3.1.0",
|
|
110
112
|
"d3-shape": "^3.2.0",
|
|
111
113
|
"d3-time": "^3.1.0",
|
|
112
|
-
"es-toolkit": "^1.
|
|
114
|
+
"es-toolkit": "^1.37.2",
|
|
113
115
|
"fast-equals": "^5.2.2",
|
|
114
116
|
"merge-deep": "^3.0.3",
|
|
115
117
|
"svelte": "5.28.2"
|