svelteplot 0.8.1-pr-298.6 → 0.8.1-pr-301.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 +1 -1
- package/dist/core/Plot.svelte +4 -4
- package/dist/hooks/usePlot.svelte.d.ts +50 -0
- package/dist/hooks/usePlot.svelte.js +87 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/marks/Area.svelte +3 -5
- package/dist/marks/Arrow.svelte +3 -5
- package/dist/marks/AxisX.svelte +2 -3
- package/dist/marks/AxisY.svelte +2 -3
- package/dist/marks/BarX.svelte +2 -4
- package/dist/marks/BarY.svelte +2 -4
- package/dist/marks/Brush.svelte +3 -3
- package/dist/marks/Cell.svelte +2 -4
- package/dist/marks/ColorLegend.svelte +2 -4
- package/dist/marks/CustomMarkHTML.svelte +5 -10
- package/dist/marks/DifferenceY.svelte +3 -5
- package/dist/marks/Dot.svelte +4 -5
- package/dist/marks/Frame.svelte +3 -9
- package/dist/marks/Geo.svelte +3 -5
- package/dist/marks/GridX.svelte +3 -10
- package/dist/marks/GridY.svelte +3 -4
- package/dist/marks/HTMLTooltip.svelte +5 -5
- package/dist/marks/Line.svelte +2 -4
- package/dist/marks/Link.svelte +2 -4
- package/dist/marks/Pointer.svelte +4 -4
- package/dist/marks/Rect.svelte +2 -4
- package/dist/marks/RectX.svelte +4 -4
- package/dist/marks/RectY.svelte +4 -4
- package/dist/marks/RuleX.svelte +2 -4
- package/dist/marks/RuleY.svelte +2 -4
- package/dist/marks/SymbolLegend.svelte +2 -4
- package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
- package/dist/marks/TickX.svelte +2 -3
- package/dist/marks/TickY.svelte +2 -3
- package/dist/marks/Trail.svelte +3 -5
- package/dist/marks/Vector.svelte +3 -4
- package/dist/marks/WaffleX.svelte +2 -3
- package/dist/marks/WaffleY.svelte +2 -4
- package/dist/marks/helpers/AreaCanvas.svelte +2 -4
- package/dist/marks/helpers/Box.svelte +0 -1
- package/dist/marks/helpers/CanvasLayer.svelte +2 -4
- package/dist/marks/helpers/DotCanvas.svelte +3 -5
- package/dist/marks/helpers/GeoCanvas.svelte +2 -4
- package/dist/marks/helpers/LineCanvas.svelte +2 -4
- package/dist/marks/helpers/LinearGradientX.svelte +3 -4
- package/dist/marks/helpers/LinearGradientY.svelte +3 -4
- package/dist/marks/helpers/MarkerPath.svelte +4 -5
- package/dist/marks/helpers/MultilineText.svelte +4 -4
- package/dist/marks/helpers/RectPath.svelte +5 -6
- package/dist/marks/helpers/Regression.svelte +4 -8
- package/dist/marks/helpers/TrailCanvas.svelte +2 -4
- package/dist/marks/helpers/events.d.ts +2 -2
- package/dist/marks/helpers/events.js +4 -4
- package/dist/types/plot.d.ts +1 -0
- package/dist/ui/Spiral.svelte +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SveltePlot
|
|
2
2
|
|
|
3
|
-
 
