svelteplot 0.0.1-alpha.9 → 0.1.3-next.4
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/LICENSE.md +5 -0
- package/README.md +3 -36
- package/dist/Mark.svelte +290 -0
- package/dist/Mark.svelte.d.ts +22 -0
- package/dist/Plot.svelte +148 -156
- package/dist/Plot.svelte.d.ts +15 -15
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +109 -0
- package/dist/core/Facet.svelte +59 -0
- package/dist/core/Facet.svelte.d.ts +18 -0
- package/dist/core/FacetAxes.svelte +66 -0
- package/dist/core/FacetAxes.svelte.d.ts +4 -0
- package/dist/core/FacetGrid.svelte +86 -0
- package/dist/core/FacetGrid.svelte.d.ts +13 -0
- package/dist/core/Plot.svelte +567 -0
- package/dist/core/Plot.svelte.d.ts +14 -0
- package/dist/helpers/arrowPath.d.ts +14 -0
- package/dist/helpers/arrowPath.js +129 -0
- package/dist/helpers/autoProjection.d.ts +19 -0
- package/dist/helpers/autoProjection.js +87 -0
- package/dist/helpers/autoScales.d.ts +23 -0
- package/dist/helpers/autoScales.js +203 -0
- package/dist/helpers/autoTicks.d.ts +3 -0
- package/dist/helpers/autoTicks.js +40 -0
- package/dist/helpers/autoTimeFormat.d.ts +2 -2
- package/dist/helpers/autoTimeFormat.js +34 -5
- package/dist/helpers/callWithProps.d.ts +8 -0
- package/dist/helpers/callWithProps.js +13 -0
- package/dist/helpers/colors.js +17 -2
- package/dist/helpers/curves.d.ts +3 -0
- package/dist/helpers/curves.js +42 -0
- package/dist/helpers/data.d.ts +9 -0
- package/dist/helpers/data.js +16 -0
- package/dist/helpers/facets.d.ts +12 -0
- package/dist/helpers/facets.js +49 -0
- package/dist/helpers/formats.d.ts +3 -0
- package/dist/helpers/formats.js +3 -0
- package/dist/helpers/getBaseStyles.d.ts +7 -2
- package/dist/helpers/getBaseStyles.js +34 -10
- package/dist/helpers/getLogTicks.js +5 -5
- package/dist/helpers/group.d.ts +6 -0
- package/dist/helpers/group.js +53 -0
- package/dist/helpers/index.d.ts +18 -0
- package/dist/helpers/index.js +53 -0
- package/dist/helpers/isRawValue.d.ts +2 -0
- package/dist/helpers/isRawValue.js +5 -0
- package/dist/helpers/isValid.d.ts +6 -0
- package/dist/helpers/isValid.js +6 -0
- package/dist/helpers/math.d.ts +19 -0
- package/dist/helpers/math.js +116 -0
- package/dist/helpers/mergeDeep.d.ts +1 -1
- package/dist/helpers/noise.d.ts +1 -0
- package/dist/helpers/noise.js +72 -0
- package/dist/helpers/projection.d.ts +33 -0
- package/dist/helpers/projection.js +100 -0
- package/dist/helpers/reduce.d.ts +10 -0
- package/dist/helpers/reduce.js +85 -0
- package/dist/helpers/regressionLoess.d.ts +12 -0
- package/dist/helpers/regressionLoess.js +47 -0
- package/dist/helpers/removeIdenticalLines.d.ts +8 -1
- package/dist/helpers/removeIdenticalLines.js +14 -7
- package/dist/helpers/resolve.d.ts +17 -0
- package/dist/helpers/resolve.js +152 -0
- package/dist/helpers/roundedRect.d.ts +9 -0
- package/dist/helpers/roundedRect.js +31 -0
- package/dist/helpers/scales.d.ts +42 -0
- package/dist/helpers/scales.js +309 -0
- package/dist/helpers/time.d.ts +6 -0
- package/dist/helpers/time.js +282 -0
- package/dist/helpers/typeChecks.d.ts +8 -5
- package/dist/helpers/typeChecks.js +27 -6
- package/dist/index.d.ts +49 -1
- package/dist/index.js +53 -2
- package/dist/marks/Area.svelte +146 -0
- package/dist/marks/Area.svelte.d.ts +30 -0
- package/dist/marks/AreaX.svelte +27 -0
- package/dist/marks/AreaX.svelte.d.ts +12 -0
- package/dist/marks/AreaY.svelte +38 -0
- package/dist/marks/AreaY.svelte.d.ts +19 -0
- package/dist/marks/Arrow.svelte +139 -0
- package/dist/marks/Arrow.svelte.d.ts +44 -0
- package/dist/marks/AxisX.svelte +198 -93
- package/dist/marks/AxisX.svelte.d.ts +17 -16
- package/dist/marks/AxisY.svelte +176 -62
- package/dist/marks/AxisY.svelte.d.ts +17 -14
- package/dist/marks/BarX.svelte +81 -0
- package/dist/marks/BarX.svelte.d.ts +4 -0
- package/dist/marks/BarY.svelte +95 -0
- package/dist/marks/BarY.svelte.d.ts +4 -0
- package/dist/marks/BollingerX.svelte +44 -0
- package/dist/marks/BollingerX.svelte.d.ts +18 -0
- package/dist/marks/BollingerY.svelte +39 -0
- package/dist/marks/BollingerY.svelte.d.ts +18 -0
- package/dist/marks/BoxX.svelte +89 -0
- package/dist/marks/BoxX.svelte.d.ts +4 -0
- package/dist/marks/BoxY.svelte +110 -0
- package/dist/marks/BoxY.svelte.d.ts +29 -0
- package/dist/marks/Cell.svelte +110 -0
- package/dist/marks/Cell.svelte.d.ts +16 -0
- package/dist/marks/CellX.svelte +24 -0
- package/dist/marks/CellX.svelte.d.ts +3 -0
- package/dist/marks/CellY.svelte +24 -0
- package/dist/marks/CellY.svelte.d.ts +3 -0
- package/dist/marks/ColorLegend.svelte +148 -27
- package/dist/marks/ColorLegend.svelte.d.ts +12 -13
- package/dist/marks/CustomMark.svelte +43 -0
- package/dist/marks/CustomMark.svelte.d.ts +16 -0
- package/dist/marks/CustomMarkHTML.svelte +103 -0
- package/dist/marks/CustomMarkHTML.svelte.d.ts +17 -0
- package/dist/marks/DifferenceY.svelte +144 -0
- package/dist/marks/DifferenceY.svelte.d.ts +30 -0
- package/dist/marks/Dot.svelte +128 -73
- package/dist/marks/Dot.svelte.d.ts +24 -14
- package/dist/marks/DotX.svelte +15 -3
- package/dist/marks/DotX.svelte.d.ts +8 -16
- package/dist/marks/DotY.svelte +8 -3
- package/dist/marks/DotY.svelte.d.ts +5 -17
- package/dist/marks/Frame.svelte +32 -31
- package/dist/marks/Frame.svelte.d.ts +7 -14
- package/dist/marks/Geo.svelte +102 -0
- package/dist/marks/Geo.svelte.d.ts +10 -0
- package/dist/marks/Graticule.svelte +28 -0
- package/dist/marks/Graticule.svelte.d.ts +9 -0
- package/dist/marks/GridX.svelte +67 -36
- package/dist/marks/GridX.svelte.d.ts +7 -18
- package/dist/marks/GridY.svelte +64 -25
- package/dist/marks/GridY.svelte.d.ts +7 -14
- package/dist/marks/HTMLTooltip.svelte +91 -0
- package/dist/marks/HTMLTooltip.svelte.d.ts +11 -0
- package/dist/marks/Line.svelte +219 -58
- package/dist/marks/Line.svelte.d.ts +30 -14
- package/dist/marks/LineX.svelte +8 -8
- package/dist/marks/LineX.svelte.d.ts +4 -17
- package/dist/marks/LineY.svelte +7 -8
- package/dist/marks/LineY.svelte.d.ts +4 -17
- package/dist/marks/Link.svelte +173 -0
- package/dist/marks/Link.svelte.d.ts +21 -0
- package/dist/marks/Pointer.svelte +126 -0
- package/dist/marks/Pointer.svelte.d.ts +23 -0
- package/dist/marks/Rect.svelte +103 -0
- package/dist/marks/Rect.svelte.d.ts +15 -0
- package/dist/marks/RectX.svelte +33 -0
- package/dist/marks/RectX.svelte.d.ts +15 -0
- package/dist/marks/RectY.svelte +33 -0
- package/dist/marks/RectY.svelte.d.ts +15 -0
- package/dist/marks/RegressionX.svelte +26 -0
- package/dist/marks/RegressionX.svelte.d.ts +4 -0
- package/dist/marks/RegressionY.svelte +26 -0
- package/dist/marks/RegressionY.svelte.d.ts +4 -0
- package/dist/marks/RuleX.svelte +52 -28
- package/dist/marks/RuleX.svelte.d.ts +14 -14
- package/dist/marks/RuleY.svelte +52 -28
- package/dist/marks/RuleY.svelte.d.ts +14 -14
- package/dist/marks/Sphere.svelte +8 -0
- package/dist/marks/Sphere.svelte.d.ts +51 -0
- package/dist/marks/Spike.svelte +15 -0
- package/dist/marks/Spike.svelte.d.ts +4 -0
- package/dist/marks/SymbolLegend.svelte +27 -12
- package/dist/marks/SymbolLegend.svelte.d.ts +8 -14
- package/dist/marks/Text.svelte +185 -0
- package/dist/marks/Text.svelte.d.ts +26 -0
- package/dist/marks/TickX.svelte +89 -0
- package/dist/marks/TickX.svelte.d.ts +22 -0
- package/dist/marks/TickY.svelte +90 -0
- package/dist/marks/TickY.svelte.d.ts +22 -0
- package/dist/marks/Vector.svelte +213 -0
- package/dist/marks/Vector.svelte.d.ts +31 -0
- package/dist/marks/helpers/BaseAxisX.svelte +210 -0
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +24 -0
- package/dist/marks/helpers/BaseAxisY.svelte +187 -0
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +23 -0
- package/dist/marks/helpers/CanvasLayer.svelte +38 -0
- package/dist/marks/helpers/CanvasLayer.svelte.d.ts +13 -0
- package/dist/marks/helpers/DotCanvas.svelte +184 -0
- package/dist/marks/helpers/DotCanvas.svelte.d.ts +11 -0
- package/dist/marks/helpers/GeoCanvas.svelte +165 -0
- package/dist/marks/helpers/GeoCanvas.svelte.d.ts +13 -0
- package/dist/marks/helpers/GroupMultiple.svelte +17 -0
- package/dist/marks/helpers/GroupMultiple.svelte.d.ts +9 -0
- package/dist/marks/helpers/Marker.svelte +93 -0
- package/dist/marks/helpers/Marker.svelte.d.ts +10 -0
- package/dist/marks/helpers/MarkerPath.svelte +164 -0
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +44 -0
- package/dist/marks/helpers/Regression.svelte +174 -0
- package/dist/marks/helpers/Regression.svelte.d.ts +26 -0
- package/dist/marks/helpers/events.d.ts +8 -0
- package/dist/marks/helpers/events.js +64 -0
- package/dist/transforms/bin.d.ts +51 -0
- package/dist/transforms/bin.js +171 -0
- package/dist/transforms/bollinger.d.ts +21 -0
- package/dist/transforms/bollinger.js +53 -0
- package/dist/transforms/centroid.d.ts +9 -0
- package/dist/transforms/centroid.js +13 -0
- package/dist/transforms/facet.d.ts +1 -0
- package/dist/transforms/facet.js +1 -0
- package/dist/transforms/filter.d.ts +2 -0
- package/dist/transforms/filter.js +8 -0
- package/dist/transforms/group.d.ts +66 -0
- package/dist/transforms/group.js +109 -0
- package/dist/transforms/interval.d.ts +11 -0
- package/dist/transforms/interval.js +34 -0
- package/dist/transforms/jitter.d.ts +0 -0
- package/dist/transforms/jitter.js +1 -0
- package/dist/transforms/map.d.ts +10 -0
- package/dist/transforms/map.js +89 -0
- package/dist/transforms/normalize.d.ts +9 -0
- package/dist/transforms/normalize.js +86 -0
- package/dist/transforms/recordize.d.ts +13 -0
- package/dist/transforms/recordize.js +75 -0
- package/dist/transforms/rename.d.ts +14 -0
- package/dist/transforms/rename.js +42 -0
- package/dist/transforms/select.d.ts +35 -0
- package/dist/transforms/select.js +55 -0
- package/dist/transforms/shift.d.ts +13 -0
- package/dist/transforms/shift.js +45 -0
- package/dist/transforms/sort.d.ts +28 -0
- package/dist/transforms/sort.js +61 -0
- package/dist/transforms/stack.d.ts +10 -0
- package/dist/transforms/stack.js +110 -0
- package/dist/transforms/window.d.ts +22 -0
- package/dist/transforms/window.js +73 -0
- package/dist/types.d.ts +625 -188
- package/dist/ui/Checkbox.svelte +6 -0
- package/dist/ui/Checkbox.svelte.d.ts +13 -0
- package/dist/ui/RadioInput.svelte +27 -0
- package/dist/ui/RadioInput.svelte.d.ts +9 -0
- package/dist/ui/Select.svelte +27 -0
- package/dist/ui/Select.svelte.d.ts +9 -0
- package/dist/ui/Slider.svelte +47 -0
- package/dist/ui/Slider.svelte.d.ts +11 -0
- package/dist/ui/Spiral.svelte +46 -0
- package/dist/ui/Spiral.svelte.d.ts +15 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +4 -0
- package/package.json +79 -40
- package/LICENSE +0 -11
- package/dist/classes/Channel.svelte.js +0 -74
- package/dist/classes/Mark.svelte.js +0 -17
- package/dist/classes/Plot.svelte.js +0 -98
- package/dist/contants.d.ts +0 -3
- package/dist/contants.js +0 -40
- package/dist/helpers/GroupMultiple.svelte +0 -8
- package/dist/helpers/GroupMultiple.svelte.d.ts +0 -19
- package/dist/helpers/createScale.d.ts +0 -5
- package/dist/helpers/createScale.js +0 -57
- package/dist/helpers/resolveChannel.d.ts +0 -2
- package/dist/helpers/resolveChannel.js +0 -28
- package/dist/helpers/wrapArray.d.ts +0 -2
- package/dist/helpers/wrapArray.js +0 -4
- package/dist/marks/BaseMark.svelte +0 -22
- package/dist/marks/BaseMark.svelte.d.ts +0 -19
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { CurveName, DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, MarkerOptions } from '../types.js';
|
|
2
|
+
export type BaseLineMarkProps = {
|
|
3
|
+
data: DataRecord[];
|
|
4
|
+
z?: ChannelAccessor;
|
|
5
|
+
stroke?: ChannelAccessor;
|
|
6
|
+
outlineStroke?: ConstantAccessor<string>;
|
|
7
|
+
outlineStrokeWidth?: ConstantAccessor<number>;
|
|
8
|
+
dx?: ConstantAccessor<number>;
|
|
9
|
+
dy?: ConstantAccessor<number>;
|
|
10
|
+
curve?: CurveName | CurveFactory;
|
|
11
|
+
tension?: number;
|
|
12
|
+
sort?: ConstantAccessor<RawValue> | {
|
|
13
|
+
channel: 'stroke' | 'fill';
|
|
7
14
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
15
|
+
text?: ConstantAccessor<string>;
|
|
16
|
+
textFill?: ConstantAccessor<string>;
|
|
17
|
+
textStroke?: ConstantAccessor<string>;
|
|
18
|
+
textStartOffset?: ConstantAccessor<string>;
|
|
19
|
+
textStrokeWidth?: ConstantAccessor<number>;
|
|
20
|
+
lineClass?: ConstantAccessor<string>;
|
|
21
|
+
} & MarkerOptions;
|
|
22
|
+
import { type CurveFactory } from 'd3-shape';
|
|
23
|
+
import type { RawValue } from '../types.js';
|
|
24
|
+
type LineMarkProps = BaseMarkProps & {
|
|
25
|
+
x?: ChannelAccessor;
|
|
26
|
+
y?: ChannelAccessor;
|
|
27
|
+
} & BaseLineMarkProps;
|
|
28
|
+
/** Line mark, useful for line charts */
|
|
29
|
+
declare const Line: import("svelte").Component<LineMarkProps, {}, "">;
|
|
30
|
+
type Line = ReturnType<typeof Line>;
|
|
31
|
+
export default Line;
|
package/dist/marks/LineX.svelte
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Line, { type BaseLineMarkProps } from './Line.svelte';
|
|
3
|
+
import { recordizeX } from '../index.js';
|
|
4
|
+
|
|
5
|
+
let { data = [{}], ...rest }: BaseLineMarkProps = $props();
|
|
6
|
+
|
|
7
|
+
let args = $derived(recordizeX({ data, ...rest }));
|
|
3
8
|
</script>
|
|
4
9
|
|
|
5
|
-
<Line
|
|
6
|
-
data={data.map((value, index) => ({ value, index, ___orig___: value }))}
|
|
7
|
-
x="value"
|
|
8
|
-
y="index"
|
|
9
|
-
{...rest}
|
|
10
|
-
/>
|
|
10
|
+
<Line {...args} />
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
data: RawValue[];
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {};
|
|
11
|
-
};
|
|
12
|
-
export type LineXProps = typeof __propDef.props;
|
|
13
|
-
export type LineXEvents = typeof __propDef.events;
|
|
14
|
-
export type LineXSlots = typeof __propDef.slots;
|
|
15
|
-
export default class LineX extends SvelteComponent<LineXProps, LineXEvents, LineXSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
1
|
+
import { type BaseLineMarkProps } from './Line.svelte';
|
|
2
|
+
declare const LineX: import("svelte").Component<BaseLineMarkProps, {}, "">;
|
|
3
|
+
type LineX = ReturnType<typeof LineX>;
|
|
4
|
+
export default LineX;
|
package/dist/marks/LineY.svelte
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Line, { type BaseLineMarkProps } from './Line.svelte';
|
|
3
|
+
import { recordizeY } from '../index.js';
|
|
4
|
+
|
|
5
|
+
let { data = [{}], ...rest }: BaseLineMarkProps = $props();
|
|
6
|
+
let args = $derived(recordizeY({ data, ...rest }));
|
|
3
7
|
</script>
|
|
4
8
|
|
|
5
|
-
<Line
|
|
6
|
-
data={data.map((value, index) => ({ value, index, ___orig___: value }))}
|
|
7
|
-
x="index"
|
|
8
|
-
y="value"
|
|
9
|
-
{...rest}
|
|
10
|
-
/>
|
|
9
|
+
<Line {...args} />
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
data: RawValue[];
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {};
|
|
11
|
-
};
|
|
12
|
-
export type LineYProps = typeof __propDef.props;
|
|
13
|
-
export type LineYEvents = typeof __propDef.events;
|
|
14
|
-
export type LineYSlots = typeof __propDef.slots;
|
|
15
|
-
export default class LineY extends SvelteComponent<LineYProps, LineYEvents, LineYSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
1
|
+
import { type BaseLineMarkProps } from './Line.svelte';
|
|
2
|
+
declare const LineY: import("svelte").Component<BaseLineMarkProps, {}, "">;
|
|
3
|
+
type LineY = ReturnType<typeof LineY>;
|
|
4
|
+
export default LineY;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, type Snippet } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
PlotContext,
|
|
5
|
+
DataRecord,
|
|
6
|
+
BaseMarkProps,
|
|
7
|
+
ConstantAccessor,
|
|
8
|
+
ChannelAccessor,
|
|
9
|
+
CurveName,
|
|
10
|
+
MarkerOptions,
|
|
11
|
+
RawValue,
|
|
12
|
+
FacetContext,
|
|
13
|
+
DataRow,
|
|
14
|
+
ScaledDataRecord
|
|
15
|
+
} from '../types.js';
|
|
16
|
+
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
17
|
+
import { maybeData, testFilter } from '../helpers/index.js';
|
|
18
|
+
import { getUsedScales, projectXY } from '../helpers/scales.js';
|
|
19
|
+
import Mark from '../Mark.svelte';
|
|
20
|
+
import MarkerPath from './helpers/MarkerPath.svelte';
|
|
21
|
+
import { replaceChannels } from '../transforms/rename.js';
|
|
22
|
+
import { line, type CurveFactory } from 'd3-shape';
|
|
23
|
+
import callWithProps from '../helpers/callWithProps.js';
|
|
24
|
+
import { maybeCurve } from '../helpers/curves.js';
|
|
25
|
+
import { geoPath } from 'd3-geo';
|
|
26
|
+
import { pick } from 'es-toolkit';
|
|
27
|
+
|
|
28
|
+
type LinkMarkProps = BaseMarkProps & {
|
|
29
|
+
data: DataRecord[];
|
|
30
|
+
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
31
|
+
x1: ChannelAccessor;
|
|
32
|
+
y1: ChannelAccessor;
|
|
33
|
+
x2: ChannelAccessor;
|
|
34
|
+
y2: ChannelAccessor;
|
|
35
|
+
stroke?: ChannelAccessor;
|
|
36
|
+
curve?: 'auto' | CurveName | CurveFactory;
|
|
37
|
+
tension?: number;
|
|
38
|
+
text: ConstantAccessor<string>;
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
} & MarkerOptions;
|
|
41
|
+
|
|
42
|
+
let {
|
|
43
|
+
data = [{}],
|
|
44
|
+
curve = 'auto',
|
|
45
|
+
tension = 0,
|
|
46
|
+
text,
|
|
47
|
+
class: className = null,
|
|
48
|
+
...options
|
|
49
|
+
}: LinkMarkProps = $props();
|
|
50
|
+
|
|
51
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
52
|
+
let plot = $derived(getPlotState());
|
|
53
|
+
|
|
54
|
+
function isValid(value: RawValue): value is number | Date | string {
|
|
55
|
+
return value !== null && (typeof value === 'string' || !Number.isNaN(value));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const sorted = $derived(
|
|
59
|
+
options.sort
|
|
60
|
+
? maybeData(data).toSorted((a, b) =>
|
|
61
|
+
resolveChannel('sort', a, options) > resolveChannel('sort', b, options) ? 1 : -1
|
|
62
|
+
)
|
|
63
|
+
: maybeData(data)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const args = $derived(
|
|
67
|
+
replaceChannels(
|
|
68
|
+
{ data: sorted, stroke: 'currentColor', ...options },
|
|
69
|
+
{ y: ['y1', 'y2'], x: ['x1', 'x2'] }
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const sphericalLine = $derived(plot.scales.projection && curve === 'auto');
|
|
74
|
+
|
|
75
|
+
const linePath: (d: ScaledDataRecord) => string = $derived.by(() => {
|
|
76
|
+
const fn = callWithProps(line, [], {
|
|
77
|
+
curve: maybeCurve(curve === 'auto' ? 'linear' : curve, tension),
|
|
78
|
+
x: (d) => d[0],
|
|
79
|
+
y: (d) => d[1]
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return (d: ScaledDataRecord) =>
|
|
83
|
+
fn([
|
|
84
|
+
[d.x1, d.y1],
|
|
85
|
+
[d.x2, d.y2]
|
|
86
|
+
]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const sphericalLinePath: (d: ScaledDataRecord) => string = $derived.by(() => {
|
|
90
|
+
const fn = sphereLine(plot.scales.projection);
|
|
91
|
+
return (d: ScaledDataRecord) => {
|
|
92
|
+
const x1 = resolveChannel('x1', d.datum, args);
|
|
93
|
+
const y1 = resolveChannel('y1', d.datum, args);
|
|
94
|
+
const x2 = resolveChannel('x2', d.datum, args);
|
|
95
|
+
const y2 = resolveChannel('y2', d.datum, args);
|
|
96
|
+
return fn(x1, y1, x2, y2);
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
// sphericalLine
|
|
100
|
+
// ?
|
|
101
|
+
|
|
102
|
+
// sphereLine(plot.scales.projection)
|
|
103
|
+
// :
|
|
104
|
+
// );
|
|
105
|
+
|
|
106
|
+
function sphereLine(projection) {
|
|
107
|
+
const path = geoPath(projection);
|
|
108
|
+
return (x1: number, y1: number, x2: number, y2: number) => {
|
|
109
|
+
return path({
|
|
110
|
+
type: 'LineString',
|
|
111
|
+
coordinates: [
|
|
112
|
+
[x1, y1],
|
|
113
|
+
[x2, y2]
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<Mark
|
|
121
|
+
type="link"
|
|
122
|
+
required={['x1', 'x2', 'y1', 'y2']}
|
|
123
|
+
channels={['x1', 'y1', 'x2', 'y2', 'opacity', 'stroke', 'strokeOpacity']}
|
|
124
|
+
{...args}>
|
|
125
|
+
{#snippet children({ mark, scaledData, usedScales })}
|
|
126
|
+
<g class={['link', className]} data-use-x={usedScales.x ? 1 : 0}>
|
|
127
|
+
{#each scaledData as d}
|
|
128
|
+
{#if d.valid || true}
|
|
129
|
+
{@const dx = resolveProp(args.dx, d.datum, 0)}
|
|
130
|
+
{@const dy = resolveProp(args.dx, d.datum, 0)}
|
|
131
|
+
{@const [style, styleClass] = resolveStyles(
|
|
132
|
+
plot,
|
|
133
|
+
d,
|
|
134
|
+
{ strokeWidth: 1.6, ...args },
|
|
135
|
+
'stroke',
|
|
136
|
+
usedScales
|
|
137
|
+
)}
|
|
138
|
+
{@const [textStyle, textStyleClass] = resolveStyles(
|
|
139
|
+
plot,
|
|
140
|
+
d,
|
|
141
|
+
{
|
|
142
|
+
textAnchor: 'middle',
|
|
143
|
+
...pick(args, ['fontSize', 'fontWeight', 'fontStyle', 'textAnchor']),
|
|
144
|
+
fill: args.textFill || args.stroke,
|
|
145
|
+
stroke: args.textStroke,
|
|
146
|
+
strokeWidth: args.textStrokeWidth
|
|
147
|
+
},
|
|
148
|
+
'fill',
|
|
149
|
+
usedScales
|
|
150
|
+
)}
|
|
151
|
+
|
|
152
|
+
<MarkerPath
|
|
153
|
+
{mark}
|
|
154
|
+
scales={plot.scales}
|
|
155
|
+
markerStart={args.markerStart}
|
|
156
|
+
markerEnd={args.markerEnd}
|
|
157
|
+
marker={args.marker}
|
|
158
|
+
class={styleClass}
|
|
159
|
+
strokeWidth={args.strokeWidth}
|
|
160
|
+
datum={d.datum}
|
|
161
|
+
color={d.stroke}
|
|
162
|
+
d={sphericalLine ? sphericalLinePath(d) : linePath(d)}
|
|
163
|
+
{style}
|
|
164
|
+
text={text ? resolveProp(text, d.datum) : null}
|
|
165
|
+
startOffset={resolveProp(args.textStartOffset, d.datum, '50%')}
|
|
166
|
+
{textStyle}
|
|
167
|
+
{textStyleClass}
|
|
168
|
+
transform={dx || dy ? `translate(${dx}, ${dy})` : null} />
|
|
169
|
+
{/if}
|
|
170
|
+
{/each}
|
|
171
|
+
</g>
|
|
172
|
+
{/snippet}
|
|
173
|
+
</Mark>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, CurveName, MarkerOptions, RawValue } from '../types.js';
|
|
3
|
+
import { type CurveFactory } from 'd3-shape';
|
|
4
|
+
type LinkMarkProps = BaseMarkProps & {
|
|
5
|
+
data: DataRecord[];
|
|
6
|
+
sort?: ConstantAccessor<RawValue> | {
|
|
7
|
+
channel: 'stroke' | 'fill';
|
|
8
|
+
};
|
|
9
|
+
x1: ChannelAccessor;
|
|
10
|
+
y1: ChannelAccessor;
|
|
11
|
+
x2: ChannelAccessor;
|
|
12
|
+
y2: ChannelAccessor;
|
|
13
|
+
stroke?: ChannelAccessor;
|
|
14
|
+
curve?: 'auto' | CurveName | CurveFactory;
|
|
15
|
+
tension?: number;
|
|
16
|
+
text: ConstantAccessor<string>;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
} & MarkerOptions;
|
|
19
|
+
declare const Link: import("svelte").Component<LinkMarkProps, {}, "">;
|
|
20
|
+
type Link = ReturnType<typeof Link>;
|
|
21
|
+
export default Link;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { ChannelAccessor, DataRow } from '../types.js';
|
|
3
|
+
|
|
4
|
+
export type PointerMarkProps = {
|
|
5
|
+
data: DataRow[];
|
|
6
|
+
children: Snippet<[{ data: DataRow[] }]>;
|
|
7
|
+
x?: ChannelAccessor;
|
|
8
|
+
y?: ChannelAccessor;
|
|
9
|
+
z?: ChannelAccessor;
|
|
10
|
+
/**
|
|
11
|
+
* maximum cursor distance to select data points
|
|
12
|
+
*/
|
|
13
|
+
maxDistance: number;
|
|
14
|
+
/**
|
|
15
|
+
* called whenever the selection changes
|
|
16
|
+
* @param data
|
|
17
|
+
*/
|
|
18
|
+
onupdate: (data: DataRow[]) => void;
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { getContext, type Snippet } from 'svelte';
|
|
24
|
+
import type { PlotContext } from '../types.js';
|
|
25
|
+
import { groups as d3Groups } from 'd3-array';
|
|
26
|
+
|
|
27
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
28
|
+
const plot = $derived(getPlotState());
|
|
29
|
+
|
|
30
|
+
import { resolveChannel } from '../helpers/resolve.js';
|
|
31
|
+
import { quadtree } from 'd3-quadtree';
|
|
32
|
+
import { projectXY } from '../helpers/scales.js';
|
|
33
|
+
import isDataRecord from '../helpers/isDataRecord.js';
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
data = [{}],
|
|
37
|
+
children,
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
z,
|
|
41
|
+
maxDistance = 15,
|
|
42
|
+
onupdate = null
|
|
43
|
+
}: PointerMarkProps = $props();
|
|
44
|
+
|
|
45
|
+
let selectedData = $state([]);
|
|
46
|
+
|
|
47
|
+
function onMouseMove(evt: MouseEvent) {
|
|
48
|
+
updateSelection(evt.layerX, evt.layerY);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function onTouchMove(evt: TouchEvent) {
|
|
52
|
+
if (evt.touches) {
|
|
53
|
+
const rect = (evt.target as HTMLElement).getBoundingClientRect();
|
|
54
|
+
const pageTop = window.scrollY || document.documentElement.scrollTop;
|
|
55
|
+
const ox = rect.left;
|
|
56
|
+
const oy = rect.top + pageTop;
|
|
57
|
+
|
|
58
|
+
const touch = evt.touches[0] || evt.changedTouches[0];
|
|
59
|
+
if (touch) {
|
|
60
|
+
const ex = touch.pageX - ox;
|
|
61
|
+
const ey = touch.pageY - oy;
|
|
62
|
+
updateSelection(ex, ey);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function onMouseLeave() {
|
|
68
|
+
selectedData = [];
|
|
69
|
+
if (onupdate) onupdate(selectedData);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function updateSelection(ex: number, ey: number) {
|
|
73
|
+
// find data row with minimum distance to
|
|
74
|
+
const points = trees.map((tree) =>
|
|
75
|
+
tree.find(x != null ? ex : 0, y != null ? ey : 0, maxDistance)
|
|
76
|
+
);
|
|
77
|
+
selectedData = points.filter((d) => d != null);
|
|
78
|
+
if (onupdate) onupdate(selectedData);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
$effect(() => {
|
|
82
|
+
plot.body?.addEventListener('mousemove', onMouseMove);
|
|
83
|
+
plot.body?.addEventListener('mouseleave', onMouseLeave);
|
|
84
|
+
plot.body?.addEventListener('touchmove', onTouchMove);
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
plot.body?.removeEventListener('mousemove', onMouseMove);
|
|
88
|
+
plot.body?.removeEventListener('mouseleave', onMouseLeave);
|
|
89
|
+
plot.body?.removeEventListener('touchmove', onTouchMove);
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const groups = $derived(
|
|
94
|
+
z != null ? d3Groups(data, (d) => resolveChannel('z', d, { x, z })) : [[null, data]]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const trees = $derived(
|
|
98
|
+
groups.map(([, items]) =>
|
|
99
|
+
quadtree()
|
|
100
|
+
.x(x != null ? (d) => d.__pointerX : () => 0)
|
|
101
|
+
.y(y != null ? (d) => d.__pointerY : () => 0)
|
|
102
|
+
.addAll(
|
|
103
|
+
items?.map((d) => {
|
|
104
|
+
const [px, py] = projectXY(
|
|
105
|
+
plot.scales,
|
|
106
|
+
resolveChannel('x', d, { x }),
|
|
107
|
+
resolveChannel('y', d, { y }),
|
|
108
|
+
true,
|
|
109
|
+
true
|
|
110
|
+
);
|
|
111
|
+
return {
|
|
112
|
+
...(isDataRecord(d) ? d : { ___orig___: d }),
|
|
113
|
+
__pointerX: px,
|
|
114
|
+
__pointerY: py
|
|
115
|
+
};
|
|
116
|
+
}) ?? []
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
{#if children}
|
|
123
|
+
<g class="pointer">
|
|
124
|
+
{@render children({ data: selectedData })}
|
|
125
|
+
</g>
|
|
126
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChannelAccessor, DataRow } from '../types.js';
|
|
2
|
+
export type PointerMarkProps = {
|
|
3
|
+
data: DataRow[];
|
|
4
|
+
children: Snippet<[{
|
|
5
|
+
data: DataRow[];
|
|
6
|
+
}]>;
|
|
7
|
+
x?: ChannelAccessor;
|
|
8
|
+
y?: ChannelAccessor;
|
|
9
|
+
z?: ChannelAccessor;
|
|
10
|
+
/**
|
|
11
|
+
* maximum cursor distance to select data points
|
|
12
|
+
*/
|
|
13
|
+
maxDistance: number;
|
|
14
|
+
/**
|
|
15
|
+
* called whenever the selection changes
|
|
16
|
+
* @param data
|
|
17
|
+
*/
|
|
18
|
+
onupdate: (data: DataRow[]) => void;
|
|
19
|
+
};
|
|
20
|
+
import { type Snippet } from 'svelte';
|
|
21
|
+
declare const Pointer: import("svelte").Component<PointerMarkProps, {}, "">;
|
|
22
|
+
type Pointer = ReturnType<typeof Pointer>;
|
|
23
|
+
export default Pointer;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
For arbitrary rectangles, requires quantitative x and y scales
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import Mark from '../Mark.svelte';
|
|
7
|
+
import { getContext } from 'svelte';
|
|
8
|
+
import { recordizeY, intervalX, intervalY } from '../index.js';
|
|
9
|
+
import {
|
|
10
|
+
resolveChannel,
|
|
11
|
+
resolveProp,
|
|
12
|
+
resolveScaledStyles,
|
|
13
|
+
resolveStyles
|
|
14
|
+
} from '../helpers/resolve.js';
|
|
15
|
+
import { getUsedScales, projectX, projectY } from '../helpers/scales.js';
|
|
16
|
+
import { coalesce, testFilter, maybeNumber } from '../helpers/index.js';
|
|
17
|
+
import type {
|
|
18
|
+
PlotContext,
|
|
19
|
+
DataRecord,
|
|
20
|
+
BaseMarkProps,
|
|
21
|
+
BaseRectMarkProps,
|
|
22
|
+
ChannelAccessor
|
|
23
|
+
} from '../types.js';
|
|
24
|
+
import { isValid } from '../helpers/isValid.js';
|
|
25
|
+
import { addEventHandlers } from './helpers/events.js';
|
|
26
|
+
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
27
|
+
|
|
28
|
+
type RectMarkProps = BaseMarkProps & {
|
|
29
|
+
data: DataRecord[];
|
|
30
|
+
x?: ChannelAccessor;
|
|
31
|
+
x1?: ChannelAccessor;
|
|
32
|
+
x2?: ChannelAccessor;
|
|
33
|
+
y?: ChannelAccessor;
|
|
34
|
+
y1?: ChannelAccessor;
|
|
35
|
+
y2?: ChannelAccessor;
|
|
36
|
+
interval?: number | string;
|
|
37
|
+
} & BaseRectMarkProps;
|
|
38
|
+
|
|
39
|
+
let { data = [{}], class: className = null, ...options }: RectMarkProps = $props();
|
|
40
|
+
|
|
41
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
42
|
+
let plot = $derived(getPlotState());
|
|
43
|
+
|
|
44
|
+
const args = $derived(
|
|
45
|
+
intervalY(intervalX({ data, ...options }, { plot }), { plot }) as RectMarkProps
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<Mark
|
|
50
|
+
type="rect"
|
|
51
|
+
required={[]}
|
|
52
|
+
channels={['x1', 'x2', 'y1', 'y2', 'fill', 'stroke', 'opacity', 'fillOpacity', 'strokeOpacity']}
|
|
53
|
+
{...args}>
|
|
54
|
+
{#snippet children({ mark, usedScales, scaledData })}
|
|
55
|
+
<g class="rect">
|
|
56
|
+
{#each scaledData as d}
|
|
57
|
+
{#if d.valid}
|
|
58
|
+
{@const x1 = d.x1 == null ? plot.options.marginLeft : d.x1}
|
|
59
|
+
{@const x2 = d.x2 == null ? plot.options.marginLeft + plot.facetWidth : d.x2}
|
|
60
|
+
{@const y1 = d.y1 == null ? plot.options.marginTop : d.y1}
|
|
61
|
+
{@const y2 = d.y2 == null ? plot.options.marginTop + plot.facetHeight : d.y2}
|
|
62
|
+
|
|
63
|
+
{@const miny = Math.min(y1, y2)}
|
|
64
|
+
{@const maxy = Math.max(y1, y2)}
|
|
65
|
+
{@const minx = Math.min(x1, x2)}
|
|
66
|
+
{@const maxx = Math.max(x1, x2)}
|
|
67
|
+
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
68
|
+
{@const insetLeft = resolveProp(args.insetLeft, d.datum)}
|
|
69
|
+
{@const insetRight = resolveProp(args.insetRight, d.datum)}
|
|
70
|
+
{@const insetTop = resolveProp(args.insetTop, d.datum)}
|
|
71
|
+
{@const insetBottom = resolveProp(args.insetBottom, d.datum)}
|
|
72
|
+
{@const insetL = maybeNumber(coalesce(insetLeft, inset, 0))}
|
|
73
|
+
{@const insetT = maybeNumber(coalesce(insetTop, inset, 0))}
|
|
74
|
+
{@const insetR = maybeNumber(coalesce(insetRight, inset, 0))}
|
|
75
|
+
{@const insetB = maybeNumber(coalesce(insetBottom, inset, 0))}
|
|
76
|
+
|
|
77
|
+
{@const [style, styleClass] = resolveStyles(plot, d, args, 'fill', usedScales)}
|
|
78
|
+
<rect
|
|
79
|
+
class={[styleClass]}
|
|
80
|
+
{style}
|
|
81
|
+
x={minx + insetL}
|
|
82
|
+
y={miny + insetT}
|
|
83
|
+
width={maxx - minx - insetL - insetR}
|
|
84
|
+
height={maxy - miny - insetT - insetB}
|
|
85
|
+
rx={resolveProp(args.rx, d.datum, null)}
|
|
86
|
+
ry={resolveProp(args.ry, d.datum, null)}
|
|
87
|
+
use:addEventHandlers={{
|
|
88
|
+
getPlotState,
|
|
89
|
+
options: args,
|
|
90
|
+
datum: d.datum
|
|
91
|
+
}} />
|
|
92
|
+
{/if}
|
|
93
|
+
{/each}
|
|
94
|
+
</g>
|
|
95
|
+
{/snippet}
|
|
96
|
+
</Mark>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
rect {
|
|
100
|
+
stroke: none;
|
|
101
|
+
/* fill: none; */
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataRecord, BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
|
|
2
|
+
type RectMarkProps = BaseMarkProps & {
|
|
3
|
+
data: DataRecord[];
|
|
4
|
+
x?: ChannelAccessor;
|
|
5
|
+
x1?: ChannelAccessor;
|
|
6
|
+
x2?: ChannelAccessor;
|
|
7
|
+
y?: ChannelAccessor;
|
|
8
|
+
y1?: ChannelAccessor;
|
|
9
|
+
y2?: ChannelAccessor;
|
|
10
|
+
interval?: number | string;
|
|
11
|
+
} & BaseRectMarkProps;
|
|
12
|
+
/** For arbitrary rectangles, requires quantitative x and y scales */
|
|
13
|
+
declare const Rect: import("svelte").Component<RectMarkProps, {}, "">;
|
|
14
|
+
type Rect = ReturnType<typeof Rect>;
|
|
15
|
+
export default Rect;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Rect from './Rect.svelte';
|
|
3
|
+
import { intervalY, stackX, recordizeX } from '../index.js';
|
|
4
|
+
import type {
|
|
5
|
+
DataRecord,
|
|
6
|
+
BaseMarkProps,
|
|
7
|
+
ChannelAccessor,
|
|
8
|
+
BaseRectMarkProps,
|
|
9
|
+
PlotContext
|
|
10
|
+
} from '../types.js';
|
|
11
|
+
import type { StackOptions } from '../transforms/stack.js';
|
|
12
|
+
import { getContext } from 'svelte';
|
|
13
|
+
|
|
14
|
+
type RectXMarkProps = BaseMarkProps & {
|
|
15
|
+
data: DataRecord[];
|
|
16
|
+
x?: ChannelAccessor;
|
|
17
|
+
x1?: ChannelAccessor;
|
|
18
|
+
x2?: ChannelAccessor;
|
|
19
|
+
y1?: ChannelAccessor;
|
|
20
|
+
y2?: ChannelAccessor;
|
|
21
|
+
stack?: StackOptions;
|
|
22
|
+
interval?: number | string;
|
|
23
|
+
} & BaseRectMarkProps;
|
|
24
|
+
|
|
25
|
+
let { data = [{}], stack, ...options }: RectXMarkProps = $props();
|
|
26
|
+
|
|
27
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
28
|
+
let plot = $derived(getPlotState());
|
|
29
|
+
|
|
30
|
+
const args = $derived(stackX(intervalY(recordizeX({ data, ...options }), { plot }), stack));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Rect {...args}></Rect>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataRecord, BaseMarkProps, ChannelAccessor, BaseRectMarkProps } from '../types.js';
|
|
2
|
+
import type { StackOptions } from '../transforms/stack.js';
|
|
3
|
+
type RectXMarkProps = BaseMarkProps & {
|
|
4
|
+
data: DataRecord[];
|
|
5
|
+
x?: ChannelAccessor;
|
|
6
|
+
x1?: ChannelAccessor;
|
|
7
|
+
x2?: ChannelAccessor;
|
|
8
|
+
y1?: ChannelAccessor;
|
|
9
|
+
y2?: ChannelAccessor;
|
|
10
|
+
stack?: StackOptions;
|
|
11
|
+
interval?: number | string;
|
|
12
|
+
} & BaseRectMarkProps;
|
|
13
|
+
declare const RectX: import("svelte").Component<RectXMarkProps, {}, "">;
|
|
14
|
+
type RectX = ReturnType<typeof RectX>;
|
|
15
|
+
export default RectX;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Rect from './Rect.svelte';
|
|
3
|
+
import { intervalX, stackY, recordizeY } from '../index.js';
|
|
4
|
+
import type { StackOptions } from '../transforms/stack.js';
|
|
5
|
+
import type {
|
|
6
|
+
DataRecord,
|
|
7
|
+
BaseMarkProps,
|
|
8
|
+
ChannelAccessor,
|
|
9
|
+
BaseRectMarkProps,
|
|
10
|
+
PlotContext
|
|
11
|
+
} from '../types.js';
|
|
12
|
+
import { getContext } from 'svelte';
|
|
13
|
+
|
|
14
|
+
type RectYMarkProps = BaseMarkProps & {
|
|
15
|
+
data: DataRecord[];
|
|
16
|
+
y?: ChannelAccessor;
|
|
17
|
+
y1?: ChannelAccessor;
|
|
18
|
+
y2?: ChannelAccessor;
|
|
19
|
+
x1?: ChannelAccessor;
|
|
20
|
+
x2?: ChannelAccessor;
|
|
21
|
+
stack?: StackOptions;
|
|
22
|
+
interval?: number | string;
|
|
23
|
+
} & BaseRectMarkProps;
|
|
24
|
+
|
|
25
|
+
let { data = [{}], stack, ...options }: RectYMarkProps = $props();
|
|
26
|
+
|
|
27
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
28
|
+
const plot = $derived(getPlotState());
|
|
29
|
+
|
|
30
|
+
const args = $derived(stackY(intervalX(recordizeY({ data, ...options }), { plot }), stack));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Rect {...args}></Rect>
|