svelteplot 0.2.7 → 0.2.8-pr-68.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/Plot.svelte CHANGED
@@ -91,89 +91,101 @@
91
91
  <!-- There's a bug triggering RangeError: Maximum call stack size exceeded
92
92
  when using SveltePlot in ssr, so for now, we're disabling it -->
93
93
 
94
- <Plot
95
- {overlay}
96
- {underlay}
97
- {...restOptions}
98
- header={userHeader ||
99
- restOptions.title ||
100
- restOptions.subtitle ||
101
- restOptions.color?.legend ||
102
- restOptions.symbol?.legend
103
- ? header
104
- : null}
105
- footer={userFooter || restOptions?.caption ? footer : null}
106
- projection={projectionOpts}
107
- implicitScales
108
- {...scales}>
109
- {#snippet children({
110
- hasProjection,
111
- hasExplicitAxisX,
112
- hasExplicitAxisY,
113
- hasExplicitGridX,
114
- hasExplicitGridY,
115
- options,
116
- scales,
117
- ...restProps
118
- })}
119
- <svelte:boundary onerror={(err) => console.warn(err)}>
120
- <!-- implicit axes -->
121
- {#if !hasProjection && !hasExplicitAxisX}
122
- {#if options.axes && (options.x.axis === 'top' || options.x.axis === 'both')}
123
- <AxisX anchor="top" automatic />
94
+ <svelte:boundary>
95
+ <Plot
96
+ {overlay}
97
+ {underlay}
98
+ {...restOptions}
99
+ header={userHeader ||
100
+ restOptions.title ||
101
+ restOptions.subtitle ||
102
+ restOptions.color?.legend ||
103
+ restOptions.symbol?.legend
104
+ ? header
105
+ : null}
106
+ footer={userFooter || restOptions?.caption ? footer : null}
107
+ projection={projectionOpts}
108
+ implicitScales
109
+ {...scales}>
110
+ {#snippet children({
111
+ hasProjection,
112
+ hasExplicitAxisX,
113
+ hasExplicitAxisY,
114
+ hasExplicitGridX,
115
+ hasExplicitGridY,
116
+ options,
117
+ scales,
118
+ ...restProps
119
+ })}
120
+ <svelte:boundary onerror={(err) => console.warn(err)}>
121
+ <!-- implicit axes -->
122
+ {#if !hasProjection && !hasExplicitAxisX}
123
+ {#if options.axes && (options.x.axis === 'top' || options.x.axis === 'both')}
124
+ <AxisX anchor="top" automatic />
125
+ {/if}
126
+ {#if options.axes && (options.x.axis === 'bottom' || options.x.axis === 'both')}
127
+ <AxisX anchor="bottom" automatic />
128
+ {/if}
124
129
  {/if}
125
- {#if options.axes && (options.x.axis === 'bottom' || options.x.axis === 'both')}
126
- <AxisX anchor="bottom" automatic />
130
+ {#if !hasProjection && !hasExplicitAxisY}
131
+ {#if options.axes && (options.y.axis === 'left' || options.y.axis === 'both')}
132
+ <AxisY anchor="left" automatic />
133
+ {/if}
134
+ {#if options.axes && (options.y.axis === 'right' || options.y.axis === 'both')}
135
+ <AxisY anchor="right" automatic />
136
+ {/if}
127
137
  {/if}
128
- {/if}
129
- {#if !hasProjection && !hasExplicitAxisY}
130
- {#if options.axes && (options.y.axis === 'left' || options.y.axis === 'both')}
131
- <AxisY anchor="left" automatic />
138
+ <!-- implicit grids -->
139
+ {#if !hasExplicitGridX && (options.grid || options.x.grid)}
140
+ <GridX automatic />
132
141
  {/if}
133
- {#if options.axes && (options.y.axis === 'right' || options.y.axis === 'both')}
134
- <AxisY anchor="right" automatic />
142
+ {#if !hasExplicitGridY && (options.grid || options.y.grid)}
143
+ <GridY automatic />
135
144
  {/if}
136
- {/if}
137
- <!-- implicit grids -->
138
- {#if !hasExplicitGridX && (options.grid || options.x.grid)}
139
- <GridX automatic />
140
- {/if}
141
- {#if !hasExplicitGridY && (options.grid || options.y.grid)}
142
- <GridY automatic />
143
- {/if}
144
- <!-- implicit frame -->
145
- {#if options.frame}
146
- <Frame automatic />
147
- {/if}
148
- {@render parentChildren?.({
149
- options,
150
- scales,
151
- ...restProps
152
- })}
153
- {#snippet failed(error, reset)}
154
- <text class="error" transform="translate(10,10)">
155
- {#each error.message.split('\n') as line, i (i)}
156
- <tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
157
- {/each}
158
- </text>{/snippet}
159
- </svelte:boundary>
160
- {/snippet}
161
- {#snippet facetAxes()}
162
- <FacetAxes />
145
+ <!-- implicit frame -->
146
+ {#if options.frame}
147
+ <Frame automatic />
148
+ {/if}
149
+ {@render parentChildren?.({
150
+ options,
151
+ scales,
152
+ ...restProps
153
+ })}
154
+ {#snippet failed(error, reset)}
155
+ <text class="error" transform="translate(10,10)">
156
+ {#each error.message.split('\n') as line, i (i)}
157
+ <tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
158
+ {/each}
159
+ </text>{/snippet}
160
+ </svelte:boundary>
161
+ {/snippet}
162
+ {#snippet facetAxes()}
163
+ <FacetAxes />
164
+ {/snippet}
165
+ </Plot>
166
+ {#snippet failed(error)}
167
+ <div class="error">Error: {error.message}</div>
163
168
  {/snippet}
164
- </Plot>
169
+ </svelte:boundary>
165
170
 
166
171
  <style>
167
172
  :root {
168
173
  --plot-bg: white;
169
174
  --plot-fg: currentColor;
170
175
  }
171
- text.error {
172
- stroke: var(--plot-bg);
173
- fill: crimson;
176
+ .error {
174
177
  font-size: 11px;
175
178
  stroke-width: 3px;
176
179
  font-weight: bold;
180
+ }
181
+ text.error {
182
+ stroke: var(--plot-bg);
183
+ fill: crimson;
177
184
  paint-order: stroke fill;
178
185
  }
186
+ div.error {
187
+ color: crimson;
188
+ white-space: pre-wrap;
189
+ line-height: 1.1;
190
+ }
179
191
  </style>
@@ -1,5 +1,5 @@
1
1
  import { maybeTimeInterval } from './time.js';
2
- import { range as rangei } from 'd3-array';
2
+ import { extent, range as rangei } from 'd3-array';
3
3
  export function maybeInterval(interval) {
4
4
  if (interval == null)
5
5
  return;
@@ -30,11 +30,12 @@ export function maybeInterval(interval) {
30
30
  return interval;
31
31
  }
32
32
  export function autoTicks(type, ticks, interval, domain, scaleFn, count) {
33
- return ticks
34
- ? ticks
35
- : interval
36
- ? maybeInterval(interval, type).range(domain[0], domain[1])
37
- : typeof scaleFn.ticks === 'function'
38
- ? scaleFn.ticks(count)
39
- : [];
33
+ if (ticks)
34
+ return ticks;
35
+ if (interval) {
36
+ const [lo, hi] = extent(domain);
37
+ const I = maybeInterval(interval, type);
38
+ return I.range(lo, I.offset(hi));
39
+ }
40
+ return typeof scaleFn.ticks === 'function' ? scaleFn.ticks(count) : [];
40
41
  }
@@ -6,7 +6,7 @@ type SchemeGetter = (n: number) => readonly string[];
6
6
  export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
7
7
  export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
8
8
  export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
9
- export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
9
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
10
10
  export declare function isQuantitativeScheme(scheme: string): boolean;
11
11
  export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
12
12
  export declare function isDivergingScheme(scheme: string): boolean;
@@ -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)[]): RawValue | null;
7
- export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): string | number | boolean | symbol | Date | null;
6
+ export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
7
+ export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): any;
8
8
  export declare function randomId(): string;
9
9
  export declare function isSnippet(value: unknown): value is Snippet;
10
10
  export declare function isValid(value: RawValue | undefined): value is number | Date | string;
@@ -15,7 +15,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
15
15
  autoTitle?: undefined;
16
16
  } | {
17
17
  type: ScaleType;
18
- domain: RawValue[] | [undefined, undefined];
18
+ domain: any;
19
19
  range: any;
20
20
  fn: any;
21
21
  skip: Map<ScaledChannelName, Set<symbol>>;
@@ -5,6 +5,7 @@ import { isSymbolOrNull } from './typeChecks.js';
5
5
  import { resolveProp, toChannelOption } from './resolve.js';
6
6
  import isDataRecord from './isDataRecord.js';
7
7
  import { createProjection } from './projection.js';
8
+ import { maybeInterval } from './autoTicks.js';
8
9
  /**
9
10
  * compute the plot scales
10
11
  */
@@ -148,7 +149,7 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
148
149
  valueArr.sort(ascending);
149
150
  }
150
151
  const valueArray = type === 'quantile' || type === 'quantile-cont' ? allDataValues.toSorted() : valueArr;
151
- const domain = scaleOptions.domain
152
+ let domain = scaleOptions.domain
152
153
  ? isOrdinal
153
154
  ? scaleOptions.domain
154
155
  : extent(scaleOptions.zero ? [0, ...scaleOptions.domain] : scaleOptions.domain)
@@ -162,6 +163,14 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
162
163
  ? valueArray.toReversed()
163
164
  : valueArray
164
165
  : extent(scaleOptions.zero ? [0, ...valueArray] : valueArray);
166
+ if (scaleOptions.interval) {
167
+ if (isOrdinal) {
168
+ domain = domainFromInterval(domain, scaleOptions.interval);
169
+ }
170
+ else {
171
+ throw new Error('Setting interval via axis options is only supported for ordinal scales');
172
+ }
173
+ }
165
174
  if (!scaleOptions.scale) {
166
175
  throw new Error(`No scale function defined for ${name}`);
167
176
  }
@@ -192,6 +201,11 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
192
201
  : null
193
202
  };
194
203
  }
204
+ function domainFromInterval(domain, interval) {
205
+ const interval_ = maybeInterval(interval);
206
+ const [lo, hi] = extent(domain);
207
+ return interval_.range(lo, interval_.offset(hi));
208
+ }
195
209
  /**
196
210
  * Infer a scale type based on the scale name, the data values mapped to it and
197
211
  * the mark types that are bound to the scale
@@ -1,10 +1,10 @@
1
1
  import type { RawValue } from '../types.js';
2
- export declare function isBooleanOrNull(v: RawValue): v is boolean;
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): v is Date | null | undefined;
4
+ export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
5
5
  export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
6
6
  export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
7
- export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
7
+ export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
8
8
  export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
9
- export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): any;
10
10
  export declare function isOpacityOrNull(v: RawValue): boolean;
@@ -13,6 +13,6 @@ export type BollingerXMarkProps = BaseMarkProps & {
13
13
  };
14
14
  import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
15
15
  /** line representing a moving average and an area representing volatility as a band */
16
- declare const BollingerX: import("svelte").Component<BollingerXMarkProps, {}, "">;
16
+ declare const BollingerX: import("svelte").Component<any, {}, "">;
17
17
  type BollingerX = ReturnType<typeof BollingerX>;
18
18
  export default BollingerX;
@@ -13,6 +13,6 @@ export type BollingerYMarkProps = BaseMarkProps & {
13
13
  };
14
14
  import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
15
15
  /** line representing a moving average and an area representing volatility as a band */
16
- declare const BollingerY: import("svelte").Component<BollingerYMarkProps, {}, "">;
16
+ declare const BollingerY: import("svelte").Component<any, {}, "">;
17
17
  type BollingerY = ReturnType<typeof BollingerY>;
18
18
  export default BollingerY;
@@ -129,7 +129,7 @@
129
129
  marginBottom={20}
130
130
  height={38}
131
131
  inset={0}
132
- x={{ domain, tickSpacing, tickFormat }}>
132
+ x={{ domain, tickSpacing: 30, tickFormat }}>
133
133
  <defs>
134
134
  <linearGradient id="gradient-{randId}" x2="1">
135
135
  {#each ticks as t (t)}
@@ -1,61 +1,6 @@
1
1
  import { type BaseMarkProps } from '../types.js';
2
2
  export type SphereMarkProps = BaseMarkProps;
3
3
  /** Geo mark with Sphere geometry object */
4
- declare const Sphere: import("svelte").Component<Partial<{
5
- filter?: import("../types.js").ConstantAccessor<boolean>;
6
- facet?: "auto" | "include" | "exclude";
7
- fx: import("../types.js").ChannelAccessor;
8
- fy: import("../types.js").ChannelAccessor;
9
- dx: import("../types.js").ConstantAccessor<number>;
10
- dy: import("../types.js").ConstantAccessor<number>;
11
- fill: import("../types.js").ConstantAccessor<string>;
12
- fillOpacity: import("../types.js").ConstantAccessor<number>;
13
- stroke: import("../types.js").ConstantAccessor<string>;
14
- strokeWidth: import("../types.js").ConstantAccessor<number>;
15
- strokeOpacity: import("../types.js").ConstantAccessor<number>;
16
- strokeLinejoin: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin>;
17
- strokeLinecap: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinecap>;
18
- strokeMiterlimit: import("../types.js").ConstantAccessor<number>;
19
- opacity: import("../types.js").ConstantAccessor<number>;
20
- strokeDasharray: import("../types.js").ConstantAccessor<string>;
21
- strokeDashoffset: import("../types.js").ConstantAccessor<number>;
22
- mixBlendMode: import("../types.js").ConstantAccessor<import("csstype").Property.MixBlendMode>;
23
- clipPath: string;
24
- imageFilter: import("../types.js").ConstantAccessor<string>;
25
- shapeRendering: import("../types.js").ConstantAccessor<import("csstype").Property.ShapeRendering>;
26
- paintOrder: import("../types.js").ConstantAccessor<string>;
27
- onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
28
- ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
29
- onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
30
- onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
31
- onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
32
- onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
- onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- class: string | null;
58
- cursor: import("../types.js").ConstantAccessor<import("csstype").Property.Cursor>;
59
- }>, {}, "">;
4
+ declare const Sphere: import("svelte").Component<BaseMarkProps, {}, "">;
60
5
  type Sphere = ReturnType<typeof Sphere>;
61
6
  export default Sphere;
@@ -2,6 +2,27 @@
2
2
  import { getContext } from 'svelte';
3
3
  import type { PlotContext } from '../../types';
4
4
  import { devicePixelRatio } from 'svelte/reactivity/window';
5
+ import { MediaQuery } from 'svelte/reactivity';
6
+ import type { Attachment } from 'svelte/attachments';
7
+
8
+ const darkMode = new MediaQuery('prefers-color-scheme: dark');
9
+ let colorScheme = $state();
10
+
11
+ /**
12
+ * we need to repaint on dark mode changes in case the user
13
+ * is using any css variables or currentColor that changes
14
+ * with the color scheme
15
+ */
16
+ const watchColorScheme: Attachment = (element: Element) => {
17
+ const htmlElement = element.ownerDocument.documentElement;
18
+ const observer = new MutationObserver(() => {
19
+ colorScheme = getComputedStyle(htmlElement).colorScheme;
20
+ });
21
+ observer.observe(htmlElement, { attributes: true });
22
+ return () => {
23
+ observer.disconnect();
24
+ };
25
+ };
5
26
 
6
27
  let restProps: {} = $props();
7
28
 
@@ -14,14 +35,15 @@
14
35
  canvas element inside a foreignObject for use in a plot and takes care of
15
36
  scaling it to the device pixel ratio.
16
37
  -->
17
-
18
- <foreignObject x="0" y="0" width={plot.width} height={plot.height}>
19
- <canvas
20
- xmlns="http://www.w3.org/1999/xhtml"
21
- {...restProps}
22
- width={plot.width * (devicePixelRatio.current ?? 1)}
23
- height={plot.height * (devicePixelRatio.current ?? 1)}
24
- style="width: {plot.width}px; height: {plot.height}px;"></canvas>
38
+ <foreignObject x="0" y="0" {@attach watchColorScheme} width={plot.width} height={plot.height}>
39
+ {#key [colorScheme, darkMode.current]}
40
+ <canvas
41
+ xmlns="http://www.w3.org/1999/xhtml"
42
+ {...restProps}
43
+ width={plot.width * (devicePixelRatio.current ?? 1)}
44
+ height={plot.height * (devicePixelRatio.current ?? 1)}
45
+ style="width: {plot.width}px; height: {plot.height}px;"></canvas>
46
+ {/key}
25
47
  </foreignObject>
26
48
 
27
49
  <style>
@@ -1,44 +1,4 @@
1
- import { type MarkerShape } from './Marker.svelte';
2
- import type { BaseMarkProps, ConstantAccessor, DataRecord, Mark, PlotScales } from '../../types.js';
3
- type MarkerPathProps = BaseMarkProps & {
4
- /**
5
- * the datum associated with this path, usually the first
6
- * element of the data array group
7
- */
8
- datum: DataRecord;
9
- /**
10
- * the marker shape to use at the start of the path, defaults to
11
- * circle
12
- */
13
- markerStart?: boolean | MarkerShape;
14
- /**
15
- * the marker shape to use at the middle of the path, defaults to circle
16
- */
17
- markerMid?: boolean | MarkerShape;
18
- /**
19
- * the marker shape to use at the end of the path, defaults to circle
20
- */
21
- markerEnd?: boolean | MarkerShape;
22
- /**
23
- * shorthand for setting all markers
24
- */
25
- marker?: boolean | MarkerShape;
26
- /**
27
- * path string
28
- */
29
- d: string;
30
- style: string;
31
- startOffset: string;
32
- textStyle: string;
33
- textStyleClass?: string | null;
34
- text: string;
35
- transform: string;
36
- color: string;
37
- strokeWidth: ConstantAccessor<number>;
38
- mark: Mark<BaseMarkProps>;
39
- scales: PlotScales;
40
- };
41
1
  /** Helper component for paths with markers and optional text along the path. */
42
- declare const MarkerPath: import("svelte").Component<MarkerPathProps, {}, "">;
2
+ declare const MarkerPath: import("svelte").Component<any, {}, "">;
43
3
  type MarkerPath = ReturnType<typeof MarkerPath>;
44
4
  export default MarkerPath;
@@ -11,11 +11,4 @@ export type BollingerOptions = {
11
11
  };
12
12
  export declare function bollingerX(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
13
13
  export declare function bollingerY(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
14
- export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): {
15
- data: {
16
- __x: import("../types.js").RawValue;
17
- __lo: number;
18
- __avg: number;
19
- __hi: number;
20
- }[];
21
- };
14
+ export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): any;
@@ -1,9 +1,2 @@
1
1
  import type { DataRecord, TransformArg } from '../types.js';
2
- export declare function geoCentroid({ data, ...options }: TransformArg<DataRecord>): {
3
- x: (d: any) => any;
4
- y: (d: any) => any;
5
- data: {
6
- __centroid__: [number, number];
7
- ___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
8
- }[];
9
- };
2
+ export declare function geoCentroid({ data, ...options }: TransformArg<DataRecord>): any;
@@ -38,29 +38,21 @@ type GroupZOptions = GroupXOptions | GroupYOptions;
38
38
  * groups the dataset by x and y channel and optionally reduces the group items
39
39
  * to output channels fill, stroke, r, opacity, fillOpacity, or strokeOpacity
40
40
  */
41
- export declare function group({ data, ...channels }: TransformArg<T, DataRecord>, options?: GroupXOptions): {
42
- data: DataRecord[];
43
- };
41
+ export declare function group({ data, ...channels }: TransformArg<T, DataRecord>, options?: GroupXOptions): any;
44
42
  /**
45
43
  * groups the dataset by the x channel and optionally reduces the group items
46
44
  * to output channels y, y1, y2, fill, stroke, r, opacity, fillOpacity, or strokeOpacity
47
45
  */
48
- export declare function groupX(input: TransformArg<T, DataRecord>, options?: GroupXOptions): {
49
- data: DataRecord[];
50
- };
46
+ export declare function groupX(input: TransformArg<T, DataRecord>, options?: GroupXOptions): any;
51
47
  /**
52
48
  * groups the dataset by the y channel and optionally reduces the group items
53
49
  * to output channels x, x1, x2, fill, stroke, r, opacity, fillOpacity, or strokeOpacity
54
50
  */
55
- export declare function groupY(input: TransformArg<T, DataRecord>, options?: GroupYOptions): {
56
- data: DataRecord[];
57
- };
51
+ export declare function groupY(input: TransformArg<T, DataRecord>, options?: GroupYOptions): any;
58
52
  /**
59
53
  * groups the dataset by the z channel and optionally reduces the group items
60
54
  * to output channels x, x1, x2, y, y1, y2, fill, stroke, r, opacity, fillOpacity,
61
55
  * or strokeOpacity
62
56
  */
63
- export declare function groupZ(input: TransformArg<T, DataRecord>, options?: GroupZOptions): {
64
- data: DataRecord[];
65
- };
57
+ export declare function groupZ(input: TransformArg<T, DataRecord>, options?: GroupZOptions): any;
66
58
  export {};
@@ -1,11 +1,7 @@
1
1
  import type { PlotState, TransformArg } from '../types.js';
2
2
  export declare function intervalX<T>(args: TransformArg<T>, { plot }: {
3
3
  plot: PlotState;
4
- }): {
5
- data: T[];
6
- };
4
+ }): any;
7
5
  export declare function intervalY<T>(args: TransformArg<T>, { plot }: {
8
6
  plot: PlotState;
9
- }): {
10
- data: T[];
11
- };
7
+ }): any;
@@ -1,10 +1,4 @@
1
- import type { TransformArg, MapOptions, MapMethod, DataRecord } from '../types.js';
2
- export declare function map<T>(args: TransformArg<T>, options: MapOptions): {
3
- data: DataRecord[];
4
- };
5
- export declare function mapX<T>(args: TransformArg<T>, mapper: MapMethod): {
6
- data: DataRecord[];
7
- };
8
- export declare function mapY<T>(args: TransformArg<T>, mapper: MapMethod): {
9
- data: DataRecord[];
10
- };
1
+ import type { TransformArg, MapOptions, MapMethod } from '../types.js';
2
+ export declare function map<T>(args: TransformArg<T>, options: MapOptions): any;
3
+ export declare function mapX<T>(args: TransformArg<T>, mapper: MapMethod): any;
4
+ export declare function mapY<T>(args: TransformArg<T>, mapper: MapMethod): any;
@@ -1,9 +1,5 @@
1
1
  import type { TransformArg, MapIndexObject } from '../types.js';
2
2
  type NormalizeBasis = 'deviation' | 'first' | 'last' | 'min' | 'max' | 'mean' | 'median' | 'sum' | 'extent' | MapIndexObject;
3
- export declare function normalizeX<T>(args: TransformArg<T>, basis: NormalizeBasis): {
4
- data: import("../types.js").DataRecord[];
5
- };
6
- export declare function normalizeY<T>(args: TransformArg<T>, basis: NormalizeBasis): {
7
- data: import("../types.js").DataRecord[];
8
- };
3
+ export declare function normalizeX<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
4
+ export declare function normalizeY<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
9
5
  export {};
@@ -5,31 +5,17 @@ type AtLeastOne<T, U = {
5
5
  type SelectOptions = 'first' | 'last' | AtLeastOne<{
6
6
  [k in ChannelName]: 'min' | 'max';
7
7
  }>;
8
- export declare function select({ data, ...channels }: TransformArg<DataRecord>, options: SelectOptions): {
9
- data: DataRecord[];
10
- };
8
+ export declare function select({ data, ...channels }: TransformArg<DataRecord>, options: SelectOptions): any;
11
9
  /**
12
10
  * Keeps only the first item of each group
13
11
  */
14
- export declare function selectFirst(args: TransformArg<DataRecord>): {
15
- data: DataRecord[];
16
- };
12
+ export declare function selectFirst(args: TransformArg<DataRecord>): any;
17
13
  /**
18
14
  * Keeps only the last item of each group
19
15
  */
20
- export declare function selectLast(args: TransformArg<DataRecord>): {
21
- data: DataRecord[];
22
- };
23
- export declare function selectMinX(args: TransformArg<DataRecord>): {
24
- data: DataRecord[];
25
- };
26
- export declare function selectMaxX(args: TransformArg<DataRecord>): {
27
- data: DataRecord[];
28
- };
29
- export declare function selectMinY(args: TransformArg<DataRecord>): {
30
- data: DataRecord[];
31
- };
32
- export declare function selectMaxY(args: TransformArg<DataRecord>): {
33
- data: DataRecord[];
34
- };
16
+ export declare function selectLast(args: TransformArg<DataRecord>): any;
17
+ export declare function selectMinX(args: TransformArg<DataRecord>): any;
18
+ export declare function selectMaxX(args: TransformArg<DataRecord>): any;
19
+ export declare function selectMinY(args: TransformArg<DataRecord>): any;
20
+ export declare function selectMaxY(args: TransformArg<DataRecord>): any;
35
21
  export {};
@@ -2,27 +2,14 @@ import type { DataRecord, DataRow, TransformArg } from '../types.js';
2
2
  export declare const SORT_KEY: unique symbol;
3
3
  export declare function sort({ data, ...channels }: TransformArg<DataRecord>, options?: {
4
4
  reverse?: boolean;
5
- }): {
6
- sort: null;
7
- data: {
8
- ___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
9
- }[];
10
- } | {
11
- data: DataRecord[];
12
- };
5
+ }): any;
13
6
  /**
14
7
  * reverses the data row order
15
8
  */
16
9
  export declare function shuffle({ data, ...channels }: TransformArg<DataRow[]>, options?: {
17
10
  seed?: number;
18
- }): {
19
- sort: null;
20
- data: DataRow[][];
21
- };
11
+ }): any;
22
12
  /**
23
13
  * reverses the data row order
24
14
  */
25
- export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>): {
26
- sort: null;
27
- data: DataRow[][];
28
- };
15
+ export declare function reverse({ data, ...channels }: TransformArg<DataRow[]>): any;
@@ -7,18 +7,6 @@ type WindowOptions = {
7
7
  reduce: ReducerName;
8
8
  strict: boolean;
9
9
  };
10
- export declare function windowX(args: TransformArg<DataRecord>, options: WindowOptions): {
11
- data: {
12
- [x: string]: import("../types.js").RawValue;
13
- [x: symbol]: import("../types.js").RawValue;
14
- ___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
15
- }[];
16
- };
17
- export declare function windowY(args: TransformArg<DataRecord>, options: WindowOptions): {
18
- data: {
19
- [x: string]: import("../types.js").RawValue;
20
- [x: symbol]: import("../types.js").RawValue;
21
- ___orig___?: import("../types.js").RawValue | [import("../types.js").RawValue, import("../types.js").RawValue];
22
- }[];
23
- };
10
+ export declare function windowX(args: TransformArg<DataRecord>, options: WindowOptions): any;
11
+ export declare function windowY(args: TransformArg<DataRecord>, options: WindowOptions): any;
24
12
  export {};
package/package.json CHANGED
@@ -1,123 +1,124 @@
1
1
  {
2
- "name": "svelteplot",
3
- "version": "0.2.7",
4
- "license": "ISC",
5
- "author": {
6
- "name": "Gregor Aisch",
7
- "email": "gka@users.noreply.github.com"
8
- },
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "svelte": "./dist/index.js"
2
+ "name": "svelteplot",
3
+ "version": "0.2.8-pr-68.0",
4
+ "license": "ISC",
5
+ "author": {
6
+ "name": "Gregor Aisch",
7
+ "email": "gka@users.noreply.github.com"
13
8
  },
14
- "./*.js": {
15
- "import": "./dist/*.js"
9
+ "scripts": {
10
+ "dev": "vite dev",
11
+ "build": "vite build",
12
+ "preview": "vite preview",
13
+ "test": "npm run test:unit",
14
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
15
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
16
+ "lint": "prettier --check src && eslint src",
17
+ "format": "prettier --write .",
18
+ "test:unit": "vitest",
19
+ "prepack": "npx svelte-package",
20
+ "release-next": "npm version prerelease --preid next && npm publish && git push && git push --tags && sleep 1 && npm dist-tag add svelteplot@$(npm view . version) next",
21
+ "docs": "npm run build && cd build && rsync --recursive . vis4.net:svelteplot/alpha0/"
16
22
  },
17
- "./*.svelte": {
18
- "import": "./dist/*.svelte"
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "svelte": "./dist/index.js"
27
+ },
28
+ "./*.js": {
29
+ "import": "./dist/*.js"
30
+ },
31
+ "./*.svelte": {
32
+ "import": "./dist/*.svelte"
33
+ },
34
+ "./core/*.svelte": {
35
+ "import": "./dist/core/*.svelte"
36
+ },
37
+ "./marks/*.svelte": {
38
+ "import": "./dist/marks/*.svelte"
39
+ },
40
+ "./transforms": {
41
+ "import": "./dist/transforms/index.js"
42
+ }
19
43
  },
20
- "./core/*.svelte": {
21
- "import": "./dist/core/*.svelte"
44
+ "main": "./dist/index.js",
45
+ "files": [
46
+ "dist",
47
+ "!dist/**/*.test.*",
48
+ "!dist/**/*.spec.*"
49
+ ],
50
+ "devDependencies": {
51
+ "@aitodotai/json-stringify-pretty-compact": "^1.3.0",
52
+ "@emotion/css": "^11.13.5",
53
+ "@sveltejs/adapter-auto": "^6.0.1",
54
+ "@sveltejs/adapter-static": "^3.0.8",
55
+ "@sveltejs/eslint-config": "^8.2.0",
56
+ "@sveltejs/kit": "^2.21.1",
57
+ "@sveltejs/package": "^2.3.11",
58
+ "@sveltejs/vite-plugin-svelte": "5.0.3",
59
+ "@sveltepress/theme-default": "^6.0.3",
60
+ "@sveltepress/twoslash": "^1.2.2",
61
+ "@sveltepress/vite": "^1.2.2",
62
+ "@testing-library/svelte": "^5.2.8",
63
+ "@testing-library/user-event": "^14.6.1",
64
+ "@types/d3-array": "^3.2.1",
65
+ "@types/d3-color": "^3.1.3",
66
+ "@types/d3-dsv": "^3.0.7",
67
+ "@types/d3-geo": "^3.1.0",
68
+ "@types/d3-interpolate": "^3.0.4",
69
+ "@types/d3-path": "^3.1.1",
70
+ "@types/d3-random": "^3.0.3",
71
+ "@types/d3-scale": "^4.0.9",
72
+ "@types/d3-scale-chromatic": "^3.1.0",
73
+ "@types/d3-shape": "^3.1.7",
74
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
75
+ "@typescript-eslint/parser": "^8.32.1",
76
+ "csstype": "^3.1.3",
77
+ "d3-dsv": "^3.0.1",
78
+ "d3-fetch": "^3.0.1",
79
+ "d3-force": "^3.0.0",
80
+ "eslint": "^9.27.0",
81
+ "eslint-config-prettier": "^10.1.5",
82
+ "eslint-plugin-svelte": "3.9.0",
83
+ "jsdom": "^26.1.0",
84
+ "prettier": "^3.5.3",
85
+ "prettier-plugin-svelte": "^3.4.0",
86
+ "remark-code-extra": "^1.0.1",
87
+ "remark-code-frontmatter": "^1.0.0",
88
+ "resize-observer-polyfill": "^1.5.1",
89
+ "sass": "^1.89.0",
90
+ "svelte-check": "^4.2.1",
91
+ "svelte-eslint-parser": "1.2.0",
92
+ "svelte-highlight": "^7.8.3",
93
+ "svg-path-parser": "^1.1.0",
94
+ "topojson-client": "^3.1.0",
95
+ "tslib": "^2.8.1",
96
+ "typedoc": "^0.28.5",
97
+ "typedoc-plugin-markdown": "^4.6.3",
98
+ "typescript": "^5.8.3",
99
+ "vite": "^6.3.5",
100
+ "vitest": "^3.1.4",
101
+ "vitest-matchmedia-mock": "^2.0.3"
22
102
  },
23
- "./marks/*.svelte": {
24
- "import": "./dist/marks/*.svelte"
25
- },
26
- "./transforms": {
27
- "import": "./dist/transforms/index.js"
103
+ "types": "./dist/index.d.ts",
104
+ "type": "module",
105
+ "dependencies": {
106
+ "d3-array": "^3.2.4",
107
+ "d3-color": "^3.1.0",
108
+ "d3-format": "^3.1.0",
109
+ "d3-geo": "^3.1.1",
110
+ "d3-interpolate": "^3.0.1",
111
+ "d3-path": "^3.1.0",
112
+ "d3-quadtree": "^3.0.1",
113
+ "d3-random": "^3.0.1",
114
+ "d3-regression": "^1.3.10",
115
+ "d3-scale": "^4.0.2",
116
+ "d3-scale-chromatic": "^3.1.0",
117
+ "d3-shape": "^3.2.0",
118
+ "d3-time": "^3.1.0",
119
+ "es-toolkit": "^1.38.0",
120
+ "fast-equals": "^5.2.2",
121
+ "merge-deep": "^3.0.3",
122
+ "svelte": "5.33.2"
28
123
  }
29
- },
30
- "main": "./dist/index.js",
31
- "files": [
32
- "dist",
33
- "!dist/**/*.test.*",
34
- "!dist/**/*.spec.*"
35
- ],
36
- "devDependencies": {
37
- "@aitodotai/json-stringify-pretty-compact": "^1.3.0",
38
- "@emotion/css": "^11.13.5",
39
- "@sveltejs/adapter-auto": "^6.0.1",
40
- "@sveltejs/adapter-static": "^3.0.8",
41
- "@sveltejs/eslint-config": "^8.2.0",
42
- "@sveltejs/kit": "^2.21.1",
43
- "@sveltejs/package": "^2.3.11",
44
- "@sveltejs/vite-plugin-svelte": "5.0.3",
45
- "@sveltepress/theme-default": "^6.0.3",
46
- "@sveltepress/twoslash": "^1.2.2",
47
- "@sveltepress/vite": "^1.2.2",
48
- "@testing-library/svelte": "^5.2.8",
49
- "@testing-library/user-event": "^14.6.1",
50
- "@types/d3-array": "^3.2.1",
51
- "@types/d3-color": "^3.1.3",
52
- "@types/d3-dsv": "^3.0.7",
53
- "@types/d3-geo": "^3.1.0",
54
- "@types/d3-interpolate": "^3.0.4",
55
- "@types/d3-path": "^3.1.1",
56
- "@types/d3-random": "^3.0.3",
57
- "@types/d3-scale": "^4.0.9",
58
- "@types/d3-scale-chromatic": "^3.1.0",
59
- "@types/d3-shape": "^3.1.7",
60
- "@typescript-eslint/eslint-plugin": "^8.32.1",
61
- "@typescript-eslint/parser": "^8.32.1",
62
- "csstype": "^3.1.3",
63
- "d3-dsv": "^3.0.1",
64
- "d3-fetch": "^3.0.1",
65
- "d3-force": "^3.0.0",
66
- "eslint": "^9.27.0",
67
- "eslint-config-prettier": "^10.1.5",
68
- "eslint-plugin-svelte": "3.9.0",
69
- "jsdom": "^26.1.0",
70
- "prettier": "^3.5.3",
71
- "prettier-plugin-svelte": "^3.4.0",
72
- "remark-code-extra": "^1.0.1",
73
- "remark-code-frontmatter": "^1.0.0",
74
- "resize-observer-polyfill": "^1.5.1",
75
- "sass": "^1.89.0",
76
- "svelte-check": "^4.2.1",
77
- "svelte-eslint-parser": "1.2.0",
78
- "svelte-highlight": "^7.8.3",
79
- "svg-path-parser": "^1.1.0",
80
- "topojson-client": "^3.1.0",
81
- "tslib": "^2.8.1",
82
- "typedoc": "^0.28.5",
83
- "typedoc-plugin-markdown": "^4.6.3",
84
- "typescript": "^5.8.3",
85
- "vite": "^6.3.5",
86
- "vitest": "^3.1.4",
87
- "vitest-matchmedia-mock": "^2.0.3"
88
- },
89
- "types": "./dist/index.d.ts",
90
- "type": "module",
91
- "dependencies": {
92
- "d3-array": "^3.2.4",
93
- "d3-color": "^3.1.0",
94
- "d3-format": "^3.1.0",
95
- "d3-geo": "^3.1.1",
96
- "d3-interpolate": "^3.0.1",
97
- "d3-path": "^3.1.0",
98
- "d3-quadtree": "^3.0.1",
99
- "d3-random": "^3.0.1",
100
- "d3-regression": "^1.3.10",
101
- "d3-scale": "^4.0.2",
102
- "d3-scale-chromatic": "^3.1.0",
103
- "d3-shape": "^3.2.0",
104
- "d3-time": "^3.1.0",
105
- "es-toolkit": "^1.38.0",
106
- "fast-equals": "^5.2.2",
107
- "merge-deep": "^3.0.3",
108
- "svelte": "5.33.2"
109
- },
110
- "scripts": {
111
- "dev": "vite dev",
112
- "build": "vite build",
113
- "preview": "vite preview",
114
- "test": "npm run test:unit",
115
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
116
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
117
- "lint": "prettier --check src && eslint src",
118
- "format": "prettier --write .",
119
- "test:unit": "vitest",
120
- "release-next": "npm version prerelease --preid next && npm publish && git push && git push --tags && sleep 1 && npm dist-tag add svelteplot@$(npm view . version) next",
121
- "docs": "npm run build && cd build && rsync --recursive . vis4.net:svelteplot/alpha0/"
122
- }
123
- }
124
+ }