svelteplot 0.7.1 → 0.8.0-pr-270.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.d.ts +5 -4
- package/dist/constants.d.ts +1 -1
- package/dist/core/Plot.svelte +8 -2
- package/dist/helpers/colors.d.ts +9 -12
- package/dist/helpers/facets.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +2 -4
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/reduce.d.ts +1 -1
- package/dist/helpers/scales.d.ts +7 -7
- package/dist/helpers/symbols.d.ts +2 -2
- package/dist/helpers/time.d.ts +3 -3
- package/dist/helpers/typeChecks.d.ts +8 -8
- package/dist/marks/Area.svelte.d.ts +5 -4
- package/dist/marks/AreaX.svelte.d.ts +6 -5
- package/dist/marks/Arrow.svelte.d.ts +5 -4
- package/dist/marks/AxisX.svelte +34 -14
- package/dist/marks/AxisX.svelte.d.ts +6 -5
- package/dist/marks/AxisY.svelte +35 -15
- package/dist/marks/AxisY.svelte.d.ts +6 -5
- package/dist/marks/BarX.svelte +1 -3
- package/dist/marks/BarX.svelte.d.ts +5 -4
- package/dist/marks/BarY.svelte +1 -3
- package/dist/marks/BarY.svelte.d.ts +5 -4
- package/dist/marks/BollingerX.svelte.d.ts +2 -76
- package/dist/marks/BollingerY.svelte.d.ts +2 -76
- package/dist/marks/BoxY.svelte +4 -2
- package/dist/marks/BoxY.svelte.d.ts +1 -63
- package/dist/marks/Brush.svelte +12 -13
- package/dist/marks/Brush.svelte.d.ts +1 -63
- package/dist/marks/Cell.svelte +1 -3
- package/dist/marks/Cell.svelte.d.ts +5 -4
- package/dist/marks/CustomMark.svelte.d.ts +2 -84
- package/dist/marks/DifferenceY.svelte.d.ts +1 -63
- package/dist/marks/Dot.svelte.d.ts +5 -4
- package/dist/marks/DotX.svelte.d.ts +6 -5
- package/dist/marks/DotY.svelte.d.ts +6 -5
- package/dist/marks/Frame.svelte +2 -1
- package/dist/marks/Frame.svelte.d.ts +6 -5
- package/dist/marks/Geo.svelte.d.ts +5 -4
- package/dist/marks/Graticule.svelte +4 -5
- package/dist/marks/GridX.svelte.d.ts +5 -4
- package/dist/marks/GridY.svelte.d.ts +5 -4
- package/dist/marks/Image.svelte.d.ts +2 -75
- package/dist/marks/Line.svelte.d.ts +5 -4
- package/dist/marks/LineX.svelte.d.ts +7 -6
- package/dist/marks/LineY.svelte.d.ts +7 -6
- package/dist/marks/Link.svelte.d.ts +5 -4
- package/dist/marks/Rect.svelte +1 -3
- package/dist/marks/Rect.svelte.d.ts +5 -4
- package/dist/marks/RuleX.svelte.d.ts +5 -4
- package/dist/marks/RuleY.svelte.d.ts +5 -4
- package/dist/marks/Sphere.svelte +1 -2
- package/dist/marks/Spike.svelte +4 -5
- package/dist/marks/Spike.svelte.d.ts +6 -5
- package/dist/marks/Text.svelte.d.ts +5 -4
- package/dist/marks/TickX.svelte.d.ts +5 -4
- package/dist/marks/TickY.svelte.d.ts +5 -4
- package/dist/marks/Vector.svelte.d.ts +5 -4
- package/dist/marks/WaffleX.svelte +1 -3
- package/dist/marks/WaffleX.svelte.d.ts +2 -85
- package/dist/marks/WaffleY.svelte +1 -3
- package/dist/marks/WaffleY.svelte.d.ts +2 -83
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -102
- package/dist/transforms/bollinger.d.ts +1 -69
- package/dist/transforms/centroid.d.ts +1 -4
- package/dist/transforms/density.d.ts +40 -0
- package/dist/transforms/density.js +259 -0
- 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 -128
- package/dist/transforms/normalize.d.ts +23 -0
- package/dist/transforms/recordize.d.ts +4 -7
- package/dist/transforms/select.d.ts +7 -448
- package/dist/transforms/sort.d.ts +5 -253
- package/dist/transforms/stack.d.ts +3 -23
- package/dist/transforms/stack.js +4 -1
- package/dist/transforms/window.d.ts +2 -134
- package/dist/ui/ExamplesPagePreview.svelte +9 -13
- package/package.json +24 -18
package/dist/Mark.svelte.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
|
+
import { CHANNEL_SCALE } from './constants.js';
|
|
2
3
|
import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
|
|
3
4
|
import { getUsedScales } from './helpers/scales.js';
|
|
4
5
|
declare function $$render<Datum extends DataRecord>(): {
|
|
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
9
10
|
fy: ChannelAccessor<Datum>;
|
|
10
11
|
dx: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
11
12
|
dy: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX:
|
|
13
|
-
dodgeY:
|
|
13
|
+
dodgeX: CHANNEL_SCALE;
|
|
14
|
+
dodgeY: CHANNEL_SCALE;
|
|
14
15
|
fill: ChannelAccessor<Datum>;
|
|
15
16
|
fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
16
|
-
sort:
|
|
17
|
+
sort: {
|
|
17
18
|
channel: string;
|
|
18
19
|
order?: "ascending" | "descending";
|
|
19
|
-
} | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
|
|
20
|
+
} | ((a: RawValue, b: RawValue) => number) | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
|
|
20
21
|
stroke: ChannelAccessor<Datum>;
|
|
21
22
|
strokeWidth: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
22
23
|
strokeOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
|
package/dist/constants.d.ts
CHANGED
package/dist/core/Plot.svelte
CHANGED
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
unknown: '#cccccc99',
|
|
68
68
|
sortOrdinalDomains: true,
|
|
69
69
|
categoricalColorScheme: 'observable10',
|
|
70
|
-
pointScaleHeight:
|
|
70
|
+
pointScaleHeight: 20,
|
|
71
71
|
bandScaleHeight: 30,
|
|
72
72
|
locale: 'en-US',
|
|
73
73
|
numberFormat: {
|
|
@@ -208,6 +208,12 @@
|
|
|
208
208
|
isOneDimensional && explicitScales.has('x') ? 1 : preScales.y.domain.length
|
|
209
209
|
);
|
|
210
210
|
|
|
211
|
+
const defaultPointScaleHeight = $derived(
|
|
212
|
+
explicitScales.has('r') && plotOptions.r.range
|
|
213
|
+
? plotOptions.r.range[1] * 2
|
|
214
|
+
: DEFAULTS.pointScaleHeight
|
|
215
|
+
);
|
|
216
|
+
|
|
211
217
|
// compute the (automatic) height based on various factors:
|
|
212
218
|
// - if the plot used a projection and the projection requires an aspect ratio,
|
|
213
219
|
// we use it, but adjust for the facet counts
|
|
@@ -239,7 +245,7 @@
|
|
|
239
245
|
: preScales.y.type === 'band'
|
|
240
246
|
? yFacetCount * yDomainCount * DEFAULTS.bandScaleHeight
|
|
241
247
|
: preScales.y.type === 'point'
|
|
242
|
-
? yFacetCount * yDomainCount *
|
|
248
|
+
? yFacetCount * yDomainCount * defaultPointScaleHeight
|
|
243
249
|
: DEFAULTS.height) +
|
|
244
250
|
plotOptions.marginTop +
|
|
245
251
|
plotOptions.marginBottom
|
package/dist/helpers/colors.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { interpolateBrBG } from 'd3-scale-chromatic';
|
|
2
1
|
import type { ColorScheme } from '../types/index.js';
|
|
3
|
-
export declare const categoricalSchemes:
|
|
4
|
-
export declare function isCategoricalScheme(scheme: string):
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function isDivergingScheme(scheme: string): boolean;
|
|
13
|
-
export {};
|
|
2
|
+
export declare const categoricalSchemes: any;
|
|
3
|
+
export declare function isCategoricalScheme(scheme: string): any;
|
|
4
|
+
export declare function isOrdinalScheme(scheme: ColorScheme): any;
|
|
5
|
+
export declare function ordinalScheme(scheme: string): any;
|
|
6
|
+
export declare function ordinalRange(scheme: string, length: number): any;
|
|
7
|
+
export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
|
|
8
|
+
export declare function isQuantitativeScheme(scheme: string): any;
|
|
9
|
+
export declare function quantitativeScheme(scheme: string): any;
|
|
10
|
+
export declare function isDivergingScheme(scheme: string): any;
|
package/dist/helpers/facets.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ import type { GenericMarkOptions, Mark, RawValue } from '../types/index.js';
|
|
|
9
9
|
* @param fyValues y facet domain
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
export declare function getEmptyFacets(marks: Mark<GenericMarkOptions>[], fxValues: RawValue[], fyValues: RawValue[]):
|
|
12
|
+
export declare function getEmptyFacets(marks: Mark<GenericMarkOptions>[], fxValues: RawValue[], fyValues: RawValue[]): any;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Channels } from '../types/index.js';
|
|
2
2
|
import type { DataRow } from '../types/index.js';
|
|
3
|
-
export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>):
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export default function (datum: DataRow, props: Partial<Channels>): string;
|
|
3
|
+
export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): any;
|
|
4
|
+
export default function (datum: DataRow, props: Partial<Channels>): any;
|
|
7
5
|
export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
|
|
8
6
|
export declare function maybeFromPixel(value: string | number): string | number;
|
|
9
7
|
export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
|
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<T>(datum: T, options: Channels<T>):
|
|
6
|
+
export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
|
|
7
|
+
export declare function testFilter<T>(datum: T, options: Channels<T>): 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;
|
|
@@ -15,4 +15,4 @@ export declare const POSITION_CHANNELS: Set<ChannelName>;
|
|
|
15
15
|
export declare function parseInset(inset: number | string, width: number): number;
|
|
16
16
|
export declare function omit<T extends {}, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
|
|
17
17
|
export declare function identity<T>(x: T): T;
|
|
18
|
-
export declare const GEOJSON_PREFER_STROKE:
|
|
18
|
+
export declare const GEOJSON_PREFER_STROKE: any;
|
package/dist/helpers/reduce.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type ReducerOption = ReducerName | ReducerFunc;
|
|
|
4
4
|
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
5
5
|
export type ReducerPercentile = (`p${Digit}${Digit}` & Record<never, never>) | 'p25' | 'p50' | 'p75';
|
|
6
6
|
export type ReducerName = 'count' | 'deviation' | 'difference' | 'first' | 'last' | 'max' | 'mean' | 'median' | 'min' | 'mode' | 'ratio' | 'sum' | 'variance' | ReducerPercentile;
|
|
7
|
-
export declare const Reducer:
|
|
7
|
+
export declare const Reducer: any;
|
|
8
8
|
export declare function mayberReducer(r: ReducerOption): ReducerFunc;
|
|
9
9
|
export declare function reduceOutputs(newDatum: DataRecord, data: DataRecord[], options: Record<ChannelName, ReducerOption>, outputs: Iterable<ChannelName>, channels: Channels, newChannels: Channels): void;
|
|
10
10
|
export {};
|
package/dist/helpers/scales.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, UsedScales } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* compute the plot scales
|
|
4
4
|
*/
|
|
@@ -8,19 +8,19 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
|
|
|
8
8
|
domain: number[];
|
|
9
9
|
range: number[];
|
|
10
10
|
fn: (() => string) | (() => number);
|
|
11
|
-
skip:
|
|
11
|
+
skip: any;
|
|
12
12
|
isDummy: boolean;
|
|
13
13
|
manualActiveMarks?: undefined;
|
|
14
14
|
uniqueScaleProps?: undefined;
|
|
15
15
|
autoTitle?: undefined;
|
|
16
16
|
} | {
|
|
17
17
|
type: ScaleType;
|
|
18
|
-
domain:
|
|
18
|
+
domain: any;
|
|
19
19
|
range: any;
|
|
20
20
|
fn: any;
|
|
21
|
-
skip:
|
|
21
|
+
skip: any;
|
|
22
22
|
manualActiveMarks: number;
|
|
23
|
-
uniqueScaleProps:
|
|
23
|
+
uniqueScaleProps: any;
|
|
24
24
|
autoTitle: string | null;
|
|
25
25
|
isDummy?: undefined;
|
|
26
26
|
};
|
|
@@ -36,8 +36,8 @@ export declare function inferScaleType(name: ScaleName, dataValues: RawValue[],
|
|
|
36
36
|
* not. That's what this function is used for.
|
|
37
37
|
*/
|
|
38
38
|
export declare function getUsedScales(plot: PlotState, options: GenericMarkOptions, mark: Mark<GenericMarkOptions>): UsedScales;
|
|
39
|
-
export declare function looksLikeANumber(input: string | number):
|
|
39
|
+
export declare function looksLikeANumber(input: string | number): any;
|
|
40
40
|
export declare function projectXY(scales: PlotScales, x: RawValue, y: RawValue, useXScale?: boolean, useYScale?: boolean): [number, number];
|
|
41
41
|
export declare function projectX(channel: 'x' | 'x1' | 'x2', scales: PlotScales, value: RawValue): number;
|
|
42
42
|
export declare function projectY(channel: 'y' | 'y1' | 'y2', scales: PlotScales, value: RawValue): number;
|
|
43
|
-
export declare function isOrdinalScale(scaleType: ScaleType): scaleType is "
|
|
43
|
+
export declare function isOrdinalScale(scaleType: ScaleType): scaleType is "point" | "ordinal" | "band" | "categorical" | "threshold";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SymbolType } from 'd3-shape';
|
|
2
2
|
export declare const sqrt3: number;
|
|
3
3
|
export declare const sqrt4_3: number;
|
|
4
|
-
export declare function isSymbol(value: string | SymbolType):
|
|
5
|
-
export declare function maybeSymbol(symbol: SymbolType | string):
|
|
4
|
+
export declare function isSymbol(value: string | SymbolType): any;
|
|
5
|
+
export declare function maybeSymbol(symbol: SymbolType | string): any;
|
package/dist/helpers/time.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const durations:
|
|
2
|
-
export declare const intervalDuration:
|
|
3
|
-
export declare const intervalType:
|
|
1
|
+
export declare const durations: any;
|
|
2
|
+
export declare const intervalDuration: any;
|
|
3
|
+
export declare const intervalType: any;
|
|
4
4
|
export declare function parseTimeInterval(input: string): [string, number];
|
|
5
5
|
export declare function maybeTimeInterval(input: string): any;
|
|
6
6
|
export declare function maybeUtcInterval(input: string): any;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { RawValue } from '../types/index.js';
|
|
2
|
-
export declare function isBooleanOrNull(v: RawValue):
|
|
2
|
+
export declare function isBooleanOrNull(v: RawValue): boolean;
|
|
3
3
|
export declare function isDate(v: RawValue): v is Date;
|
|
4
|
-
export declare function isDateOrNull(v: RawValue | null | undefined):
|
|
5
|
-
export declare function isNumberOrNull(v: RawValue | null | undefined):
|
|
6
|
-
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined):
|
|
7
|
-
export declare function isStringOrNull(v: RawValue | null | undefined):
|
|
8
|
-
export declare function isSymbolOrNull(v: RawValue | null | undefined):
|
|
9
|
-
export declare function isColorOrNull(v: RawValue | null | undefined):
|
|
10
|
-
export declare function isOpacityOrNull(v: RawValue):
|
|
4
|
+
export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
|
|
5
|
+
export declare function isNumberOrNull(v: RawValue | null | undefined): any;
|
|
6
|
+
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): any;
|
|
7
|
+
export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
|
|
8
|
+
export declare function isSymbolOrNull(v: RawValue | null | undefined): any;
|
|
9
|
+
export declare function isColorOrNull(v: RawValue | null | undefined): any;
|
|
10
|
+
export declare function isOpacityOrNull(v: RawValue): any;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CurveFactory } from 'd3-shape';
|
|
2
|
+
import callWithProps from '../helpers/callWithProps.js';
|
|
2
3
|
import type { CurveName, DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps, RawValue } from '../types/index.js';
|
|
3
4
|
import type { StackOptions } from '../transforms/stack.js';
|
|
4
5
|
declare function $$render<Datum extends DataRecord>(): {
|
|
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
9
10
|
fy: ChannelAccessor<Datum>;
|
|
10
11
|
dx: ConstantAccessor<number, Datum>;
|
|
11
12
|
dy: ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX:
|
|
13
|
-
dodgeY:
|
|
13
|
+
dodgeX: callWithProps;
|
|
14
|
+
dodgeY: callWithProps;
|
|
14
15
|
fill: ChannelAccessor<Datum>;
|
|
15
16
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
16
|
-
sort:
|
|
17
|
+
sort: {
|
|
17
18
|
channel: string;
|
|
18
19
|
order?: "ascending" | "descending";
|
|
19
|
-
} | ConstantAccessor<RawValue, Datum>;
|
|
20
|
+
} | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
|
|
20
21
|
stroke: ChannelAccessor<Datum>;
|
|
21
22
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
22
23
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renameChannels } from '../transforms/rename.js';
|
|
1
2
|
import type { ChannelAccessor, DataRow } from '../types/index.js';
|
|
2
3
|
declare function $$render<Datum extends DataRow>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
7
8
|
fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
8
9
|
dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
9
10
|
dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: renameChannels;
|
|
12
|
+
dodgeY: renameChannels;
|
|
12
13
|
fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
13
14
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
|
|
18
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
|
|
18
19
|
stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
19
20
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
20
21
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -74,7 +75,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
74
75
|
sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
|
|
75
76
|
channel: "stroke" | "fill";
|
|
76
77
|
};
|
|
77
|
-
stack?: Partial<
|
|
78
|
+
stack?: Partial<renameChannels>;
|
|
78
79
|
canvas?: boolean;
|
|
79
80
|
areaClass?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
80
81
|
}, "y1" | "y2"> & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DataRecord, ConstantAccessor, ChannelAccessor, RawValue } from '../types/index.js';
|
|
2
2
|
import { type SweepOption } from '../helpers/arrowPath.js';
|
|
3
|
+
import { replaceChannels } from '../transforms/rename.js';
|
|
3
4
|
declare function $$render<Datum extends DataRecord>(): {
|
|
4
5
|
props: Omit<Partial<{
|
|
5
6
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -8,14 +9,14 @@ declare function $$render<Datum extends DataRecord>(): {
|
|
|
8
9
|
fy: ChannelAccessor<Datum>;
|
|
9
10
|
dx: ConstantAccessor<number, Datum>;
|
|
10
11
|
dy: ConstantAccessor<number, Datum>;
|
|
11
|
-
dodgeX:
|
|
12
|
-
dodgeY:
|
|
12
|
+
dodgeX: replaceChannels;
|
|
13
|
+
dodgeY: replaceChannels;
|
|
13
14
|
fill: ChannelAccessor<Datum>;
|
|
14
15
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
15
|
-
sort:
|
|
16
|
+
sort: {
|
|
16
17
|
channel: string;
|
|
17
18
|
order?: "ascending" | "descending";
|
|
18
|
-
} | ConstantAccessor<RawValue, Datum>;
|
|
19
|
+
} | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
|
|
19
20
|
stroke: ChannelAccessor<Datum>;
|
|
20
21
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
21
22
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
package/dist/marks/AxisX.svelte
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
19
19
|
import { resolveScaledStyles } from '../helpers/resolve.js';
|
|
20
20
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
21
|
+
import { extent } from 'd3-array';
|
|
21
22
|
|
|
22
|
-
interface AxisXMarkProps
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
> {
|
|
23
|
+
interface AxisXMarkProps extends Omit<
|
|
24
|
+
BaseMarkProps<Datum>,
|
|
25
|
+
'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
|
|
26
|
+
> {
|
|
27
27
|
data?: Datum[];
|
|
28
28
|
automatic?: boolean;
|
|
29
29
|
title?: string | false | null;
|
|
@@ -68,14 +68,15 @@
|
|
|
68
68
|
...getPlotDefaults().axisX
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
const { ticks: magicTicks } = $derived({ ...DEFAULTS, ...markProps });
|
|
72
|
+
|
|
71
73
|
const {
|
|
72
|
-
|
|
73
|
-
data = Array.isArray(magicTicks) ? magicTicks : [],
|
|
74
|
+
data,
|
|
74
75
|
automatic = false,
|
|
75
76
|
title,
|
|
76
77
|
anchor,
|
|
77
78
|
facetAnchor = 'auto',
|
|
78
|
-
interval
|
|
79
|
+
interval,
|
|
79
80
|
tickSize,
|
|
80
81
|
tickFontSize,
|
|
81
82
|
tickPadding,
|
|
@@ -83,11 +84,17 @@
|
|
|
83
84
|
tickFormat,
|
|
84
85
|
tickClass,
|
|
85
86
|
class: className,
|
|
86
|
-
tickCount
|
|
87
|
+
tickCount,
|
|
87
88
|
tickSpacing,
|
|
88
89
|
text = true,
|
|
89
90
|
...options
|
|
90
|
-
}: AxisXMarkProps = $derived({
|
|
91
|
+
}: AxisXMarkProps = $derived({
|
|
92
|
+
data: Array.isArray(magicTicks) ? magicTicks : [],
|
|
93
|
+
tickCount: typeof magicTicks === 'number' ? magicTicks : undefined,
|
|
94
|
+
interval: typeof magicTicks === 'string' ? magicTicks : undefined,
|
|
95
|
+
...DEFAULTS,
|
|
96
|
+
...markProps
|
|
97
|
+
});
|
|
91
98
|
|
|
92
99
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
93
100
|
const plot = $derived(getPlotState());
|
|
@@ -115,6 +122,21 @@
|
|
|
115
122
|
)
|
|
116
123
|
);
|
|
117
124
|
|
|
125
|
+
const useCompactNotation = $derived.by(() => {
|
|
126
|
+
const range =
|
|
127
|
+
extent(plot.scales.x.domain).filter(
|
|
128
|
+
(d): d is number => typeof d === 'number' && Number.isFinite(d)
|
|
129
|
+
) ?? [];
|
|
130
|
+
|
|
131
|
+
if (range[0] === undefined || range[1] === undefined) return false;
|
|
132
|
+
const crossesZero = range[0] <= 0 && range[1] >= 0;
|
|
133
|
+
if (crossesZero) return true;
|
|
134
|
+
const magnitudes = range.map((d) =>
|
|
135
|
+
d === 0 ? -Infinity : Math.floor(Math.log10(Math.abs(d)))
|
|
136
|
+
);
|
|
137
|
+
return magnitudes[0] !== magnitudes[1];
|
|
138
|
+
});
|
|
139
|
+
|
|
118
140
|
const tickFmt = $derived(tickFormat || plot.options.x.tickFormat);
|
|
119
141
|
|
|
120
142
|
const useTickFormat = $derived(
|
|
@@ -133,10 +155,8 @@
|
|
|
133
155
|
: // auto
|
|
134
156
|
(d: RawValue) =>
|
|
135
157
|
Intl.NumberFormat(plot.options.locale, {
|
|
136
|
-
// use compact notation if range covers
|
|
137
|
-
...(
|
|
138
|
-
? { notation: 'compact' }
|
|
139
|
-
: {}),
|
|
158
|
+
// use compact notation if range covers multiple magnitudes
|
|
159
|
+
...(useCompactNotation ? { notation: 'compact' } : {}),
|
|
140
160
|
...DEFAULTS.numberFormat,
|
|
141
161
|
style: plot.options.x.percent ? 'percent' : 'decimal'
|
|
142
162
|
}).format(d)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RawValue, ConstantAccessor } from '../types/index.js';
|
|
2
2
|
import type * as CSS from 'csstype';
|
|
3
|
+
import autoTimeFormat from '../helpers/autoTimeFormat.js';
|
|
3
4
|
declare function $$render<Datum extends RawValue>(): {
|
|
4
5
|
props: Omit<Partial<{
|
|
5
6
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -8,14 +9,14 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
8
9
|
fy: import("../types/channel").ChannelAccessor<Datum>;
|
|
9
10
|
dx: ConstantAccessor<number, Datum>;
|
|
10
11
|
dy: ConstantAccessor<number, Datum>;
|
|
11
|
-
dodgeX:
|
|
12
|
-
dodgeY:
|
|
12
|
+
dodgeX: autoTimeFormat;
|
|
13
|
+
dodgeY: autoTimeFormat;
|
|
13
14
|
fill: import("../types/channel").ChannelAccessor<Datum>;
|
|
14
15
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
15
|
-
sort:
|
|
16
|
+
sort: {
|
|
16
17
|
channel: string;
|
|
17
18
|
order?: "ascending" | "descending";
|
|
18
|
-
} | ConstantAccessor<RawValue, Datum>;
|
|
19
|
+
} | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
|
|
19
20
|
stroke: import("../types/channel").ChannelAccessor<Datum>;
|
|
20
21
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
21
22
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -63,7 +64,7 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
63
64
|
class: string;
|
|
64
65
|
style: string;
|
|
65
66
|
cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
|
|
66
|
-
}>, "fillOpacity" | "
|
|
67
|
+
}>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
|
|
67
68
|
data?: Datum[];
|
|
68
69
|
automatic?: boolean;
|
|
69
70
|
title?: string | false | null;
|
package/dist/marks/AxisY.svelte
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
18
18
|
import { resolveScaledStyles } from '../helpers/resolve.js';
|
|
19
19
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
20
|
+
import { extent } from 'd3-array';
|
|
20
21
|
|
|
21
|
-
interface AxisYMarkProps
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
> {
|
|
22
|
+
interface AxisYMarkProps extends Omit<
|
|
23
|
+
BaseMarkProps<Datum>,
|
|
24
|
+
'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
|
|
25
|
+
> {
|
|
26
26
|
data?: Datum[];
|
|
27
27
|
automatic?: boolean;
|
|
28
28
|
title?: string | false | null;
|
|
@@ -65,15 +65,16 @@
|
|
|
65
65
|
...getPlotDefaults().axisY
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
const { ticks: magicTicks } = $derived({ ...DEFAULTS, ...markProps });
|
|
69
|
+
|
|
68
70
|
const {
|
|
69
|
-
|
|
70
|
-
data = Array.isArray(magicTicks) ? magicTicks : [],
|
|
71
|
+
data,
|
|
71
72
|
automatic = false,
|
|
72
73
|
title,
|
|
73
74
|
anchor = 'left',
|
|
74
75
|
class: className,
|
|
75
76
|
facetAnchor = 'auto',
|
|
76
|
-
interval
|
|
77
|
+
interval,
|
|
77
78
|
lineAnchor = 'center',
|
|
78
79
|
textAnchor,
|
|
79
80
|
tickSize,
|
|
@@ -81,11 +82,17 @@
|
|
|
81
82
|
tickPadding,
|
|
82
83
|
tickFormat,
|
|
83
84
|
tickClass,
|
|
84
|
-
tickCount
|
|
85
|
+
tickCount,
|
|
85
86
|
tickSpacing,
|
|
86
87
|
text = true,
|
|
87
88
|
...options
|
|
88
|
-
}: AxisYMarkProps = $derived({
|
|
89
|
+
}: AxisYMarkProps = $derived({
|
|
90
|
+
data: Array.isArray(magicTicks) ? magicTicks : [],
|
|
91
|
+
tickCount: typeof magicTicks === 'number' ? magicTicks : undefined,
|
|
92
|
+
interval: typeof magicTicks === 'string' ? magicTicks : undefined,
|
|
93
|
+
...DEFAULTS,
|
|
94
|
+
...markProps
|
|
95
|
+
});
|
|
89
96
|
|
|
90
97
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
91
98
|
const plot = $derived(getPlotState());
|
|
@@ -113,6 +120,21 @@
|
|
|
113
120
|
)
|
|
114
121
|
);
|
|
115
122
|
|
|
123
|
+
const useCompactNotation = $derived.by(() => {
|
|
124
|
+
const range =
|
|
125
|
+
extent(plot.scales.y.domain).filter(
|
|
126
|
+
(d): d is number => typeof d === 'number' && Number.isFinite(d)
|
|
127
|
+
) ?? [];
|
|
128
|
+
|
|
129
|
+
if (range[0] === undefined || range[1] === undefined) return false;
|
|
130
|
+
const crossesZero = range[0] <= 0 && range[1] >= 0;
|
|
131
|
+
if (crossesZero) return true;
|
|
132
|
+
const magnitudes = range.map((d) =>
|
|
133
|
+
d === 0 ? -Infinity : Math.floor(Math.log10(Math.abs(d)))
|
|
134
|
+
);
|
|
135
|
+
return magnitudes[0] !== magnitudes[1];
|
|
136
|
+
});
|
|
137
|
+
|
|
116
138
|
const tickFmt = $derived(tickFormat || plot.options.y.tickFormat);
|
|
117
139
|
|
|
118
140
|
const useTickFormat = $derived(
|
|
@@ -131,10 +153,8 @@
|
|
|
131
153
|
: // auto
|
|
132
154
|
(d: RawValue) =>
|
|
133
155
|
Intl.NumberFormat(plot.options.locale, {
|
|
134
|
-
// use compact notation if range covers
|
|
135
|
-
...(
|
|
136
|
-
? { notation: 'compact' }
|
|
137
|
-
: {}),
|
|
156
|
+
// use compact notation if range covers multiple magnitudes
|
|
157
|
+
...(useCompactNotation ? { notation: 'compact' } : {}),
|
|
138
158
|
...DEFAULTS.numberFormat,
|
|
139
159
|
style: plot.options.y.percent ? 'percent' : 'decimal'
|
|
140
160
|
}).format(d)
|
|
@@ -161,7 +181,7 @@
|
|
|
161
181
|
facetAnchor !== 'auto' ? facetAnchor : anchor === 'left' ? 'left-empty' : 'right-empty'
|
|
162
182
|
);
|
|
163
183
|
|
|
164
|
-
const showAxis = $
|
|
184
|
+
const showAxis = $derived(
|
|
165
185
|
useFacetAnchor === 'left'
|
|
166
186
|
? left
|
|
167
187
|
: useFacetAnchor === 'right'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RawValue, ConstantAccessor } from '../types/index.js';
|
|
2
|
+
import autoTimeFormat from '../helpers/autoTimeFormat.js';
|
|
2
3
|
declare function $$render<Datum extends RawValue>(): {
|
|
3
4
|
props: Omit<Partial<{
|
|
4
5
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -7,14 +8,14 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
7
8
|
fy: import("../types/channel").ChannelAccessor<Datum>;
|
|
8
9
|
dx: ConstantAccessor<number, Datum>;
|
|
9
10
|
dy: ConstantAccessor<number, Datum>;
|
|
10
|
-
dodgeX:
|
|
11
|
-
dodgeY:
|
|
11
|
+
dodgeX: autoTimeFormat;
|
|
12
|
+
dodgeY: autoTimeFormat;
|
|
12
13
|
fill: import("../types/channel").ChannelAccessor<Datum>;
|
|
13
14
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
14
|
-
sort:
|
|
15
|
+
sort: {
|
|
15
16
|
channel: string;
|
|
16
17
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ConstantAccessor<RawValue, Datum>;
|
|
18
|
+
} | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
|
|
18
19
|
stroke: import("../types/channel").ChannelAccessor<Datum>;
|
|
19
20
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
21
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -62,7 +63,7 @@ declare function $$render<Datum extends RawValue>(): {
|
|
|
62
63
|
class: string;
|
|
63
64
|
style: string;
|
|
64
65
|
cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
|
|
65
|
-
}>, "fillOpacity" | "
|
|
66
|
+
}>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
|
|
66
67
|
data?: Datum[];
|
|
67
68
|
automatic?: boolean;
|
|
68
69
|
title?: string | false | null;
|
package/dist/marks/BarX.svelte
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts" generics="Datum extends DataRow">
|
|
6
6
|
interface BarXMarkProps
|
|
7
|
-
extends BaseMarkProps<Datum>,
|
|
8
|
-
LinkableMarkProps<Datum>,
|
|
9
|
-
BaseRectMarkProps<Datum> {
|
|
7
|
+
extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
|
|
10
8
|
data: Datum[];
|
|
11
9
|
x?: ChannelAccessor<Datum>;
|
|
12
10
|
x1?: ChannelAccessor<Datum>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { stackX } from '../index.js';
|
|
1
2
|
import type { StackOptions } from '../transforms/stack.js';
|
|
2
3
|
import type { DataRow } from '../types/index.js';
|
|
3
4
|
import type { BaseRectMarkProps, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
|
|
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
9
10
|
fy: ChannelAccessor<Datum>;
|
|
10
11
|
dx: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
11
12
|
dy: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX:
|
|
13
|
-
dodgeY:
|
|
13
|
+
dodgeX: stackX;
|
|
14
|
+
dodgeY: stackX;
|
|
14
15
|
fill: ChannelAccessor<Datum>;
|
|
15
16
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
16
|
-
sort:
|
|
17
|
+
sort: {
|
|
17
18
|
channel: string;
|
|
18
19
|
order?: "ascending" | "descending";
|
|
19
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/
|
|
20
|
+
} | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Datum>;
|
|
20
21
|
stroke: ChannelAccessor<Datum>;
|
|
21
22
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
22
23
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
package/dist/marks/BarY.svelte
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<script lang="ts" generics="Datum extends DataRow">
|
|
7
7
|
interface BarYMarkProps
|
|
8
|
-
extends BaseMarkProps<Datum>,
|
|
9
|
-
LinkableMarkProps<Datum>,
|
|
10
|
-
BaseRectMarkProps<Datum> {
|
|
8
|
+
extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
|
|
11
9
|
data: Datum[];
|
|
12
10
|
x?: ChannelAccessor<Datum>;
|
|
13
11
|
y?: ChannelAccessor<Datum>;
|