svelteplot 0.8.1 → 0.9.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/Mark.svelte +1 -1
- package/dist/Mark.svelte.d.ts +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/core/Plot.svelte +4 -4
- package/dist/helpers/projection.js +7 -2
- package/dist/hooks/usePlot.svelte.d.ts +51 -0
- package/dist/hooks/usePlot.svelte.js +90 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/marks/Area.svelte +3 -5
- package/dist/marks/Area.svelte.d.ts +1 -0
- package/dist/marks/AreaX.svelte.d.ts +1 -0
- package/dist/marks/Arrow.svelte +3 -5
- package/dist/marks/Arrow.svelte.d.ts +1 -0
- package/dist/marks/AxisX.svelte +2 -3
- package/dist/marks/AxisX.svelte.d.ts +1 -0
- package/dist/marks/AxisY.svelte +3 -4
- package/dist/marks/AxisY.svelte.d.ts +1 -0
- package/dist/marks/BarX.svelte +2 -4
- package/dist/marks/BarX.svelte.d.ts +1 -0
- package/dist/marks/BarY.svelte +2 -4
- package/dist/marks/BarY.svelte.d.ts +1 -0
- package/dist/marks/BollingerX.svelte.d.ts +1 -0
- package/dist/marks/BollingerY.svelte.d.ts +1 -0
- package/dist/marks/BoxX.svelte +4 -138
- package/dist/marks/BoxY.svelte +20 -137
- package/dist/marks/BoxY.svelte.d.ts +8 -3
- package/dist/marks/Brush.svelte +3 -3
- package/dist/marks/Brush.svelte.d.ts +1 -0
- package/dist/marks/Cell.svelte +2 -4
- package/dist/marks/Cell.svelte.d.ts +1 -0
- package/dist/marks/ColorLegend.svelte +2 -4
- package/dist/marks/CustomMark.svelte.d.ts +1 -0
- package/dist/marks/CustomMarkHTML.svelte +5 -10
- package/dist/marks/DifferenceY.svelte +3 -5
- package/dist/marks/DifferenceY.svelte.d.ts +1 -0
- package/dist/marks/Dot.svelte +4 -5
- package/dist/marks/Dot.svelte.d.ts +1 -0
- package/dist/marks/DotX.svelte.d.ts +1 -0
- package/dist/marks/DotY.svelte.d.ts +1 -0
- package/dist/marks/Frame.svelte +3 -9
- package/dist/marks/Frame.svelte.d.ts +1 -0
- package/dist/marks/Geo.svelte +5 -5
- package/dist/marks/Geo.svelte.d.ts +2 -0
- package/dist/marks/GridX.svelte +3 -10
- package/dist/marks/GridX.svelte.d.ts +1 -0
- package/dist/marks/GridY.svelte +3 -4
- package/dist/marks/GridY.svelte.d.ts +1 -0
- package/dist/marks/HTMLTooltip.svelte +5 -5
- package/dist/marks/Image.svelte.d.ts +1 -0
- package/dist/marks/Line.svelte +7 -6
- package/dist/marks/Line.svelte.d.ts +1 -0
- package/dist/marks/LineX.svelte.d.ts +1 -0
- package/dist/marks/LineY.svelte.d.ts +1 -0
- package/dist/marks/Link.svelte +2 -4
- package/dist/marks/Link.svelte.d.ts +1 -0
- package/dist/marks/Pointer.svelte +4 -4
- package/dist/marks/Rect.svelte +2 -4
- package/dist/marks/Rect.svelte.d.ts +1 -0
- package/dist/marks/RectX.svelte +4 -4
- package/dist/marks/RectY.svelte +4 -4
- package/dist/marks/RuleX.svelte +2 -4
- package/dist/marks/RuleX.svelte.d.ts +1 -0
- package/dist/marks/RuleY.svelte +2 -4
- package/dist/marks/RuleY.svelte.d.ts +1 -0
- package/dist/marks/Spike.svelte.d.ts +1 -0
- package/dist/marks/SymbolLegend.svelte +2 -4
- package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
- package/dist/marks/Text.svelte.d.ts +1 -0
- package/dist/marks/TickX.svelte +2 -3
- package/dist/marks/TickX.svelte.d.ts +1 -0
- package/dist/marks/TickY.svelte +2 -3
- package/dist/marks/TickY.svelte.d.ts +1 -0
- package/dist/marks/Trail.svelte +161 -0
- package/dist/marks/Trail.svelte.d.ts +107 -0
- package/dist/marks/Vector.svelte +3 -4
- package/dist/marks/Vector.svelte.d.ts +1 -0
- package/dist/marks/WaffleX.svelte +2 -3
- package/dist/marks/WaffleX.svelte.d.ts +1 -0
- package/dist/marks/WaffleY.svelte +2 -4
- package/dist/marks/WaffleY.svelte.d.ts +1 -0
- package/dist/marks/helpers/AreaCanvas.svelte +2 -4
- package/dist/marks/helpers/Box.svelte +271 -0
- package/dist/marks/helpers/Box.svelte.d.ts +118 -0
- 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/MarkerPath.svelte.d.ts +1 -0
- 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 +138 -0
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
- package/dist/marks/helpers/events.d.ts +2 -2
- package/dist/marks/helpers/events.js +4 -4
- package/dist/marks/helpers/trail.d.ts +23 -0
- package/dist/marks/helpers/trail.js +372 -0
- package/dist/marks/index.d.ts +1 -0
- package/dist/marks/index.js +1 -0
- package/dist/transforms/bollinger.d.ts +1 -0
- package/dist/transforms/interval.d.ts +2 -0
- package/dist/transforms/select.d.ts +7 -0
- package/dist/transforms/sort.d.ts +4 -0
- package/dist/transforms/window.d.ts +2 -0
- package/dist/types/mark.d.ts +2 -1
- package/dist/types/plot.d.ts +6 -1
- package/dist/ui/Spiral.svelte +4 -0
- package/package.json +24 -23
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/Mark.svelte
CHANGED
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
// check if the mark has defined an accessor for this channel
|
|
152
152
|
if (options?.[channel] !== undefined && out[channel] === undefined) {
|
|
153
153
|
// resolve value
|
|
154
|
-
out[channel] = resolveChannel(channel, row, options);
|
|
154
|
+
out[channel] = resolveChannel(channel, row, options, index);
|
|
155
155
|
if (options[channel] === INDEX) {
|
|
156
156
|
const scale = plot.scales[CHANNEL_SCALE[channel]];
|
|
157
157
|
if (scale.type === 'band' || scale.type === 'point') {
|
package/dist/Mark.svelte.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
28
28
|
strokeDashoffset: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
+
mask: string;
|
|
31
32
|
imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -117,6 +117,8 @@ export const CSS_COLOR_CONTRAST = /^color-contrast\(/; // just check for prefix
|
|
|
117
117
|
export const CSS_RGBA = /^rgba\(/; // just check for prefix
|
|
118
118
|
export const CSS_URL = /^url\(#/; // just check for prefix
|
|
119
119
|
export const INDEX = Symbol('index');
|
|
120
|
+
export const PI = Math.PI;
|
|
121
|
+
export const TAU = PI * 2;
|
|
120
122
|
// export const CHANNEL_MAP: Record<ScaleName, ValueOf<typeof SCALE_TYPES>> = {
|
|
121
123
|
// x: SCALE_TYPES.x,
|
|
122
124
|
// y: SCALE_TYPES.y,
|
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
|
|
|
@@ -50,7 +50,7 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
|
|
|
50
50
|
let transform;
|
|
51
51
|
let invertTransform = (d) => d;
|
|
52
52
|
// If a domain is specified, fit the projection to the frame.
|
|
53
|
-
if (domain != null) {
|
|
53
|
+
if (domain != null && dx > 0 && dy > 0) {
|
|
54
54
|
const [[x0, y0], [x1, y1]] = geoPath(projInstance).bounds(domain);
|
|
55
55
|
const k = Math.min(dx / (x1 - x0), dy / (y1 - y0));
|
|
56
56
|
aspectRatio = (y1 - y0) / (x1 - x0);
|
|
@@ -66,9 +66,14 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
|
|
|
66
66
|
invertTransform = ([x, y]) => [(x - tx) / k, (y - ty) / k];
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
else if (domain != null) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
|
|
76
|
+
}
|
|
72
77
|
transform ??=
|
|
73
78
|
tx === 0 && ty === 0
|
|
74
79
|
? identity()
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
get css(): ((d: string) => string) | null;
|
|
48
|
+
}
|
|
49
|
+
export declare function setPlot(initialState: PlotState): PlotState;
|
|
50
|
+
export declare function usePlot(): Readonly<TPlotState>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
get css() {
|
|
79
|
+
return this.#plotState.css;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function setPlot(initialState) {
|
|
83
|
+
return new PlotState({
|
|
84
|
+
...initialState
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export function usePlot() {
|
|
88
|
+
const { getPlotState } = getContext('svelteplot');
|
|
89
|
+
return getPlotState().publicState;
|
|
90
|
+
}
|
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
|
})}
|
|
@@ -28,6 +28,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
28
28
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
+
mask: string;
|
|
31
32
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
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
|
})}>
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
27
27
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
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
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
27
27
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: ConstantAccessor<string, Datum>;
|
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
|
|
@@ -170,7 +169,7 @@
|
|
|
170
169
|
: optionsLabel !== undefined
|
|
171
170
|
? optionsLabel
|
|
172
171
|
: plot.scales.y.autoTitle
|
|
173
|
-
?
|
|
172
|
+
? `${!plot.options.y.reverse ? '↑' : '↓'} ${plot.scales.y.autoTitle}${plot.options.y.percent ? ' (%)' : ''}`
|
|
174
173
|
: ''
|
|
175
174
|
);
|
|
176
175
|
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
26
26
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: ConstantAccessor<string, Datum>;
|
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(
|
|
@@ -28,6 +28,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
28
28
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
29
29
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
30
|
clipPath: string;
|
|
31
|
+
mask: string;
|
|
31
32
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
32
33
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
33
34
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
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,
|
|
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
27
27
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
28
28
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
29
|
clipPath: string;
|
|
30
|
+
mask: string;
|
|
30
31
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
31
32
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
33
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
26
|
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
27
|
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
28
|
clipPath: string;
|
|
29
|
+
mask: string;
|
|
29
30
|
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
30
31
|
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
31
32
|
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|