svelteplot 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Mark.svelte +1 -1
- package/dist/Plot.svelte +1 -5
- package/dist/constants.js +9 -2
- package/dist/core/FacetAxes.svelte +14 -3
- package/dist/core/FacetGrid.svelte +15 -4
- package/dist/core/Plot.svelte +1 -5
- package/dist/helpers/autoProjection.d.ts +13 -8
- package/dist/helpers/autoProjection.js +1 -1
- package/dist/helpers/autoScales.d.ts +1 -1
- package/dist/helpers/autoTicks.d.ts +11 -2
- package/dist/helpers/autoTicks.js +3 -1
- package/dist/helpers/callWithProps.d.ts +1 -3
- package/dist/helpers/callWithProps.js +5 -3
- package/dist/helpers/colors.d.ts +4 -4
- package/dist/helpers/colors.js +4 -3
- package/dist/helpers/curves.d.ts +3 -3
- package/dist/helpers/getBaseStyles.d.ts +2 -3
- package/dist/helpers/getBaseStyles.js +2 -1
- package/dist/helpers/group.d.ts +1 -1
- package/dist/helpers/group.js +15 -14
- package/dist/helpers/math.d.ts +3 -3
- package/dist/helpers/math.js +7 -1
- package/dist/helpers/resolve.d.ts +1 -1
- package/dist/helpers/resolve.js +12 -7
- package/dist/helpers/symbols.d.ts +3 -1
- package/dist/helpers/typeChecks.d.ts +2 -2
- package/dist/marks/CellX.svelte +6 -4
- package/dist/marks/CellX.svelte.d.ts +92 -5
- package/dist/marks/CellY.svelte +6 -4
- package/dist/marks/CellY.svelte.d.ts +92 -5
- package/dist/marks/DotX.svelte +3 -2
- package/dist/marks/DotX.svelte.d.ts +12 -11
- package/dist/marks/WaffleX.svelte +1 -1
- package/dist/marks/helpers/BaseAxisX.svelte +3 -1
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
- package/dist/marks/helpers/BaseAxisY.svelte +4 -2
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
- package/dist/marks/helpers/Marker.svelte +1 -1
- package/dist/transforms/bollinger.d.ts +4 -73
- package/dist/transforms/index.d.ts +1 -1
- package/dist/transforms/index.js +1 -1
- package/dist/transforms/interval.js +1 -1
- package/dist/transforms/jitter.d.ts +12 -10
- package/dist/transforms/jitter.js +44 -28
- package/dist/transforms/map.js +2 -1
- package/dist/transforms/recordize.d.ts +5 -5
- package/dist/types/data.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/mark.d.ts +2 -1
- package/dist/types/plot.d.ts +2 -0
- package/dist/types/scale.d.ts +15 -15
- package/package.json +147 -147
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
  [](https://app.netlify.com/projects/svelteplot/deploys)
|
|
4
4
|
|
|
5
|
-
SveltePlot is a visualization framework based on the [layered grammar of graphics](https://vita.had.co.nz/papers/layered-grammar.html) ideas. It's API is heavily inspired by [Observable Plot](https://github.com/observablehq/plot). Created by Gregor Aisch.
|
|
6
|
-
|
|
7
5
|
<img src="static/logo.svg" alt="SveltePlot logo" width="401" />
|
|
8
6
|
|
|
7
|
+
SveltePlot is a [Svelte](https://svelte.dev/)-native visualization framework based on the [layered grammar of graphics](https://vita.had.co.nz/papers/layered-grammar.html) principle. It's API is heavily inspired by [Observable Plot](https://github.com/observablehq/plot). Created by Gregor Aisch.
|
|
8
|
+
|
|
9
9
|
## Development
|
|
10
10
|
|
|
11
11
|
Clone the repo and install dependencies:
|
package/dist/Mark.svelte
CHANGED
package/dist/Plot.svelte
CHANGED
|
@@ -177,17 +177,13 @@
|
|
|
177
177
|
</svelte:boundary>
|
|
178
178
|
|
|
179
179
|
<style>
|
|
180
|
-
:root {
|
|
181
|
-
--plot-bg: white;
|
|
182
|
-
--plot-fg: currentColor;
|
|
183
|
-
}
|
|
184
180
|
.error {
|
|
185
181
|
font-size: 11px;
|
|
186
182
|
stroke-width: 3px;
|
|
187
183
|
font-weight: bold;
|
|
188
184
|
}
|
|
189
185
|
text.error {
|
|
190
|
-
stroke: var(--
|
|
186
|
+
stroke: var(--svelteplot-bg, white);
|
|
191
187
|
fill: crimson;
|
|
192
188
|
paint-order: stroke fill;
|
|
193
189
|
}
|
package/dist/constants.js
CHANGED
|
@@ -86,8 +86,15 @@ export const VALID_SCALE_TYPES = {
|
|
|
86
86
|
'quantile',
|
|
87
87
|
'quantize',
|
|
88
88
|
'threshold'
|
|
89
|
-
])
|
|
90
|
-
|
|
89
|
+
]),
|
|
90
|
+
symbol: new Set(['categorical', 'ordinal']),
|
|
91
|
+
opacity: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
92
|
+
r: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
93
|
+
length: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
94
|
+
fx: new Set(['band']),
|
|
95
|
+
fy: new Set(['band']),
|
|
96
|
+
// projection is a special type not mapping to a D3 scale
|
|
97
|
+
projection: new Set()
|
|
91
98
|
};
|
|
92
99
|
/**
|
|
93
100
|
* Map of all scaled channels
|
|
@@ -21,10 +21,16 @@
|
|
|
21
21
|
|
|
22
22
|
// create band scales for fx and fy
|
|
23
23
|
const facetXScale = $derived(
|
|
24
|
-
scaleBand()
|
|
24
|
+
scaleBand()
|
|
25
|
+
.paddingInner(plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
|
|
26
|
+
.domain(fxValues)
|
|
27
|
+
.rangeRound([0, plot.plotWidth])
|
|
25
28
|
);
|
|
26
29
|
const facetYScale = $derived(
|
|
27
|
-
scaleBand()
|
|
30
|
+
scaleBand()
|
|
31
|
+
.paddingInner(plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
|
|
32
|
+
.domain(fyValues)
|
|
33
|
+
.rangeRound([0, plot.plotHeight])
|
|
28
34
|
);
|
|
29
35
|
</script>
|
|
30
36
|
|
|
@@ -32,13 +38,17 @@
|
|
|
32
38
|
{#if fxValues.length > 1 && plot.options.fx.axis}
|
|
33
39
|
<g transform="translate({plot.options.marginLeft}, 0)">
|
|
34
40
|
<BaseAxisX
|
|
41
|
+
class="facet-axis-x"
|
|
35
42
|
scaleFn={facetXScale}
|
|
36
43
|
scaleType="band"
|
|
37
44
|
ticks={fxValues}
|
|
38
45
|
tickFormat={plot.options.fx.tickFormat || ((d) => d)}
|
|
39
46
|
tickFontSize={11}
|
|
40
47
|
tickSize={0}
|
|
41
|
-
tickPadding={
|
|
48
|
+
tickPadding={plot.options.x.axis === plot.options.fx.axis ||
|
|
49
|
+
plot.options.x.axis === 'both'
|
|
50
|
+
? 25
|
|
51
|
+
: 5}
|
|
42
52
|
anchor={plot.options.fx.axis}
|
|
43
53
|
options={plot.options.fx.axisOptions || {}}
|
|
44
54
|
{...plot.options.fx.axisProps || {}}
|
|
@@ -50,6 +60,7 @@
|
|
|
50
60
|
{#if fyValues.length > 1 && plot.options.fy.axis}
|
|
51
61
|
<g transform="translate(0, {plot.options.marginTop})">
|
|
52
62
|
<BaseAxisY
|
|
63
|
+
class="facet-axis-y"
|
|
53
64
|
scaleFn={facetYScale}
|
|
54
65
|
scaleType="band"
|
|
55
66
|
ticks={fyValues}
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
import { scaleBand } from 'd3-scale';
|
|
10
10
|
import Facet from './Facet.svelte';
|
|
11
11
|
import { getEmptyFacets } from '../helpers/facets.js';
|
|
12
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
+
const { updateDimensions } = getContext<PlotContext>('svelteplot');
|
|
14
15
|
// we need the plot context for the overall width & height
|
|
15
|
-
const plot =
|
|
16
|
+
const plot = usePlot();
|
|
16
17
|
|
|
17
18
|
let {
|
|
18
19
|
children,
|
|
@@ -36,13 +37,23 @@
|
|
|
36
37
|
// create band scales for fx and fy
|
|
37
38
|
const facetXScale = $derived(
|
|
38
39
|
scaleBand()
|
|
39
|
-
.
|
|
40
|
+
.paddingOuter(0)
|
|
41
|
+
.paddingInner(
|
|
42
|
+
fxValues.length > 1
|
|
43
|
+
? (plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
|
|
44
|
+
: 0
|
|
45
|
+
)
|
|
40
46
|
.domain(fxValues)
|
|
41
47
|
.rangeRound([0, plot.plotWidth])
|
|
42
48
|
);
|
|
43
49
|
const facetYScale = $derived(
|
|
44
50
|
scaleBand()
|
|
45
|
-
.
|
|
51
|
+
.paddingOuter(0)
|
|
52
|
+
.paddingInner(
|
|
53
|
+
fyValues.length > 1
|
|
54
|
+
? (plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
|
|
55
|
+
: 0
|
|
56
|
+
)
|
|
46
57
|
.domain(fyValues)
|
|
47
58
|
.rangeRound([0, plot.plotHeight])
|
|
48
59
|
);
|
package/dist/core/Plot.svelte
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { GeoProjection } from 'd3-geo';
|
|
2
|
+
type ProjectionOptions = {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
rotate?: [number, number] | [number, number, number];
|
|
6
|
+
precision?: number;
|
|
7
|
+
clip?: number | null;
|
|
8
|
+
parallels?: [number, number];
|
|
9
|
+
domain?: any;
|
|
10
|
+
};
|
|
1
11
|
export declare function namedProjection(projection: string): {
|
|
2
|
-
type: ({ width, height, rotate, precision, clip }:
|
|
3
|
-
width: any;
|
|
4
|
-
height: any;
|
|
5
|
-
rotate: any;
|
|
6
|
-
precision?: number | undefined;
|
|
7
|
-
clip: any;
|
|
8
|
-
}) => any;
|
|
12
|
+
type: ({ width, height, rotate, precision, clip }: ProjectionOptions) => GeoProjection;
|
|
9
13
|
aspectRatio: number;
|
|
10
14
|
} | {
|
|
11
15
|
type: () => {
|
|
@@ -13,7 +17,8 @@ export declare function namedProjection(projection: string): {
|
|
|
13
17
|
};
|
|
14
18
|
} | {
|
|
15
19
|
type: () => {
|
|
16
|
-
invert(x:
|
|
20
|
+
invert(x: number, y: number): number[];
|
|
17
21
|
stream(s: import("d3-geo").GeoStream): import("d3-geo").GeoTransformPrototype & import("d3-geo").GeoStream;
|
|
18
22
|
};
|
|
19
23
|
};
|
|
24
|
+
export {};
|
|
@@ -75,7 +75,7 @@ function conicProjection(createProjection, kx, ky) {
|
|
|
75
75
|
const { parallels, domain, width, height } = options;
|
|
76
76
|
const projection = type(options);
|
|
77
77
|
if (parallels != null) {
|
|
78
|
-
projection.parallels(parallels);
|
|
78
|
+
projection.parallels?.(parallels);
|
|
79
79
|
if (domain === undefined) {
|
|
80
80
|
projection.fitSize([width, height], { type: 'Sphere' });
|
|
81
81
|
}
|
|
@@ -9,7 +9,7 @@ export declare function autoScale({ name, type, domain, scaleOptions, plotOption
|
|
|
9
9
|
plotHeight: number;
|
|
10
10
|
plotHasFilledDotMarks: boolean;
|
|
11
11
|
plotDefaults: PlotDefaults;
|
|
12
|
-
}):
|
|
12
|
+
}): (val: any) => any;
|
|
13
13
|
export declare function autoScaleColor({ type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }: {
|
|
14
14
|
name: ScaleName;
|
|
15
15
|
type: ScaleType;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { RawValue, ScaleType } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type IntervalLike = {
|
|
3
|
+
floor: (d: number) => number;
|
|
4
|
+
round?: (d: number) => number;
|
|
5
|
+
offset: (d: number, step?: number) => number;
|
|
6
|
+
range: (lo: number, hi: number) => number[];
|
|
7
|
+
};
|
|
8
|
+
export declare function maybeInterval(interval: null | number | string | IntervalLike): any;
|
|
9
|
+
export declare function autoTicks(type: ScaleType, ticks: RawValue[], interval: string | number | null, domain: RawValue[], scaleFn: {
|
|
10
|
+
ticks?: (count: number) => RawValue[];
|
|
11
|
+
}, count: number): any;
|
|
12
|
+
export {};
|
|
@@ -34,7 +34,9 @@ export function autoTicks(type, ticks, interval, domain, scaleFn, count) {
|
|
|
34
34
|
return ticks;
|
|
35
35
|
if (interval) {
|
|
36
36
|
const [lo, hi] = extent(domain);
|
|
37
|
-
|
|
37
|
+
if (lo == null || hi == null)
|
|
38
|
+
return [];
|
|
39
|
+
const I = maybeInterval(interval);
|
|
38
40
|
return I.range(lo, I.offset(hi)).filter((d) => d >= lo && d <= hi);
|
|
39
41
|
}
|
|
40
42
|
return typeof scaleFn.ticks === 'function' ? scaleFn.ticks(count) : [];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RawValue } from '../types/index.js';
|
|
2
|
-
type Setter = (v: any) => void;
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to call a D3 "function class" while also calling
|
|
5
4
|
* property setter functions on the result.
|
|
6
5
|
*/
|
|
7
|
-
export default function (d3func: () =>
|
|
8
|
-
export {};
|
|
6
|
+
export default function <T extends object>(d3func: (...args: RawValue[]) => T, args?: RawValue[], props?: Record<string, RawValue>): T;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Helper function to call a D3 "function class" while also calling
|
|
3
3
|
* property setter functions on the result.
|
|
4
4
|
*/
|
|
5
|
-
export default function (d3func, args, props = {}) {
|
|
5
|
+
export default function (d3func, args = [], props = {}) {
|
|
6
6
|
const res = d3func(...args);
|
|
7
|
+
const resWithKeys = res;
|
|
7
8
|
for (const [key, val] of Object.entries(props)) {
|
|
8
|
-
|
|
9
|
+
const setter = resWithKeys[key];
|
|
10
|
+
if (typeof setter !== 'function')
|
|
9
11
|
throw new Error(`function ${key} does not exist`);
|
|
10
|
-
|
|
12
|
+
setter(val);
|
|
11
13
|
}
|
|
12
14
|
return res;
|
|
13
15
|
}
|
package/dist/helpers/colors.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export declare const categoricalSchemes: Map<string, readonly string[]>;
|
|
|
4
4
|
export declare function isCategoricalScheme(scheme: string): boolean;
|
|
5
5
|
type SchemeGetter = (n: number) => readonly string[];
|
|
6
6
|
export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
|
|
7
|
-
export declare function ordinalScheme(scheme: string): SchemeGetter
|
|
8
|
-
export declare function ordinalRange(scheme: string, length: number): readonly string[]
|
|
9
|
-
export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
|
|
7
|
+
export declare function ordinalScheme(scheme: ColorScheme | string): SchemeGetter;
|
|
8
|
+
export declare function ordinalRange(scheme: ColorScheme | string, length: number): readonly string[];
|
|
9
|
+
export declare function maybeBooleanRange(domain: boolean[], scheme?: ColorScheme | string): unknown[] | undefined;
|
|
10
10
|
export declare function isQuantitativeScheme(scheme: string): boolean;
|
|
11
|
-
export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
|
|
11
|
+
export declare function quantitativeScheme(scheme: ColorScheme | string): typeof interpolateBrBG | undefined;
|
|
12
12
|
export declare function isDivergingScheme(scheme: string): boolean;
|
|
13
13
|
export {};
|
package/dist/helpers/colors.js
CHANGED
|
@@ -113,13 +113,14 @@ function schemeicyclical(interpolate) {
|
|
|
113
113
|
}
|
|
114
114
|
export function ordinalScheme(scheme) {
|
|
115
115
|
const s = `${scheme}`.toLowerCase();
|
|
116
|
-
|
|
116
|
+
const match = ordinalSchemes.get(s);
|
|
117
|
+
if (!match)
|
|
117
118
|
throw new Error(`unknown ordinal scheme: ${s}`);
|
|
118
|
-
return
|
|
119
|
+
return match;
|
|
119
120
|
}
|
|
120
121
|
export function ordinalRange(scheme, length) {
|
|
121
122
|
const s = ordinalScheme(scheme);
|
|
122
|
-
const r = typeof s === 'function' ? s(
|
|
123
|
+
const r = typeof s === 'function' ? s(length) : s;
|
|
123
124
|
return r.length !== length ? r.slice(0, length) : r;
|
|
124
125
|
}
|
|
125
126
|
// If the specified domain contains only booleans (ignoring null and undefined),
|
package/dist/helpers/curves.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type CurveFactory } from 'd3-shape';
|
|
3
|
-
export declare function maybeCurve(curve:
|
|
1
|
+
import type { CurveName } from '../types/index.js';
|
|
2
|
+
import { type CurveFactory, type CurveBundleFactory } from 'd3-shape';
|
|
3
|
+
export declare function maybeCurve(curve: (CurveName | CurveFactory) | undefined, tension: number): CurveFactory | CurveBundleFactory;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Channels } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): {
|
|
2
|
+
export declare function getBaseStylesObject<T>(datum: T, props: Partial<Channels<T>>): {
|
|
4
3
|
[k: string]: string | number;
|
|
5
4
|
};
|
|
6
|
-
export default function (datum:
|
|
5
|
+
export default function <T>(datum: T, props: Partial<Channels<T>>): string;
|
|
7
6
|
export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
|
|
8
7
|
export declare function maybeFromPixel(value: string | number): string | number;
|
|
9
8
|
export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
|
|
@@ -32,7 +32,8 @@ export function getBaseStylesObject(datum, props) {
|
|
|
32
32
|
.filter(([key, cssKey]) => cssKey && props[key] != null)
|
|
33
33
|
.map(([key, cssKey]) => [
|
|
34
34
|
cssKey,
|
|
35
|
-
maybeToPixel(cssKey, resolveProp(props[key], datum, styleDefaults[key] || null)
|
|
35
|
+
maybeToPixel(cssKey, (resolveProp(props[key], datum, styleDefaults[key] || null) ??
|
|
36
|
+
''))
|
|
36
37
|
]));
|
|
37
38
|
}
|
|
38
39
|
export default function (datum, props) {
|
package/dist/helpers/group.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { Channels } from '../types/index.js';
|
|
|
3
3
|
* Groups the data by the fx, fy and z channels and calls the reduce function
|
|
4
4
|
* for each group. Returns the new channels to be added in the transform.
|
|
5
5
|
*/
|
|
6
|
-
export declare function groupFacetsAndZ<T>(items: T[], channels: Channels<T>, reduce: (items: T[]) => any): any;
|
|
6
|
+
export declare function groupFacetsAndZ<T>(items: T[], channels: Channels<T>, reduce: (items: T[], groupProps?: Record<string, unknown>) => any): any;
|
package/dist/helpers/group.js
CHANGED
|
@@ -6,17 +6,18 @@ import { groups as d3Groups } from 'd3-array';
|
|
|
6
6
|
*/
|
|
7
7
|
export function groupFacetsAndZ(items, channels, reduce) {
|
|
8
8
|
const groupBy = ['fx', 'fy', 'z'].map((groupChannel) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
let groupByChannel = null;
|
|
10
|
+
if (groupChannel === 'z') {
|
|
11
|
+
if (channels.z)
|
|
12
|
+
groupByChannel = 'z';
|
|
13
|
+
else if (channels.fill)
|
|
14
|
+
groupByChannel = 'fill';
|
|
15
|
+
else if (channels.stroke)
|
|
16
|
+
groupByChannel = 'stroke';
|
|
17
|
+
}
|
|
18
|
+
else if (channels[groupChannel]) {
|
|
19
|
+
groupByChannel = groupChannel;
|
|
20
|
+
}
|
|
20
21
|
if (groupByChannel) {
|
|
21
22
|
const groupByPropName = typeof channels[groupByChannel] === 'string'
|
|
22
23
|
? channels[groupByChannel]
|
|
@@ -34,13 +35,13 @@ export function groupFacetsAndZ(items, channels, reduce) {
|
|
|
34
35
|
const groups = d3Groups(items, ...groupBy.map((d) => d[2]));
|
|
35
36
|
for (const [fxKey, fxGroups] of groups) {
|
|
36
37
|
const newItemGroupProps = {};
|
|
37
|
-
if (groupBy[0][0] !== null)
|
|
38
|
+
if (groupBy[0][0] !== null && groupBy[0][1])
|
|
38
39
|
newItemGroupProps[groupBy[0][1]] = fxKey;
|
|
39
40
|
for (const [fyKey, fyGroups] of fxGroups) {
|
|
40
|
-
if (groupBy[1][0] !== null)
|
|
41
|
+
if (groupBy[1][0] !== null && groupBy[1][1])
|
|
41
42
|
newItemGroupProps[groupBy[1][1]] = fyKey;
|
|
42
43
|
for (const [zKey, zGroups] of fyGroups) {
|
|
43
|
-
if (groupBy[2][0] !== null)
|
|
44
|
+
if (groupBy[2][0] !== null && groupBy[2][1])
|
|
44
45
|
newItemGroupProps[groupBy[2][1]] = zKey;
|
|
45
46
|
reduce(zGroups, newItemGroupProps);
|
|
46
47
|
}
|
package/dist/helpers/math.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare function normdev(p: number): number | false;
|
|
|
12
12
|
export declare function confidenceInterval(data: {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
|
-
}[], predict:
|
|
16
|
-
x:
|
|
15
|
+
}[], predict: (x: number) => number, confidenceLevel: number): (x: number) => {
|
|
16
|
+
x: number;
|
|
17
17
|
left: number;
|
|
18
|
-
right:
|
|
18
|
+
right: number;
|
|
19
19
|
};
|
package/dist/helpers/math.js
CHANGED
|
@@ -75,7 +75,13 @@ function inverseT(p, df) {
|
|
|
75
75
|
if (y > 0.05 + a) {
|
|
76
76
|
// The procedure normdev(p) is assumed to return a negative normal
|
|
77
77
|
// deviate at the lower tail probability level p, e.g. -2.32 for p = 0.01.
|
|
78
|
-
|
|
78
|
+
const _x = normdev(p / 2);
|
|
79
|
+
if (_x === false) {
|
|
80
|
+
throw new Error('normdev returned false for p/2 in inverseT');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
x = _x;
|
|
84
|
+
}
|
|
79
85
|
y = x * x;
|
|
80
86
|
if (df < 5)
|
|
81
87
|
c = c + 0.3 * (df - 4.5) * (x + 0.6);
|
|
@@ -3,7 +3,7 @@ import type { ScaleName, ChannelName, ScaledChannelName, ChannelAccessor, DataRo
|
|
|
3
3
|
type ChannelAlias = {
|
|
4
4
|
channel: ScaledChannelName;
|
|
5
5
|
};
|
|
6
|
-
export declare function resolveProp<K, T>(accessor: ConstantAccessor<K, T>, datum: DataRecord | null, _defaultValue?: K | null): K | typeof _defaultValue;
|
|
6
|
+
export declare function resolveProp<K, T>(accessor: ConstantAccessor<K, T>, datum: DataRecord<T> | null, _defaultValue?: K | null): K | typeof _defaultValue;
|
|
7
7
|
type ChannelOptions = {
|
|
8
8
|
value: ChannelAccessor;
|
|
9
9
|
scale?: ScaleName | null;
|
package/dist/helpers/resolve.js
CHANGED
|
@@ -6,17 +6,22 @@ import { getBaseStylesObject } from './getBaseStyles.js';
|
|
|
6
6
|
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
7
7
|
export function resolveProp(accessor, datum, _defaultValue = null) {
|
|
8
8
|
if (typeof accessor === 'function') {
|
|
9
|
+
const accessorFn = accessor;
|
|
9
10
|
// datum[RAW_VALUE] exists if an array of raw values was used as dataset and got
|
|
10
|
-
// "recordized" by the
|
|
11
|
+
// "recordized" by the recordi e transform. We want to hide this wrapping to the user
|
|
11
12
|
// so we're passing the original value to accessor functions instead of our wrapped record
|
|
12
13
|
return datum == null
|
|
13
|
-
?
|
|
14
|
-
:
|
|
14
|
+
? accessorFn()
|
|
15
|
+
: accessorFn(datum.hasOwnProperty(RAW_VALUE) ? datum[RAW_VALUE] : datum, datum[INDEX]);
|
|
15
16
|
}
|
|
16
|
-
else
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
else {
|
|
18
|
+
const accessorValue = accessor;
|
|
19
|
+
// accessor may be a
|
|
20
|
+
if ((typeof accessorValue === 'string' || typeof accessorValue === 'symbol') &&
|
|
21
|
+
datum &&
|
|
22
|
+
datum[accessorValue] !== undefined) {
|
|
23
|
+
return datum[accessor];
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
return isRawValue(accessor) ? accessor : _defaultValue;
|
|
22
27
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type SymbolType } from 'd3-shape';
|
|
2
2
|
export declare const sqrt3: number;
|
|
3
3
|
export declare const sqrt4_3: number;
|
|
4
|
-
|
|
4
|
+
type BuiltinSymbol = 'asterisk' | 'circle' | 'cross' | 'diamond' | 'diamond2' | 'hexagon' | 'plus' | 'square' | 'square2' | 'star' | 'times' | 'triangle' | 'triangle2' | 'wye';
|
|
5
|
+
export declare function isSymbol(value: any): value is SymbolType | BuiltinSymbol;
|
|
5
6
|
export declare function maybeSymbol(symbol: SymbolType | string): SymbolType;
|
|
7
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { RawValue } from '../types/index.js';
|
|
2
|
-
export declare function isBooleanOrNull(v: RawValue): v is boolean;
|
|
2
|
+
export declare function isBooleanOrNull(v: RawValue): v is boolean | null;
|
|
3
3
|
export declare function isDate(v: RawValue): v is Date;
|
|
4
4
|
export declare function isDateOrNull(v: RawValue | null | undefined): v is Date | null | undefined;
|
|
5
5
|
export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
|
|
6
6
|
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
|
|
7
7
|
export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
|
|
8
|
-
export declare function isSymbolOrNull(v: RawValue | null | undefined):
|
|
8
|
+
export declare function isSymbolOrNull(v: RawValue | null | undefined): v is ("square" | "circle" | "asterisk" | "cross" | "diamond" | "diamond2" | "hexagon" | "plus" | "square2" | "star" | "times" | "triangle" | "triangle2" | "wye") | import("d3-shape").SymbolType | null | undefined;
|
|
9
9
|
export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
|
|
10
10
|
export declare function isOpacityOrNull(v: RawValue): boolean;
|
package/dist/marks/CellX.svelte
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
@component
|
|
3
3
|
For arbitrary rectangles with fixed y position, requires band x scale
|
|
4
4
|
-->
|
|
5
|
-
<script lang="ts">
|
|
5
|
+
<script lang="ts" generics="Datum extends DataRow">
|
|
6
6
|
import Cell from './Cell.svelte';
|
|
7
7
|
import { recordizeY } from '../index.js';
|
|
8
8
|
import type { ComponentProps } from 'svelte';
|
|
9
|
-
import type { TransformArgsRow } from '../types/index.js';
|
|
9
|
+
import type { DataRow, TransformArgsRow } from '../types/index.js';
|
|
10
10
|
|
|
11
|
-
interface CellXMarkProps extends Omit<ComponentProps<typeof Cell>, 'y'> {
|
|
11
|
+
interface CellXMarkProps extends Omit<ComponentProps<typeof Cell>, 'y' | 'data'> {
|
|
12
|
+
data: Datum[];
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
let { data = [{}], ...options }: CellXMarkProps = $props();
|
|
14
16
|
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
recordizeY({
|
|
17
19
|
data,
|
|
18
20
|
...options
|
|
19
|
-
} as TransformArgsRow)
|
|
21
|
+
} as TransformArgsRow<Datum>)
|
|
20
22
|
);
|
|
21
23
|
</script>
|
|
22
24
|
|
|
@@ -1,8 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { DataRow } from '../types/index.js';
|
|
2
|
+
declare function $$render<Datum extends DataRow>(): {
|
|
3
|
+
props: Omit<Partial<{
|
|
4
|
+
filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
5
|
+
facet: "auto" | "include" | "exclude";
|
|
6
|
+
fx: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
7
|
+
fy: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
8
|
+
dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
9
|
+
dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
10
|
+
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
11
|
+
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
12
|
+
fill: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
13
|
+
fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
14
|
+
sort: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
|
|
15
|
+
channel: string;
|
|
16
|
+
order?: "ascending" | "descending";
|
|
17
|
+
} | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
18
|
+
stroke: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
19
|
+
strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
20
|
+
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
21
|
+
strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
22
|
+
strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
23
|
+
strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
24
|
+
opacity: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
25
|
+
strokeDasharray: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
26
|
+
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
27
|
+
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
28
|
+
clipPath: string;
|
|
29
|
+
mask: string;
|
|
30
|
+
imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
31
|
+
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
32
|
+
paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
33
|
+
onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
34
|
+
ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
35
|
+
onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
36
|
+
onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
37
|
+
onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
38
|
+
onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
39
|
+
onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
40
|
+
onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
41
|
+
onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
42
|
+
onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
43
|
+
onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
44
|
+
onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
45
|
+
onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
46
|
+
onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
47
|
+
onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
48
|
+
onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
49
|
+
onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
50
|
+
ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
51
|
+
ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
52
|
+
ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
53
|
+
ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
54
|
+
ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
55
|
+
ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
56
|
+
ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
57
|
+
ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
58
|
+
ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
59
|
+
ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
60
|
+
ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
61
|
+
oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
62
|
+
onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
63
|
+
class: string;
|
|
64
|
+
style: string;
|
|
65
|
+
cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
66
|
+
}> & import("../types/index.js").LinkableMarkProps<Record<string | symbol, import("../types/index.js").RawValue>> & import("../types/index.js").BaseRectMarkProps<Record<string | symbol, import("../types/index.js").RawValue>> & {
|
|
67
|
+
data: Record<string | symbol, import("../types/index.js").RawValue>[];
|
|
68
|
+
x?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
69
|
+
y?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
|
|
70
|
+
}, "data" | "y"> & {
|
|
71
|
+
data: Datum[];
|
|
72
|
+
};
|
|
73
|
+
exports: {};
|
|
74
|
+
bindings: "";
|
|
75
|
+
slots: {};
|
|
76
|
+
events: {};
|
|
77
|
+
};
|
|
78
|
+
declare class __sveltets_Render<Datum extends DataRow> {
|
|
79
|
+
props(): ReturnType<typeof $$render<Datum>>['props'];
|
|
80
|
+
events(): ReturnType<typeof $$render<Datum>>['events'];
|
|
81
|
+
slots(): ReturnType<typeof $$render<Datum>>['slots'];
|
|
82
|
+
bindings(): "";
|
|
83
|
+
exports(): {};
|
|
84
|
+
}
|
|
85
|
+
interface $$IsomorphicComponent {
|
|
86
|
+
new <Datum extends DataRow>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
|
|
87
|
+
$$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
|
|
88
|
+
} & ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
89
|
+
<Datum extends DataRow>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
90
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
4
91
|
}
|
|
5
92
|
/** For arbitrary rectangles with fixed y position, requires band x scale */
|
|
6
|
-
declare const CellX:
|
|
7
|
-
type CellX =
|
|
93
|
+
declare const CellX: $$IsomorphicComponent;
|
|
94
|
+
type CellX<Datum extends DataRow> = InstanceType<typeof CellX<Datum>>;
|
|
8
95
|
export default CellX;
|