svelteplot 0.2.0 → 0.2.2
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 +12 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/resolve.d.ts +1 -1
- package/dist/helpers/resolve.js +6 -5
- package/dist/helpers/scales.d.ts +2 -2
- package/dist/helpers/scales.js +5 -4
- package/dist/helpers/typeChecks.js +14 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -2
- package/dist/marks/BarX.svelte +11 -37
- package/dist/marks/BarY.svelte +27 -58
- package/dist/marks/BarY.svelte.d.ts +2 -8
- package/dist/marks/Cell.svelte +12 -36
- package/dist/marks/ColorLegend.svelte +6 -10
- package/dist/marks/Dot.svelte +2 -2
- package/dist/marks/Geo.svelte +50 -41
- package/dist/marks/Geo.svelte.d.ts +3 -1
- package/dist/marks/GridX.svelte +2 -2
- package/dist/marks/GridY.svelte +2 -2
- package/dist/marks/Line.svelte +98 -80
- package/dist/marks/Line.svelte.d.ts +5 -3
- package/dist/marks/Pointer.svelte +2 -1
- package/dist/marks/Rect.svelte +10 -24
- package/dist/marks/helpers/CanvasLayer.svelte +10 -16
- package/dist/marks/helpers/CanvasLayer.svelte.d.ts +2 -6
- package/dist/marks/helpers/DotCanvas.svelte +72 -159
- package/dist/marks/helpers/DotCanvas.svelte.d.ts +2 -4
- package/dist/marks/helpers/GeoCanvas.svelte +95 -145
- package/dist/marks/helpers/GeoCanvas.svelte.d.ts +3 -5
- package/dist/marks/helpers/LineCanvas.svelte +116 -0
- package/dist/marks/helpers/LineCanvas.svelte.d.ts +12 -0
- package/dist/marks/helpers/LinearGradientX.svelte +27 -0
- package/dist/marks/helpers/LinearGradientX.svelte.d.ts +11 -0
- package/dist/marks/helpers/LinearGradientY.svelte +27 -0
- package/dist/marks/helpers/LinearGradientY.svelte.d.ts +11 -0
- package/dist/marks/helpers/RectPath.svelte +129 -0
- package/dist/marks/helpers/RectPath.svelte.d.ts +27 -0
- package/dist/marks/helpers/canvas.d.ts +1 -0
- package/dist/marks/helpers/canvas.js +34 -0
- package/dist/transforms/recordize.d.ts +1 -0
- package/dist/transforms/recordize.js +16 -5
- package/dist/transforms/stack.js +10 -7
- package/dist/types.d.ts +12 -6
- package/package.json +19 -17
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types.js';
|
|
2
|
+
import { type Line } from 'd3-shape';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
mark: Mark<BaseMarkProps>;
|
|
5
|
+
groupedLineData: ScaledDataRecord[][];
|
|
6
|
+
usedScales: UsedScales;
|
|
7
|
+
linePath: Line<ScaledDataRecord>;
|
|
8
|
+
groupByKey?: unknown;
|
|
9
|
+
};
|
|
10
|
+
declare const LineCanvas: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type LineCanvas = ReturnType<typeof LineCanvas>;
|
|
12
|
+
export default LineCanvas;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import type { PlotContext, RawValue } from '../../types';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
id,
|
|
7
|
+
stops
|
|
8
|
+
}: {
|
|
9
|
+
id: string;
|
|
10
|
+
stops: { x: RawValue; color: string }[];
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
14
|
+
const plot = $derived(getPlotState());
|
|
15
|
+
|
|
16
|
+
const projectedStops = $derived(
|
|
17
|
+
stops
|
|
18
|
+
.map((d) => ({ ...d, px: plot.scales.x.fn(d.x) / plot.width }))
|
|
19
|
+
.sort((a, b) => a.px - b.px)
|
|
20
|
+
);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<linearGradient {id} gradientUnits="userSpaceOnUse" x1={0} y2={0} y1={0} x2={plot.width}>
|
|
24
|
+
{#each projectedStops as { px, color }}
|
|
25
|
+
<stop stop-color={color} offset={px} />
|
|
26
|
+
{/each}
|
|
27
|
+
</linearGradient>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RawValue } from '../../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
stops: {
|
|
5
|
+
x: RawValue;
|
|
6
|
+
color: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
declare const LinearGradientX: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type LinearGradientX = ReturnType<typeof LinearGradientX>;
|
|
11
|
+
export default LinearGradientX;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import type { PlotContext, RawValue } from '../../types';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
id,
|
|
7
|
+
stops
|
|
8
|
+
}: {
|
|
9
|
+
id: string;
|
|
10
|
+
stops: { y: RawValue; color: string }[];
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
14
|
+
const plot = $derived(getPlotState());
|
|
15
|
+
|
|
16
|
+
const projectedStops = $derived(
|
|
17
|
+
stops
|
|
18
|
+
.map((d) => ({ ...d, py: plot.scales.y.fn(d.y) / plot.height }))
|
|
19
|
+
.sort((a, b) => a.py - b.py)
|
|
20
|
+
);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<linearGradient {id} gradientUnits="userSpaceOnUse" x1={0} x2={0} y1={0} y2={plot.height}>
|
|
24
|
+
{#each projectedStops as { py, color }}
|
|
25
|
+
<stop stop-color={color} offset={py} />
|
|
26
|
+
{/each}
|
|
27
|
+
</linearGradient>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RawValue } from '../../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
stops: {
|
|
5
|
+
y: RawValue;
|
|
6
|
+
color: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
declare const LinearGradientY: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type LinearGradientY = ReturnType<typeof LinearGradientY>;
|
|
11
|
+
export default LinearGradientY;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Helper component for rendering rectangular marks in SVG
|
|
3
|
+
-->
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { resolveProp, resolveStyles } from '../../helpers/resolve';
|
|
6
|
+
import { roundedRect } from '../../helpers/roundedRect';
|
|
7
|
+
import type {
|
|
8
|
+
BaseMarkProps,
|
|
9
|
+
BaseRectMarkProps,
|
|
10
|
+
BorderRadius,
|
|
11
|
+
ScaledDataRecord,
|
|
12
|
+
UsedScales,
|
|
13
|
+
PlotContext
|
|
14
|
+
} from '../../types';
|
|
15
|
+
import { addEventHandlers } from './events';
|
|
16
|
+
import { getContext } from 'svelte';
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
datum,
|
|
20
|
+
options,
|
|
21
|
+
class: className = null,
|
|
22
|
+
x,
|
|
23
|
+
y,
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
26
|
+
useInsetAsFallbackVertically = true,
|
|
27
|
+
useInsetAsFallbackHorizontally = true,
|
|
28
|
+
usedScales
|
|
29
|
+
}: {
|
|
30
|
+
datum: ScaledDataRecord;
|
|
31
|
+
class: string | null;
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
options: BaseRectMarkProps & BaseMarkProps;
|
|
37
|
+
/**
|
|
38
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
39
|
+
* can tweak this behavior for insetTop and insetBottom by setting the
|
|
40
|
+
* useInsetAsFallbackVertically prop to false.
|
|
41
|
+
*/
|
|
42
|
+
useInsetAsFallbackVertically?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
45
|
+
* can tweak this behavior for insetLeft and insetRight by setting the
|
|
46
|
+
* useInsetAsFallbackHorizontally prop to false.
|
|
47
|
+
*/
|
|
48
|
+
useInsetAsFallbackHorizontally?: boolean;
|
|
49
|
+
usedScales: UsedScales;
|
|
50
|
+
} = $props();
|
|
51
|
+
|
|
52
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
53
|
+
const plot = $derived(getPlotState());
|
|
54
|
+
|
|
55
|
+
const dx = $derived(+(resolveProp(options.dx, datum.datum, 0) as number));
|
|
56
|
+
const dy = $derived(+(resolveProp(options.dy, datum.datum, 0) as number));
|
|
57
|
+
const inset = $derived(+(resolveProp(options.inset, datum.datum, 0) as number));
|
|
58
|
+
const insetLeft = $derived(
|
|
59
|
+
+(resolveProp(
|
|
60
|
+
options.insetLeft,
|
|
61
|
+
datum.datum,
|
|
62
|
+
useInsetAsFallbackHorizontally ? inset : 0
|
|
63
|
+
) as number)
|
|
64
|
+
);
|
|
65
|
+
const insetRight = $derived(
|
|
66
|
+
+(resolveProp(
|
|
67
|
+
options.insetRight,
|
|
68
|
+
datum.datum,
|
|
69
|
+
useInsetAsFallbackHorizontally ? inset : 0
|
|
70
|
+
) as number)
|
|
71
|
+
);
|
|
72
|
+
const insetTop = $derived(
|
|
73
|
+
+(resolveProp(
|
|
74
|
+
options.insetTop,
|
|
75
|
+
datum.datum,
|
|
76
|
+
useInsetAsFallbackVertically ? inset : 0
|
|
77
|
+
) as number)
|
|
78
|
+
);
|
|
79
|
+
const insetBottom = $derived(
|
|
80
|
+
+(resolveProp(
|
|
81
|
+
options.insetBottom,
|
|
82
|
+
datum.datum,
|
|
83
|
+
useInsetAsFallbackVertically ? inset : 0
|
|
84
|
+
) as number)
|
|
85
|
+
);
|
|
86
|
+
const borderRadius = $derived((options.borderRadius ?? 0) as BorderRadius);
|
|
87
|
+
const hasBorderRadius = $derived(
|
|
88
|
+
(typeof borderRadius === 'number' && borderRadius > 0) ||
|
|
89
|
+
(typeof borderRadius === 'object' &&
|
|
90
|
+
Math.max(
|
|
91
|
+
borderRadius.topRight ?? 0,
|
|
92
|
+
borderRadius.bottomRight ?? 0,
|
|
93
|
+
borderRadius.topLeft ?? 0,
|
|
94
|
+
borderRadius.bottomLeft ?? 0
|
|
95
|
+
) > 0)
|
|
96
|
+
);
|
|
97
|
+
const [style, styleClass] = $derived(resolveStyles(plot, datum, options, 'fill', usedScales));
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
{#if hasBorderRadius}
|
|
101
|
+
<path
|
|
102
|
+
transform="translate({[x + dx + insetLeft, y + insetBottom + dy]})"
|
|
103
|
+
d={roundedRect(
|
|
104
|
+
0,
|
|
105
|
+
0,
|
|
106
|
+
width - insetLeft - insetRight,
|
|
107
|
+
height - insetTop - insetBottom,
|
|
108
|
+
borderRadius
|
|
109
|
+
)}
|
|
110
|
+
class={[styleClass, className]}
|
|
111
|
+
{style}
|
|
112
|
+
use:addEventHandlers={{
|
|
113
|
+
getPlotState,
|
|
114
|
+
options,
|
|
115
|
+
datum: datum.datum
|
|
116
|
+
}} />
|
|
117
|
+
{:else}
|
|
118
|
+
<rect
|
|
119
|
+
transform="translate({[x + dx + insetLeft, y + insetBottom + dy]})"
|
|
120
|
+
width={width - insetLeft - insetRight}
|
|
121
|
+
height={height - insetTop - insetBottom}
|
|
122
|
+
class={[styleClass, className]}
|
|
123
|
+
{style}
|
|
124
|
+
use:addEventHandlers={{
|
|
125
|
+
getPlotState,
|
|
126
|
+
options,
|
|
127
|
+
datum: datum.datum
|
|
128
|
+
}} />
|
|
129
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BaseMarkProps, BaseRectMarkProps, ScaledDataRecord, UsedScales } from '../../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
datum: ScaledDataRecord;
|
|
4
|
+
class: string | null;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
options: BaseRectMarkProps & BaseMarkProps;
|
|
10
|
+
/**
|
|
11
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
12
|
+
* can tweak this behavior for insetTop and insetBottom by setting the
|
|
13
|
+
* useInsetAsFallbackVertically prop to false.
|
|
14
|
+
*/
|
|
15
|
+
useInsetAsFallbackVertically?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
18
|
+
* can tweak this behavior for insetLeft and insetRight by setting the
|
|
19
|
+
* useInsetAsFallbackHorizontally prop to false.
|
|
20
|
+
*/
|
|
21
|
+
useInsetAsFallbackHorizontally?: boolean;
|
|
22
|
+
usedScales: UsedScales;
|
|
23
|
+
};
|
|
24
|
+
/** Helper component for rendering rectangular marks in SVG */
|
|
25
|
+
declare const RectPath: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
26
|
+
type RectPath = ReturnType<typeof RectPath>;
|
|
27
|
+
export default RectPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveColor(color: string, canvas: HTMLCanvasElement): string | CanvasGradient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CSS_URL, CSS_VAR } from "../../constants";
|
|
2
|
+
export function resolveColor(color, canvas) {
|
|
3
|
+
if (`${color}`.toLowerCase() === 'currentcolor') {
|
|
4
|
+
color = getComputedStyle(canvas?.parentElement?.parentElement).getPropertyValue('color');
|
|
5
|
+
}
|
|
6
|
+
if (CSS_VAR.test(color)) {
|
|
7
|
+
color = getComputedStyle(canvas).getPropertyValue(color.slice(4, -1));
|
|
8
|
+
}
|
|
9
|
+
if (CSS_URL.test(color)) {
|
|
10
|
+
// might be a gradient we can parse!
|
|
11
|
+
const m = color.match(/^url\((#[^\)]+)\)/);
|
|
12
|
+
const gradientId = m[1];
|
|
13
|
+
const gradient = canvas.ownerDocument.querySelector(gradientId);
|
|
14
|
+
if (gradient) {
|
|
15
|
+
// parse gradient
|
|
16
|
+
if (gradient.nodeName.toLowerCase() === 'lineargradient') {
|
|
17
|
+
const x0 = +gradient.getAttribute('x1');
|
|
18
|
+
const x1 = +gradient.getAttribute('x2');
|
|
19
|
+
const y0 = +gradient.getAttribute('y1');
|
|
20
|
+
const y1 = +gradient.getAttribute('y2');
|
|
21
|
+
const ctxGradient = canvas
|
|
22
|
+
.getContext('2d')
|
|
23
|
+
.createLinearGradient(x0, y0, x1, y1);
|
|
24
|
+
for (const stop of gradient.querySelectorAll('stop')) {
|
|
25
|
+
const offset = +stop.getAttribute('offset');
|
|
26
|
+
const color = resolveColor(stop.getAttribute('stop-color'), canvas);
|
|
27
|
+
ctxGradient.addColorStop(offset, color);
|
|
28
|
+
}
|
|
29
|
+
return ctxGradient;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return color;
|
|
34
|
+
}
|
|
@@ -13,3 +13,4 @@ export declare function recordizeY({ data, ...channels }: TransformArgsRow, { wi
|
|
|
13
13
|
* the rest of our code doesn't have to deal with this case anymore.
|
|
14
14
|
*/
|
|
15
15
|
export declare function recordizeXY({ data, ...channels }: TransformArgsRow): TransformArgsRecord;
|
|
16
|
+
export declare function recordize({ data, ...channels }: TransformArgsRow): TransformArgsRecord;
|
|
@@ -11,13 +11,12 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
11
11
|
return {
|
|
12
12
|
data: data.map((value, index) => ({
|
|
13
13
|
__value: value,
|
|
14
|
-
...(withIndex ? {
|
|
14
|
+
...(withIndex ? { [INDEX]: index } : {}),
|
|
15
15
|
[RAW_VALUE]: value,
|
|
16
|
-
___orig___: value
|
|
17
16
|
})),
|
|
18
17
|
...channels,
|
|
19
|
-
x:
|
|
20
|
-
...(withIndex ? { y:
|
|
18
|
+
x: RAW_VALUE,
|
|
19
|
+
...(withIndex ? { y: INDEX } : {})
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
return { data: data, ...channels };
|
|
@@ -35,7 +34,6 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
35
34
|
data: Array.from(data).map((value, index) => ({
|
|
36
35
|
...(withIndex ? { __index: index } : {}),
|
|
37
36
|
[RAW_VALUE]: value,
|
|
38
|
-
___orig___: value
|
|
39
37
|
})),
|
|
40
38
|
...channels,
|
|
41
39
|
...(withIndex ? { x: '__index' } : {}),
|
|
@@ -76,3 +74,16 @@ export function recordizeXY({ data, ...channels }) {
|
|
|
76
74
|
}
|
|
77
75
|
return { data, ...channels };
|
|
78
76
|
}
|
|
77
|
+
export function recordize({ data, ...channels }) {
|
|
78
|
+
if (!data)
|
|
79
|
+
return { data, ...channels };
|
|
80
|
+
if (!isDataRecord(data[0])) {
|
|
81
|
+
return {
|
|
82
|
+
data: data.map((d) => ({
|
|
83
|
+
[RAW_VALUE]: d,
|
|
84
|
+
})),
|
|
85
|
+
...channels,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return { data, ...channels };
|
|
89
|
+
}
|
package/dist/transforms/stack.js
CHANGED
|
@@ -2,6 +2,9 @@ import isDataRecord from '../helpers/isDataRecord.js';
|
|
|
2
2
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
3
3
|
import { stack, stackOffsetExpand, stackOffsetSilhouette, stackOffsetWiggle, stackOrderAppearance, stackOrderAscending, stackOrderInsideOut, stackOrderNone, stackOffsetDiverging } from 'd3-shape';
|
|
4
4
|
import { index, union, groups as d3Groups } from 'd3-array';
|
|
5
|
+
import { RAW_VALUE } from './recordize';
|
|
6
|
+
const GROUP = Symbol('group');
|
|
7
|
+
const FACET = Symbol('group');
|
|
5
8
|
const DEFAULT_STACK_OPTIONS = {
|
|
6
9
|
order: null,
|
|
7
10
|
offset: null,
|
|
@@ -39,8 +42,8 @@ function stackXY(byDim, data, channels, options) {
|
|
|
39
42
|
const resolvedData = data.map((d) => ({
|
|
40
43
|
...(isDataRecord(d) ? d : { __orig: d }),
|
|
41
44
|
[`__${secondDim}`]: resolveChannel(secondDim, d, channels),
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
[GROUP]: groupBy === true ? 'G' : resolveChannel(groupBy, d, channels),
|
|
46
|
+
[FACET]: groupFacetsBy.length > 0
|
|
44
47
|
? groupFacetsBy
|
|
45
48
|
.map((channel) => String(resolveChannel(channel, d, channels)))
|
|
46
49
|
.join('---')
|
|
@@ -51,11 +54,11 @@ function stackXY(byDim, data, channels, options) {
|
|
|
51
54
|
const out = [];
|
|
52
55
|
// first we group the dataset by facets to avoid stacking of rows that are
|
|
53
56
|
// in separate panels
|
|
54
|
-
const groups = d3Groups(resolvedData, (d) => d
|
|
57
|
+
const groups = d3Groups(resolvedData, (d) => d[FACET]);
|
|
55
58
|
for (const [, facetData] of groups) {
|
|
56
59
|
// now we index the data on the second dimension, e.g. over x
|
|
57
60
|
// when stacking over y
|
|
58
|
-
const indexed = index(facetData, (d) => d[`__${secondDim}`], (d) => d
|
|
61
|
+
const indexed = index(facetData, (d) => d[`__${secondDim}`], (d) => d[GROUP]);
|
|
59
62
|
const stackOrder = (series) => {
|
|
60
63
|
const f = STACK_ORDER[options.order || 'none'];
|
|
61
64
|
return options.reverse ? f(series).reverse() : f(series);
|
|
@@ -64,7 +67,7 @@ function stackXY(byDim, data, channels, options) {
|
|
|
64
67
|
const series = stack()
|
|
65
68
|
.order(stackOrder)
|
|
66
69
|
.offset(STACK_OFFSET[options.offset])
|
|
67
|
-
.keys(union(facetData.map((d) => d
|
|
70
|
+
.keys(union(facetData.map((d) => d[GROUP])))
|
|
68
71
|
.value(([, group], key) => (group.get(key) ? group.get(key)[`__${byDim}`] : 0))(indexed);
|
|
69
72
|
// and combine it all back into a flat array
|
|
70
73
|
const newData = series
|
|
@@ -75,8 +78,8 @@ function stackXY(byDim, data, channels, options) {
|
|
|
75
78
|
.map((d) => {
|
|
76
79
|
const datum = d.data[1].get(groupKey);
|
|
77
80
|
// cleanup our internal keys
|
|
78
|
-
delete datum
|
|
79
|
-
delete datum
|
|
81
|
+
delete datum[GROUP];
|
|
82
|
+
delete datum[FACET];
|
|
80
83
|
return { ...datum, [`__${byLow}`]: d[0], [`__${byHigh}`]: d[1] };
|
|
81
84
|
});
|
|
82
85
|
})
|
package/dist/types.d.ts
CHANGED
|
@@ -246,11 +246,11 @@ export type PlotOptions = {
|
|
|
246
246
|
/**
|
|
247
247
|
* Options for the shared radius scale
|
|
248
248
|
*/
|
|
249
|
-
r: ScaleOptions
|
|
249
|
+
r: Partial<ScaleOptions>;
|
|
250
250
|
color: Partial<ColorScaleOptions>;
|
|
251
|
-
opacity: ScaleOptions
|
|
252
|
-
symbol: LegendScaleOptions
|
|
253
|
-
length: ScaleOptions
|
|
251
|
+
opacity: Partial<ScaleOptions>;
|
|
252
|
+
symbol: Partial<LegendScaleOptions>;
|
|
253
|
+
length: Partial<ScaleOptions>;
|
|
254
254
|
fx: Partial<ScaleOptions>;
|
|
255
255
|
fy: Partial<ScaleOptions>;
|
|
256
256
|
children: Snippet<[
|
|
@@ -555,14 +555,19 @@ export type BaseMarkProps = Partial<{
|
|
|
555
555
|
class: string;
|
|
556
556
|
cursor: ConstantAccessor<CSS.Property.Cursor>;
|
|
557
557
|
}>;
|
|
558
|
+
export type BorderRadius = number | {
|
|
559
|
+
topLeft?: number;
|
|
560
|
+
topRight?: number;
|
|
561
|
+
bottomRight?: number;
|
|
562
|
+
bottomLeft?: number;
|
|
563
|
+
};
|
|
558
564
|
export type BaseRectMarkProps = {
|
|
559
|
-
rx?: ConstantAccessor<number>;
|
|
560
|
-
ry?: ConstantAccessor<number>;
|
|
561
565
|
inset?: ConstantAccessor<number>;
|
|
562
566
|
insetLeft?: ConstantAccessor<number>;
|
|
563
567
|
insetTop?: ConstantAccessor<number>;
|
|
564
568
|
insetRight?: ConstantAccessor<number>;
|
|
565
569
|
insetBottom?: ConstantAccessor<number>;
|
|
570
|
+
borderRadius?: BorderRadius;
|
|
566
571
|
};
|
|
567
572
|
export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean | symbol>>;
|
|
568
573
|
export type TransformArg<K> = Channels & {
|
|
@@ -652,4 +657,5 @@ export type MapIndexObject = {
|
|
|
652
657
|
};
|
|
653
658
|
export type MapMethod = 'cumsum' | 'rank' | 'quantile' | ((I: number[], S: number[]) => number[]) | MapIndexObject;
|
|
654
659
|
export type MapOptions = Partial<Record<ScaledChannelName, MapMethod>>;
|
|
660
|
+
export type UsedScales = Record<ScaledChannelName, boolean>;
|
|
655
661
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gregor Aisch",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@aitodotai/json-stringify-pretty-compact": "^1.3.0",
|
|
49
49
|
"@emotion/css": "^11.13.5",
|
|
50
|
-
"@sveltejs/adapter-auto": "^6.0.
|
|
50
|
+
"@sveltejs/adapter-auto": "^6.0.1",
|
|
51
51
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
52
52
|
"@sveltejs/eslint-config": "^8.2.0",
|
|
53
|
-
"@sveltejs/kit": "^2.
|
|
53
|
+
"@sveltejs/kit": "^2.21.0",
|
|
54
54
|
"@sveltejs/package": "^2.3.11",
|
|
55
55
|
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
|
56
|
-
"@sveltepress/theme-default": "^6.0.
|
|
57
|
-
"@sveltepress/twoslash": "^1.2.
|
|
58
|
-
"@sveltepress/vite": "^1.2.
|
|
56
|
+
"@sveltepress/theme-default": "^6.0.3",
|
|
57
|
+
"@sveltepress/twoslash": "^1.2.2",
|
|
58
|
+
"@sveltepress/vite": "^1.2.2",
|
|
59
59
|
"@testing-library/svelte": "^5.2.7",
|
|
60
60
|
"@testing-library/user-event": "^14.6.1",
|
|
61
61
|
"@types/d3-array": "^3.2.1",
|
|
@@ -68,32 +68,34 @@
|
|
|
68
68
|
"@types/d3-scale": "^4.0.9",
|
|
69
69
|
"@types/d3-scale-chromatic": "^3.1.0",
|
|
70
70
|
"@types/d3-shape": "^3.1.7",
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
72
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
72
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
73
73
|
"csstype": "^3.1.3",
|
|
74
74
|
"d3-dsv": "^3.0.1",
|
|
75
75
|
"d3-fetch": "^3.0.1",
|
|
76
76
|
"d3-force": "^3.0.0",
|
|
77
77
|
"eslint": "^9.26.0",
|
|
78
|
-
"eslint-config-prettier": "^10.1.
|
|
79
|
-
"eslint-plugin-svelte": "3.
|
|
78
|
+
"eslint-config-prettier": "^10.1.5",
|
|
79
|
+
"eslint-plugin-svelte": "3.7.0",
|
|
80
80
|
"jsdom": "^26.1.0",
|
|
81
81
|
"prettier": "^3.5.3",
|
|
82
|
-
"prettier-plugin-svelte": "^3.
|
|
82
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
83
83
|
"remark-code-extra": "^1.0.1",
|
|
84
84
|
"remark-code-frontmatter": "^1.0.0",
|
|
85
85
|
"resize-observer-polyfill": "^1.5.1",
|
|
86
|
-
"sass": "^1.
|
|
87
|
-
"svelte-check": "^4.1
|
|
88
|
-
"svelte-eslint-parser": "1.
|
|
86
|
+
"sass": "^1.89.0",
|
|
87
|
+
"svelte-check": "^4.2.1",
|
|
88
|
+
"svelte-eslint-parser": "1.2.0",
|
|
89
89
|
"svelte-highlight": "^7.8.3",
|
|
90
|
+
"svg-path-parser": "^1.1.0",
|
|
90
91
|
"topojson-client": "^3.1.0",
|
|
91
92
|
"tslib": "^2.8.1",
|
|
92
93
|
"typedoc": "^0.28.4",
|
|
93
94
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
94
95
|
"typescript": "^5.8.3",
|
|
95
|
-
"vite": "^6.3.
|
|
96
|
-
"vitest": "^3.1.
|
|
96
|
+
"vite": "^6.3.5",
|
|
97
|
+
"vitest": "^3.1.3",
|
|
98
|
+
"vitest-matchmedia-mock": "^2.0.3"
|
|
97
99
|
},
|
|
98
100
|
"types": "./dist/index.d.ts",
|
|
99
101
|
"type": "module",
|
|
@@ -114,6 +116,6 @@
|
|
|
114
116
|
"es-toolkit": "^1.37.2",
|
|
115
117
|
"fast-equals": "^5.2.2",
|
|
116
118
|
"merge-deep": "^3.0.3",
|
|
117
|
-
"svelte": "5.
|
|
119
|
+
"svelte": "5.30.1"
|
|
118
120
|
}
|
|
119
121
|
}
|