svelteplot 0.10.3 → 0.11.0-pr-514.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/dist/Mark.svelte +42 -25
- package/dist/Mark.svelte.d.ts +111 -32
- package/dist/Plot.svelte +21 -15
- package/dist/core/Facet.svelte +1 -1
- package/dist/core/FacetAxes.svelte +13 -8
- package/dist/core/FacetGrid.svelte +4 -4
- package/dist/core/Plot.svelte +70 -36
- package/dist/helpers/arrowPath.js +10 -5
- package/dist/helpers/autoScales.d.ts +3 -3
- package/dist/helpers/autoScales.js +28 -18
- package/dist/helpers/autoTicks.js +2 -0
- package/dist/helpers/callWithProps.d.ts +1 -2
- package/dist/helpers/colors.d.ts +4 -4
- package/dist/helpers/facets.d.ts +42 -1
- package/dist/helpers/facets.js +83 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/math.js +1 -1
- package/dist/helpers/mergeDeep.d.ts +1 -3
- package/dist/helpers/mergeDeep.js +15 -16
- package/dist/helpers/noise.js +1 -1
- package/dist/helpers/projection.d.ts +4 -3
- package/dist/helpers/projection.js +17 -5
- package/dist/helpers/reduce.d.ts +4 -4
- package/dist/helpers/reduce.js +6 -4
- package/dist/helpers/regressionLoess.js +2 -1
- package/dist/helpers/resolve.d.ts +6 -3
- package/dist/helpers/resolve.js +25 -16
- package/dist/helpers/roundedRect.js +1 -1
- package/dist/helpers/scales.d.ts +11 -10
- package/dist/helpers/scales.js +43 -13
- package/dist/helpers/time.d.ts +10 -3
- package/dist/helpers/time.js +2 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/plotDefaults.d.ts +3 -1
- package/dist/hooks/plotDefaults.js +33 -1
- package/dist/hooks/usePlot.svelte.d.ts +10 -25
- package/dist/hooks/usePlot.svelte.js +8 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/marks/Area.svelte +24 -13
- package/dist/marks/Area.svelte.d.ts +118 -34
- package/dist/marks/AreaX.svelte +42 -8
- package/dist/marks/AreaX.svelte.d.ts +154 -71
- package/dist/marks/AreaY.svelte +42 -8
- package/dist/marks/AreaY.svelte.d.ts +154 -71
- package/dist/marks/Arrow.svelte +42 -23
- package/dist/marks/Arrow.svelte.d.ts +114 -35
- package/dist/marks/AxisX.svelte +43 -28
- package/dist/marks/AxisX.svelte.d.ts +125 -40
- package/dist/marks/AxisY.svelte +43 -26
- package/dist/marks/AxisY.svelte.d.ts +127 -40
- package/dist/marks/BarX.svelte +12 -10
- package/dist/marks/BarX.svelte.d.ts +104 -32
- package/dist/marks/BarY.svelte +11 -10
- package/dist/marks/BarY.svelte.d.ts +106 -34
- package/dist/marks/BollingerX.svelte +4 -7
- package/dist/marks/BollingerX.svelte.d.ts +105 -30
- package/dist/marks/BollingerY.svelte +3 -0
- package/dist/marks/BollingerY.svelte.d.ts +105 -30
- package/dist/marks/BoxX.svelte +3 -3
- package/dist/marks/BoxY.svelte +12 -9
- package/dist/marks/BoxY.svelte.d.ts +128 -53
- package/dist/marks/Brush.svelte +26 -21
- package/dist/marks/Brush.svelte.d.ts +119 -60
- package/dist/marks/Cell.svelte +13 -9
- package/dist/marks/Cell.svelte.d.ts +105 -30
- package/dist/marks/CellX.svelte +2 -1
- package/dist/marks/CellX.svelte.d.ts +105 -32
- package/dist/marks/CellY.svelte +2 -1
- package/dist/marks/CellY.svelte.d.ts +105 -32
- package/dist/marks/ColorLegend.svelte +24 -13
- package/dist/marks/ColorLegend.svelte.d.ts +1 -0
- package/dist/marks/CustomMark.svelte +16 -10
- package/dist/marks/CustomMark.svelte.d.ts +112 -31
- package/dist/marks/CustomMarkHTML.svelte +8 -2
- package/dist/marks/CustomMarkHTML.svelte.d.ts +8 -2
- package/dist/marks/DifferenceY.svelte +31 -20
- package/dist/marks/DifferenceY.svelte.d.ts +134 -55
- package/dist/marks/Dot.svelte +21 -11
- package/dist/marks/Dot.svelte.d.ts +117 -38
- package/dist/marks/DotX.svelte +2 -0
- package/dist/marks/DotX.svelte.d.ts +136 -62
- package/dist/marks/DotY.svelte +1 -0
- package/dist/marks/DotY.svelte.d.ts +135 -62
- package/dist/marks/Frame.svelte +47 -9
- package/dist/marks/Frame.svelte.d.ts +124 -41
- package/dist/marks/Geo.svelte +21 -12
- package/dist/marks/Geo.svelte.d.ts +105 -30
- package/dist/marks/Graticule.svelte +3 -0
- package/dist/marks/Graticule.svelte.d.ts +3 -0
- package/dist/marks/GridX.svelte +31 -16
- package/dist/marks/GridX.svelte.d.ts +108 -32
- package/dist/marks/GridY.svelte +30 -15
- package/dist/marks/GridY.svelte.d.ts +108 -32
- package/dist/marks/HTMLTooltip.svelte +37 -27
- package/dist/marks/HTMLTooltip.svelte.d.ts +7 -0
- package/dist/marks/Image.svelte +50 -25
- package/dist/marks/Image.svelte.d.ts +117 -35
- package/dist/marks/Line.svelte +67 -44
- package/dist/marks/Line.svelte.d.ts +119 -30
- package/dist/marks/LineX.svelte +2 -1
- package/dist/marks/LineX.svelte.d.ts +142 -69
- package/dist/marks/LineY.svelte +2 -1
- package/dist/marks/LineY.svelte.d.ts +142 -69
- package/dist/marks/Link.svelte +70 -46
- package/dist/marks/Link.svelte.d.ts +126 -41
- package/dist/marks/Pointer.svelte +46 -35
- package/dist/marks/Pointer.svelte.d.ts +7 -0
- package/dist/marks/Rect.svelte +13 -5
- package/dist/marks/Rect.svelte.d.ts +116 -35
- package/dist/marks/RectX.svelte +6 -3
- package/dist/marks/RectX.svelte.d.ts +158 -12
- package/dist/marks/RectY.svelte +6 -3
- package/dist/marks/RectY.svelte.d.ts +158 -12
- package/dist/marks/RegressionX.svelte +13 -6
- package/dist/marks/RegressionX.svelte.d.ts +8 -3
- package/dist/marks/RegressionY.svelte +13 -6
- package/dist/marks/RegressionY.svelte.d.ts +8 -3
- package/dist/marks/RuleX.svelte +18 -11
- package/dist/marks/RuleX.svelte.d.ts +112 -32
- package/dist/marks/RuleY.svelte +19 -12
- package/dist/marks/RuleY.svelte.d.ts +114 -34
- package/dist/marks/Spike.svelte +11 -5
- package/dist/marks/Spike.svelte.d.ts +146 -68
- package/dist/marks/Text.svelte +24 -7
- package/dist/marks/Text.svelte.d.ts +253 -75
- package/dist/marks/TickX.svelte +56 -48
- package/dist/marks/TickX.svelte.d.ts +114 -40
- package/dist/marks/TickY.svelte +59 -51
- package/dist/marks/TickY.svelte.d.ts +117 -43
- package/dist/marks/Trail.svelte +25 -13
- package/dist/marks/Trail.svelte.d.ts +116 -33
- package/dist/marks/Vector.svelte +20 -11
- package/dist/marks/Vector.svelte.d.ts +116 -35
- package/dist/marks/WaffleX.svelte +18 -16
- package/dist/marks/WaffleX.svelte.d.ts +131 -57
- package/dist/marks/WaffleY.svelte +16 -15
- package/dist/marks/WaffleY.svelte.d.ts +129 -56
- package/dist/marks/helpers/Anchor.svelte +17 -2
- package/dist/marks/helpers/Anchor.svelte.d.ts +16 -1
- package/dist/marks/helpers/AreaCanvas.svelte +8 -8
- package/dist/marks/helpers/BaseAxisX.svelte +38 -41
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +11 -17
- package/dist/marks/helpers/BaseAxisY.svelte +35 -35
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +12 -15
- package/dist/marks/helpers/Box.svelte +35 -28
- package/dist/marks/helpers/Box.svelte.d.ts +122 -50
- package/dist/marks/helpers/DotCanvas.svelte +11 -9
- package/dist/marks/helpers/GeoCanvas.svelte +7 -6
- package/dist/marks/helpers/LineCanvas.svelte +7 -7
- package/dist/marks/helpers/LinearGradientX.svelte +2 -2
- package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +2 -2
- package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
- package/dist/marks/helpers/Marker.svelte +2 -2
- package/dist/marks/helpers/MarkerPath.svelte +15 -12
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +105 -32
- package/dist/marks/helpers/MultilineText.svelte +24 -17
- package/dist/marks/helpers/MultilineText.svelte.d.ts +1 -1
- package/dist/marks/helpers/RectCanvas.svelte +31 -26
- package/dist/marks/helpers/RectPath.svelte +2 -2
- package/dist/marks/helpers/Regression.svelte +176 -86
- package/dist/marks/helpers/Regression.svelte.d.ts +20 -8
- package/dist/marks/helpers/RuleCanvas.svelte +9 -6
- package/dist/marks/helpers/TextCanvas.svelte +13 -9
- package/dist/marks/helpers/TextCanvas.svelte.d.ts +6 -6
- package/dist/marks/helpers/TickCanvas.svelte +6 -5
- package/dist/marks/helpers/TrailCanvas.svelte +16 -18
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +3 -5
- package/dist/marks/helpers/canvas.js +16 -9
- package/dist/marks/helpers/events.d.ts +2 -2
- package/dist/marks/helpers/events.js +14 -7
- package/dist/marks/helpers/trail.js +1 -1
- package/dist/marks/helpers/waffle.d.ts +3 -3
- package/dist/marks/helpers/waffle.js +7 -5
- package/dist/regression/polynomial.d.ts +1 -1
- package/dist/regression/polynomial.js +7 -7
- package/dist/regression/utils/determination.d.ts +1 -1
- package/dist/regression/utils/determination.js +1 -1
- package/dist/regression/utils/geometry.d.ts +1 -1
- package/dist/regression/utils/interpose.d.ts +1 -1
- package/dist/regression/utils/interpose.js +1 -1
- package/dist/regression/utils/points.d.ts +1 -1
- package/dist/transforms/bin.d.ts +3 -3
- package/dist/transforms/bin.js +29 -20
- package/dist/transforms/bollinger.d.ts +8 -0
- package/dist/transforms/bollinger.js +15 -4
- package/dist/transforms/centroid.d.ts +4 -0
- package/dist/transforms/centroid.js +4 -0
- package/dist/transforms/density.d.ts +4 -4
- package/dist/transforms/density.js +23 -16
- package/dist/transforms/dodge.d.ts +12 -1
- package/dist/transforms/dodge.js +15 -6
- package/dist/transforms/group.d.ts +141 -4
- package/dist/transforms/group.js +4 -1
- package/dist/transforms/interval.d.ts +204 -60
- package/dist/transforms/jitter.d.ts +421 -4
- package/dist/transforms/jitter.js +10 -1
- package/dist/transforms/map.d.ts +412 -4
- package/dist/transforms/map.js +5 -5
- package/dist/transforms/normalize.d.ts +276 -5
- package/dist/transforms/normalize.js +6 -4
- package/dist/transforms/recordize.d.ts +17 -5
- package/dist/transforms/recordize.js +13 -9
- package/dist/transforms/rename.d.ts +11 -4
- package/dist/transforms/rename.js +7 -2
- package/dist/transforms/select.d.ts +722 -210
- package/dist/transforms/select.js +13 -1
- package/dist/transforms/shift.d.ts +8 -0
- package/dist/transforms/shift.js +20 -6
- package/dist/transforms/sort.d.ts +13 -258
- package/dist/transforms/sort.js +13 -10
- package/dist/transforms/stack.d.ts +58 -9
- package/dist/transforms/stack.js +27 -11
- package/dist/transforms/window.d.ts +221 -66
- package/dist/transforms/window.js +8 -2
- package/dist/types/axes.d.ts +43 -0
- package/dist/types/axes.js +1 -0
- package/dist/types/channel.d.ts +30 -2
- package/dist/types/data.d.ts +14 -1
- package/dist/types/facet.d.ts +5 -0
- package/dist/types/index.d.ts +33 -8
- package/dist/types/index.js +11 -7
- package/dist/types/mark.d.ts +125 -36
- package/dist/types/plot.d.ts +118 -16
- package/dist/types/scale.d.ts +125 -8
- package/package.json +37 -32
- package/dist/helpers/autoTicks.d.ts +0 -12
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getContext } from 'svelte';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* internal state representation of a Plot, using Svelte 5 runes for reactivity
|
|
4
4
|
*/
|
|
5
5
|
class PlotState {
|
|
6
|
-
// Define properties and methods for PlotState as needed
|
|
7
6
|
width = $state(50);
|
|
8
7
|
height = $state(50);
|
|
9
8
|
options = $state({});
|
|
@@ -11,8 +10,8 @@ class PlotState {
|
|
|
11
10
|
facetHeight = $state(0);
|
|
12
11
|
plotWidth = $state(0);
|
|
13
12
|
plotHeight = $state(0);
|
|
14
|
-
scales = $state();
|
|
15
|
-
body = $state();
|
|
13
|
+
scales = $state(undefined);
|
|
14
|
+
body = $state(undefined);
|
|
16
15
|
/**
|
|
17
16
|
* True if there's a color scale and a symbol scale and both are bound to the same
|
|
18
17
|
* single channel accessor.
|
|
@@ -27,16 +26,16 @@ class PlotState {
|
|
|
27
26
|
// Initialization code here
|
|
28
27
|
Object.assign(this, state);
|
|
29
28
|
}
|
|
29
|
+
/** merges partial state into the current plot state */
|
|
30
30
|
update(newState) {
|
|
31
31
|
Object.assign(this, newState);
|
|
32
32
|
}
|
|
33
|
+
/** returns a read-only wrapper exposing only public properties */
|
|
33
34
|
get publicState() {
|
|
34
35
|
return new PublicPlotState(this);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
/**
|
|
38
|
-
* A public-facing wrapper around PlotState that exposes only read-only properties.
|
|
39
|
-
*/
|
|
38
|
+
/** read-only wrapper around PlotState that exposes only getter properties */
|
|
40
39
|
class PublicPlotState {
|
|
41
40
|
#plotState;
|
|
42
41
|
constructor(plotState) {
|
|
@@ -79,11 +78,13 @@ class PublicPlotState {
|
|
|
79
78
|
return this.#plotState.css;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
81
|
+
/** creates a new PlotState instance from the given initial state */
|
|
82
82
|
export function setPlot(initialState) {
|
|
83
83
|
return new PlotState({
|
|
84
84
|
...initialState
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
/** returns the current Plot's public state from Svelte context. Must be called within a `<Plot>` component tree. */
|
|
87
88
|
export function usePlot() {
|
|
88
89
|
const { getPlotState } = getContext('svelteplot');
|
|
89
90
|
return getPlotState().publicState;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export { default as Plot } from './Plot.svelte';
|
|
|
2
2
|
export { default as PlotCore } from './core/Plot.svelte';
|
|
3
3
|
export * from './marks/index.js';
|
|
4
4
|
export * from './transforms/index.js';
|
|
5
|
+
export * from './hooks/index.js';
|
|
5
6
|
export { formatMonth } from './helpers/formats.js';
|
|
6
7
|
export { default as wordwrap } from './helpers/wordwrap.js';
|
|
7
|
-
export * from './hooks/plotDefaults.js';
|
|
8
|
-
export { usePlot } from './hooks/usePlot.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,7 @@ export { default as Plot } from './Plot.svelte';
|
|
|
2
2
|
export { default as PlotCore } from './core/Plot.svelte';
|
|
3
3
|
export * from './marks/index.js';
|
|
4
4
|
export * from './transforms/index.js';
|
|
5
|
+
export * from './hooks/index.js';
|
|
5
6
|
// helpers
|
|
6
7
|
export { formatMonth } from './helpers/formats.js';
|
|
7
8
|
export { default as wordwrap } from './helpers/wordwrap.js';
|
|
8
|
-
// hooks
|
|
9
|
-
export * from './hooks/plotDefaults.js';
|
|
10
|
-
export { usePlot } from './hooks/usePlot.svelte.js';
|
package/dist/marks/Area.svelte
CHANGED
|
@@ -3,17 +3,29 @@
|
|
|
3
3
|
-->
|
|
4
4
|
<script lang="ts" generics="Datum extends DataRecord">
|
|
5
5
|
interface AreaMarkProps extends BaseMarkProps<Datum>, LinkableMarkProps<Datum> {
|
|
6
|
-
data
|
|
6
|
+
/** the input data array; each element becomes one point in the area */
|
|
7
|
+
data?: Datum[];
|
|
8
|
+
/** the starting horizontal position channel for the area baseline */
|
|
7
9
|
x1?: ChannelAccessor<Datum>;
|
|
10
|
+
/** the ending horizontal position channel for the area topline */
|
|
8
11
|
x2?: ChannelAccessor<Datum>;
|
|
12
|
+
/** the starting vertical position channel for the area baseline */
|
|
9
13
|
y1?: ChannelAccessor<Datum>;
|
|
14
|
+
/** the ending vertical position channel for the area topline */
|
|
10
15
|
y2?: ChannelAccessor<Datum>;
|
|
16
|
+
/** the series channel; data is grouped into separate areas by unique z values */
|
|
11
17
|
z?: ChannelAccessor<Datum>;
|
|
18
|
+
/** the curve interpolation method for connecting data points */
|
|
12
19
|
curve?: CurveName | CurveFactory;
|
|
20
|
+
/** the tension parameter for cardinal or Catmull-Rom curve interpolation */
|
|
13
21
|
tension?: number;
|
|
22
|
+
/** controls the order of data points before rendering */
|
|
14
23
|
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
24
|
+
/** options for stacking area data values */
|
|
15
25
|
stack?: Partial<StackOptions>;
|
|
26
|
+
/** if true, renders using Canvas instead of SVG */
|
|
16
27
|
canvas?: boolean;
|
|
28
|
+
/** CSS class name(s) to apply to individual area path elements */
|
|
17
29
|
areaClass?: ConstantAccessor<string, Datum>;
|
|
18
30
|
}
|
|
19
31
|
|
|
@@ -21,7 +33,7 @@
|
|
|
21
33
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
22
34
|
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
23
35
|
import { groups as d3Groups } from 'd3-array';
|
|
24
|
-
import { area, type CurveFactory } from 'd3-shape';
|
|
36
|
+
import { area, type Area, type CurveFactory } from 'd3-shape';
|
|
25
37
|
import callWithProps from '../helpers/callWithProps.js';
|
|
26
38
|
import { maybeCurve } from '../helpers/curves.js';
|
|
27
39
|
import { isValid } from '../helpers/index.js';
|
|
@@ -39,7 +51,7 @@
|
|
|
39
51
|
RawValue
|
|
40
52
|
} from '../types/index.js';
|
|
41
53
|
import type { StackOptions } from '../transforms/stack.js';
|
|
42
|
-
import { addEventHandlers } from './helpers/events';
|
|
54
|
+
import { addEventHandlers } from './helpers/events.js';
|
|
43
55
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
44
56
|
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
45
57
|
|
|
@@ -89,7 +101,7 @@
|
|
|
89
101
|
y0: (d: ScaledDataRecord) => d.y1,
|
|
90
102
|
y1: (d: ScaledDataRecord) => d.y2
|
|
91
103
|
})
|
|
92
|
-
})
|
|
104
|
+
}) as unknown as Area<ScaledDataRecord>
|
|
93
105
|
);
|
|
94
106
|
|
|
95
107
|
function groupAndSort(data: ScaledDataRecord[]) {
|
|
@@ -97,12 +109,11 @@
|
|
|
97
109
|
? d3Groups(data, (d) => resolveProp(groupByKey, d.datum)).map((d) => d[1])
|
|
98
110
|
: [data];
|
|
99
111
|
if (options.sort) {
|
|
100
|
-
return groups.toSorted((a, b) =>
|
|
101
|
-
resolveChannel('sort', a[0].datum, options)
|
|
102
|
-
resolveChannel('sort', b[0].datum, options)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
112
|
+
return groups.toSorted((a, b) => {
|
|
113
|
+
const av = resolveChannel('sort', a[0].datum, options) as string | number | null;
|
|
114
|
+
const bv = resolveChannel('sort', b[0].datum, options) as string | number | null;
|
|
115
|
+
return av! > bv! ? 1 : -1;
|
|
116
|
+
});
|
|
106
117
|
}
|
|
107
118
|
return groups;
|
|
108
119
|
}
|
|
@@ -113,8 +124,8 @@
|
|
|
113
124
|
{data}
|
|
114
125
|
channels={['x1', 'x2', 'y1', 'y2', 'fill', 'stroke', 'opacity', 'fillOpacity', 'strokeOpacity']}
|
|
115
126
|
required={['x1', 'y1']}
|
|
116
|
-
{...markProps}
|
|
117
|
-
{...options}>
|
|
127
|
+
{...markProps as any}
|
|
128
|
+
{...options as any}>
|
|
118
129
|
{#snippet children({ mark, usedScales, scaledData })}
|
|
119
130
|
{@const grouped = groupAndSort(scaledData)}
|
|
120
131
|
{#if canvas}
|
|
@@ -124,7 +135,7 @@
|
|
|
124
135
|
{#each grouped as areaData, i (i)}
|
|
125
136
|
{@const datum = areaData[0]}
|
|
126
137
|
{#if areaData.length > 0}
|
|
127
|
-
<Anchor {options} {datum}>
|
|
138
|
+
<Anchor options={options as any} {datum}>
|
|
128
139
|
{@const title = resolveProp(options.title, datum.datum, '')}
|
|
129
140
|
{@const [style, styleClass] = resolveStyles(
|
|
130
141
|
plot,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CurveFactory } from 'd3-shape';
|
|
1
|
+
import { type Area, type CurveFactory } from 'd3-shape';
|
|
2
2
|
import type { CurveName, DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps, RawValue } from '../types/index.js';
|
|
3
3
|
import type { StackOptions } from '../transforms/stack.js';
|
|
4
4
|
declare function $$render<Datum extends DataRecord>(): {
|
|
@@ -9,10 +9,20 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
9
9
|
fy: ChannelAccessor<Datum>;
|
|
10
10
|
dx: ConstantAccessor<number, Datum>;
|
|
11
11
|
dy: ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
13
|
-
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
12
|
+
dodgeX: import("../transforms/dodge.js").DodgeXOptions;
|
|
13
|
+
dodgeY: import("../transforms/dodge.js").DodgeYOptions;
|
|
14
14
|
fill: ChannelAccessor<Datum>;
|
|
15
15
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
16
|
+
fontFamily: ConstantAccessor<import("csstype").Property.FontFamily, Datum>;
|
|
17
|
+
fontSize: ConstantAccessor<import("csstype").Property.FontSize<number>, Datum>;
|
|
18
|
+
fontStyle: ConstantAccessor<import("csstype").Property.FontStyle, Datum>;
|
|
19
|
+
fontVariant: ConstantAccessor<import("csstype").Property.FontVariant, Datum>;
|
|
20
|
+
fontWeight: ConstantAccessor<import("csstype").Property.FontWeight, Datum>;
|
|
21
|
+
letterSpacing: ConstantAccessor<import("csstype").Property.LetterSpacing<0 | (string & {})>, Datum>;
|
|
22
|
+
wordSpacing: ConstantAccessor<import("csstype").Property.WordSpacing<0 | (string & {})>, Datum>;
|
|
23
|
+
textAnchor: ConstantAccessor<import("csstype").Property.TextAnchor, Datum>;
|
|
24
|
+
textTransform: ConstantAccessor<import("csstype").Property.TextTransform, Datum>;
|
|
25
|
+
textDecoration: ConstantAccessor<import("csstype").Property.TextDecoration<0 | (string & {})>, Datum>;
|
|
16
26
|
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
17
27
|
channel: string;
|
|
18
28
|
order?: "ascending" | "descending";
|
|
@@ -26,59 +36,133 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
26
36
|
opacity: ChannelAccessor<Datum>;
|
|
27
37
|
strokeDasharray: ConstantAccessor<string, Datum>;
|
|
28
38
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
39
|
+
blend: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
29
40
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
30
41
|
clipPath: string;
|
|
31
42
|
mask: string;
|
|
32
43
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
33
44
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
45
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
35
|
-
onclick:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
46
|
+
onclick: (event: Event & {
|
|
47
|
+
currentTarget: SVGPathElement;
|
|
48
|
+
}, datum: Datum, index: number) => void;
|
|
49
|
+
ondblclick: (event: Event & {
|
|
50
|
+
currentTarget: SVGPathElement;
|
|
51
|
+
}, datum: Datum, index: number) => void;
|
|
52
|
+
onmouseup: (event: Event & {
|
|
53
|
+
currentTarget: SVGPathElement;
|
|
54
|
+
}, datum: Datum, index: number) => void;
|
|
55
|
+
onmousedown: (event: Event & {
|
|
56
|
+
currentTarget: SVGPathElement;
|
|
57
|
+
}, datum: Datum, index: number) => void;
|
|
58
|
+
onmouseenter: (event: Event & {
|
|
59
|
+
currentTarget: SVGPathElement;
|
|
60
|
+
}, datum: Datum, index: number) => void;
|
|
61
|
+
onmousemove: (event: Event & {
|
|
62
|
+
currentTarget: SVGPathElement;
|
|
63
|
+
}, datum: Datum, index: number) => void;
|
|
64
|
+
onmouseleave: (event: Event & {
|
|
65
|
+
currentTarget: SVGPathElement;
|
|
66
|
+
}, datum: Datum, index: number) => void;
|
|
67
|
+
onmouseout: (event: Event & {
|
|
68
|
+
currentTarget: SVGPathElement;
|
|
69
|
+
}, datum: Datum, index: number) => void;
|
|
70
|
+
onmouseover: (event: Event & {
|
|
71
|
+
currentTarget: SVGPathElement;
|
|
72
|
+
}, datum: Datum, index: number) => void;
|
|
73
|
+
onpointercancel: (event: Event & {
|
|
74
|
+
currentTarget: SVGPathElement;
|
|
75
|
+
}, datum: Datum, index: number) => void;
|
|
76
|
+
onpointerdown: (event: Event & {
|
|
77
|
+
currentTarget: SVGPathElement;
|
|
78
|
+
}, datum: Datum, index: number) => void;
|
|
79
|
+
onpointerup: (event: Event & {
|
|
80
|
+
currentTarget: SVGPathElement;
|
|
81
|
+
}, datum: Datum, index: number) => void;
|
|
82
|
+
onpointerenter: (event: Event & {
|
|
83
|
+
currentTarget: SVGPathElement;
|
|
84
|
+
}, datum: Datum, index: number) => void;
|
|
85
|
+
onpointerleave: (event: Event & {
|
|
86
|
+
currentTarget: SVGPathElement;
|
|
87
|
+
}, datum: Datum, index: number) => void;
|
|
88
|
+
onpointermove: (event: Event & {
|
|
89
|
+
currentTarget: SVGPathElement;
|
|
90
|
+
}, datum: Datum, index: number) => void;
|
|
91
|
+
onpointerover: (event: Event & {
|
|
92
|
+
currentTarget: SVGPathElement;
|
|
93
|
+
}, datum: Datum, index: number) => void;
|
|
94
|
+
onpointerout: (event: Event & {
|
|
95
|
+
currentTarget: SVGPathElement;
|
|
96
|
+
}, datum: Datum, index: number) => void;
|
|
97
|
+
ondrag: (event: Event & {
|
|
98
|
+
currentTarget: SVGPathElement;
|
|
99
|
+
}, datum: Datum, index: number) => void;
|
|
100
|
+
ondrop: (event: Event & {
|
|
101
|
+
currentTarget: SVGPathElement;
|
|
102
|
+
}, datum: Datum, index: number) => void;
|
|
103
|
+
ondragstart: (event: Event & {
|
|
104
|
+
currentTarget: SVGPathElement;
|
|
105
|
+
}, datum: Datum, index: number) => void;
|
|
106
|
+
ondragenter: (event: Event & {
|
|
107
|
+
currentTarget: SVGPathElement;
|
|
108
|
+
}, datum: Datum, index: number) => void;
|
|
109
|
+
ondragleave: (event: Event & {
|
|
110
|
+
currentTarget: SVGPathElement;
|
|
111
|
+
}, datum: Datum, index: number) => void;
|
|
112
|
+
ondragover: (event: Event & {
|
|
113
|
+
currentTarget: SVGPathElement;
|
|
114
|
+
}, datum: Datum, index: number) => void;
|
|
115
|
+
ondragend: (event: Event & {
|
|
116
|
+
currentTarget: SVGPathElement;
|
|
117
|
+
}, datum: Datum, index: number) => void;
|
|
118
|
+
ontouchstart: (event: Event & {
|
|
119
|
+
currentTarget: SVGPathElement;
|
|
120
|
+
}, datum: Datum, index: number) => void;
|
|
121
|
+
ontouchmove: (event: Event & {
|
|
122
|
+
currentTarget: SVGPathElement;
|
|
123
|
+
}, datum: Datum, index: number) => void;
|
|
124
|
+
ontouchend: (event: Event & {
|
|
125
|
+
currentTarget: SVGPathElement;
|
|
126
|
+
}, datum: Datum, index: number) => void;
|
|
127
|
+
ontouchcancel: (event: Event & {
|
|
128
|
+
currentTarget: SVGPathElement;
|
|
129
|
+
}, datum: Datum, index: number) => void;
|
|
130
|
+
oncontextmenu: (event: Event & {
|
|
131
|
+
currentTarget: SVGPathElement;
|
|
132
|
+
}, datum: Datum, index: number) => void;
|
|
133
|
+
onwheel: (event: Event & {
|
|
134
|
+
currentTarget: SVGPathElement;
|
|
135
|
+
}, datum: Datum, index: number) => void;
|
|
65
136
|
class: string;
|
|
66
137
|
style: string;
|
|
67
138
|
cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
|
|
139
|
+
title: ConstantAccessor<string, Datum>;
|
|
68
140
|
}> & LinkableMarkProps<Datum> & {
|
|
69
|
-
data
|
|
141
|
+
/** the input data array; each element becomes one point in the area */
|
|
142
|
+
data?: Datum[];
|
|
143
|
+
/** the starting horizontal position channel for the area baseline */
|
|
70
144
|
x1?: ChannelAccessor<Datum>;
|
|
145
|
+
/** the ending horizontal position channel for the area topline */
|
|
71
146
|
x2?: ChannelAccessor<Datum>;
|
|
147
|
+
/** the starting vertical position channel for the area baseline */
|
|
72
148
|
y1?: ChannelAccessor<Datum>;
|
|
149
|
+
/** the ending vertical position channel for the area topline */
|
|
73
150
|
y2?: ChannelAccessor<Datum>;
|
|
151
|
+
/** the series channel; data is grouped into separate areas by unique z values */
|
|
74
152
|
z?: ChannelAccessor<Datum>;
|
|
153
|
+
/** the curve interpolation method for connecting data points */
|
|
75
154
|
curve?: CurveName | CurveFactory;
|
|
155
|
+
/** the tension parameter for cardinal or Catmull-Rom curve interpolation */
|
|
76
156
|
tension?: number;
|
|
157
|
+
/** controls the order of data points before rendering */
|
|
77
158
|
sort?: ConstantAccessor<RawValue> | {
|
|
78
159
|
channel: "stroke" | "fill";
|
|
79
160
|
};
|
|
161
|
+
/** options for stacking area data values */
|
|
80
162
|
stack?: Partial<StackOptions>;
|
|
163
|
+
/** if true, renders using Canvas instead of SVG */
|
|
81
164
|
canvas?: boolean;
|
|
165
|
+
/** CSS class name(s) to apply to individual area path elements */
|
|
82
166
|
areaClass?: ConstantAccessor<string, Datum>;
|
|
83
167
|
};
|
|
84
168
|
exports: {};
|
package/dist/marks/AreaX.svelte
CHANGED
|
@@ -3,33 +3,67 @@
|
|
|
3
3
|
stacked horizontally if just the x channel is defined.
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts" generics="Datum extends DataRow">
|
|
6
|
-
interface AreaXMarkProps extends
|
|
6
|
+
interface AreaXMarkProps extends BaseMarkProps<Datum>, LinkableMarkProps<Datum> {
|
|
7
|
+
/** the input data array; each element becomes one point in the area */
|
|
8
|
+
data?: Datum[];
|
|
9
|
+
/** the horizontal position channel, implicit stacking is used to derive x1 and x2 channels */
|
|
7
10
|
x?: ChannelAccessor<Datum>;
|
|
11
|
+
/** the horizontal position channel of the lower end of bands */
|
|
12
|
+
x1?: ChannelAccessor<Datum>;
|
|
13
|
+
/** the horizontal position channel of the upper end of bands */
|
|
14
|
+
x2?: ChannelAccessor<Datum>;
|
|
15
|
+
/** the vertical position channel */
|
|
8
16
|
y?: ChannelAccessor<Datum>;
|
|
17
|
+
/** the series channel; data is grouped into separate areas by unique z values */
|
|
18
|
+
z?: ChannelAccessor<Datum>;
|
|
19
|
+
/** the curve interpolation method for connecting data points */
|
|
20
|
+
curve?: CurveName | CurveFactory;
|
|
21
|
+
/** the tension parameter for cardinal or Catmull-Rom curve interpolation */
|
|
22
|
+
tension?: number;
|
|
23
|
+
/** controls the order of data points before rendering */
|
|
24
|
+
sort?: ConstantAccessor<RawValue, Datum> | { channel: 'stroke' | 'fill' };
|
|
25
|
+
/** options for stacking area data values */
|
|
26
|
+
stack?: Partial<StackOptions>;
|
|
27
|
+
/** if true, renders using Canvas instead of SVG */
|
|
28
|
+
canvas?: boolean;
|
|
29
|
+
/** CSS class name(s) to apply to individual area path elements */
|
|
30
|
+
areaClass?: ConstantAccessor<string, Datum>;
|
|
9
31
|
}
|
|
10
32
|
import Area from './Area.svelte';
|
|
11
33
|
import { renameChannels } from '../transforms/rename.js';
|
|
12
34
|
import { stackX } from '../transforms/stack.js';
|
|
13
35
|
import { recordizeX } from '../transforms/recordize.js';
|
|
14
|
-
import type {
|
|
15
|
-
import {
|
|
36
|
+
import type { CurveFactory } from 'd3-shape';
|
|
37
|
+
import type { StackOptions } from '../transforms/stack.js';
|
|
38
|
+
import type {
|
|
39
|
+
BaseMarkProps,
|
|
40
|
+
ChannelAccessor,
|
|
41
|
+
ConstantAccessor,
|
|
42
|
+
CurveName,
|
|
43
|
+
DataRow,
|
|
44
|
+
LinkableMarkProps,
|
|
45
|
+
RawValue
|
|
46
|
+
} from '../types/index.js';
|
|
16
47
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
17
48
|
|
|
18
49
|
let markProps: AreaXMarkProps = $props();
|
|
19
50
|
|
|
20
51
|
const DEFAULTS = getPlotDefaults().areaX;
|
|
21
52
|
|
|
22
|
-
const {
|
|
53
|
+
const {
|
|
54
|
+
data = [],
|
|
55
|
+
stack,
|
|
56
|
+
...options
|
|
57
|
+
}: AreaXMarkProps = $derived({
|
|
23
58
|
...(markProps.x == undefined ? { x1: 0, x2: 0 } : {}),
|
|
24
59
|
...DEFAULTS,
|
|
25
60
|
...markProps
|
|
26
61
|
});
|
|
27
62
|
|
|
28
63
|
const args = $derived(
|
|
29
|
-
renameChannels
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
64
|
+
renameChannels(stackX(recordizeX({ data, ...options, y1: null, y2: null }), stack), {
|
|
65
|
+
y: 'y1'
|
|
66
|
+
})
|
|
33
67
|
);
|
|
34
68
|
</script>
|
|
35
69
|
|