svelteplot 0.2.6-next.5 → 0.2.6-pr-67.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 +1 -1
- package/dist/Plot.svelte +1 -1
- package/dist/core/FacetGrid.svelte +2 -2
- package/dist/core/Plot.svelte +1 -0
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/resolve.js +7 -4
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/scales.js +2 -1
- package/dist/helpers/time.d.ts +4 -3
- package/dist/helpers/time.js +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +17 -23
- package/dist/marks/Area.svelte.d.ts +9 -17
- package/dist/marks/AreaX.svelte +7 -6
- package/dist/marks/AreaX.svelte.d.ts +7 -6
- package/dist/marks/AreaY.svelte +7 -15
- package/dist/marks/AreaY.svelte.d.ts +7 -10
- package/dist/marks/Arrow.svelte +25 -25
- package/dist/marks/Arrow.svelte.d.ts +5 -8
- package/dist/marks/AxisX.svelte +50 -44
- package/dist/marks/AxisX.svelte.d.ts +4 -3
- package/dist/marks/AxisY.svelte +39 -31
- package/dist/marks/AxisY.svelte.d.ts +7 -4
- package/dist/marks/BarX.svelte +27 -12
- package/dist/marks/BarX.svelte.d.ts +17 -1
- package/dist/marks/BarY.svelte +21 -11
- package/dist/marks/BarY.svelte.d.ts +4 -4
- package/dist/marks/BollingerX.svelte +15 -7
- package/dist/marks/BollingerX.svelte.d.ts +3 -3
- package/dist/marks/BollingerY.svelte +9 -7
- package/dist/marks/BollingerY.svelte.d.ts +3 -3
- package/dist/marks/BoxX.svelte +3 -0
- package/dist/marks/BoxX.svelte.d.ts +1 -0
- package/dist/marks/BoxY.svelte +3 -0
- package/dist/marks/BoxY.svelte.d.ts +1 -0
- package/dist/marks/BrushX.svelte +5 -1
- package/dist/marks/BrushX.svelte.d.ts +2 -1
- package/dist/marks/BrushY.svelte +5 -1
- package/dist/marks/BrushY.svelte.d.ts +2 -1
- package/dist/marks/Cell.svelte +18 -21
- package/dist/marks/Cell.svelte.d.ts +3 -9
- package/dist/marks/CellX.svelte +7 -12
- package/dist/marks/CellX.svelte.d.ts +3 -1
- package/dist/marks/CellY.svelte +7 -12
- package/dist/marks/CellY.svelte.d.ts +3 -1
- package/dist/marks/ColorLegend.svelte +10 -8
- package/dist/marks/ColorLegend.svelte.d.ts +3 -5
- package/dist/marks/CustomMark.svelte +1 -1
- package/dist/marks/CustomMarkHTML.svelte +1 -1
- package/dist/marks/DifferenceY.svelte +22 -20
- package/dist/marks/DifferenceY.svelte.d.ts +5 -5
- package/dist/marks/Dot.svelte +17 -27
- package/dist/marks/Dot.svelte.d.ts +5 -15
- package/dist/marks/DotX.svelte +10 -9
- package/dist/marks/DotX.svelte.d.ts +4 -7
- package/dist/marks/DotY.svelte +9 -2
- package/dist/marks/DotY.svelte.d.ts +4 -3
- package/dist/marks/Frame.svelte +42 -31
- package/dist/marks/Frame.svelte.d.ts +8 -3
- package/dist/marks/Geo.svelte +18 -11
- package/dist/marks/Geo.svelte.d.ts +4 -3
- package/dist/marks/Graticule.svelte +15 -8
- package/dist/marks/Graticule.svelte.d.ts +2 -1
- package/dist/marks/GridX.svelte +11 -6
- package/dist/marks/GridX.svelte.d.ts +3 -2
- package/dist/marks/GridY.svelte +11 -3
- package/dist/marks/GridY.svelte.d.ts +3 -2
- package/dist/marks/HTMLTooltip.svelte +2 -1
- package/dist/marks/HTMLTooltip.svelte.d.ts +4 -0
- package/dist/marks/Line.svelte +9 -19
- package/dist/marks/Line.svelte.d.ts +6 -11
- package/dist/marks/LineX.svelte +5 -2
- package/dist/marks/LineX.svelte.d.ts +3 -2
- package/dist/marks/LineY.svelte +5 -2
- package/dist/marks/LineY.svelte.d.ts +3 -2
- package/dist/marks/Link.svelte +20 -19
- package/dist/marks/Link.svelte.d.ts +6 -6
- package/dist/marks/Rect.svelte +15 -12
- package/dist/marks/Rect.svelte.d.ts +3 -3
- package/dist/marks/RectX.svelte +10 -20
- package/dist/marks/RectX.svelte.d.ts +6 -12
- package/dist/marks/RectY.svelte +10 -20
- package/dist/marks/RectY.svelte.d.ts +6 -12
- package/dist/marks/RegressionX.svelte +10 -2
- package/dist/marks/RegressionX.svelte.d.ts +2 -0
- package/dist/marks/RegressionY.svelte +9 -2
- package/dist/marks/RegressionY.svelte.d.ts +2 -0
- package/dist/marks/RuleX.svelte +16 -13
- package/dist/marks/RuleX.svelte.d.ts +3 -4
- package/dist/marks/RuleY.svelte +16 -13
- package/dist/marks/RuleY.svelte.d.ts +3 -4
- package/dist/marks/Sphere.svelte +9 -2
- package/dist/marks/Sphere.svelte.d.ts +4 -59
- package/dist/marks/Spike.svelte +9 -1
- package/dist/marks/Spike.svelte.d.ts +2 -0
- package/dist/marks/SymbolLegend.svelte +1 -1
- package/dist/marks/Text.svelte +34 -35
- package/dist/marks/Text.svelte.d.ts +4 -7
- package/dist/marks/TickX.svelte +25 -20
- package/dist/marks/TickX.svelte.d.ts +3 -3
- package/dist/marks/TickY.svelte +25 -20
- package/dist/marks/TickY.svelte.d.ts +3 -3
- package/dist/marks/Vector.svelte +5 -5
- package/dist/marks/Vector.svelte.d.ts +2 -5
- package/dist/marks/helpers/BaseAxisX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/RectPath.svelte +17 -13
- package/dist/marks/helpers/RectPath.svelte.d.ts +1 -0
- package/dist/marks/helpers/events.js +3 -6
- package/dist/transforms/bollinger.d.ts +1 -8
- package/dist/transforms/centroid.d.ts +1 -8
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/index.d.ts +1 -0
- package/dist/transforms/index.js +1 -0
- package/dist/transforms/interval.d.ts +2 -6
- package/dist/transforms/jitter.d.ts +17 -0
- package/dist/transforms/jitter.js +60 -1
- package/dist/transforms/map.d.ts +4 -10
- package/dist/transforms/normalize.d.ts +2 -6
- package/dist/transforms/recordize.js +4 -4
- package/dist/transforms/select.d.ts +7 -21
- package/dist/transforms/sort.d.ts +3 -16
- package/dist/transforms/window.d.ts +2 -14
- package/dist/types.d.ts +13 -11
- package/dist/ui/RadioInput.svelte +1 -1
- package/dist/ui/Select.svelte +1 -1
- package/package.json +9 -9
package/dist/Mark.svelte
CHANGED
package/dist/Plot.svelte
CHANGED
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
})}
|
|
153
153
|
{#snippet failed(error, reset)}
|
|
154
154
|
<text class="error" transform="translate(10,10)">
|
|
155
|
-
{#each error.message.split('\n') as line, i}
|
|
155
|
+
{#each error.message.split('\n') as line, i (i)}
|
|
156
156
|
<tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
|
|
157
157
|
{/each}
|
|
158
158
|
</text>{/snippet}
|
package/dist/core/Plot.svelte
CHANGED
package/dist/helpers/colors.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type SchemeGetter = (n: number) => readonly string[];
|
|
|
6
6
|
export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
|
|
7
7
|
export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
|
|
8
8
|
export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
|
|
9
|
-
export declare function maybeBooleanRange(domain: boolean[], scheme?: string):
|
|
9
|
+
export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
|
|
10
10
|
export declare function isQuantitativeScheme(scheme: string): boolean;
|
|
11
11
|
export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
|
|
12
12
|
export declare function isDivergingScheme(scheme: string): boolean;
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { Snippet } from 'svelte';
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns first argument that is not null or undefined
|
|
5
5
|
*/
|
|
6
|
-
export declare function coalesce(...args: (RawValue | undefined | null)[]):
|
|
7
|
-
export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>):
|
|
6
|
+
export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
|
|
7
|
+
export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): any;
|
|
8
8
|
export declare function randomId(): string;
|
|
9
9
|
export declare function isSnippet(value: unknown): value is Snippet;
|
|
10
10
|
export declare function isValid(value: RawValue | undefined): value is number | Date | string;
|
package/dist/helpers/resolve.js
CHANGED
|
@@ -13,7 +13,9 @@ export function resolveProp(accessor, datum, _defaultValue = null) {
|
|
|
13
13
|
? accessor()
|
|
14
14
|
: accessor(datum[RAW_VALUE] != null ? datum[RAW_VALUE] : datum);
|
|
15
15
|
}
|
|
16
|
-
else if ((typeof accessor === 'string' || typeof accessor === 'symbol') &&
|
|
16
|
+
else if ((typeof accessor === 'string' || typeof accessor === 'symbol') &&
|
|
17
|
+
datum &&
|
|
18
|
+
datum[accessor] !== undefined) {
|
|
17
19
|
return datum[accessor];
|
|
18
20
|
}
|
|
19
21
|
return isRawValue(accessor) ? accessor : _defaultValue;
|
|
@@ -51,7 +53,8 @@ function resolve(datum, accessor, channel, scale) {
|
|
|
51
53
|
// so we're passing the original value to accessor functions instead of our wrapped record
|
|
52
54
|
return accessor(datum[RAW_VALUE] != null ? datum[RAW_VALUE] : datum);
|
|
53
55
|
// use accessor string
|
|
54
|
-
if ((typeof accessor === 'string' || typeof accessor === 'symbol') &&
|
|
56
|
+
if ((typeof accessor === 'string' || typeof accessor === 'symbol') &&
|
|
57
|
+
datum[accessor] !== undefined)
|
|
55
58
|
return datum[accessor];
|
|
56
59
|
// fallback to channel name as accessor
|
|
57
60
|
if (accessor === null && datum[channel] !== undefined)
|
|
@@ -122,7 +125,7 @@ function stylePropsToCSS(props) {
|
|
|
122
125
|
}
|
|
123
126
|
export function resolveStyles(plot, datum, channels, defaultColorProp = null, useScale, recomputeChannels = false) {
|
|
124
127
|
const styleProps = {
|
|
125
|
-
...getBaseStylesObject(datum
|
|
128
|
+
...getBaseStylesObject(datum?.datum, channels),
|
|
126
129
|
fill: 'none',
|
|
127
130
|
stroke: 'none',
|
|
128
131
|
...(defaultColorProp && channels[oppositeColor[defaultColorProp]] == null
|
|
@@ -133,7 +136,7 @@ export function resolveStyles(plot, datum, channels, defaultColorProp = null, us
|
|
|
133
136
|
.map(([key, cssAttr]) => [
|
|
134
137
|
key,
|
|
135
138
|
cssAttr,
|
|
136
|
-
recomputeChannels ? resolveChannel(key, datum
|
|
139
|
+
recomputeChannels ? resolveChannel(key, datum?.datum, channels) : datum?.[key]
|
|
137
140
|
])
|
|
138
141
|
.filter(([key, , value]) => isValid(value) || key === 'fill' || key === 'stroke')
|
|
139
142
|
.map(([key, cssAttr, value]) => {
|
package/dist/helpers/scales.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
|
|
|
15
15
|
autoTitle?: undefined;
|
|
16
16
|
} | {
|
|
17
17
|
type: ScaleType;
|
|
18
|
-
domain:
|
|
18
|
+
domain: any;
|
|
19
19
|
range: any;
|
|
20
20
|
fn: any;
|
|
21
21
|
skip: Map<ScaledChannelName, Set<symbol>>;
|
package/dist/helpers/scales.js
CHANGED
|
@@ -113,7 +113,8 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
|
|
|
113
113
|
for (const datum of mark.data) {
|
|
114
114
|
const value = resolveProp(channelOptions.value, datum);
|
|
115
115
|
dataValues.add(value);
|
|
116
|
-
if (name === 'color' && scaleOptions.type === 'quantile' ||
|
|
116
|
+
if ((name === 'color' && scaleOptions.type === 'quantile') ||
|
|
117
|
+
scaleOptions.type === 'quantile-cont') {
|
|
117
118
|
allDataValues.push(value);
|
|
118
119
|
}
|
|
119
120
|
}
|
package/dist/helpers/time.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export declare const durations: Map<string, number>;
|
|
1
2
|
export declare const intervalDuration: unique symbol;
|
|
2
3
|
export declare const intervalType: unique symbol;
|
|
3
|
-
export declare function parseTimeInterval(input:
|
|
4
|
-
export declare function maybeTimeInterval(input:
|
|
5
|
-
export declare function maybeUtcInterval(input:
|
|
4
|
+
export declare function parseTimeInterval(input: string): [string, number];
|
|
5
|
+
export declare function maybeTimeInterval(input: string): any;
|
|
6
|
+
export declare function maybeUtcInterval(input: string): any;
|
|
6
7
|
export declare function generalizeTimeInterval(interval: any, n: any): any;
|
package/dist/helpers/time.js
CHANGED
|
@@ -54,7 +54,7 @@ const tickIntervals = [
|
|
|
54
54
|
['50 years', 50 * durationYear],
|
|
55
55
|
['100 years', 100 * durationYear] // TODO generalize to longer time scales
|
|
56
56
|
];
|
|
57
|
-
const durations = new Map([
|
|
57
|
+
export const durations = new Map([
|
|
58
58
|
['second', durationSecond],
|
|
59
59
|
['minute', durationMinute],
|
|
60
60
|
['hour', durationHour],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { RawValue } from '../types.js';
|
|
2
|
-
export declare function isBooleanOrNull(v: RawValue):
|
|
3
|
-
export declare function isDate(v: RawValue):
|
|
2
|
+
export declare function isBooleanOrNull(v: RawValue): boolean;
|
|
3
|
+
export declare function isDate(v: RawValue): v is Date;
|
|
4
4
|
export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
|
|
5
5
|
export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
|
|
6
6
|
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
|
|
7
|
-
export declare function isStringOrNull(v: RawValue | null | undefined):
|
|
7
|
+
export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
|
|
8
8
|
export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
|
|
9
|
-
export declare function isColorOrNull(v: RawValue | null | undefined):
|
|
9
|
+
export declare function isColorOrNull(v: RawValue | null | undefined): any;
|
|
10
10
|
export declare function isOpacityOrNull(v: RawValue): boolean;
|
package/dist/marks/Area.svelte
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates an area chart with filled regions between two x-y value pairs
|
|
3
|
+
-->
|
|
1
4
|
<script module lang="ts">
|
|
2
5
|
export type AreaMarkProps = {
|
|
6
|
+
data: DataRecord[];
|
|
7
|
+
x1?: ChannelAccessor;
|
|
8
|
+
x2?: ChannelAccessor;
|
|
9
|
+
y1?: ChannelAccessor;
|
|
10
|
+
y2?: ChannelAccessor;
|
|
3
11
|
z?: ChannelAccessor;
|
|
4
|
-
fill?: ChannelAccessor;
|
|
5
|
-
stroke?: ChannelAccessor;
|
|
6
|
-
dx?: ConstantAccessor<number>;
|
|
7
|
-
dy?: ConstantAccessor<number>;
|
|
8
12
|
curve?: CurveName | CurveFactory;
|
|
9
13
|
tension?: number;
|
|
10
14
|
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
11
15
|
stack?: Partial<StackOptions>;
|
|
12
16
|
canvas?: boolean;
|
|
13
|
-
}
|
|
17
|
+
} & BaseMarkProps &
|
|
18
|
+
LinkableMarkProps;
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
21
|
<script lang="ts">
|
|
@@ -33,22 +38,12 @@
|
|
|
33
38
|
ConstantAccessor,
|
|
34
39
|
ChannelAccessor,
|
|
35
40
|
FacetContext,
|
|
36
|
-
ScaledDataRecord
|
|
41
|
+
ScaledDataRecord,
|
|
42
|
+
LinkableMarkProps
|
|
37
43
|
} from '../types.js';
|
|
38
44
|
import type { RawValue } from '../types.js';
|
|
39
45
|
import type { StackOptions } from '../transforms/stack.js';
|
|
40
46
|
|
|
41
|
-
type AreaProps = BaseMarkProps & {
|
|
42
|
-
data: DataRecord[];
|
|
43
|
-
/**
|
|
44
|
-
* Lorem ipsum
|
|
45
|
-
*/
|
|
46
|
-
x1?: ChannelAccessor;
|
|
47
|
-
x2?: ChannelAccessor;
|
|
48
|
-
y1?: ChannelAccessor;
|
|
49
|
-
y2?: ChannelAccessor;
|
|
50
|
-
} & AreaMarkProps;
|
|
51
|
-
|
|
52
47
|
let {
|
|
53
48
|
data,
|
|
54
49
|
/** the curve */
|
|
@@ -57,7 +52,7 @@
|
|
|
57
52
|
class: className = '',
|
|
58
53
|
canvas = false,
|
|
59
54
|
...options
|
|
60
|
-
}:
|
|
55
|
+
}: AreaMarkProps = $props();
|
|
61
56
|
|
|
62
57
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
63
58
|
const plot = $derived(getPlotState());
|
|
@@ -103,9 +98,6 @@
|
|
|
103
98
|
}
|
|
104
99
|
return groups;
|
|
105
100
|
}
|
|
106
|
-
|
|
107
|
-
const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
|
|
108
|
-
let testFacet = $derived(getTestFacet());
|
|
109
101
|
</script>
|
|
110
102
|
|
|
111
103
|
<Mark
|
|
@@ -120,8 +112,9 @@
|
|
|
120
112
|
<AreaCanvas groupedAreaData={grouped} {mark} {usedScales} {areaPath} />
|
|
121
113
|
{:else}
|
|
122
114
|
<GroupMultiple length={grouped.length}>
|
|
123
|
-
{#each grouped as areaData}
|
|
115
|
+
{#each grouped as areaData, i (i)}
|
|
124
116
|
{#snippet el(datum: ScaledDataRecord)}
|
|
117
|
+
{@const title = resolveProp(options.title, datum.datum, '')}
|
|
125
118
|
{@const [style, styleClass] = resolveStyles(
|
|
126
119
|
plot,
|
|
127
120
|
datum,
|
|
@@ -133,7 +126,8 @@
|
|
|
133
126
|
class={['svelteplot-area', className, styleClass]}
|
|
134
127
|
clip-path={options.clipPath}
|
|
135
128
|
d={areaPath(areaData)}
|
|
136
|
-
{style}
|
|
129
|
+
{style}
|
|
130
|
+
>{#if title}<title>{title}</title>{/if}</path>
|
|
137
131
|
{/snippet}
|
|
138
132
|
{#if areaData.length > 0}
|
|
139
133
|
{#if options.href}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type AreaMarkProps = {
|
|
2
|
+
data: DataRecord[];
|
|
3
|
+
x1?: ChannelAccessor;
|
|
4
|
+
x2?: ChannelAccessor;
|
|
5
|
+
y1?: ChannelAccessor;
|
|
6
|
+
y2?: ChannelAccessor;
|
|
2
7
|
z?: ChannelAccessor;
|
|
3
|
-
fill?: ChannelAccessor;
|
|
4
|
-
stroke?: ChannelAccessor;
|
|
5
|
-
dx?: ConstantAccessor<number>;
|
|
6
|
-
dy?: ConstantAccessor<number>;
|
|
7
8
|
curve?: CurveName | CurveFactory;
|
|
8
9
|
tension?: number;
|
|
9
10
|
sort?: ConstantAccessor<RawValue> | {
|
|
@@ -11,21 +12,12 @@ export type AreaMarkProps = {
|
|
|
11
12
|
};
|
|
12
13
|
stack?: Partial<StackOptions>;
|
|
13
14
|
canvas?: boolean;
|
|
14
|
-
};
|
|
15
|
+
} & BaseMarkProps & LinkableMarkProps;
|
|
15
16
|
import { type CurveFactory } from 'd3-shape';
|
|
16
|
-
import type { CurveName, DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
17
|
+
import type { CurveName, DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, LinkableMarkProps } from '../types.js';
|
|
17
18
|
import type { RawValue } from '../types.js';
|
|
18
19
|
import type { StackOptions } from '../transforms/stack.js';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Lorem ipsum
|
|
23
|
-
*/
|
|
24
|
-
x1?: ChannelAccessor;
|
|
25
|
-
x2?: ChannelAccessor;
|
|
26
|
-
y1?: ChannelAccessor;
|
|
27
|
-
y2?: ChannelAccessor;
|
|
28
|
-
} & AreaMarkProps;
|
|
29
|
-
declare const Area: import("svelte").Component<AreaProps, {}, "">;
|
|
20
|
+
/** Creates an area chart with filled regions between two x-y value pairs */
|
|
21
|
+
declare const Area: import("svelte").Component<AreaMarkProps, {}, "">;
|
|
30
22
|
type Area = ReturnType<typeof Area>;
|
|
31
23
|
export default Area;
|
package/dist/marks/AreaX.svelte
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a horizontal area chart with x value and baseline. Areas are implicitly
|
|
3
|
+
stacked horizontally if just the x channel is defined.
|
|
4
|
+
-->
|
|
1
5
|
<script lang="ts">
|
|
2
6
|
import Area, { type AreaMarkProps } from './Area.svelte';
|
|
3
7
|
import { renameChannels } from '../transforms/rename.js';
|
|
4
8
|
import { stackX } from '../transforms/stack.js';
|
|
5
9
|
import { recordizeX } from '../transforms/recordize.js';
|
|
6
|
-
import type {
|
|
10
|
+
import type { ChannelAccessor } from '../types.js';
|
|
7
11
|
|
|
8
|
-
type AreaXProps =
|
|
9
|
-
data: DataRecord[];
|
|
12
|
+
type AreaXProps = Omit<AreaMarkProps, 'y1' | 'y2'> & {
|
|
10
13
|
x?: ChannelAccessor;
|
|
11
|
-
x1?: ChannelAccessor;
|
|
12
|
-
x2?: ChannelAccessor;
|
|
13
14
|
y?: ChannelAccessor;
|
|
14
|
-
}
|
|
15
|
+
};
|
|
15
16
|
|
|
16
17
|
// we're discarding y1 and y2 props since they are not
|
|
17
18
|
let { data, stack, ...options }: AreaXProps = $props();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type AreaMarkProps } from './Area.svelte';
|
|
2
|
-
import type {
|
|
3
|
-
type AreaXProps =
|
|
4
|
-
data: DataRecord[];
|
|
2
|
+
import type { ChannelAccessor } from '../types.js';
|
|
3
|
+
type AreaXProps = Omit<AreaMarkProps, 'y1' | 'y2'> & {
|
|
5
4
|
x?: ChannelAccessor;
|
|
6
|
-
x1?: ChannelAccessor;
|
|
7
|
-
x2?: ChannelAccessor;
|
|
8
5
|
y?: ChannelAccessor;
|
|
9
|
-
}
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Creates a horizontal area chart with x value and baseline. Areas are implicitly
|
|
9
|
+
* stacked horizontally if just the x channel is defined.
|
|
10
|
+
*/
|
|
10
11
|
declare const AreaX: import("svelte").Component<AreaXProps, {}, "">;
|
|
11
12
|
type AreaX = ReturnType<typeof AreaX>;
|
|
12
13
|
export default AreaX;
|
package/dist/marks/AreaY.svelte
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates a vertical area chart with y value and baseline. Areas are implicitly
|
|
3
|
+
stacked vertically if just the y channel is defined.
|
|
4
|
+
-->
|
|
1
5
|
<script lang="ts">
|
|
2
6
|
import Area, { type AreaMarkProps } from './Area.svelte';
|
|
3
7
|
import { renameChannels } from '../transforms/rename.js';
|
|
4
8
|
import { stackY } from '../transforms/stack.js';
|
|
5
9
|
import { recordizeY } from '../transforms/recordize.js';
|
|
6
|
-
import type {
|
|
10
|
+
import type { ChannelAccessor } from '../types.js';
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* AreaY mark foo
|
|
10
14
|
*/
|
|
11
|
-
type AreaYProps =
|
|
12
|
-
data: DataRecord[];
|
|
15
|
+
type AreaYProps = Omit<AreaMarkProps, 'x1' | 'x2'> & {
|
|
13
16
|
x?: ChannelAccessor;
|
|
14
|
-
y1?: ChannelAccessor;
|
|
15
|
-
y2?: ChannelAccessor;
|
|
16
|
-
/**
|
|
17
|
-
* this some extensive help for the y channel
|
|
18
|
-
*/
|
|
19
17
|
y?: ChannelAccessor;
|
|
20
|
-
}
|
|
18
|
+
};
|
|
21
19
|
|
|
22
20
|
let { data, stack, ...options }: AreaYProps = $props();
|
|
23
21
|
|
|
@@ -29,10 +27,4 @@
|
|
|
29
27
|
);
|
|
30
28
|
</script>
|
|
31
29
|
|
|
32
|
-
<!--
|
|
33
|
-
@component
|
|
34
|
-
The AreaY component can be used for foobar
|
|
35
|
-
|
|
36
|
-
-->
|
|
37
|
-
|
|
38
30
|
<Area {...args}></Area>
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { type AreaMarkProps } from './Area.svelte';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ChannelAccessor } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* AreaY mark foo
|
|
5
5
|
*/
|
|
6
|
-
type AreaYProps =
|
|
7
|
-
data: DataRecord[];
|
|
6
|
+
type AreaYProps = Omit<AreaMarkProps, 'x1' | 'x2'> & {
|
|
8
7
|
x?: ChannelAccessor;
|
|
9
|
-
y1?: ChannelAccessor;
|
|
10
|
-
y2?: ChannelAccessor;
|
|
11
|
-
/**
|
|
12
|
-
* this some extensive help for the y channel
|
|
13
|
-
*/
|
|
14
8
|
y?: ChannelAccessor;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates a vertical area chart with y value and baseline. Areas are implicitly
|
|
12
|
+
* stacked vertically if just the y channel is defined.
|
|
13
|
+
*/
|
|
17
14
|
declare const AreaY: import("svelte").Component<AreaYProps, {}, "">;
|
|
18
15
|
type AreaY = ReturnType<typeof AreaY>;
|
|
19
16
|
export default AreaY;
|
package/dist/marks/Arrow.svelte
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
1
|
+
<!-- @component
|
|
2
|
+
Creates arrows with customizable heads, angles, and bending
|
|
3
3
|
-->
|
|
4
|
-
<script lang="ts">
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
PlotContext,
|
|
8
|
-
DataRecord,
|
|
9
|
-
BaseMarkProps,
|
|
10
|
-
ConstantAccessor,
|
|
11
|
-
ChannelAccessor,
|
|
12
|
-
RawValue
|
|
13
|
-
} from '../types.js';
|
|
14
|
-
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
15
|
-
import { coalesce, maybeData, maybeNumber } from '../helpers/index.js';
|
|
16
|
-
import Mark from '../Mark.svelte';
|
|
17
|
-
import { arrowPath, maybeSweep, type SweepOption } from '../helpers/arrowPath.js';
|
|
18
|
-
import { replaceChannels } from '../transforms/rename.js';
|
|
19
|
-
import { addEventHandlers } from './helpers/events.js';
|
|
20
|
-
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
21
|
-
|
|
22
|
-
type ArrowProps = BaseMarkProps & {
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type ArrowMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
23
6
|
data: DataRecord[];
|
|
24
7
|
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
|
|
25
8
|
x1: ChannelAccessor;
|
|
26
9
|
y1: ChannelAccessor;
|
|
27
10
|
x2: ChannelAccessor;
|
|
28
11
|
y2: ChannelAccessor;
|
|
29
|
-
stroke?: ChannelAccessor;
|
|
30
12
|
/**
|
|
31
13
|
* the bend angle, in degrees; defaults to 0°; true for 22.5°
|
|
32
14
|
*/
|
|
@@ -52,10 +34,28 @@
|
|
|
52
34
|
*/
|
|
53
35
|
inset?: ConstantAccessor<number>;
|
|
54
36
|
sweep?: SweepOption;
|
|
55
|
-
children?: Snippet;
|
|
56
37
|
};
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
import { getContext, type Snippet } from 'svelte';
|
|
42
|
+
import type {
|
|
43
|
+
PlotContext,
|
|
44
|
+
DataRecord,
|
|
45
|
+
BaseMarkProps,
|
|
46
|
+
ConstantAccessor,
|
|
47
|
+
ChannelAccessor,
|
|
48
|
+
RawValue
|
|
49
|
+
} from '../types.js';
|
|
50
|
+
import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
51
|
+
import { coalesce, maybeData, maybeNumber } from '../helpers/index.js';
|
|
52
|
+
import Mark from '../Mark.svelte';
|
|
53
|
+
import { arrowPath, maybeSweep, type SweepOption } from '../helpers/arrowPath.js';
|
|
54
|
+
import { replaceChannels } from '../transforms/rename.js';
|
|
55
|
+
import { addEventHandlers } from './helpers/events.js';
|
|
56
|
+
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
57
57
|
|
|
58
|
-
let { data = [{}], class: className = null, ...options }:
|
|
58
|
+
let { data = [{}], class: className = null, ...options }: ArrowMarkProps = $props();
|
|
59
59
|
|
|
60
60
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
61
61
|
const plot = $derived(getPlotState());
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
{#snippet children({ mark, usedScales, scaledData })}
|
|
82
82
|
{@const sweep = maybeSweep(args.sweep)}
|
|
83
83
|
<GroupMultiple class="arrow" length={scaledData.length}>
|
|
84
|
-
{#each scaledData as d}
|
|
84
|
+
{#each scaledData as d, i (i)}
|
|
85
85
|
{#if d.valid}
|
|
86
86
|
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
87
87
|
{@const insetStart = resolveProp(args.insetStart, d.datum)}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, RawValue } from '../types.js';
|
|
3
|
-
import { type SweepOption } from '../helpers/arrowPath.js';
|
|
4
|
-
type ArrowProps = BaseMarkProps & {
|
|
1
|
+
export type ArrowMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
5
2
|
data: DataRecord[];
|
|
6
3
|
sort?: ConstantAccessor<RawValue> | {
|
|
7
4
|
channel: 'stroke' | 'fill';
|
|
@@ -10,7 +7,6 @@ type ArrowProps = BaseMarkProps & {
|
|
|
10
7
|
y1: ChannelAccessor;
|
|
11
8
|
x2: ChannelAccessor;
|
|
12
9
|
y2: ChannelAccessor;
|
|
13
|
-
stroke?: ChannelAccessor;
|
|
14
10
|
/**
|
|
15
11
|
* the bend angle, in degrees; defaults to 0°; true for 22.5°
|
|
16
12
|
*/
|
|
@@ -36,9 +32,10 @@ type ArrowProps = BaseMarkProps & {
|
|
|
36
32
|
*/
|
|
37
33
|
inset?: ConstantAccessor<number>;
|
|
38
34
|
sweep?: SweepOption;
|
|
39
|
-
children?: Snippet;
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, RawValue } from '../types.js';
|
|
37
|
+
import { type SweepOption } from '../helpers/arrowPath.js';
|
|
38
|
+
/** Creates arrows with customizable heads, angles, and bending */
|
|
39
|
+
declare const Arrow: import("svelte").Component<ArrowMarkProps, {}, "">;
|
|
43
40
|
type Arrow = ReturnType<typeof Arrow>;
|
|
44
41
|
export default Arrow;
|
package/dist/marks/AxisX.svelte
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders a horizontal axis with labels and tick marks
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type AxisXMarkProps = Omit<
|
|
6
|
+
BaseMarkProps,
|
|
7
|
+
'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
|
|
8
|
+
> & {
|
|
9
|
+
data?: RawValue[];
|
|
10
|
+
automatic?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
anchor?: 'top' | 'bottom';
|
|
13
|
+
interval?: string | number;
|
|
14
|
+
facetAnchor?: 'auto' | 'top-empty' | 'bottom-empty' | 'top' | 'bottom';
|
|
15
|
+
labelAnchor?: 'auto' | 'left' | 'center' | 'right';
|
|
16
|
+
tickSize?: number;
|
|
17
|
+
tickFontSize?: ConstantAccessor<number>;
|
|
18
|
+
tickPadding?: number;
|
|
19
|
+
tickFormat?:
|
|
20
|
+
| 'auto'
|
|
21
|
+
| Intl.DateTimeFormatOptions
|
|
22
|
+
| Intl.NumberFormatOptions
|
|
23
|
+
| ((d: RawValue) => string);
|
|
24
|
+
tickClass?: ConstantAccessor<string>;
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
1
28
|
<script lang="ts">
|
|
2
29
|
import { getContext } from 'svelte';
|
|
3
30
|
import Mark from '../Mark.svelte';
|
|
@@ -23,30 +50,11 @@
|
|
|
23
50
|
...getContext<Partial<DefaultOptions>>('svelteplot/_defaults')
|
|
24
51
|
};
|
|
25
52
|
|
|
26
|
-
type AxisXProps = BaseMarkProps & {
|
|
27
|
-
data?: RawValue[];
|
|
28
|
-
automatic?: boolean;
|
|
29
|
-
title?: string;
|
|
30
|
-
anchor?: 'top' | 'bottom';
|
|
31
|
-
interval?: string | number;
|
|
32
|
-
facetAnchor?: 'auto' | 'top-empty' | 'bottom-empty' | 'top' | 'bottom';
|
|
33
|
-
labelAnchor?: 'auto' | 'left' | 'center' | 'right';
|
|
34
|
-
tickSize?: number;
|
|
35
|
-
tickFontSize?: ConstantAccessor<number>;
|
|
36
|
-
tickPadding?: number;
|
|
37
|
-
tickFormat?:
|
|
38
|
-
| 'auto'
|
|
39
|
-
| Intl.DateTimeFormatOptions
|
|
40
|
-
| Intl.NumberFormatOptions
|
|
41
|
-
| ((d: RawValue) => string);
|
|
42
|
-
tickClass?: ConstantAccessor<string>;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
53
|
let {
|
|
46
54
|
data = [],
|
|
47
55
|
automatic = false,
|
|
48
56
|
title,
|
|
49
|
-
anchor = DEFAULTS.axisXAnchor,
|
|
57
|
+
anchor = DEFAULTS.axisXAnchor as 'top' | 'bottom',
|
|
50
58
|
facetAnchor = 'auto',
|
|
51
59
|
interval,
|
|
52
60
|
tickSize = DEFAULTS.tickSize,
|
|
@@ -55,17 +63,18 @@
|
|
|
55
63
|
labelAnchor,
|
|
56
64
|
tickFormat,
|
|
57
65
|
tickClass,
|
|
66
|
+
class: className,
|
|
58
67
|
...options
|
|
59
|
-
}:
|
|
68
|
+
}: AxisXMarkProps = $props();
|
|
60
69
|
|
|
61
70
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
62
|
-
|
|
71
|
+
const plot = $derived(getPlotState());
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
const autoTickCount = $derived(
|
|
65
74
|
Math.max(3, Math.round(plot.facetWidth / plot.options.x.tickSpacing))
|
|
66
75
|
);
|
|
67
76
|
|
|
68
|
-
|
|
77
|
+
const ticks: RawValue[] = $derived(
|
|
69
78
|
data.length > 0
|
|
70
79
|
? // use custom tick values if user passed any as prop
|
|
71
80
|
data
|
|
@@ -103,12 +112,11 @@
|
|
|
103
112
|
}).format(d)
|
|
104
113
|
);
|
|
105
114
|
|
|
106
|
-
|
|
115
|
+
const optionsLabel = $derived(plot.options?.x?.label);
|
|
116
|
+
const scaleType = $derived(plot.scales.x.type);
|
|
117
|
+
const isQuantitative = $derived(scaleType !== 'point' && scaleType !== 'band');
|
|
107
118
|
|
|
108
|
-
|
|
109
|
-
let isQuantitative = $derived(scaleType !== 'point' && scaleType !== 'band');
|
|
110
|
-
|
|
111
|
-
let useTitle = $derived(
|
|
119
|
+
const useTitle = $derived(
|
|
112
120
|
title ||
|
|
113
121
|
(optionsLabel === null
|
|
114
122
|
? null
|
|
@@ -123,28 +131,26 @@
|
|
|
123
131
|
: '')
|
|
124
132
|
);
|
|
125
133
|
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
const useLabelAnchor = $derived(labelAnchor || plot.options?.x?.labelAnchor || 'auto');
|
|
135
|
+
const titleAlign = $derived(
|
|
128
136
|
useLabelAnchor === 'auto' ? (isQuantitative ? 'right' : 'center') : useLabelAnchor
|
|
129
137
|
);
|
|
130
138
|
|
|
131
139
|
const { getFacetState } = getContext<FacetContext>('svelteplot/facet');
|
|
132
|
-
|
|
140
|
+
const { left, top, bottom, bottomEmpty, topEmpty } = $derived(getFacetState());
|
|
133
141
|
|
|
134
|
-
|
|
142
|
+
const useFacetAnchor = $derived(
|
|
135
143
|
facetAnchor !== 'auto' ? facetAnchor : anchor === 'bottom' ? 'bottom-empty' : 'top-empty'
|
|
136
144
|
);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
useFacetAnchor === '
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
: bottomEmpty;
|
|
147
|
-
});
|
|
145
|
+
const showAxis = $derived(
|
|
146
|
+
useFacetAnchor === 'top'
|
|
147
|
+
? top
|
|
148
|
+
: useFacetAnchor === 'bottom'
|
|
149
|
+
? bottom
|
|
150
|
+
: useFacetAnchor === 'top-empty'
|
|
151
|
+
? topEmpty
|
|
152
|
+
: bottomEmpty
|
|
153
|
+
);
|
|
148
154
|
</script>
|
|
149
155
|
|
|
150
156
|
<Mark
|