|
|
3
|
+
  [](https://app.netlify.com/projects/svelteplot/deploys)
|
|
4
4
|
|
|
5
5
|
SveltePlot is a visualization framework based on the [layered grammar of graphics](https://vita.had.co.nz/papers/layered-grammar.html) ideas. It's API is heavily inspired by [Observable Plot](https://github.com/observablehq/plot). Created by Gregor Aisch.
|
|
6
6
|
|
package/dist/core/Plot.svelte
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
import { CHANNEL_SCALE, SCALES } from '../constants.js';
|
|
32
32
|
import { getPlotDefaults, setPlotDefaults } from '../hooks/plotDefaults.js';
|
|
33
33
|
import { maybeNumber } from '../helpers/index.js';
|
|
34
|
+
import { setPlot, usePlot } from '../hooks/usePlot.svelte.js';
|
|
34
35
|
|
|
35
36
|
// automatic margins can be applied by the marks, registered
|
|
36
37
|
// with their respective unique identifier as keys
|
|
@@ -261,11 +262,10 @@
|
|
|
261
262
|
let facetWidth: number | null = $state(null);
|
|
262
263
|
let facetHeight: number | null = $state(null);
|
|
263
264
|
|
|
264
|
-
|
|
265
|
-
let plotState: PlotState = $state(computePlotState());
|
|
265
|
+
let plotState = setPlot(computePlotState());
|
|
266
266
|
|
|
267
267
|
$effect(() => {
|
|
268
|
-
plotState
|
|
268
|
+
plotState.update(computePlotState());
|
|
269
269
|
});
|
|
270
270
|
|
|
271
271
|
function computePlotState() {
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
if (facetHeight !== h) facetHeight = h;
|
|
338
338
|
},
|
|
339
339
|
updatePlotState() {
|
|
340
|
-
plotState
|
|
340
|
+
plotState.update(computePlotState());
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PlotOptions } from '../types/plot';
|
|
2
|
+
import type { PlotScales, PlotState as TPlotState } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal state representation of a Plot.
|
|
5
|
+
*/
|
|
6
|
+
declare class PlotState implements TPlotState {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
options: PlotOptions;
|
|
10
|
+
facetWidth: number;
|
|
11
|
+
facetHeight: number;
|
|
12
|
+
plotWidth: number;
|
|
13
|
+
plotHeight: number;
|
|
14
|
+
scales: PlotScales;
|
|
15
|
+
body: HTMLDivElement;
|
|
16
|
+
/**
|
|
17
|
+
* True if there's a color scale and a symbol scale and both are bound to the same
|
|
18
|
+
* single channel accessor.
|
|
19
|
+
*/
|
|
20
|
+
colorSymbolRedundant: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* True if the plot is using filled dot marks.
|
|
23
|
+
*/
|
|
24
|
+
hasFilledDotMarks: boolean;
|
|
25
|
+
css: ((d: string) => string) | null;
|
|
26
|
+
constructor(state: PlotState);
|
|
27
|
+
update(newState: Partial<PlotState>): void;
|
|
28
|
+
get publicState(): PublicPlotState;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A public-facing wrapper around PlotState that exposes only read-only properties.
|
|
32
|
+
*/
|
|
33
|
+
declare class PublicPlotState {
|
|
34
|
+
#private;
|
|
35
|
+
constructor(plotState: PlotState);
|
|
36
|
+
get width(): number;
|
|
37
|
+
get height(): number;
|
|
38
|
+
get options(): PlotOptions;
|
|
39
|
+
get scales(): PlotScales;
|
|
40
|
+
get plotWidth(): number;
|
|
41
|
+
get plotHeight(): number;
|
|
42
|
+
get facetWidth(): number;
|
|
43
|
+
get facetHeight(): number;
|
|
44
|
+
get body(): HTMLDivElement;
|
|
45
|
+
get colorSymbolRedundant(): boolean;
|
|
46
|
+
get hasFilledDotMarks(): boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare function setPlot(initialState: PlotState): PlotState;
|
|
49
|
+
export declare function usePlot(): Readonly<TPlotState>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { getContext } from 'svelte';
|
|
2
|
+
/**
|
|
3
|
+
* Internal state representation of a Plot.
|
|
4
|
+
*/
|
|
5
|
+
class PlotState {
|
|
6
|
+
// Define properties and methods for PlotState as needed
|
|
7
|
+
width = $state(50);
|
|
8
|
+
height = $state(50);
|
|
9
|
+
options = $state({});
|
|
10
|
+
facetWidth = $state(0);
|
|
11
|
+
facetHeight = $state(0);
|
|
12
|
+
plotWidth = $state(0);
|
|
13
|
+
plotHeight = $state(0);
|
|
14
|
+
scales = $state();
|
|
15
|
+
body = $state();
|
|
16
|
+
/**
|
|
17
|
+
* True if there's a color scale and a symbol scale and both are bound to the same
|
|
18
|
+
* single channel accessor.
|
|
19
|
+
*/
|
|
20
|
+
colorSymbolRedundant = $state(false);
|
|
21
|
+
/**
|
|
22
|
+
* True if the plot is using filled dot marks.
|
|
23
|
+
*/
|
|
24
|
+
hasFilledDotMarks = $state(false);
|
|
25
|
+
css = $state(null);
|
|
26
|
+
constructor(state) {
|
|
27
|
+
// Initialization code here
|
|
28
|
+
Object.assign(this, state);
|
|
29
|
+
}
|
|
30
|
+
update(newState) {
|
|
31
|
+
Object.assign(this, newState);
|
|
32
|
+
}
|
|
33
|
+
get publicState() {
|
|
34
|
+
return new PublicPlotState(this);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A public-facing wrapper around PlotState that exposes only read-only properties.
|
|
39
|
+
*/
|
|
40
|
+
class PublicPlotState {
|
|
41
|
+
#plotState;
|
|
42
|
+
constructor(plotState) {
|
|
43
|
+
this.#plotState = plotState;
|
|
44
|
+
}
|
|
45
|
+
get width() {
|
|
46
|
+
return this.#plotState.width;
|
|
47
|
+
}
|
|
48
|
+
get height() {
|
|
49
|
+
return this.#plotState.height;
|
|
50
|
+
}
|
|
51
|
+
get options() {
|
|
52
|
+
return this.#plotState.options;
|
|
53
|
+
}
|
|
54
|
+
get scales() {
|
|
55
|
+
return this.#plotState.scales;
|
|
56
|
+
}
|
|
57
|
+
get plotWidth() {
|
|
58
|
+
return this.#plotState.plotWidth;
|
|
59
|
+
}
|
|
60
|
+
get plotHeight() {
|
|
61
|
+
return this.#plotState.plotHeight;
|
|
62
|
+
}
|
|
63
|
+
get facetWidth() {
|
|
64
|
+
return this.#plotState.facetWidth;
|
|
65
|
+
}
|
|
66
|
+
get facetHeight() {
|
|
67
|
+
return this.#plotState.facetHeight;
|
|
68
|
+
}
|
|
69
|
+
get body() {
|
|
70
|
+
return this.#plotState.body;
|
|
71
|
+
}
|
|
72
|
+
get colorSymbolRedundant() {
|
|
73
|
+
return this.#plotState.colorSymbolRedundant;
|
|
74
|
+
}
|
|
75
|
+
get hasFilledDotMarks() {
|
|
76
|
+
return this.#plotState.hasFilledDotMarks;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function setPlot(initialState) {
|
|
80
|
+
return new PlotState({
|
|
81
|
+
...initialState
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export function usePlot() {
|
|
85
|
+
const { getPlotState } = getContext('svelteplot');
|
|
86
|
+
return getPlotState().publicState;
|
|
87
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/marks/Area.svelte
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
import Mark from '../Mark.svelte';
|
|
21
21
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
22
|
-
import { getContext } from 'svelte';
|
|
23
22
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
24
23
|
import { groups as d3Groups } from 'd3-array';
|
|
25
24
|
import { area, type CurveFactory } from 'd3-shape';
|
|
@@ -31,7 +30,6 @@
|
|
|
31
30
|
|
|
32
31
|
import type {
|
|
33
32
|
CurveName,
|
|
34
|
-
PlotContext,
|
|
35
33
|
DataRecord,
|
|
36
34
|
BaseMarkProps,
|
|
37
35
|
ConstantAccessor,
|
|
@@ -43,6 +41,7 @@
|
|
|
43
41
|
import type { StackOptions } from '../transforms/stack.js';
|
|
44
42
|
import { addEventHandlers } from './helpers/events';
|
|
45
43
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
44
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
46
45
|
|
|
47
46
|
let markProps: AreaMarkProps = $props();
|
|
48
47
|
|
|
@@ -64,8 +63,7 @@
|
|
|
64
63
|
...options
|
|
65
64
|
}: AreaMarkProps = $derived({ ...DEFAULTS, ...markProps });
|
|
66
65
|
|
|
67
|
-
const
|
|
68
|
-
const plot = $derived(getPlotState());
|
|
66
|
+
const plot = usePlot();
|
|
69
67
|
|
|
70
68
|
const groupByKey = $derived(options.z || options.fill || options.stroke);
|
|
71
69
|
|
|
@@ -144,7 +142,7 @@
|
|
|
144
142
|
clip-path={options.clipPath}
|
|
145
143
|
d={areaPath(areaData)}
|
|
146
144
|
{@attach addEventHandlers({
|
|
147
|
-
|
|
145
|
+
plot,
|
|
148
146
|
options,
|
|
149
147
|
datum: datum?.datum
|
|
150
148
|
})}
|
package/dist/marks/Arrow.svelte
CHANGED
|
@@ -37,9 +37,7 @@
|
|
|
37
37
|
inset?: ConstantAccessor<number, Datum>;
|
|
38
38
|
sweep?: SweepOption;
|
|
39
39
|
}
|
|
40
|
-
import { getContext } from 'svelte';
|
|
41
40
|
import type {
|
|
42
|
-
PlotContext,
|
|
43
41
|
DataRecord,
|
|
44
42
|
BaseMarkProps,
|
|
45
43
|
ConstantAccessor,
|
|
@@ -57,6 +55,7 @@
|
|
|
57
55
|
import { sort } from '../transforms/sort.js';
|
|
58
56
|
import { indexData } from '../transforms/recordize.js';
|
|
59
57
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
58
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
60
59
|
|
|
61
60
|
let markProps: ArrowMarkProps = $props();
|
|
62
61
|
|
|
@@ -76,8 +75,7 @@
|
|
|
76
75
|
...markProps
|
|
77
76
|
});
|
|
78
77
|
|
|
79
|
-
const
|
|
80
|
-
const plot = $derived(getPlotState());
|
|
78
|
+
const plot = usePlot();
|
|
81
79
|
|
|
82
80
|
const args: ArrowMarkProps = $derived(
|
|
83
81
|
sort(
|
|
@@ -134,7 +132,7 @@
|
|
|
134
132
|
<g
|
|
135
133
|
class={[className]}
|
|
136
134
|
{@attach addEventHandlers({
|
|
137
|
-
|
|
135
|
+
plot,
|
|
138
136
|
options,
|
|
139
137
|
datum: d?.datum
|
|
140
138
|
})}>
|
package/dist/marks/AxisX.svelte
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import Mark from '../Mark.svelte';
|
|
7
7
|
import BaseAxisX from './helpers/BaseAxisX.svelte';
|
|
8
8
|
import type {
|
|
9
|
-
PlotContext,
|
|
10
9
|
BaseMarkProps,
|
|
11
10
|
RawValue,
|
|
12
11
|
ConstantAccessor,
|
|
@@ -19,6 +18,7 @@
|
|
|
19
18
|
import { resolveScaledStyles } from '../helpers/resolve.js';
|
|
20
19
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
21
20
|
import { extent } from 'd3-array';
|
|
21
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
22
22
|
|
|
23
23
|
interface AxisXMarkProps extends Omit<
|
|
24
24
|
BaseMarkProps<Datum>,
|
|
@@ -96,8 +96,7 @@
|
|
|
96
96
|
...markProps
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
const
|
|
100
|
-
const plot = $derived(getPlotState());
|
|
99
|
+
const plot = usePlot();
|
|
101
100
|
|
|
102
101
|
const autoTickCount = $derived(
|
|
103
102
|
tickCount != null
|
package/dist/marks/AxisY.svelte
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import BaseAxisY from './helpers/BaseAxisY.svelte';
|
|
7
7
|
import Mark from '../Mark.svelte';
|
|
8
8
|
import type {
|
|
9
|
-
PlotContext,
|
|
10
9
|
BaseMarkProps,
|
|
11
10
|
RawValue,
|
|
12
11
|
FacetContext,
|
|
@@ -18,6 +17,7 @@
|
|
|
18
17
|
import { resolveScaledStyles } from '../helpers/resolve.js';
|
|
19
18
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
20
19
|
import { extent } from 'd3-array';
|
|
20
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
21
21
|
|
|
22
22
|
interface AxisYMarkProps extends Omit<
|
|
23
23
|
BaseMarkProps<Datum>,
|
|
@@ -94,8 +94,7 @@
|
|
|
94
94
|
...markProps
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
const
|
|
98
|
-
const plot = $derived(getPlotState());
|
|
97
|
+
const plot = usePlot();
|
|
99
98
|
|
|
100
99
|
const autoTickCount = $derived(
|
|
101
100
|
tickCount != null
|
package/dist/marks/BarX.svelte
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
import Mark from '../Mark.svelte';
|
|
22
|
-
import { getContext } from 'svelte';
|
|
23
22
|
import { stackX, recordizeX, intervalX, sort } from '../index.js';
|
|
24
23
|
|
|
25
24
|
import type { StackOptions } from '../transforms/stack.js';
|
|
@@ -27,13 +26,13 @@
|
|
|
27
26
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
28
27
|
import RectPath from './helpers/RectPath.svelte';
|
|
29
28
|
import type {
|
|
30
|
-
PlotContext,
|
|
31
29
|
BaseMarkProps,
|
|
32
30
|
BaseRectMarkProps,
|
|
33
31
|
ChannelAccessor,
|
|
34
32
|
LinkableMarkProps
|
|
35
33
|
} from '../types/index.js';
|
|
36
34
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
35
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
37
36
|
|
|
38
37
|
const DEFAULTS = {
|
|
39
38
|
fill: 'currentColor',
|
|
@@ -50,8 +49,7 @@
|
|
|
50
49
|
...options
|
|
51
50
|
}: BarXMarkProps = $derived({ ...DEFAULTS, ...markProps });
|
|
52
51
|
|
|
53
|
-
const
|
|
54
|
-
const plot = $derived(getPlotState());
|
|
52
|
+
const plot = usePlot();
|
|
55
53
|
|
|
56
54
|
const args = $derived(
|
|
57
55
|
stackX(
|
package/dist/marks/BarY.svelte
CHANGED
|
@@ -20,14 +20,12 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
import Mark from '../Mark.svelte';
|
|
23
|
-
import { getContext } from 'svelte';
|
|
24
23
|
import { intervalY, stackY, recordizeY, sort } from '../index.js';
|
|
25
24
|
|
|
26
25
|
import type { StackOptions } from '../transforms/stack.js';
|
|
27
26
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
28
27
|
import RectPath from './helpers/RectPath.svelte';
|
|
29
28
|
import type {
|
|
30
|
-
PlotContext,
|
|
31
29
|
BaseMarkProps,
|
|
32
30
|
BaseRectMarkProps,
|
|
33
31
|
ChannelAccessor,
|
|
@@ -35,9 +33,9 @@
|
|
|
35
33
|
LinkableMarkProps
|
|
36
34
|
} from '../types/index.js';
|
|
37
35
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
36
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
38
37
|
|
|
39
|
-
const
|
|
40
|
-
const plot = $derived(getPlotState());
|
|
38
|
+
const plot = usePlot();
|
|
41
39
|
|
|
42
40
|
const DEFAULTS = {
|
|
43
41
|
...getPlotDefaults().bar,
|
package/dist/marks/Brush.svelte
CHANGED
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
}
|
|
35
35
|
import { getContext, untrack } from 'svelte';
|
|
36
36
|
import Rect from './Rect.svelte';
|
|
37
|
-
import type { BaseMarkProps, DataRecord
|
|
37
|
+
import type { BaseMarkProps, DataRecord } from '../types/index.js';
|
|
38
38
|
import { clientToLayerCoordinates } from './helpers/events.js';
|
|
39
39
|
import Frame from './Frame.svelte';
|
|
40
40
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
41
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
41
42
|
|
|
42
43
|
let { brush: brushExternal = $bindable({ enabled: false }), ...markProps }: BrushMarkProps =
|
|
43
44
|
$props();
|
|
@@ -85,8 +86,7 @@
|
|
|
85
86
|
...markProps
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
const
|
|
89
|
-
const plot = $derived(getPlotState());
|
|
89
|
+
const plot = usePlot();
|
|
90
90
|
|
|
91
91
|
const xScaleFn = $derived(plot.scales.x.fn);
|
|
92
92
|
const yScaleFn = $derived(plot.scales.y.fn);
|
package/dist/marks/Cell.svelte
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
y?: ChannelAccessor<Datum>;
|
|
11
11
|
}
|
|
12
12
|
import type {
|
|
13
|
-
PlotContext,
|
|
14
13
|
DataRecord,
|
|
15
14
|
BaseMarkProps,
|
|
16
15
|
BaseRectMarkProps,
|
|
@@ -18,13 +17,13 @@
|
|
|
18
17
|
LinkableMarkProps
|
|
19
18
|
} from '../types/index.js';
|
|
20
19
|
import Mark from '../Mark.svelte';
|
|
21
|
-
import { getContext } from 'svelte';
|
|
22
20
|
import { recordizeY, sort } from '../index.js';
|
|
23
21
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
24
22
|
|
|
25
23
|
import { isValid } from '../helpers/index.js';
|
|
26
24
|
import RectPath from './helpers/RectPath.svelte';
|
|
27
25
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
26
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
28
27
|
|
|
29
28
|
let markProps: CellMarkProps = $props();
|
|
30
29
|
|
|
@@ -41,8 +40,7 @@
|
|
|
41
40
|
...markProps
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
const
|
|
45
|
-
const plot = $derived(getPlotState());
|
|
43
|
+
const plot = usePlot();
|
|
46
44
|
|
|
47
45
|
const args = $derived(
|
|
48
46
|
options.sort !== undefined
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
interface ColorLegendMarkProps {
|
|
3
3
|
class: string | null;
|
|
4
4
|
}
|
|
5
|
-
import { getContext } from 'svelte';
|
|
6
5
|
import Plot from '../Plot.svelte';
|
|
7
6
|
import AxisX from './AxisX.svelte';
|
|
8
7
|
import Frame from './Frame.svelte';
|
|
@@ -10,13 +9,12 @@
|
|
|
10
9
|
import { range as d3Range, extent } from 'd3-array';
|
|
11
10
|
import { maybeSymbol } from '../helpers/symbols.js';
|
|
12
11
|
|
|
13
|
-
import type { PlotContext } from '../types/plot.js';
|
|
14
12
|
import { getPlotDefaults } from '../hooks/plotDefaults';
|
|
13
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
15
14
|
|
|
16
15
|
let { class: className = null }: ColorLegendMarkProps = $props();
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
const plot = $derived(getPlotState());
|
|
17
|
+
const plot = usePlot();
|
|
20
18
|
|
|
21
19
|
const DEFAULTS = getPlotDefaults();
|
|
22
20
|
|
|
@@ -23,21 +23,16 @@
|
|
|
23
23
|
class: string | null;
|
|
24
24
|
children: Snippet<{ datum: Datum; x: number; y: number }>;
|
|
25
25
|
}
|
|
26
|
-
import {
|
|
27
|
-
import type {
|
|
28
|
-
|
|
29
|
-
ConstantAccessor,
|
|
30
|
-
DataRecord,
|
|
31
|
-
PlotContext
|
|
32
|
-
} from '../types/index.js';
|
|
33
|
-
|
|
34
|
-
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
35
|
-
const plot = $derived(getPlotState());
|
|
26
|
+
import { type Snippet } from 'svelte';
|
|
27
|
+
import type { ChannelAccessor, ConstantAccessor, DataRecord } from '../types/index.js';
|
|
28
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
36
29
|
|
|
37
30
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
38
31
|
import { projectX, projectY, projectXY } from '../helpers/scales.js';
|
|
39
32
|
import { isValid } from '../helpers/index.js';
|
|
40
33
|
|
|
34
|
+
const plot = usePlot();
|
|
35
|
+
|
|
41
36
|
let {
|
|
42
37
|
data = [{} as Datum],
|
|
43
38
|
x,
|
|
@@ -49,19 +49,17 @@
|
|
|
49
49
|
BaseMarkProps,
|
|
50
50
|
ChannelAccessor,
|
|
51
51
|
CurveName,
|
|
52
|
-
DataRecord
|
|
53
|
-
PlotContext
|
|
52
|
+
DataRecord
|
|
54
53
|
} from '../types/index.js';
|
|
55
54
|
import { Line, Area } from './index.js';
|
|
56
55
|
import { randomId, coalesce } from '../helpers/index.js';
|
|
57
|
-
import { getContext } from 'svelte';
|
|
58
56
|
import { extent, max, min } from 'd3-array';
|
|
59
57
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
60
58
|
import type { CurveFactory } from 'd3-shape';
|
|
61
59
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
60
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
62
61
|
|
|
63
|
-
const
|
|
64
|
-
let plot = $derived(getPlotState());
|
|
62
|
+
const plot = usePlot();
|
|
65
63
|
|
|
66
64
|
let markProps: DifferenceYMarkProps = $props();
|
|
67
65
|
|
package/dist/marks/Dot.svelte
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
dotClass?: ConstantAccessor<string, Datum>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { type Snippet } from 'svelte';
|
|
16
16
|
import type {
|
|
17
|
-
PlotContext,
|
|
18
17
|
DataRecord,
|
|
19
18
|
BaseMarkProps,
|
|
20
19
|
ConstantAccessor,
|
|
@@ -33,6 +32,7 @@
|
|
|
33
32
|
import Anchor from './helpers/Anchor.svelte';
|
|
34
33
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
35
34
|
import { isOrdinalScale } from '../helpers/scales.js';
|
|
35
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
36
36
|
|
|
37
37
|
const DEFAULTS = {
|
|
38
38
|
...getPlotDefaults().dot
|
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
...options
|
|
49
49
|
}: DotMarkProps = $derived({ ...DEFAULTS, ...markProps });
|
|
50
50
|
|
|
51
|
-
const
|
|
52
|
-
const plot = $derived(getPlotState());
|
|
51
|
+
const plot = usePlot();
|
|
53
52
|
|
|
54
53
|
function getSymbolPath(symbolType, size) {
|
|
55
54
|
return d3Symbol(maybeSymbol(symbolType), size)();
|
|
@@ -113,7 +112,7 @@
|
|
|
113
112
|
]}
|
|
114
113
|
{style}
|
|
115
114
|
{@attach addEventHandlers({
|
|
116
|
-
|
|
115
|
+
plot,
|
|
117
116
|
options: args,
|
|
118
117
|
datum: d?.datum
|
|
119
118
|
})} />
|
package/dist/marks/Frame.svelte
CHANGED
|
@@ -21,17 +21,12 @@
|
|
|
21
21
|
insetBottom?: number;
|
|
22
22
|
}
|
|
23
23
|
import Mark from '../Mark.svelte';
|
|
24
|
-
import {
|
|
25
|
-
import type {
|
|
26
|
-
PlotContext,
|
|
27
|
-
BaseRectMarkProps,
|
|
28
|
-
LinkableMarkProps,
|
|
29
|
-
DataRecord
|
|
30
|
-
} from '../types/index.js';
|
|
24
|
+
import type { BaseRectMarkProps, LinkableMarkProps, DataRecord } from '../types/index.js';
|
|
31
25
|
import type { BaseMarkProps } from '../types/index.js';
|
|
32
26
|
import RectPath from './helpers/RectPath.svelte';
|
|
33
27
|
import { resolveProp } from '../helpers/resolve';
|
|
34
28
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
29
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
35
30
|
|
|
36
31
|
let markProps: FrameMarkProps = $props();
|
|
37
32
|
|
|
@@ -61,8 +56,7 @@
|
|
|
61
56
|
const dx = $derived(resolveProp(options.dx, null, 0) || 0);
|
|
62
57
|
const dy = $derived(resolveProp(options.dy, null, 0) || 0);
|
|
63
58
|
|
|
64
|
-
const
|
|
65
|
-
const plot = $derived(getPlotState());
|
|
59
|
+
const plot = usePlot();
|
|
66
60
|
</script>
|
|
67
61
|
|
|
68
62
|
<Mark type="frame" {automatic}>
|
package/dist/marks/Geo.svelte
CHANGED
|
@@ -23,10 +23,8 @@
|
|
|
23
23
|
r?: ChannelAccessor<Datum>;
|
|
24
24
|
svgFilter?: ConstantAccessor<string | undefined, Datum>;
|
|
25
25
|
}
|
|
26
|
-
import { getContext } from 'svelte';
|
|
27
26
|
import type {
|
|
28
27
|
DataRecord,
|
|
29
|
-
PlotContext,
|
|
30
28
|
BaseMarkProps,
|
|
31
29
|
ConstantAccessor,
|
|
32
30
|
LinkableMarkProps,
|
|
@@ -43,9 +41,9 @@
|
|
|
43
41
|
import { GEOJSON_PREFER_STROKE } from '../helpers/index.js';
|
|
44
42
|
import Anchor from './helpers/Anchor.svelte';
|
|
45
43
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
44
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
46
45
|
|
|
47
|
-
const
|
|
48
|
-
const plot = $derived(getPlotState());
|
|
46
|
+
const plot = usePlot();
|
|
49
47
|
|
|
50
48
|
let markProps: GeoMarkProps = $props();
|
|
51
49
|
|
|
@@ -114,7 +112,7 @@
|
|
|
114
112
|
class={[styleClass]}
|
|
115
113
|
filter={resolveProp(args.svgFilter, d.datum, undefined)}
|
|
116
114
|
{@attach addEventHandlers({
|
|
117
|
-
|
|
115
|
+
plot,
|
|
118
116
|
options: args,
|
|
119
117
|
datum: d?.datum
|
|
120
118
|
})}>
|
package/dist/marks/GridX.svelte
CHANGED
|
@@ -8,15 +8,8 @@
|
|
|
8
8
|
y1?: ChannelAccessor<Datum>;
|
|
9
9
|
y2?: ChannelAccessor<Datum>;
|
|
10
10
|
}
|
|
11
|
-
import { getContext } from 'svelte';
|
|
12
11
|
import Mark from '../Mark.svelte';
|
|
13
|
-
import type {
|
|
14
|
-
PlotContext,
|
|
15
|
-
BaseMarkProps,
|
|
16
|
-
RawValue,
|
|
17
|
-
DataRecord,
|
|
18
|
-
ChannelAccessor
|
|
19
|
-
} from '../types/index.js';
|
|
12
|
+
import type { BaseMarkProps, RawValue, DataRecord, ChannelAccessor } from '../types/index.js';
|
|
20
13
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
21
14
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
22
15
|
import { testFilter } from '../helpers/index.js';
|
|
@@ -24,6 +17,7 @@
|
|
|
24
17
|
import isDataRecord from '../helpers/isDataRecord';
|
|
25
18
|
import { INDEX } from '../constants';
|
|
26
19
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
20
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
27
21
|
|
|
28
22
|
let markProps: GridXMarkProps = $props();
|
|
29
23
|
|
|
@@ -41,8 +35,7 @@
|
|
|
41
35
|
...markProps
|
|
42
36
|
});
|
|
43
37
|
|
|
44
|
-
const
|
|
45
|
-
const plot = $derived(getPlotState());
|
|
38
|
+
const plot = usePlot();
|
|
46
39
|
|
|
47
40
|
const autoTickCount = $derived(
|
|
48
41
|
Math.max(3, Math.round(plot.facetWidth / plot.options.x.tickSpacing))
|