svelteplot 0.6.0-pr-266.0 → 0.7.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 +7 -0
- package/dist/Mark.svelte.d.ts +4 -5
- package/dist/Plot.svelte +10 -2
- package/dist/constants.d.ts +1 -1
- package/dist/core/FacetAxes.svelte +2 -2
- package/dist/core/Plot.svelte +7 -11
- package/dist/helpers/colors.d.ts +12 -9
- package/dist/helpers/facets.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +6 -2
- package/dist/helpers/getBaseStyles.js +8 -0
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/reduce.d.ts +1 -1
- package/dist/helpers/removeIdenticalLines.js +3 -2
- package/dist/helpers/scales.d.ts +7 -7
- package/dist/helpers/scales.js +2 -2
- 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/helpers/wordwrap.d.ts +14 -0
- package/dist/helpers/wordwrap.js +129 -0
- package/dist/marks/Area.svelte.d.ts +4 -5
- package/dist/marks/AreaX.svelte.d.ts +5 -6
- package/dist/marks/Arrow.svelte.d.ts +4 -5
- package/dist/marks/AxisX.svelte +2 -1
- package/dist/marks/AxisX.svelte.d.ts +6 -6
- package/dist/marks/AxisY.svelte.d.ts +5 -6
- package/dist/marks/BarX.svelte.d.ts +4 -5
- package/dist/marks/BarY.svelte.d.ts +4 -5
- package/dist/marks/BollingerX.svelte.d.ts +76 -2
- package/dist/marks/BollingerY.svelte.d.ts +76 -2
- package/dist/marks/BoxY.svelte.d.ts +68 -6
- package/dist/marks/Cell.svelte.d.ts +4 -5
- package/dist/marks/CustomMark.svelte.d.ts +84 -2
- package/dist/marks/CustomMarkHTML.svelte.d.ts +1 -1
- package/dist/marks/DifferenceY.svelte.d.ts +69 -7
- package/dist/marks/Dot.svelte.d.ts +4 -5
- package/dist/marks/DotX.svelte.d.ts +5 -6
- package/dist/marks/DotY.svelte.d.ts +5 -6
- package/dist/marks/Geo.svelte.d.ts +4 -5
- package/dist/marks/GridX.svelte.d.ts +4 -5
- package/dist/marks/GridY.svelte.d.ts +4 -5
- package/dist/marks/Image.svelte.d.ts +75 -2
- package/dist/marks/Line.svelte.d.ts +5 -6
- package/dist/marks/LineX.svelte.d.ts +6 -7
- package/dist/marks/LineY.svelte.d.ts +6 -7
- package/dist/marks/Link.svelte.d.ts +4 -5
- package/dist/marks/Rect.svelte.d.ts +4 -5
- package/dist/marks/RuleX.svelte.d.ts +4 -5
- package/dist/marks/RuleY.svelte.d.ts +4 -5
- package/dist/marks/Spike.svelte.d.ts +5 -6
- package/dist/marks/Text.svelte.d.ts +5 -6
- package/dist/marks/TickX.svelte.d.ts +4 -5
- package/dist/marks/TickY.svelte.d.ts +4 -5
- package/dist/marks/Vector.svelte.d.ts +4 -5
- package/dist/marks/WaffleX.svelte +115 -0
- package/dist/marks/WaffleX.svelte.d.ts +102 -0
- package/dist/marks/WaffleY.svelte +119 -0
- package/dist/marks/WaffleY.svelte.d.ts +100 -0
- package/dist/marks/helpers/Anchor.svelte.d.ts +5 -5
- package/dist/marks/helpers/BaseAxisX.svelte +31 -3
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +2 -0
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +164 -2
- package/dist/marks/helpers/RectPath.svelte.d.ts +65 -3
- package/dist/marks/helpers/waffle.d.ts +58 -0
- package/dist/marks/helpers/waffle.js +194 -0
- package/dist/marks/index.d.ts +3 -1
- package/dist/marks/index.js +3 -1
- package/dist/transforms/bollinger.d.ts +69 -1
- package/dist/transforms/centroid.d.ts +4 -1
- package/dist/transforms/group.d.ts +12 -4
- package/dist/transforms/group.js +11 -5
- package/dist/transforms/interval.d.ts +128 -2
- package/dist/transforms/recordize.d.ts +7 -4
- package/dist/transforms/select.d.ts +448 -7
- package/dist/transforms/sort.d.ts +253 -5
- package/dist/transforms/stack.d.ts +23 -3
- package/dist/transforms/window.d.ts +134 -2
- package/dist/types/data.d.ts +1 -0
- package/dist/types/mark.d.ts +1 -1
- package/dist/types/plot.d.ts +19 -5
- package/dist/types/scale.d.ts +8 -0
- package/package.json +128 -129
package/dist/Mark.svelte
CHANGED
|
@@ -152,6 +152,12 @@
|
|
|
152
152
|
if (options?.[channel] !== undefined && out[channel] === undefined) {
|
|
153
153
|
// resolve value
|
|
154
154
|
out[channel] = resolveChannel(channel, row, options);
|
|
155
|
+
if (options[channel] === INDEX) {
|
|
156
|
+
const scale = plot.scales[CHANNEL_SCALE[channel]];
|
|
157
|
+
if (scale.type === 'band' || scale.type === 'point') {
|
|
158
|
+
out[channel] = scale.domain[out[channel] % scale.domain.length];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
155
161
|
}
|
|
156
162
|
}
|
|
157
163
|
return [out];
|
|
@@ -212,6 +218,7 @@
|
|
|
212
218
|
resolvedData.flatMap((row) => {
|
|
213
219
|
const out: ScaledDataRecord<Datum> = {
|
|
214
220
|
datum: row.datum,
|
|
221
|
+
resolved: row,
|
|
215
222
|
index: row[INDEX],
|
|
216
223
|
valid: true
|
|
217
224
|
};
|
package/dist/Mark.svelte.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
|
-
import { CHANNEL_SCALE } from './constants.js';
|
|
3
2
|
import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
|
|
4
3
|
import { getUsedScales } from './helpers/scales.js';
|
|
5
4
|
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
@@ -10,14 +9,14 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
10
9
|
fy: ChannelAccessor<Datum>;
|
|
11
10
|
dx: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
12
11
|
dy: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
13
|
-
dodgeX:
|
|
14
|
-
dodgeY:
|
|
12
|
+
dodgeX: import("./transforms/dodge.js").DodgeXOptions;
|
|
13
|
+
dodgeY: import("./transforms/dodge.js").DodgeYOptions;
|
|
15
14
|
fill: ChannelAccessor<Datum>;
|
|
16
15
|
fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
17
|
-
sort: {
|
|
16
|
+
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
18
17
|
channel: string;
|
|
19
18
|
order?: "ascending" | "descending";
|
|
20
|
-
} |
|
|
19
|
+
} | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
|
|
21
20
|
stroke: ChannelAccessor<Datum>;
|
|
22
21
|
strokeWidth: import("./types/index.js").ConstantAccessor<number, Datum>;
|
|
23
22
|
strokeOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
|
package/dist/Plot.svelte
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<script lang="ts">
|
|
13
13
|
import Plot from './core/Plot.svelte';
|
|
14
14
|
|
|
15
|
-
import type { PlotOptions } from './types/index.js';
|
|
15
|
+
import type { PlotOptions, RawValue, ScaleOptions } from './types/index.js';
|
|
16
16
|
|
|
17
17
|
// implicit marks
|
|
18
18
|
import AxisX from './marks/AxisX.svelte';
|
|
@@ -62,12 +62,20 @@
|
|
|
62
62
|
const scales = $derived(
|
|
63
63
|
Object.fromEntries(
|
|
64
64
|
['x', 'y', 'r', 'color', 'opacity', 'symbol', 'length', 'fx', 'fy'].map((scale) => {
|
|
65
|
-
const scaleOpts = restOptions[scale]
|
|
65
|
+
const scaleOpts = maybeScaleOptions(restOptions[scale]);
|
|
66
66
|
const scaleFn = scaleOpts.scale || (scale === 'color' ? autoScaleColor : autoScale);
|
|
67
67
|
return [scale, { ...scaleOpts, scale: scaleFn }];
|
|
68
68
|
})
|
|
69
69
|
)
|
|
70
70
|
);
|
|
71
|
+
|
|
72
|
+
function maybeScaleOptions(
|
|
73
|
+
scaleOptions: undefined | false | RawValue[] | object
|
|
74
|
+
): Partial<ScaleOptions> | undefined {
|
|
75
|
+
if (scaleOptions === false) return { axis: false };
|
|
76
|
+
if (Array.isArray(scaleOptions)) return { domain: scaleOptions };
|
|
77
|
+
return scaleOptions || {};
|
|
78
|
+
}
|
|
71
79
|
</script>
|
|
72
80
|
|
|
73
81
|
{#snippet header()}
|
package/dist/constants.d.ts
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
scaleFn={facetXScale}
|
|
36
36
|
scaleType="band"
|
|
37
37
|
ticks={fxValues}
|
|
38
|
-
tickFormat={(d) => d}
|
|
38
|
+
tickFormat={plot.options.fx.tickFormat || ((d) => d)}
|
|
39
39
|
tickFontSize={11}
|
|
40
40
|
tickSize={0}
|
|
41
41
|
tickPadding={5}
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
scaleFn={facetYScale}
|
|
54
54
|
scaleType="band"
|
|
55
55
|
ticks={fyValues}
|
|
56
|
-
tickFormat={(d) => d}
|
|
56
|
+
tickFormat={plot.options.fy.tickFormat || ((d) => d)}
|
|
57
57
|
tickFontSize={11}
|
|
58
58
|
tickSize={0}
|
|
59
59
|
tickPadding={5}
|
package/dist/core/Plot.svelte
CHANGED
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
class: className = '',
|
|
115
115
|
css = DEFAULTS.css,
|
|
116
116
|
width: fixedWidth,
|
|
117
|
-
...
|
|
117
|
+
...initialOptions
|
|
118
118
|
}: Partial<PlotOptions> = $props();
|
|
119
119
|
|
|
120
120
|
let width = $state(DEFAULTS.initialWidth);
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
);
|
|
165
165
|
|
|
166
166
|
const explicitDomains = $derived(
|
|
167
|
-
new Set(SCALES.filter((scale) => !!
|
|
167
|
+
new Set(SCALES.filter((scale) => !!initialOptions[scale]?.domain))
|
|
168
168
|
);
|
|
169
169
|
|
|
170
170
|
// one-dimensional plots have different automatic margins and heights
|
|
@@ -173,12 +173,12 @@
|
|
|
173
173
|
// construct the plot options from the user-defined options (top-level props) as well
|
|
174
174
|
// as extending them from smart context-aware defaults
|
|
175
175
|
const plotOptions = $derived(
|
|
176
|
-
extendPlotOptions(
|
|
176
|
+
extendPlotOptions(initialOptions, {
|
|
177
177
|
explicitScales,
|
|
178
178
|
explicitDomains,
|
|
179
|
-
hasProjection: !!
|
|
180
|
-
margin:
|
|
181
|
-
inset:
|
|
179
|
+
hasProjection: !!initialOptions.projection,
|
|
180
|
+
margin: initialOptions.margin,
|
|
181
|
+
inset: initialOptions.inset
|
|
182
182
|
})
|
|
183
183
|
);
|
|
184
184
|
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
{},
|
|
370
370
|
{ sortOrdinalDomains: DEFAULTS.sortOrdinalDomains },
|
|
371
371
|
smartDefaultPlotOptions(opts),
|
|
372
|
-
|
|
372
|
+
initialOptions
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
375
|
|
|
@@ -614,10 +614,6 @@
|
|
|
614
614
|
border: 0 !important;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
.plot-header :global(h3) {
|
|
618
|
-
font-weight: 500;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
617
|
.plot-footer {
|
|
622
618
|
margin-bottom: 2rem;
|
|
623
619
|
}
|
package/dist/helpers/colors.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { interpolateBrBG } from 'd3-scale-chromatic';
|
|
1
2
|
import type { ColorScheme } from '../types/index.js';
|
|
2
|
-
export declare const categoricalSchemes:
|
|
3
|
-
export declare function isCategoricalScheme(scheme: string):
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
3
|
+
export declare const categoricalSchemes: Map<string, readonly string[]>;
|
|
4
|
+
export declare function isCategoricalScheme(scheme: string): boolean;
|
|
5
|
+
type SchemeGetter = (n: number) => readonly string[];
|
|
6
|
+
export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
|
|
7
|
+
export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
|
|
8
|
+
export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
|
|
9
|
+
export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
|
|
10
|
+
export declare function isQuantitativeScheme(scheme: string): boolean;
|
|
11
|
+
export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
|
|
12
|
+
export declare function isDivergingScheme(scheme: string): boolean;
|
|
13
|
+
export {};
|
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[]): Map<RawValue, Map<RawValue, boolean>>;
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
-
|
|
3
|
+
export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): {
|
|
4
|
+
[k: string]: string | number;
|
|
5
|
+
};
|
|
6
|
+
export default function (datum: DataRow, props: Partial<Channels>): string;
|
|
5
7
|
export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
|
|
6
8
|
export declare function maybeFromPixel(value: string | number): string | number;
|
|
7
9
|
export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
|
|
10
|
+
export declare function getClipId(): string;
|
|
11
|
+
export declare function getPatternId(): string;
|
|
@@ -54,3 +54,11 @@ export function maybeFromRem(value, rootFontSize = 16) {
|
|
|
54
54
|
? +value.slice(0, -3) * rootFontSize
|
|
55
55
|
: value;
|
|
56
56
|
}
|
|
57
|
+
let nextClipId = 0;
|
|
58
|
+
let nextPatternId = 0;
|
|
59
|
+
export function getClipId() {
|
|
60
|
+
return `svp-clip-${++nextClipId}`;
|
|
61
|
+
}
|
|
62
|
+
export function getPatternId() {
|
|
63
|
+
return `svp-pattern-${++nextPatternId}`;
|
|
64
|
+
}
|
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)[]): string | number | boolean | symbol | object | null;
|
|
7
|
+
export declare function testFilter<T>(datum: T, options: Channels<T>): true | T | null;
|
|
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: Set<string>;
|
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: Record<ReducerName, ReducerFunc>;
|
|
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 {};
|
|
@@ -12,10 +12,11 @@ export default function removeIdenticalLines(input) {
|
|
|
12
12
|
text: []
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
const maxLines = Math.max(...input.map((t) => t.text.length));
|
|
16
|
+
for (let l = 0; l < maxLines; l++) {
|
|
16
17
|
const isIdentical = input.length > 1 && input.every((tick) => input[0].text[l] === tick.text[l]);
|
|
17
18
|
for (let c = 0; c < input.length; c++) {
|
|
18
|
-
if (!isIdentical && input[c].text[l])
|
|
19
|
+
if (!isIdentical && input[c].text[l] != null)
|
|
19
20
|
uniqueTicks[c].text.push(input[c].text[l]);
|
|
20
21
|
}
|
|
21
22
|
}
|
package/dist/helpers/scales.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, UsedScales } from '../types/index.js';
|
|
1
|
+
import type { ChannelAccessor, GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, ScaledChannelName, 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: any
|
|
11
|
+
skip: Map<any, 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: RawValue[] | [undefined, undefined];
|
|
19
19
|
range: any;
|
|
20
20
|
fn: any;
|
|
21
|
-
skip:
|
|
21
|
+
skip: Map<ScaledChannelName, Set<symbol>>;
|
|
22
22
|
manualActiveMarks: number;
|
|
23
|
-
uniqueScaleProps:
|
|
23
|
+
uniqueScaleProps: Set<ChannelAccessor>;
|
|
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): boolean;
|
|
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 "ordinal" | "point" | "band" | "categorical" | "threshold";
|
package/dist/helpers/scales.js
CHANGED
|
@@ -218,8 +218,8 @@ function domainFromInterval(domain, interval, name) {
|
|
|
218
218
|
return name === 'y' ? out.toReversed() : out;
|
|
219
219
|
}
|
|
220
220
|
const markTypesWithBandDefault = {
|
|
221
|
-
x: new Set(['barY', 'cell', 'tickY']),
|
|
222
|
-
y: new Set(['barX', 'cell', 'tickX'])
|
|
221
|
+
x: new Set(['barY', 'cell', 'tickY', 'waffleY']),
|
|
222
|
+
y: new Set(['barX', 'cell', 'tickX', 'waffleX'])
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
225
225
|
* Infer a scale type based on the scale name, the data values mapped to it and
|
|
@@ -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): boolean;
|
|
5
|
+
export declare function maybeSymbol(symbol: SymbolType | string): SymbolType;
|
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: Map<string, number>;
|
|
2
|
+
export declare const intervalDuration: unique symbol;
|
|
3
|
+
export declare const intervalType: unique symbol;
|
|
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): boolean;
|
|
2
|
+
export declare function isBooleanOrNull(v: RawValue): v is 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): v is Date | null | undefined;
|
|
5
|
+
export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
|
|
6
|
+
export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
|
|
7
|
+
export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
|
|
8
|
+
export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
|
|
9
|
+
export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
|
|
10
|
+
export declare function isOpacityOrNull(v: RawValue): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Greedy word-wrapping that approximates visual width by character widths.
|
|
3
|
+
*
|
|
4
|
+
* - Splits input into words, additionally breaking on `-` to avoid very long segments.
|
|
5
|
+
* - Uses a rough character width table to approximate line widths.
|
|
6
|
+
* - Wraps once the maximum visual width is exceeded, but only after a minimum.
|
|
7
|
+
*/
|
|
8
|
+
export default function wordwrap(line: string, { maxCharactersPerLine, maxLineWidth }: {
|
|
9
|
+
maxCharactersPerLine?: number;
|
|
10
|
+
maxLineWidth?: number;
|
|
11
|
+
}, { minCharactersPerLine, minLineWidth }: {
|
|
12
|
+
minCharactersPerLine?: number;
|
|
13
|
+
minLineWidth?: number;
|
|
14
|
+
}, fontSize?: number, monospace?: boolean): string[];
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { sum } from 'd3-array';
|
|
2
|
+
// Per-character width table for a typical proportional font.
|
|
3
|
+
// This is not perfect for all fonts, but is better than treating
|
|
4
|
+
// all characters as equal width. Set `monospace = true` to bypass.
|
|
5
|
+
const CHAR_W = {
|
|
6
|
+
A: 7,
|
|
7
|
+
a: 7,
|
|
8
|
+
B: 8,
|
|
9
|
+
b: 7,
|
|
10
|
+
C: 8,
|
|
11
|
+
c: 6,
|
|
12
|
+
D: 9,
|
|
13
|
+
d: 7,
|
|
14
|
+
E: 7,
|
|
15
|
+
e: 7,
|
|
16
|
+
F: 7,
|
|
17
|
+
f: 4,
|
|
18
|
+
G: 9,
|
|
19
|
+
g: 7,
|
|
20
|
+
H: 9,
|
|
21
|
+
h: 7,
|
|
22
|
+
I: 3,
|
|
23
|
+
i: 3,
|
|
24
|
+
J: 5,
|
|
25
|
+
j: 3,
|
|
26
|
+
K: 8,
|
|
27
|
+
k: 6,
|
|
28
|
+
L: 7,
|
|
29
|
+
l: 3,
|
|
30
|
+
M: 11,
|
|
31
|
+
m: 11,
|
|
32
|
+
N: 9,
|
|
33
|
+
n: 7,
|
|
34
|
+
O: 9,
|
|
35
|
+
o: 7,
|
|
36
|
+
P: 8,
|
|
37
|
+
p: 7,
|
|
38
|
+
Q: 9,
|
|
39
|
+
q: 7,
|
|
40
|
+
R: 8,
|
|
41
|
+
r: 4,
|
|
42
|
+
S: 8,
|
|
43
|
+
s: 6,
|
|
44
|
+
T: 7,
|
|
45
|
+
t: 4,
|
|
46
|
+
U: 9,
|
|
47
|
+
u: 7,
|
|
48
|
+
V: 7,
|
|
49
|
+
v: 6,
|
|
50
|
+
W: 11,
|
|
51
|
+
w: 9,
|
|
52
|
+
X: 7,
|
|
53
|
+
x: 6,
|
|
54
|
+
Y: 7,
|
|
55
|
+
y: 6,
|
|
56
|
+
Z: 7,
|
|
57
|
+
z: 5,
|
|
58
|
+
'.': 2,
|
|
59
|
+
',': 2,
|
|
60
|
+
':': 2,
|
|
61
|
+
';': 2
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Greedy word-wrapping that approximates visual width by character widths.
|
|
65
|
+
*
|
|
66
|
+
* - Splits input into words, additionally breaking on `-` to avoid very long segments.
|
|
67
|
+
* - Uses a rough character width table to approximate line widths.
|
|
68
|
+
* - Wraps once the maximum visual width is exceeded, but only after a minimum.
|
|
69
|
+
*/
|
|
70
|
+
export default function wordwrap(line, { maxCharactersPerLine, maxLineWidth }, { minCharactersPerLine, minLineWidth }, fontSize = 12, monospace = false) {
|
|
71
|
+
// Tokenized words (with hyphen-splitting applied) including trailing spaces/hyphens.
|
|
72
|
+
const tokens = [];
|
|
73
|
+
// First split by spaces, then further split by hyphens so we can
|
|
74
|
+
// wrap inside hyphenated words if necessary.
|
|
75
|
+
const spaceSeparated = line.split(' ');
|
|
76
|
+
spaceSeparated.forEach((word, wordIndex) => {
|
|
77
|
+
const hyphenParts = word.split('-');
|
|
78
|
+
const trailingWhitespace = wordIndex < spaceSeparated.length - 1 ? ' ' : '';
|
|
79
|
+
if (hyphenParts.length > 1) {
|
|
80
|
+
hyphenParts.forEach((part, partIndex) => {
|
|
81
|
+
const suffix = partIndex < hyphenParts.length - 1 ? '-' : trailingWhitespace;
|
|
82
|
+
tokens.push(part + suffix);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
tokens.push(word + trailingWhitespace);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const maxChars = maxCharactersPerLine || 40;
|
|
90
|
+
if (!maxLineWidth) {
|
|
91
|
+
// Fallback for max characters per line if not provided / falsy.
|
|
92
|
+
// Convert character counts into approximate visual widths.
|
|
93
|
+
maxLineWidth = maxChars * CHAR_W.a;
|
|
94
|
+
}
|
|
95
|
+
if (!minLineWidth) {
|
|
96
|
+
// Estimate a good minimum line length:
|
|
97
|
+
// - start from either a provided value or
|
|
98
|
+
// - clamp a scaled median word length between 3 and half of maxChars.
|
|
99
|
+
const sortedWordLengths = tokens.map((t) => t.length).sort((a, b) => a - b);
|
|
100
|
+
const medianIndex = Math.round(tokens.length / 2);
|
|
101
|
+
const medianWordLength = sortedWordLengths[medianIndex] ?? maxChars;
|
|
102
|
+
const minChars = minCharactersPerLine || Math.max(3, Math.min(maxChars * 0.5, 0.75 * medianWordLength));
|
|
103
|
+
minLineWidth = minChars * CHAR_W.a;
|
|
104
|
+
}
|
|
105
|
+
const lines = [];
|
|
106
|
+
const currentWords = [];
|
|
107
|
+
let currentWidth = 0;
|
|
108
|
+
// Helper to look up a character width, falling back to "a" if unknown
|
|
109
|
+
// or when monospace mode is enabled.
|
|
110
|
+
const charWidth = (char) => (fontSize / 12) * (!monospace ? CHAR_W[char] : CHAR_W.a);
|
|
111
|
+
// Greedy line construction: append tokens until the next one would exceed
|
|
112
|
+
// max visual width, but only break if the line has passed the minimum width.
|
|
113
|
+
tokens.forEach((token) => {
|
|
114
|
+
const tokenWidth = sum(token.split('').map(charWidth));
|
|
115
|
+
if (currentWidth + tokenWidth > maxLineWidth && currentWidth > minLineWidth) {
|
|
116
|
+
lines.push(currentWords.join(''));
|
|
117
|
+
currentWords.length = 0;
|
|
118
|
+
currentWidth = 0;
|
|
119
|
+
}
|
|
120
|
+
currentWidth += tokenWidth;
|
|
121
|
+
currentWords.push(token);
|
|
122
|
+
});
|
|
123
|
+
// Flush trailing tokens into the last line.
|
|
124
|
+
if (currentWords.length > 0) {
|
|
125
|
+
lines.push(currentWords.join(''));
|
|
126
|
+
}
|
|
127
|
+
// Filter out any empty lines that may have been created.
|
|
128
|
+
return lines.filter((d) => d !== '');
|
|
129
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type CurveFactory } from 'd3-shape';
|
|
2
|
-
import callWithProps from '../helpers/callWithProps.js';
|
|
3
2
|
import type { CurveName, DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps, RawValue } from '../types/index.js';
|
|
4
3
|
import type { StackOptions } from '../transforms/stack.js';
|
|
5
4
|
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
@@ -10,14 +9,14 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
10
9
|
fy: ChannelAccessor<Datum>;
|
|
11
10
|
dx: ConstantAccessor<number, Datum>;
|
|
12
11
|
dy: ConstantAccessor<number, Datum>;
|
|
13
|
-
dodgeX:
|
|
14
|
-
dodgeY:
|
|
12
|
+
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
13
|
+
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
15
14
|
fill: ChannelAccessor<Datum>;
|
|
16
15
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
17
|
-
sort: {
|
|
16
|
+
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
18
17
|
channel: string;
|
|
19
18
|
order?: "ascending" | "descending";
|
|
20
|
-
} |
|
|
19
|
+
} | ConstantAccessor<RawValue, Datum>;
|
|
21
20
|
stroke: ChannelAccessor<Datum>;
|
|
22
21
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
23
22
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { renameChannels } from '../transforms/rename.js';
|
|
2
1
|
import type { ChannelAccessor, DataRow } from '../types/index.js';
|
|
3
2
|
declare class __sveltets_Render<Datum extends DataRow> {
|
|
4
3
|
props(): Omit<Partial<{
|
|
@@ -8,14 +7,14 @@ declare class __sveltets_Render<Datum extends DataRow> {
|
|
|
8
7
|
fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
9
8
|
dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
10
9
|
dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
11
|
-
dodgeX:
|
|
12
|
-
dodgeY:
|
|
10
|
+
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
11
|
+
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
13
12
|
fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
14
13
|
fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
15
|
-
sort: {
|
|
14
|
+
sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
|
|
16
15
|
channel: string;
|
|
17
16
|
order?: "ascending" | "descending";
|
|
18
|
-
} |
|
|
17
|
+
} | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
|
|
19
18
|
stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
|
|
20
19
|
strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
21
20
|
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
|
|
@@ -75,7 +74,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
|
|
|
75
74
|
sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
|
|
76
75
|
channel: "stroke" | "fill";
|
|
77
76
|
};
|
|
78
|
-
stack?: Partial<
|
|
77
|
+
stack?: Partial<import("../transforms/stack.js").StackOptions>;
|
|
79
78
|
canvas?: boolean;
|
|
80
79
|
areaClass?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
|
|
81
80
|
}, "y1" | "y2"> & {
|
|
@@ -1,6 +1,5 @@
|
|
|
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';
|
|
4
3
|
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
5
4
|
props(): Omit<Partial<{
|
|
6
5
|
filter: ConstantAccessor<boolean, Datum>;
|
|
@@ -9,14 +8,14 @@ declare class __sveltets_Render<Datum extends DataRecord> {
|
|
|
9
8
|
fy: ChannelAccessor<Datum>;
|
|
10
9
|
dx: ConstantAccessor<number, Datum>;
|
|
11
10
|
dy: ConstantAccessor<number, Datum>;
|
|
12
|
-
dodgeX:
|
|
13
|
-
dodgeY:
|
|
11
|
+
dodgeX: import("../transforms/dodge.js").DodgeXOptions;
|
|
12
|
+
dodgeY: import("../transforms/dodge.js").DodgeYOptions;
|
|
14
13
|
fill: ChannelAccessor<Datum>;
|
|
15
14
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
16
|
-
sort: {
|
|
15
|
+
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
17
16
|
channel: string;
|
|
18
17
|
order?: "ascending" | "descending";
|
|
19
|
-
} |
|
|
18
|
+
} | ConstantAccessor<RawValue, Datum>;
|
|
20
19
|
stroke: ChannelAccessor<Datum>;
|
|
21
20
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
22
21
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
package/dist/marks/AxisX.svelte
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
tickSpacing?: number;
|
|
52
52
|
/** text anchor for axis labels */
|
|
53
53
|
textAnchor?: ConstantAccessor<CSS.Property.TextAnchor | 'auto', Datum>;
|
|
54
|
+
removeDuplicateTicks: boolean;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
let markProps: AxisXMarkProps = $props();
|
|
@@ -223,7 +224,7 @@
|
|
|
223
224
|
{anchor}
|
|
224
225
|
{className}
|
|
225
226
|
{labelAnchor}
|
|
226
|
-
{options}
|
|
227
|
+
options={{ ...options, ...plot.options.x }}
|
|
227
228
|
{plot}
|
|
228
229
|
{text}
|
|
229
230
|
{tickClass}
|