svelteplot 0.2.6-next.5 → 0.2.6-pr-67.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/Mark.svelte +1 -1
- package/dist/Plot.svelte +1 -1
- package/dist/core/FacetGrid.svelte +2 -2
- package/dist/core/Plot.svelte +1 -0
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/resolve.js +7 -4
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/scales.js +2 -1
- package/dist/helpers/time.d.ts +4 -3
- package/dist/helpers/time.js +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +17 -23
- package/dist/marks/Area.svelte.d.ts +9 -17
- package/dist/marks/AreaX.svelte +7 -6
- package/dist/marks/AreaX.svelte.d.ts +7 -6
- package/dist/marks/AreaY.svelte +7 -15
- package/dist/marks/AreaY.svelte.d.ts +7 -10
- package/dist/marks/Arrow.svelte +25 -25
- package/dist/marks/Arrow.svelte.d.ts +5 -8
- package/dist/marks/AxisX.svelte +50 -44
- package/dist/marks/AxisX.svelte.d.ts +4 -3
- package/dist/marks/AxisY.svelte +39 -31
- package/dist/marks/AxisY.svelte.d.ts +7 -4
- package/dist/marks/BarX.svelte +27 -12
- package/dist/marks/BarX.svelte.d.ts +17 -1
- package/dist/marks/BarY.svelte +21 -11
- package/dist/marks/BarY.svelte.d.ts +4 -4
- package/dist/marks/BollingerX.svelte +15 -7
- package/dist/marks/BollingerX.svelte.d.ts +3 -3
- package/dist/marks/BollingerY.svelte +9 -7
- package/dist/marks/BollingerY.svelte.d.ts +3 -3
- package/dist/marks/BoxX.svelte +3 -0
- package/dist/marks/BoxX.svelte.d.ts +1 -0
- package/dist/marks/BoxY.svelte +3 -0
- package/dist/marks/BoxY.svelte.d.ts +1 -0
- package/dist/marks/BrushX.svelte +5 -1
- package/dist/marks/BrushX.svelte.d.ts +2 -1
- package/dist/marks/BrushY.svelte +5 -1
- package/dist/marks/BrushY.svelte.d.ts +2 -1
- package/dist/marks/Cell.svelte +18 -21
- package/dist/marks/Cell.svelte.d.ts +3 -9
- package/dist/marks/CellX.svelte +7 -12
- package/dist/marks/CellX.svelte.d.ts +3 -1
- package/dist/marks/CellY.svelte +7 -12
- package/dist/marks/CellY.svelte.d.ts +3 -1
- package/dist/marks/ColorLegend.svelte +10 -8
- package/dist/marks/ColorLegend.svelte.d.ts +3 -5
- package/dist/marks/CustomMark.svelte +1 -1
- package/dist/marks/CustomMarkHTML.svelte +1 -1
- package/dist/marks/DifferenceY.svelte +22 -20
- package/dist/marks/DifferenceY.svelte.d.ts +5 -5
- package/dist/marks/Dot.svelte +17 -27
- package/dist/marks/Dot.svelte.d.ts +5 -15
- package/dist/marks/DotX.svelte +10 -9
- package/dist/marks/DotX.svelte.d.ts +4 -7
- package/dist/marks/DotY.svelte +9 -2
- package/dist/marks/DotY.svelte.d.ts +4 -3
- package/dist/marks/Frame.svelte +42 -31
- package/dist/marks/Frame.svelte.d.ts +8 -3
- package/dist/marks/Geo.svelte +18 -11
- package/dist/marks/Geo.svelte.d.ts +4 -3
- package/dist/marks/Graticule.svelte +15 -8
- package/dist/marks/Graticule.svelte.d.ts +2 -1
- package/dist/marks/GridX.svelte +11 -6
- package/dist/marks/GridX.svelte.d.ts +3 -2
- package/dist/marks/GridY.svelte +11 -3
- package/dist/marks/GridY.svelte.d.ts +3 -2
- package/dist/marks/HTMLTooltip.svelte +2 -1
- package/dist/marks/HTMLTooltip.svelte.d.ts +4 -0
- package/dist/marks/Line.svelte +9 -19
- package/dist/marks/Line.svelte.d.ts +6 -11
- package/dist/marks/LineX.svelte +5 -2
- package/dist/marks/LineX.svelte.d.ts +3 -2
- package/dist/marks/LineY.svelte +5 -2
- package/dist/marks/LineY.svelte.d.ts +3 -2
- package/dist/marks/Link.svelte +20 -19
- package/dist/marks/Link.svelte.d.ts +6 -6
- package/dist/marks/Rect.svelte +15 -12
- package/dist/marks/Rect.svelte.d.ts +3 -3
- package/dist/marks/RectX.svelte +10 -20
- package/dist/marks/RectX.svelte.d.ts +6 -12
- package/dist/marks/RectY.svelte +10 -20
- package/dist/marks/RectY.svelte.d.ts +6 -12
- package/dist/marks/RegressionX.svelte +10 -2
- package/dist/marks/RegressionX.svelte.d.ts +2 -0
- package/dist/marks/RegressionY.svelte +9 -2
- package/dist/marks/RegressionY.svelte.d.ts +2 -0
- package/dist/marks/RuleX.svelte +16 -13
- package/dist/marks/RuleX.svelte.d.ts +3 -4
- package/dist/marks/RuleY.svelte +16 -13
- package/dist/marks/RuleY.svelte.d.ts +3 -4
- package/dist/marks/Sphere.svelte +9 -2
- package/dist/marks/Sphere.svelte.d.ts +4 -59
- package/dist/marks/Spike.svelte +9 -1
- package/dist/marks/Spike.svelte.d.ts +2 -0
- package/dist/marks/SymbolLegend.svelte +1 -1
- package/dist/marks/Text.svelte +34 -35
- package/dist/marks/Text.svelte.d.ts +4 -7
- package/dist/marks/TickX.svelte +25 -20
- package/dist/marks/TickX.svelte.d.ts +3 -3
- package/dist/marks/TickY.svelte +25 -20
- package/dist/marks/TickY.svelte.d.ts +3 -3
- package/dist/marks/Vector.svelte +5 -5
- package/dist/marks/Vector.svelte.d.ts +2 -5
- package/dist/marks/helpers/BaseAxisX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/RectPath.svelte +17 -13
- package/dist/marks/helpers/RectPath.svelte.d.ts +1 -0
- package/dist/marks/helpers/events.js +3 -6
- package/dist/transforms/bollinger.d.ts +1 -8
- package/dist/transforms/centroid.d.ts +1 -8
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/index.d.ts +1 -0
- package/dist/transforms/index.js +1 -0
- package/dist/transforms/interval.d.ts +2 -6
- package/dist/transforms/jitter.d.ts +17 -0
- package/dist/transforms/jitter.js +60 -1
- package/dist/transforms/map.d.ts +4 -10
- package/dist/transforms/normalize.d.ts +2 -6
- package/dist/transforms/recordize.js +4 -4
- package/dist/transforms/select.d.ts +7 -21
- package/dist/transforms/sort.d.ts +3 -16
- package/dist/transforms/window.d.ts +2 -14
- package/dist/types.d.ts +13 -11
- package/dist/ui/RadioInput.svelte +1 -1
- package/dist/ui/Select.svelte +1 -1
- package/package.json +9 -9
package/dist/marks/GridY.svelte
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders horizontal gridlines at y-axis tick positions
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type GridYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
6
|
+
data?: RawValue[];
|
|
7
|
+
automatic?: boolean;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
1
11
|
<script lang="ts">
|
|
2
12
|
import { getContext } from 'svelte';
|
|
3
13
|
import Mark from '../Mark.svelte';
|
|
@@ -7,8 +17,6 @@
|
|
|
7
17
|
import { testFilter } from '../helpers/index.js';
|
|
8
18
|
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
9
19
|
|
|
10
|
-
type GridYMarkProps = BaseMarkProps & { data?: RawValue[]; automatic?: boolean };
|
|
11
|
-
|
|
12
20
|
let { data = [], automatic = false, ...options }: GridYMarkProps = $props();
|
|
13
21
|
|
|
14
22
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -42,7 +50,7 @@
|
|
|
42
50
|
{automatic}>
|
|
43
51
|
{#snippet children({ usedScales })}
|
|
44
52
|
<g class="grid-y">
|
|
45
|
-
{#each ticks as tick}
|
|
53
|
+
{#each ticks as tick, t (t)}
|
|
46
54
|
{#if testFilter(tick, options)}
|
|
47
55
|
{@const y =
|
|
48
56
|
plot.scales.y.fn(tick) +
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
type GridYMarkProps = BaseMarkProps & {
|
|
1
|
+
export type GridYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data?: RawValue[];
|
|
4
3
|
automatic?: boolean;
|
|
5
4
|
};
|
|
5
|
+
import type { BaseMarkProps, RawValue } from '../types.js';
|
|
6
|
+
/** Renders horizontal gridlines at y-axis tick positions */
|
|
6
7
|
declare const GridY: import("svelte").Component<GridYMarkProps, {}, "">;
|
|
7
8
|
type GridY = ReturnType<typeof GridY>;
|
|
8
9
|
export default GridY;
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
x?: ChannelAccessor;
|
|
11
11
|
y?: ChannelAccessor;
|
|
12
12
|
r?: ChannelAccessor;
|
|
13
|
+
children: Snippet<[{ datum: DataRow }]>;
|
|
13
14
|
};
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<script lang="ts">
|
|
17
|
-
import { getContext } from 'svelte';
|
|
18
|
+
import { getContext, type Snippet } from 'svelte';
|
|
18
19
|
import type { PlotContext } from '../types.js';
|
|
19
20
|
|
|
20
21
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -4,7 +4,11 @@ export type HTMLTooltipMarkProps = {
|
|
|
4
4
|
x?: ChannelAccessor;
|
|
5
5
|
y?: ChannelAccessor;
|
|
6
6
|
r?: ChannelAccessor;
|
|
7
|
+
children: Snippet<[{
|
|
8
|
+
datum: DataRow;
|
|
9
|
+
}]>;
|
|
7
10
|
};
|
|
11
|
+
import { type Snippet } from 'svelte';
|
|
8
12
|
/** For showing custom HTML tooltips positioned at x/y coordinates */
|
|
9
13
|
declare const HtmlTooltip: import("svelte").Component<HTMLTooltipMarkProps, {}, "">;
|
|
10
14
|
type HtmlTooltip = ReturnType<typeof HtmlTooltip>;
|
package/dist/marks/Line.svelte
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
Line mark, useful for line charts
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates line charts with connecting points in a dataset with customizable curves and markers
|
|
4
3
|
-->
|
|
5
4
|
<script module lang="ts">
|
|
6
5
|
import type {
|
|
@@ -14,16 +13,15 @@
|
|
|
14
13
|
ScaledDataRecord
|
|
15
14
|
} from '../types.js';
|
|
16
15
|
|
|
17
|
-
export type
|
|
16
|
+
export type LineMarkProps = {
|
|
18
17
|
data: DataRecord[];
|
|
18
|
+
x?: ChannelAccessor;
|
|
19
|
+
y?: ChannelAccessor;
|
|
19
20
|
z?: ChannelAccessor;
|
|
20
|
-
stroke?: ChannelAccessor;
|
|
21
21
|
outlineStroke?: string;
|
|
22
22
|
outlineStrokeWidth?: number;
|
|
23
23
|
outlineStrokeOpacity?: number;
|
|
24
|
-
|
|
25
|
-
dy?: ConstantAccessor<number>;
|
|
26
|
-
curve?: CurveName | CurveFactory;
|
|
24
|
+
curve?: CurveName | CurveFactory | 'auto';
|
|
27
25
|
tension?: number;
|
|
28
26
|
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
29
27
|
text?: ConstantAccessor<string>;
|
|
@@ -33,7 +31,8 @@
|
|
|
33
31
|
textStrokeWidth?: ConstantAccessor<number>;
|
|
34
32
|
lineClass?: ConstantAccessor<string>;
|
|
35
33
|
canvas?: boolean;
|
|
36
|
-
} & MarkerOptions
|
|
34
|
+
} & MarkerOptions &
|
|
35
|
+
BaseMarkProps;
|
|
37
36
|
</script>
|
|
38
37
|
|
|
39
38
|
<script lang="ts">
|
|
@@ -48,11 +47,6 @@
|
|
|
48
47
|
import { pick } from 'es-toolkit';
|
|
49
48
|
import LineCanvas from './helpers/LineCanvas.svelte';
|
|
50
49
|
|
|
51
|
-
type LineMarkProps = BaseMarkProps & {
|
|
52
|
-
x?: ChannelAccessor;
|
|
53
|
-
y?: ChannelAccessor;
|
|
54
|
-
} & BaseLineMarkProps;
|
|
55
|
-
|
|
56
50
|
import type { RawValue } from '../types.js';
|
|
57
51
|
import { isValid } from '../helpers/index.js';
|
|
58
52
|
import { sort } from '../transforms/sort.js';
|
|
@@ -82,10 +76,6 @@
|
|
|
82
76
|
if (groupValue === lastGroupValue) {
|
|
83
77
|
group.push(d);
|
|
84
78
|
} else {
|
|
85
|
-
if (group.length === 1) {
|
|
86
|
-
// just one point makes a bad line, add this one, too
|
|
87
|
-
group.push(d);
|
|
88
|
-
}
|
|
89
79
|
// new group
|
|
90
80
|
group = [d];
|
|
91
81
|
groups.push(group);
|
|
@@ -144,7 +134,7 @@
|
|
|
144
134
|
<LineCanvas {groupedLineData} {mark} {usedScales} {linePath} {groupByKey} />
|
|
145
135
|
{:else}
|
|
146
136
|
<g class={['lines', className]}>
|
|
147
|
-
{#each groupedLineData as lineData, i}
|
|
137
|
+
{#each groupedLineData as lineData, i (i)}
|
|
148
138
|
{@const pathString = linePath(lineData)}
|
|
149
139
|
{#if pathString}
|
|
150
140
|
<GroupMultiple class={resolveProp(lineClass, lineData[0])}>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { CurveName, DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, MarkerOptions } from '../types.js';
|
|
2
|
-
export type
|
|
2
|
+
export type LineMarkProps = {
|
|
3
3
|
data: DataRecord[];
|
|
4
|
+
x?: ChannelAccessor;
|
|
5
|
+
y?: ChannelAccessor;
|
|
4
6
|
z?: ChannelAccessor;
|
|
5
|
-
stroke?: ChannelAccessor;
|
|
6
7
|
outlineStroke?: string;
|
|
7
8
|
outlineStrokeWidth?: number;
|
|
8
9
|
outlineStrokeOpacity?: number;
|
|
9
|
-
|
|
10
|
-
dy?: ConstantAccessor<number>;
|
|
11
|
-
curve?: CurveName | CurveFactory;
|
|
10
|
+
curve?: CurveName | CurveFactory | 'auto';
|
|
12
11
|
tension?: number;
|
|
13
12
|
sort?: ConstantAccessor<RawValue> | {
|
|
14
13
|
channel: 'stroke' | 'fill';
|
|
@@ -20,14 +19,10 @@ export type BaseLineMarkProps = {
|
|
|
20
19
|
textStrokeWidth?: ConstantAccessor<number>;
|
|
21
20
|
lineClass?: ConstantAccessor<string>;
|
|
22
21
|
canvas?: boolean;
|
|
23
|
-
} & MarkerOptions;
|
|
22
|
+
} & MarkerOptions & BaseMarkProps;
|
|
24
23
|
import { type CurveFactory } from 'd3-shape';
|
|
25
24
|
import type { RawValue } from '../types.js';
|
|
26
|
-
|
|
27
|
-
x?: ChannelAccessor;
|
|
28
|
-
y?: ChannelAccessor;
|
|
29
|
-
} & BaseLineMarkProps;
|
|
30
|
-
/** Line mark, useful for line charts */
|
|
25
|
+
/** Creates line charts with connecting points in a dataset with customizable curves and markers */
|
|
31
26
|
declare const Line: import("svelte").Component<LineMarkProps, {}, "">;
|
|
32
27
|
type Line = ReturnType<typeof Line>;
|
|
33
28
|
export default Line;
|
package/dist/marks/LineX.svelte
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a horizontal line chart with x values and index positions for y
|
|
3
|
+
-->
|
|
1
4
|
<script lang="ts">
|
|
2
|
-
import Line, { type
|
|
5
|
+
import Line, { type LineMarkProps } from './Line.svelte';
|
|
3
6
|
import { recordizeX } from '../index.js';
|
|
4
7
|
|
|
5
|
-
let { data = [{}], ...rest }:
|
|
8
|
+
let { data = [{}], ...rest }: Omit<LineMarkProps, 'y'> = $props();
|
|
6
9
|
|
|
7
10
|
let args = $derived(recordizeX({ data, ...rest }));
|
|
8
11
|
</script>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type LineMarkProps } from './Line.svelte';
|
|
2
|
+
/** Creates a horizontal line chart with x values and index positions for y */
|
|
3
|
+
declare const LineX: import("svelte").Component<Omit<LineMarkProps, "y">, {}, "">;
|
|
3
4
|
type LineX = ReturnType<typeof LineX>;
|
|
4
5
|
export default LineX;
|
package/dist/marks/LineY.svelte
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a vertical line chart with y values and index positions for x
|
|
3
|
+
-->
|
|
1
4
|
<script lang="ts">
|
|
2
|
-
import Line, { type
|
|
5
|
+
import Line, { type LineMarkProps } from './Line.svelte';
|
|
3
6
|
import { recordizeY } from '../index.js';
|
|
4
7
|
|
|
5
|
-
let { data = [{}], ...rest }:
|
|
8
|
+
let { data = [{}], ...rest }: Omit<LineMarkProps, 'x'> = $props();
|
|
6
9
|
let args = $derived(recordizeY({ data, ...rest }));
|
|
7
10
|
</script>
|
|
8
11
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type LineMarkProps } from './Line.svelte';
|
|
2
|
+
/** Creates a vertical line chart with y values and index positions for x */
|
|
3
|
+
declare const LineY: import("svelte").Component<Omit<LineMarkProps, "x">, {}, "">;
|
|
3
4
|
type LineY = ReturnType<typeof LineY>;
|
|
4
5
|
export default LineY;
|
package/dist/marks/Link.svelte
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates connections between pairs of points with optional curve styling and markers
|
|
3
|
+
-->
|
|
4
|
+
<script lang="ts" module>
|
|
5
|
+
export type LinkMarkProps = BaseMarkProps &
|
|
6
|
+
MarkerOptions & {
|
|
7
|
+
data: DataRecord[];
|
|
8
|
+
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
9
|
+
x1: ChannelAccessor;
|
|
10
|
+
y1: ChannelAccessor;
|
|
11
|
+
x2: ChannelAccessor;
|
|
12
|
+
y2: ChannelAccessor;
|
|
13
|
+
curve?: 'auto' | CurveName | CurveFactory;
|
|
14
|
+
tension?: number;
|
|
15
|
+
text: ConstantAccessor<string>;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
1
20
|
<script lang="ts">
|
|
2
21
|
import { getContext, type Snippet } from 'svelte';
|
|
3
22
|
import type {
|
|
@@ -22,20 +41,6 @@
|
|
|
22
41
|
import { geoPath } from 'd3-geo';
|
|
23
42
|
import { pick } from 'es-toolkit';
|
|
24
43
|
|
|
25
|
-
type LinkMarkProps = BaseMarkProps & {
|
|
26
|
-
data: DataRecord[];
|
|
27
|
-
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
28
|
-
x1: ChannelAccessor;
|
|
29
|
-
y1: ChannelAccessor;
|
|
30
|
-
x2: ChannelAccessor;
|
|
31
|
-
y2: ChannelAccessor;
|
|
32
|
-
stroke?: ChannelAccessor;
|
|
33
|
-
curve?: 'auto' | CurveName | CurveFactory;
|
|
34
|
-
tension?: number;
|
|
35
|
-
text: ConstantAccessor<string>;
|
|
36
|
-
children?: Snippet;
|
|
37
|
-
} & MarkerOptions;
|
|
38
|
-
|
|
39
44
|
let {
|
|
40
45
|
data = [{}],
|
|
41
46
|
curve = 'auto',
|
|
@@ -48,10 +53,6 @@
|
|
|
48
53
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
49
54
|
let plot = $derived(getPlotState());
|
|
50
55
|
|
|
51
|
-
function isValid(value: RawValue): value is number | Date | string {
|
|
52
|
-
return value !== null && (typeof value === 'string' || !Number.isNaN(value));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
56
|
const sorted = $derived(
|
|
56
57
|
options.sort
|
|
57
58
|
? maybeData(data).toSorted((a, b) =>
|
|
@@ -130,7 +131,7 @@
|
|
|
130
131
|
{...args}>
|
|
131
132
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
132
133
|
<g class={['link', className]} data-use-x={usedScales.x ? 1 : 0}>
|
|
133
|
-
{#each scaledData as d}
|
|
134
|
+
{#each scaledData as d, i (i)}
|
|
134
135
|
{#if d.valid || true}
|
|
135
136
|
{@const dx = resolveProp(args.dx, d.datum, 0)}
|
|
136
137
|
{@const dy = resolveProp(args.dx, d.datum, 0)}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, CurveName, MarkerOptions, RawValue } from '../types.js';
|
|
3
|
-
import { type CurveFactory } from 'd3-shape';
|
|
4
|
-
type LinkMarkProps = BaseMarkProps & {
|
|
1
|
+
export type LinkMarkProps = BaseMarkProps & MarkerOptions & {
|
|
5
2
|
data: DataRecord[];
|
|
6
3
|
sort?: ConstantAccessor<RawValue> | {
|
|
7
4
|
channel: 'stroke' | 'fill';
|
|
@@ -10,12 +7,15 @@ type LinkMarkProps = BaseMarkProps & {
|
|
|
10
7
|
y1: ChannelAccessor;
|
|
11
8
|
x2: ChannelAccessor;
|
|
12
9
|
y2: ChannelAccessor;
|
|
13
|
-
stroke?: ChannelAccessor;
|
|
14
10
|
curve?: 'auto' | CurveName | CurveFactory;
|
|
15
11
|
tension?: number;
|
|
16
12
|
text: ConstantAccessor<string>;
|
|
17
13
|
children?: Snippet;
|
|
18
|
-
}
|
|
14
|
+
};
|
|
15
|
+
import { type Snippet } from 'svelte';
|
|
16
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, CurveName, MarkerOptions, RawValue } from '../types.js';
|
|
17
|
+
import { type CurveFactory } from 'd3-shape';
|
|
18
|
+
/** Creates connections between pairs of points with optional curve styling and markers */
|
|
19
19
|
declare const Link: import("svelte").Component<LinkMarkProps, {}, "">;
|
|
20
20
|
type Link = ReturnType<typeof Link>;
|
|
21
21
|
export default Link;
|
package/dist/marks/Rect.svelte
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
@component
|
|
3
3
|
For arbitrary rectangles, requires quantitative x and y scales
|
|
4
4
|
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type RectMarkProps = {
|
|
7
|
+
data: DataRecord[];
|
|
8
|
+
x?: ChannelAccessor;
|
|
9
|
+
x1?: ChannelAccessor;
|
|
10
|
+
x2?: ChannelAccessor;
|
|
11
|
+
y?: ChannelAccessor;
|
|
12
|
+
y1?: ChannelAccessor;
|
|
13
|
+
y2?: ChannelAccessor;
|
|
14
|
+
interval?: number | string;
|
|
15
|
+
} & BaseMarkProps &
|
|
16
|
+
BaseRectMarkProps;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
5
19
|
<script lang="ts">
|
|
6
20
|
import Mark from '../Mark.svelte';
|
|
7
21
|
import { getContext } from 'svelte';
|
|
@@ -16,17 +30,6 @@
|
|
|
16
30
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
17
31
|
import RectPath from './helpers/RectPath.svelte';
|
|
18
32
|
|
|
19
|
-
type RectMarkProps = BaseMarkProps & {
|
|
20
|
-
data: DataRecord[];
|
|
21
|
-
x?: ChannelAccessor;
|
|
22
|
-
x1?: ChannelAccessor;
|
|
23
|
-
x2?: ChannelAccessor;
|
|
24
|
-
y?: ChannelAccessor;
|
|
25
|
-
y1?: ChannelAccessor;
|
|
26
|
-
y2?: ChannelAccessor;
|
|
27
|
-
interval?: number | string;
|
|
28
|
-
} & BaseRectMarkProps;
|
|
29
|
-
|
|
30
33
|
let { data = [{}], class: className = 'rect', ...options }: RectMarkProps = $props();
|
|
31
34
|
|
|
32
35
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -44,7 +47,7 @@
|
|
|
44
47
|
{...args}>
|
|
45
48
|
{#snippet children({ usedScales, scaledData })}
|
|
46
49
|
<GroupMultiple class={scaledData.length > 1 ? className : null} length={scaledData.length}>
|
|
47
|
-
{#each scaledData as d}
|
|
50
|
+
{#each scaledData as d, i (i)}
|
|
48
51
|
{#if d.valid}
|
|
49
52
|
{@const x1 = d.x1 == null ? plot.options.marginLeft : d.x1}
|
|
50
53
|
{@const x2 = d.x2 == null ? plot.options.marginLeft + plot.facetWidth : d.x2}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type RectMarkProps = BaseMarkProps & {
|
|
1
|
+
export type RectMarkProps = {
|
|
3
2
|
data: DataRecord[];
|
|
4
3
|
x?: ChannelAccessor;
|
|
5
4
|
x1?: ChannelAccessor;
|
|
@@ -8,7 +7,8 @@ type RectMarkProps = BaseMarkProps & {
|
|
|
8
7
|
y1?: ChannelAccessor;
|
|
9
8
|
y2?: ChannelAccessor;
|
|
10
9
|
interval?: number | string;
|
|
11
|
-
} & BaseRectMarkProps;
|
|
10
|
+
} & BaseMarkProps & BaseRectMarkProps;
|
|
11
|
+
import type { DataRecord, BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
|
|
12
12
|
/** For arbitrary rectangles, requires quantitative x and y scales */
|
|
13
13
|
declare const Rect: import("svelte").Component<RectMarkProps, {}, "">;
|
|
14
14
|
type Rect = ReturnType<typeof Rect>;
|
package/dist/marks/RectX.svelte
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Convenience wrapper for rectangles oriented along the x axis
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type RectXMarkProps = Omit<RectMarkProps, 'y'> & { stack?: Partial<StackOptions> };
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
|
-
import Rect from './Rect.svelte';
|
|
9
|
+
import Rect, { type RectMarkProps } from './Rect.svelte';
|
|
3
10
|
import { intervalY, stackX, recordizeX } from '../index.js';
|
|
4
|
-
import type {
|
|
5
|
-
DataRecord,
|
|
6
|
-
BaseMarkProps,
|
|
7
|
-
ChannelAccessor,
|
|
8
|
-
BaseRectMarkProps,
|
|
9
|
-
PlotContext
|
|
10
|
-
} from '../types.js';
|
|
11
|
-
import type { StackOptions } from '../transforms/stack.js';
|
|
11
|
+
import type { PlotContext } from '../types.js';
|
|
12
12
|
import { getContext } from 'svelte';
|
|
13
|
-
|
|
14
|
-
type RectXMarkProps = BaseMarkProps & {
|
|
15
|
-
data: DataRecord[];
|
|
16
|
-
x?: ChannelAccessor;
|
|
17
|
-
x1?: ChannelAccessor;
|
|
18
|
-
x2?: ChannelAccessor;
|
|
19
|
-
y1?: ChannelAccessor;
|
|
20
|
-
y2?: ChannelAccessor;
|
|
21
|
-
stack?: StackOptions;
|
|
22
|
-
interval?: number | string;
|
|
23
|
-
} & BaseRectMarkProps;
|
|
13
|
+
import type { StackOptions } from '../transforms/stack';
|
|
24
14
|
|
|
25
15
|
let { data = [{}], stack, ...options }: RectXMarkProps = $props();
|
|
26
16
|
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
x2?: ChannelAccessor;
|
|
8
|
-
y1?: ChannelAccessor;
|
|
9
|
-
y2?: ChannelAccessor;
|
|
10
|
-
stack?: StackOptions;
|
|
11
|
-
interval?: number | string;
|
|
12
|
-
} & BaseRectMarkProps;
|
|
1
|
+
export type RectXMarkProps = Omit<RectMarkProps, 'y'> & {
|
|
2
|
+
stack?: Partial<StackOptions>;
|
|
3
|
+
};
|
|
4
|
+
import { type RectMarkProps } from './Rect.svelte';
|
|
5
|
+
import type { StackOptions } from '../transforms/stack';
|
|
6
|
+
/** Convenience wrapper for rectangles oriented along the x axis */
|
|
13
7
|
declare const RectX: import("svelte").Component<RectXMarkProps, {}, "">;
|
|
14
8
|
type RectX = ReturnType<typeof RectX>;
|
|
15
9
|
export default RectX;
|
package/dist/marks/RectY.svelte
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Convenience wrapper for rectangles oriented along the x axis
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type RectYMarkProps = Omit<RectMarkProps, 'x'> & { stack?: Partial<StackOptions> };
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
|
-
import Rect from './Rect.svelte';
|
|
9
|
+
import Rect, { type RectMarkProps } from './Rect.svelte';
|
|
3
10
|
import { intervalX, stackY, recordizeY } from '../index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
DataRecord,
|
|
7
|
-
BaseMarkProps,
|
|
8
|
-
ChannelAccessor,
|
|
9
|
-
BaseRectMarkProps,
|
|
10
|
-
PlotContext
|
|
11
|
-
} from '../types.js';
|
|
11
|
+
import type { PlotContext } from '../types.js';
|
|
12
12
|
import { getContext } from 'svelte';
|
|
13
|
-
|
|
14
|
-
type RectYMarkProps = BaseMarkProps & {
|
|
15
|
-
data: DataRecord[];
|
|
16
|
-
y?: ChannelAccessor;
|
|
17
|
-
y1?: ChannelAccessor;
|
|
18
|
-
y2?: ChannelAccessor;
|
|
19
|
-
x1?: ChannelAccessor;
|
|
20
|
-
x2?: ChannelAccessor;
|
|
21
|
-
stack?: StackOptions;
|
|
22
|
-
interval?: number | string;
|
|
23
|
-
} & BaseRectMarkProps;
|
|
13
|
+
import type { StackOptions } from '../transforms/stack';
|
|
24
14
|
|
|
25
15
|
let { data = [{}], stack, ...options }: RectYMarkProps = $props();
|
|
26
16
|
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
y2?: ChannelAccessor;
|
|
8
|
-
x1?: ChannelAccessor;
|
|
9
|
-
x2?: ChannelAccessor;
|
|
10
|
-
stack?: StackOptions;
|
|
11
|
-
interval?: number | string;
|
|
12
|
-
} & BaseRectMarkProps;
|
|
1
|
+
export type RectYMarkProps = Omit<RectMarkProps, 'x'> & {
|
|
2
|
+
stack?: Partial<StackOptions>;
|
|
3
|
+
};
|
|
4
|
+
import { type RectMarkProps } from './Rect.svelte';
|
|
5
|
+
import type { StackOptions } from '../transforms/stack';
|
|
6
|
+
/** Convenience wrapper for rectangles oriented along the x axis */
|
|
13
7
|
declare const RectY: import("svelte").Component<RectYMarkProps, {}, "">;
|
|
14
8
|
type RectY = ReturnType<typeof RectY>;
|
|
15
9
|
export default RectY;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Calculates and displays a regression line with x as the dependent variable
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type RegressionXMarkProps = RegressionMarkProps;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<script lang="ts">
|
|
2
10
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
3
11
|
import type { ChannelName } from '../types.js';
|
|
@@ -5,7 +13,7 @@
|
|
|
5
13
|
import Regression, { type RegressionMarkProps } from './helpers/Regression.svelte';
|
|
6
14
|
import { groups as d3Groups } from 'd3-array';
|
|
7
15
|
|
|
8
|
-
let { data = [{}], ...options }:
|
|
16
|
+
let { data = [{}], ...options }: RegressionXMarkProps = $props();
|
|
9
17
|
|
|
10
18
|
let groupBy: ChannelName | null =
|
|
11
19
|
options.stroke != null ? 'stroke' : options.z != null ? 'z' : null;
|
|
@@ -20,7 +28,7 @@
|
|
|
20
28
|
</script>
|
|
21
29
|
|
|
22
30
|
<Mark type="regression">
|
|
23
|
-
{#each groups as group}
|
|
31
|
+
{#each groups as group, g (g)}
|
|
24
32
|
<Regression data={group} dependent="x" {...options} />
|
|
25
33
|
{/each}
|
|
26
34
|
</Mark>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export type RegressionXMarkProps = RegressionMarkProps;
|
|
1
2
|
import { type RegressionMarkProps } from './helpers/Regression.svelte';
|
|
3
|
+
/** Calculates and displays a regression line with x as the dependent variable */
|
|
2
4
|
declare const RegressionX: import("svelte").Component<RegressionMarkProps, {}, "">;
|
|
3
5
|
type RegressionX = ReturnType<typeof RegressionX>;
|
|
4
6
|
export default RegressionX;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Calculates and displays a regression line with y as the dependent variable
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type RegressionYMarkProps = RegressionMarkProps;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
9
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
3
10
|
import type { ChannelName } from '../types.js';
|
|
@@ -5,7 +12,7 @@
|
|
|
5
12
|
import Regression, { type RegressionMarkProps } from './helpers/Regression.svelte';
|
|
6
13
|
import { groups as d3Groups } from 'd3-array';
|
|
7
14
|
|
|
8
|
-
let { data = [{}], ...options }:
|
|
15
|
+
let { data = [{}], ...options }: RegressionYMarkProps = $props();
|
|
9
16
|
|
|
10
17
|
let groupBy: ChannelName | null =
|
|
11
18
|
options.stroke != null ? 'stroke' : options.z != null ? 'z' : null;
|
|
@@ -20,7 +27,7 @@
|
|
|
20
27
|
</script>
|
|
21
28
|
|
|
22
29
|
<Mark type="regression">
|
|
23
|
-
{#each groups as group}
|
|
30
|
+
{#each groups as group, i (i)}
|
|
24
31
|
<Regression data={group} dependent="y" {...options} />
|
|
25
32
|
{/each}
|
|
26
33
|
</Mark>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export type RegressionYMarkProps = RegressionMarkProps;
|
|
1
2
|
import { type RegressionMarkProps } from './helpers/Regression.svelte';
|
|
3
|
+
/** Calculates and displays a regression line with y as the dependent variable */
|
|
2
4
|
declare const RegressionY: import("svelte").Component<RegressionMarkProps, {}, "">;
|
|
3
5
|
type RegressionY = ReturnType<typeof RegressionY>;
|
|
4
6
|
export default RegressionY;
|
package/dist/marks/RuleX.svelte
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders vertical rule lines at specified x positions with customizable vertical range
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type RuleXMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
6
|
+
data: DataRecord[];
|
|
7
|
+
x?: ChannelAccessor;
|
|
8
|
+
y1?: ChannelAccessor;
|
|
9
|
+
y2?: ChannelAccessor;
|
|
10
|
+
inset?: ConstantAccessor<number>;
|
|
11
|
+
insetTop?: ConstantAccessor<number>;
|
|
12
|
+
insetBottom?: ConstantAccessor<number>;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
import Mark from '../Mark.svelte';
|
|
3
18
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
@@ -12,18 +27,6 @@
|
|
|
12
27
|
ChannelAccessor
|
|
13
28
|
} from '../types.js';
|
|
14
29
|
|
|
15
|
-
type RuleXMarkProps = BaseMarkProps & {
|
|
16
|
-
data: DataRecord[];
|
|
17
|
-
x?: ChannelAccessor;
|
|
18
|
-
y1?: ChannelAccessor;
|
|
19
|
-
y2?: ChannelAccessor;
|
|
20
|
-
inset?: ConstantAccessor<number>;
|
|
21
|
-
insetTop?: ConstantAccessor<number>;
|
|
22
|
-
insetBottom?: ConstantAccessor<number>;
|
|
23
|
-
dx?: ConstantAccessor<number>;
|
|
24
|
-
dy?: ConstantAccessor<number>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
30
|
let { data = [{}], class: className = null, ...options }: RuleXMarkProps = $props();
|
|
28
31
|
|
|
29
32
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
<Mark type="ruleX" channels={['x', 'y1', 'y2', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
|
|
35
38
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
36
39
|
<GroupMultiple class="rule-x {className || ''}" length={className ? 2 : scaledData.length}>
|
|
37
|
-
{#each scaledData as d}
|
|
40
|
+
{#each scaledData as d, i (i)}
|
|
38
41
|
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
39
42
|
{@const insetTop = resolveProp(args.insetTop, d.datum, 0)}
|
|
40
43
|
{@const insetBottom = resolveProp(args.insetBottom, d.datum, 0)}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type RuleXMarkProps = BaseMarkProps & {
|
|
1
|
+
export type RuleXMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data: DataRecord[];
|
|
4
3
|
x?: ChannelAccessor;
|
|
5
4
|
y1?: ChannelAccessor;
|
|
@@ -7,9 +6,9 @@ type RuleXMarkProps = BaseMarkProps & {
|
|
|
7
6
|
inset?: ConstantAccessor<number>;
|
|
8
7
|
insetTop?: ConstantAccessor<number>;
|
|
9
8
|
insetBottom?: ConstantAccessor<number>;
|
|
10
|
-
dx?: ConstantAccessor<number>;
|
|
11
|
-
dy?: ConstantAccessor<number>;
|
|
12
9
|
};
|
|
10
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
11
|
+
/** Renders vertical rule lines at specified x positions with customizable vertical range */
|
|
13
12
|
declare const RuleX: import("svelte").Component<RuleXMarkProps, {}, "">;
|
|
14
13
|
type RuleX = ReturnType<typeof RuleX>;
|
|
15
14
|
export default RuleX;
|