svelteplot 0.2.6-next.5 → 0.2.6
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/resolve.js +7 -4
- package/dist/helpers/scales.js +2 -1
- 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 +8 -14
- package/dist/marks/Line.svelte.d.ts +5 -10
- 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 -4
- 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/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/recordize.js +4 -4
- package/dist/types.d.ts +13 -11
- package/dist/ui/RadioInput.svelte +1 -1
- package/dist/ui/Select.svelte +1 -1
- package/package.json +117 -118
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type ColorLegendMarkProps = {
|
|
3
|
+
class: string | null;
|
|
4
|
+
};
|
|
5
|
+
</script>
|
|
6
|
+
|
|
1
7
|
<script lang="ts">
|
|
2
8
|
import { getContext } from 'svelte';
|
|
3
9
|
import { Plot, AxisX, Frame } from '../index.js';
|
|
@@ -7,11 +13,7 @@
|
|
|
7
13
|
|
|
8
14
|
import type { DefaultOptions, PlotContext } from '../types.js';
|
|
9
15
|
|
|
10
|
-
let {
|
|
11
|
-
width = 250,
|
|
12
|
-
tickSpacing = 30,
|
|
13
|
-
class: className = null
|
|
14
|
-
}: { width?: number; tickSpacing?: number; class?: string } = $props();
|
|
16
|
+
let { class: className = null }: ColorLegendMarkProps = $props();
|
|
15
17
|
|
|
16
18
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
17
19
|
const plot = $derived(getPlotState());
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
<div class="title">{@html legendTitle}</div>
|
|
46
48
|
{/if}
|
|
47
49
|
{#if scaleType === 'ordinal' || scaleType === 'categorical'}
|
|
48
|
-
{#each plot.scales.color.domain as value}
|
|
50
|
+
{#each plot.scales.color.domain as value (value)}
|
|
49
51
|
{@const symbolV = plot.scales.symbol.fn(value)}
|
|
50
52
|
{@const symbolType = maybeSymbol(symbolV)}
|
|
51
53
|
<div class="item">
|
|
@@ -98,7 +100,7 @@
|
|
|
98
100
|
<defs>
|
|
99
101
|
<linearGradient id="gradient-{randId}" x2="1">
|
|
100
102
|
<stop offset="0%" stop-color={range[0]} />
|
|
101
|
-
{#each ticks as t, i}
|
|
103
|
+
{#each ticks as t, i (i)}
|
|
102
104
|
{@const offset = (100 * (t - domain[0])) / (domain[1] - domain[0])}
|
|
103
105
|
<stop
|
|
104
106
|
offset="{offset - 0.001}%"
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
x={{ domain, tickSpacing, tickFormat }}>
|
|
131
133
|
<defs>
|
|
132
134
|
<linearGradient id="gradient-{randId}" x2="1">
|
|
133
|
-
{#each ticks as t}
|
|
135
|
+
{#each ticks as t (t)}
|
|
134
136
|
<stop
|
|
135
137
|
offset="{(100 * (t - domain[0])) / (domain[1] - domain[0])}%"
|
|
136
138
|
stop-color={plot.scales.color.fn(t)} />
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
tickSpacing?: number;
|
|
4
|
-
class?: string;
|
|
1
|
+
export type ColorLegendMarkProps = {
|
|
2
|
+
class: string | null;
|
|
5
3
|
};
|
|
6
4
|
/**
|
|
7
5
|
* The ColorLegend is an HTML mark that can be placed in the header, footer and overlay
|
|
8
6
|
* snippets. You can activate an implicit ColorLegend above the chart using the global
|
|
9
7
|
* color.legend scale option.
|
|
10
8
|
*/
|
|
11
|
-
declare const ColorLegend: import("svelte").Component
|
|
9
|
+
declare const ColorLegend: import("svelte").Component<ColorLegendMarkProps, {}, "">;
|
|
12
10
|
type ColorLegend = ReturnType<typeof ColorLegend>;
|
|
13
11
|
export default ColorLegend;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
32
|
<GroupMultiple class="g-custom-mark {className || ''}" length={className ? 2 : data.length}>
|
|
33
|
-
{#each data as datum}
|
|
33
|
+
{#each data as datum, i (i)}
|
|
34
34
|
{@const x_ = resolveChannel('x', datum, { x, y })}
|
|
35
35
|
{@const y_ = resolveChannel('y', datum, { x, y })}
|
|
36
36
|
{#if isValid(x_) && isValid(y_)}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
BaseMarkProps,
|
|
4
|
-
ChannelAccessor,
|
|
5
|
-
CurveName,
|
|
6
|
-
DataRecord,
|
|
7
|
-
PlotContext
|
|
8
|
-
} from '../types.js';
|
|
9
|
-
import { Line, Area } from '../index.js';
|
|
10
|
-
import { randomId, coalesce } from '../helpers/index.js';
|
|
11
|
-
import { getContext } from 'svelte';
|
|
12
|
-
import { extent, max, min } from 'd3-array';
|
|
13
|
-
import { resolveChannel } from '../helpers/resolve.js';
|
|
14
|
-
import type { CurveFactory } from 'd3-shape';
|
|
15
|
-
|
|
16
|
-
type DifferenceYMarkProps = {
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type DifferenceYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
17
3
|
data: DataRecord[];
|
|
18
4
|
/*
|
|
19
5
|
* the horizontal position of the comparison; bound to the x scale
|
|
@@ -33,14 +19,30 @@
|
|
|
33
19
|
*/
|
|
34
20
|
y2: ChannelAccessor;
|
|
35
21
|
y: ChannelAccessor;
|
|
22
|
+
fillOpacity?: number;
|
|
36
23
|
positiveFill?: string;
|
|
37
24
|
positiveFillOpacity?: number;
|
|
38
25
|
negativeFill?: string;
|
|
39
26
|
negativeFillOpacity?: number;
|
|
40
|
-
stroke: boolean | ChannelAccessor;
|
|
41
27
|
curve?: CurveName | CurveFactory;
|
|
42
28
|
tension?: number;
|
|
43
|
-
}
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import type {
|
|
34
|
+
BaseMarkProps,
|
|
35
|
+
ChannelAccessor,
|
|
36
|
+
CurveName,
|
|
37
|
+
DataRecord,
|
|
38
|
+
PlotContext
|
|
39
|
+
} from '../types.js';
|
|
40
|
+
import { Line, Area } from '../index.js';
|
|
41
|
+
import { randomId, coalesce } from '../helpers/index.js';
|
|
42
|
+
import { getContext } from 'svelte';
|
|
43
|
+
import { extent, max, min } from 'd3-array';
|
|
44
|
+
import { resolveChannel } from '../helpers/resolve.js';
|
|
45
|
+
import type { CurveFactory } from 'd3-shape';
|
|
44
46
|
|
|
45
47
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
46
48
|
let plot = $derived(getPlotState());
|
|
@@ -105,7 +107,7 @@
|
|
|
105
107
|
data={croppedX1}
|
|
106
108
|
{...options}
|
|
107
109
|
fill={options.positiveFill || 'pink'}
|
|
108
|
-
fillOpacity={coalesce(options.positiveFillOpacity, 1)}
|
|
110
|
+
fillOpacity={coalesce(options.positiveFillOpacity, options.fillOpacity, 1)}
|
|
109
111
|
x1={coalesce(x1, x2, x)}
|
|
110
112
|
y1={{ scale: null, value: 0 }}
|
|
111
113
|
y2={coalesce(y1, x1x2Differ ? coalesce(y2, y) : 0)} />
|
|
@@ -127,7 +129,7 @@
|
|
|
127
129
|
data={croppedX2}
|
|
128
130
|
{...options}
|
|
129
131
|
fill={options.negativeFill || 'cyan'}
|
|
130
|
-
fillOpacity={coalesce(options.negativeFillOpacity, 1)}
|
|
132
|
+
fillOpacity={coalesce(options.negativeFillOpacity, options.fillOpacity, 1)}
|
|
131
133
|
x1={coalesce(x2, x)}
|
|
132
134
|
y1={{ scale: null, value: 0 }}
|
|
133
135
|
y2={coalesce(y2, y)} />
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CurveFactory } from 'd3-shape';
|
|
3
|
-
type DifferenceYMarkProps = {
|
|
1
|
+
export type DifferenceYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
4
2
|
data: DataRecord[];
|
|
5
3
|
x1: ChannelAccessor;
|
|
6
4
|
/**
|
|
@@ -17,14 +15,16 @@ type DifferenceYMarkProps = {
|
|
|
17
15
|
*/
|
|
18
16
|
y2: ChannelAccessor;
|
|
19
17
|
y: ChannelAccessor;
|
|
18
|
+
fillOpacity?: number;
|
|
20
19
|
positiveFill?: string;
|
|
21
20
|
positiveFillOpacity?: number;
|
|
22
21
|
negativeFill?: string;
|
|
23
22
|
negativeFillOpacity?: number;
|
|
24
|
-
stroke: boolean | ChannelAccessor;
|
|
25
23
|
curve?: CurveName | CurveFactory;
|
|
26
24
|
tension?: number;
|
|
27
|
-
}
|
|
25
|
+
};
|
|
26
|
+
import type { BaseMarkProps, ChannelAccessor, CurveName, DataRecord } from '../types.js';
|
|
27
|
+
import type { CurveFactory } from 'd3-shape';
|
|
28
28
|
declare const DifferenceY: import("svelte").Component<DifferenceYMarkProps, {}, "">;
|
|
29
29
|
type DifferenceY = ReturnType<typeof DifferenceY>;
|
|
30
30
|
export default DifferenceY;
|
package/dist/marks/Dot.svelte
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates dots or symbols at specified positions with customizable size and appearance
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type DotMarkProps = BaseMarkProps & {
|
|
6
|
+
data: DataRecord[];
|
|
7
|
+
x: ChannelAccessor;
|
|
8
|
+
y: ChannelAccessor;
|
|
9
|
+
r?: ChannelAccessor;
|
|
10
|
+
symbol?: ChannelAccessor | Snippet<[number, string]>;
|
|
11
|
+
canvas?: boolean;
|
|
12
|
+
dotClass?: ConstantAccessor<string>;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
import { getContext, type Snippet } from 'svelte';
|
|
3
18
|
import type {
|
|
@@ -19,38 +34,13 @@
|
|
|
19
34
|
import { recordizeXY } from '../transforms/recordize.js';
|
|
20
35
|
import { addEventHandlers } from './helpers/events.js';
|
|
21
36
|
|
|
22
|
-
type DotProps = BaseMarkProps & {
|
|
23
|
-
data: DataRecord[];
|
|
24
|
-
x: ChannelAccessor;
|
|
25
|
-
y: ChannelAccessor;
|
|
26
|
-
r?: ChannelAccessor;
|
|
27
|
-
fill?: ChannelAccessor;
|
|
28
|
-
stroke?: ChannelAccessor;
|
|
29
|
-
symbol?: ChannelAccessor | Snippet<[number, string]>;
|
|
30
|
-
children?: Snippet;
|
|
31
|
-
dx?: ConstantAccessor<number>;
|
|
32
|
-
dy?: ConstantAccessor<number>;
|
|
33
|
-
canvas?: boolean;
|
|
34
|
-
dotClass?: ConstantAccessor<string>;
|
|
35
|
-
in?: any;
|
|
36
|
-
inParams?: any;
|
|
37
|
-
out?: any;
|
|
38
|
-
outParams?: any;
|
|
39
|
-
transition?: any;
|
|
40
|
-
wrap?: Snippet;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
37
|
let {
|
|
44
38
|
data = [{}],
|
|
45
39
|
canvas = false,
|
|
46
40
|
class: className = '',
|
|
47
41
|
dotClass = null,
|
|
48
|
-
in: tIn = undefined,
|
|
49
|
-
inParams = undefined,
|
|
50
|
-
out: tOut = undefined,
|
|
51
|
-
outParams = undefined,
|
|
52
42
|
...options
|
|
53
|
-
}:
|
|
43
|
+
}: DotMarkProps = $props();
|
|
54
44
|
|
|
55
45
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
56
46
|
const plot = $derived(getPlotState());
|
|
@@ -98,7 +88,7 @@
|
|
|
98
88
|
{#if canvas}
|
|
99
89
|
<DotCanvas data={scaledData} {mark} />
|
|
100
90
|
{:else}
|
|
101
|
-
{#each scaledData as d}
|
|
91
|
+
{#each scaledData as d, i (i)}
|
|
102
92
|
{#if d.valid && isValid(d.r)}
|
|
103
93
|
{@const [style, styleClass] = resolveStyles(
|
|
104
94
|
plot,
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
3
|
-
type DotProps = BaseMarkProps & {
|
|
1
|
+
export type DotMarkProps = BaseMarkProps & {
|
|
4
2
|
data: DataRecord[];
|
|
5
3
|
x: ChannelAccessor;
|
|
6
4
|
y: ChannelAccessor;
|
|
7
5
|
r?: ChannelAccessor;
|
|
8
|
-
fill?: ChannelAccessor;
|
|
9
|
-
stroke?: ChannelAccessor;
|
|
10
6
|
symbol?: ChannelAccessor | Snippet<[number, string]>;
|
|
11
|
-
children?: Snippet;
|
|
12
|
-
dx?: ConstantAccessor<number>;
|
|
13
|
-
dy?: ConstantAccessor<number>;
|
|
14
7
|
canvas?: boolean;
|
|
15
8
|
dotClass?: ConstantAccessor<string>;
|
|
16
|
-
in?: any;
|
|
17
|
-
inParams?: any;
|
|
18
|
-
out?: any;
|
|
19
|
-
outParams?: any;
|
|
20
|
-
transition?: any;
|
|
21
|
-
wrap?: Snippet;
|
|
22
9
|
};
|
|
23
|
-
|
|
10
|
+
import { type Snippet } from 'svelte';
|
|
11
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
12
|
+
/** Creates dots or symbols at specified positions with customizable size and appearance */
|
|
13
|
+
declare const Dot: import("svelte").Component<DotMarkProps, {}, "">;
|
|
24
14
|
type Dot = ReturnType<typeof Dot>;
|
|
25
15
|
export default Dot;
|
package/dist/marks/DotX.svelte
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a horizontal dot plot with x values along a single y position
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type DotXMarkProps = Omit<DotMarkProps, 'y'>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
|
-
import Dot from './Dot.svelte';
|
|
9
|
+
import Dot, { type DotMarkProps } from './Dot.svelte';
|
|
3
10
|
import { recordizeX } from '../index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type { ChannelAccessor } from '../types.js';
|
|
6
|
-
|
|
7
|
-
type DotXProps = BaseMarkProps & {
|
|
8
|
-
data: DataRow[];
|
|
9
|
-
x?: ChannelAccessor;
|
|
10
|
-
};
|
|
11
|
+
import type { DataRow } from '../types.js';
|
|
11
12
|
|
|
12
|
-
let { data = [{}], ...options }:
|
|
13
|
+
let { data = [{}], ...options }: DotXMarkProps = $props();
|
|
13
14
|
|
|
14
15
|
const args = $derived(recordizeX({ data, ...options, y: 1 }, { withIndex: false }));
|
|
15
16
|
</script>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
x?: ChannelAccessor;
|
|
6
|
-
};
|
|
7
|
-
declare const DotX: import("svelte").Component<DotXProps, {}, "">;
|
|
1
|
+
export type DotXMarkProps = Omit<DotMarkProps, 'y'>;
|
|
2
|
+
import { type DotMarkProps } from './Dot.svelte';
|
|
3
|
+
/** Creates a horizontal dot plot with x values along a single y position */
|
|
4
|
+
declare const DotX: import("svelte").Component<DotXMarkProps, {}, "">;
|
|
8
5
|
type DotX = ReturnType<typeof DotX>;
|
|
9
6
|
export default DotX;
|
package/dist/marks/DotY.svelte
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a vertical dot plot with y values along a single x position
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type DotYMarkProps = Omit<DotMarkProps, 'y'>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
|
-
import Dot from './Dot.svelte';
|
|
9
|
+
import Dot, { type DotMarkProps } from './Dot.svelte';
|
|
3
10
|
import { recordizeY } from '../index.js';
|
|
4
11
|
|
|
5
|
-
let { data = [{}], ...options } = $props();
|
|
12
|
+
let { data = [{}], ...options }: DotYMarkProps = $props();
|
|
6
13
|
|
|
7
14
|
const args = $derived(recordizeY({ data, ...options, x: 0 }, { withIndex: false }));
|
|
8
15
|
</script>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type DotYMarkProps = Omit<DotMarkProps, 'y'>;
|
|
2
|
+
import { type DotMarkProps } from './Dot.svelte';
|
|
3
|
+
/** Creates a vertical dot plot with y values along a single x position */
|
|
4
|
+
declare const DotY: import("svelte").Component<DotYMarkProps, {}, "">;
|
|
4
5
|
type DotY = ReturnType<typeof DotY>;
|
|
5
6
|
export default DotY;
|
package/dist/marks/Frame.svelte
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Renders a simple frame around the entire plot domain
|
|
4
|
+
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type FrameMarkProps = Omit<
|
|
7
|
+
BaseMarkProps,
|
|
8
|
+
'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'
|
|
9
|
+
> &
|
|
10
10
|
Omit<
|
|
11
11
|
BaseRectMarkProps,
|
|
12
12
|
'inset' | 'insetLeft' | 'insetRight' | 'insetTop' | 'insetBottom'
|
|
13
13
|
> & {
|
|
14
|
+
fill: string;
|
|
15
|
+
stroke: string;
|
|
16
|
+
fillOpacity: number;
|
|
17
|
+
strokeOpacity: number;
|
|
14
18
|
automatic?: boolean;
|
|
15
19
|
inset?: number;
|
|
16
20
|
insetLeft?: number;
|
|
@@ -18,33 +22,40 @@
|
|
|
18
22
|
insetTop?: number;
|
|
19
23
|
insetBottom?: number;
|
|
20
24
|
};
|
|
25
|
+
</script>
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
import Mark from '../Mark.svelte';
|
|
29
|
+
import { getContext } from 'svelte';
|
|
30
|
+
import type { PlotContext, BaseRectMarkProps } from '../types.js';
|
|
31
|
+
import type { BaseMarkProps } from '../types.js';
|
|
32
|
+
import RectPath from './helpers/RectPath.svelte';
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
automatic,
|
|
36
|
+
class: className = 'frame',
|
|
37
|
+
fill,
|
|
38
|
+
stroke,
|
|
39
|
+
fillOpacity,
|
|
40
|
+
strokeOpacity,
|
|
41
|
+
...options
|
|
42
|
+
}: FrameMarkProps = $props();
|
|
23
43
|
|
|
24
44
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
25
45
|
const plot = $derived(getPlotState());
|
|
26
|
-
|
|
27
|
-
const dx = $derived(resolveProp(options.dx, null, 0));
|
|
28
|
-
const dy = $derived(resolveProp(options.dy, null, 0));
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
insetLeft = options.inset || 0,
|
|
32
|
-
insetTop = options.inset || 0,
|
|
33
|
-
insetRight = options.inset || 0,
|
|
34
|
-
insetBottom = options.inset || 0
|
|
35
|
-
} = $derived(options);
|
|
36
46
|
</script>
|
|
37
47
|
|
|
38
48
|
<Mark type="frame" {automatic}>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
{#snippet children({ usedScales })}
|
|
50
|
+
<RectPath
|
|
51
|
+
class={className}
|
|
52
|
+
datum={{ fill, stroke, fillOpacity, strokeOpacity, datum: {}, valid: true }}
|
|
53
|
+
x={plot.options.marginLeft}
|
|
54
|
+
y={plot.options.marginTop}
|
|
55
|
+
width={plot.facetWidth}
|
|
56
|
+
height={plot.facetHeight}
|
|
57
|
+
{usedScales}
|
|
58
|
+
fallbackStyle="stroke"
|
|
59
|
+
options={{ ...options, fill, stroke, fillOpacity, strokeOpacity }} />
|
|
60
|
+
{/snippet}
|
|
50
61
|
</Mark>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type FrameMarkProps = Omit<BaseMarkProps, 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'> & Omit<BaseRectMarkProps, 'inset' | 'insetLeft' | 'insetRight' | 'insetTop' | 'insetBottom'> & {
|
|
2
|
+
fill: string;
|
|
3
|
+
stroke: string;
|
|
4
|
+
fillOpacity: number;
|
|
5
|
+
strokeOpacity: number;
|
|
4
6
|
automatic?: boolean;
|
|
5
7
|
inset?: number;
|
|
6
8
|
insetLeft?: number;
|
|
@@ -8,6 +10,9 @@ type FrameMarkProps = BaseMarkProps & Omit<BaseRectMarkProps, 'inset' | 'insetLe
|
|
|
8
10
|
insetTop?: number;
|
|
9
11
|
insetBottom?: number;
|
|
10
12
|
};
|
|
13
|
+
import type { BaseRectMarkProps } from '../types.js';
|
|
14
|
+
import type { BaseMarkProps } from '../types.js';
|
|
15
|
+
/** Renders a simple frame around the entire plot domain */
|
|
11
16
|
declare const Frame: import("svelte").Component<FrameMarkProps, {}, "">;
|
|
12
17
|
type Frame = ReturnType<typeof Frame>;
|
|
13
18
|
export default Frame;
|
package/dist/marks/Geo.svelte
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders geographical data using projections and GeoJSON geometries
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type GeoMarkProps = {
|
|
6
|
+
data: DataRecord[];
|
|
7
|
+
geoType?: 'sphere' | 'graticule';
|
|
8
|
+
dragRotate: boolean;
|
|
9
|
+
canvas: boolean;
|
|
10
|
+
href: ConstantAccessor<string>;
|
|
11
|
+
target: ConstantAccessor<string>;
|
|
12
|
+
} & BaseMarkProps &
|
|
13
|
+
LinkableMarkProps;
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
import { getContext } from 'svelte';
|
|
3
18
|
import type {
|
|
4
19
|
DataRecord,
|
|
5
20
|
PlotContext,
|
|
6
21
|
BaseMarkProps,
|
|
7
|
-
ConstantAccessor
|
|
22
|
+
ConstantAccessor,
|
|
23
|
+
LinkableMarkProps
|
|
8
24
|
} from '../types.js';
|
|
9
25
|
import Mark from '../Mark.svelte';
|
|
10
26
|
import { geoPath } from 'd3-geo';
|
|
@@ -19,15 +35,6 @@
|
|
|
19
35
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
20
36
|
const plot = $derived(getPlotState());
|
|
21
37
|
|
|
22
|
-
type GeoMarkProps = {
|
|
23
|
-
data: DataRecord[];
|
|
24
|
-
geoType?: 'sphere' | 'graticule';
|
|
25
|
-
dragRotate: boolean;
|
|
26
|
-
canvas: boolean;
|
|
27
|
-
href: ConstantAccessor<string>;
|
|
28
|
-
target: ConstantAccessor<string>;
|
|
29
|
-
} & BaseMarkProps;
|
|
30
|
-
|
|
31
38
|
let {
|
|
32
39
|
data = [{}],
|
|
33
40
|
canvas = false,
|
|
@@ -90,7 +97,7 @@
|
|
|
90
97
|
{#if canvas}
|
|
91
98
|
<GeoCanvas data={scaledData} {path} {mark} {usedScales} />
|
|
92
99
|
{:else}
|
|
93
|
-
{#each scaledData as d}
|
|
100
|
+
{#each scaledData as d, i (i)}
|
|
94
101
|
{#if d.valid}
|
|
95
102
|
{#if options.href}
|
|
96
103
|
<a
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
type GeoMarkProps = {
|
|
1
|
+
export type GeoMarkProps = {
|
|
3
2
|
data: DataRecord[];
|
|
4
3
|
geoType?: 'sphere' | 'graticule';
|
|
5
4
|
dragRotate: boolean;
|
|
6
5
|
canvas: boolean;
|
|
7
6
|
href: ConstantAccessor<string>;
|
|
8
7
|
target: ConstantAccessor<string>;
|
|
9
|
-
} & BaseMarkProps;
|
|
8
|
+
} & BaseMarkProps & LinkableMarkProps;
|
|
9
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, LinkableMarkProps } from '../types.js';
|
|
10
|
+
/** Renders geographical data using projections and GeoJSON geometries */
|
|
10
11
|
declare const Geo: import("svelte").Component<GeoMarkProps, {}, "">;
|
|
11
12
|
type Geo = ReturnType<typeof Geo>;
|
|
12
13
|
export default Geo;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders a geographic graticule grid with customizable step sizes
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
import type { DefaultOptions, BaseMarkProps } from '../types.js';
|
|
6
|
+
export type GraticuleMarkProps = Omit<
|
|
7
|
+
BaseMarkProps,
|
|
8
|
+
'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target' | 'cursor'
|
|
9
|
+
> & {
|
|
10
|
+
step?: number;
|
|
11
|
+
stepX?: number;
|
|
12
|
+
stepY?: number;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
import Geo from './Geo.svelte';
|
|
3
18
|
import { geoGraticule } from 'd3-geo';
|
|
4
|
-
import type { DefaultOptions, BaseMarkProps } from '../types.js';
|
|
5
|
-
|
|
6
19
|
import { getContext } from 'svelte';
|
|
7
20
|
|
|
8
21
|
const DEFAULTS = {
|
|
@@ -10,12 +23,6 @@
|
|
|
10
23
|
...getContext<Partial<DefaultOptions>>('svelteplot/defaults')
|
|
11
24
|
};
|
|
12
25
|
|
|
13
|
-
type GraticuleMarkProps = BaseMarkProps & {
|
|
14
|
-
step?: number;
|
|
15
|
-
stepX?: number;
|
|
16
|
-
stepY?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
26
|
let { step = DEFAULTS.graticuleStep, stepX, stepY, ...options }: GraticuleMarkProps = $props();
|
|
20
27
|
|
|
21
28
|
let graticule = $derived.by(() => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BaseMarkProps } from '../types.js';
|
|
2
|
-
type GraticuleMarkProps = BaseMarkProps & {
|
|
2
|
+
export type GraticuleMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target' | 'cursor'> & {
|
|
3
3
|
step?: number;
|
|
4
4
|
stepX?: number;
|
|
5
5
|
stepY?: number;
|
|
6
6
|
};
|
|
7
|
+
/** Renders a geographic graticule grid with customizable step sizes */
|
|
7
8
|
declare const Graticule: import("svelte").Component<GraticuleMarkProps, {}, "">;
|
|
8
9
|
type Graticule = ReturnType<typeof Graticule>;
|
|
9
10
|
export default Graticule;
|
package/dist/marks/GridX.svelte
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders vertical gridlines at x-axis tick positions
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type GridXMarkProps = 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,11 +17,6 @@
|
|
|
7
17
|
import { testFilter } from '../helpers/index.js';
|
|
8
18
|
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
9
19
|
|
|
10
|
-
type GridXMarkProps = BaseMarkProps & {
|
|
11
|
-
data?: RawValue[];
|
|
12
|
-
automatic?: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
20
|
let { data = [], automatic = false, ...options }: GridXMarkProps = $props();
|
|
16
21
|
|
|
17
22
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -45,7 +50,7 @@
|
|
|
45
50
|
{automatic}>
|
|
46
51
|
{#snippet children({ usedScales })}
|
|
47
52
|
<g class="grid-x">
|
|
48
|
-
{#each ticks as tick}
|
|
53
|
+
{#each ticks as tick, t (t)}
|
|
49
54
|
{#if testFilter(tick, options)}
|
|
50
55
|
{@const x =
|
|
51
56
|
plot.scales.x.fn(tick) +
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
type GridXMarkProps = BaseMarkProps & {
|
|
1
|
+
export type GridXMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data?: RawValue[];
|
|
4
3
|
automatic?: boolean;
|
|
5
4
|
};
|
|
5
|
+
import type { BaseMarkProps, RawValue } from '../types.js';
|
|
6
|
+
/** Renders vertical gridlines at x-axis tick positions */
|
|
6
7
|
declare const GridX: import("svelte").Component<GridXMarkProps, {}, "">;
|
|
7
8
|
type GridX = ReturnType<typeof GridX>;
|
|
8
9
|
export default GridX;
|