@ac-kit/model-chart 0.1.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/LICENSE +28 -0
- package/README.md +75 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/render/capabilities.d.ts +53 -0
- package/dist/render/capabilities.d.ts.map +1 -0
- package/dist/render/capabilities.js +62 -0
- package/dist/render/capabilities.js.map +1 -0
- package/dist/spec/annotation.d.ts +31 -0
- package/dist/spec/annotation.d.ts.map +1 -0
- package/dist/spec/annotation.js +2 -0
- package/dist/spec/annotation.js.map +1 -0
- package/dist/spec/channel.d.ts +16 -0
- package/dist/spec/channel.d.ts.map +1 -0
- package/dist/spec/channel.js +22 -0
- package/dist/spec/channel.js.map +1 -0
- package/dist/spec/coord.d.ts +91 -0
- package/dist/spec/coord.d.ts.map +1 -0
- package/dist/spec/coord.js +2 -0
- package/dist/spec/coord.js.map +1 -0
- package/dist/spec/encoding.d.ts +53 -0
- package/dist/spec/encoding.d.ts.map +1 -0
- package/dist/spec/encoding.js +5 -0
- package/dist/spec/encoding.js.map +1 -0
- package/dist/spec/mark.d.ts +34 -0
- package/dist/spec/mark.d.ts.map +1 -0
- package/dist/spec/mark.js +2 -0
- package/dist/spec/mark.js.map +1 -0
- package/dist/spec/plot.d.ts +82 -0
- package/dist/spec/plot.d.ts.map +1 -0
- package/dist/spec/plot.js +2 -0
- package/dist/spec/plot.js.map +1 -0
- package/dist/spec/scale.d.ts +69 -0
- package/dist/spec/scale.d.ts.map +1 -0
- package/dist/spec/scale.js +2 -0
- package/dist/spec/scale.js.map +1 -0
- package/dist/spec/transform.d.ts +145 -0
- package/dist/spec/transform.d.ts.map +1 -0
- package/dist/spec/transform.js +2 -0
- package/dist/spec/transform.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @ac-kit/model-chart
|
|
2
|
+
|
|
3
|
+
A description of a chart, independent of the medium it will be drawn in.
|
|
4
|
+
|
|
5
|
+
A spec says **what to show** — encode this field on the x axis, colour by that
|
|
6
|
+
one, bin the third — and never how big, what colour, or at what resolution. A
|
|
7
|
+
renderer decides all of that, which is what lets one spec drive an SVG canvas
|
|
8
|
+
and an eighty-column terminal.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import type { PlotSpec } from "@ac-kit/model-chart";
|
|
12
|
+
|
|
13
|
+
const barChart: PlotSpec = {
|
|
14
|
+
mark: "bar",
|
|
15
|
+
encoding: {
|
|
16
|
+
x: { field: "case" },
|
|
17
|
+
y: { field: "medianMs", scale: { zero: true } },
|
|
18
|
+
},
|
|
19
|
+
description: "Median duration per case.",
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Marks and channels, not chart types
|
|
24
|
+
|
|
25
|
+
There is no `"heatmap"` type. A heatmap is `mark: "rect"` with categorical `x`
|
|
26
|
+
and `y` and quantitative `color`; a histogram is `mark: "bar"` with a `bin`
|
|
27
|
+
transform; a Gantt row is `mark: "bar"` with `x` and `x2` on a time axis. Naming
|
|
28
|
+
the primitive rather than the picture is what keeps the catalogue open: a chart
|
|
29
|
+
nobody anticipated is a combination of marks and channels that already exist,
|
|
30
|
+
not a new type someone has to add.
|
|
31
|
+
|
|
32
|
+
## Contents
|
|
33
|
+
|
|
34
|
+
| Group | Exports |
|
|
35
|
+
| ----------- | ------------------------------------------------------------------------------------------------ |
|
|
36
|
+
| Marks | `Mark` |
|
|
37
|
+
| Channels | `Channel`, `POSITION_CHANNELS` |
|
|
38
|
+
| Encoding | `EncodingSpec`, `FieldEncoding`, `ValueEncoding`, `AxisSpec`, `LegendSpec`, `isFieldEncoding` |
|
|
39
|
+
| Scales | `ScaleSpec`, `ScaleKind`, `ColorSchemeSpec` |
|
|
40
|
+
| Transforms | `TransformSpec` and its ten members (`bin`, `aggregate`, `stack`, `density`, …) |
|
|
41
|
+
| Coordinates | `CoordSpec`, `CoordKind`, `ProjectionSpec`, `ProjectionKind`, `HierarchyLayout`, `NetworkLayout` |
|
|
42
|
+
| Composition | `PlotSpec`, `ViewSpec`, `LayerSpec`, `FacetSpec`, `ConcatSpec`, `Interpolation` |
|
|
43
|
+
| Annotations | `AnnotationSpec` |
|
|
44
|
+
| Rendering | `RendererCapabilities`, `canRender`, `resolvePlot`, `unsupportedFeatures` |
|
|
45
|
+
|
|
46
|
+
## Nothing here is in output units
|
|
47
|
+
|
|
48
|
+
No width, height, margin, pixel, cell, font or colour literal appears anywhere
|
|
49
|
+
in these types. A scale declares a **domain** and never a range; a colour scale
|
|
50
|
+
names a **scheme** and never a hex value, so a terminal with no colour can map
|
|
51
|
+
it to a glyph ramp. Anything expressed in output units would make a spec
|
|
52
|
+
renderable by exactly one adapter.
|
|
53
|
+
|
|
54
|
+
Binning follows the same rule: it is declared, never pre-applied. A frame that
|
|
55
|
+
already carries buckets cannot be re-fitted, and an eighty-column terminal, a
|
|
56
|
+
1200 px canvas and an eight-cell sparkline each want a different bucket count.
|
|
57
|
+
|
|
58
|
+
## Declining gracefully
|
|
59
|
+
|
|
60
|
+
A renderer declares what it can draw as `RendererCapabilities`; `resolvePlot`
|
|
61
|
+
walks a spec's `fallback` chain and returns the first drawable one. A `null`
|
|
62
|
+
result is the signal to apply the universal fallback and render the underlying
|
|
63
|
+
frame as a table. Every spec carries a `description` so a renderer that declines
|
|
64
|
+
still has something to say.
|
|
65
|
+
|
|
66
|
+
## Transforms are declared here, computed elsewhere
|
|
67
|
+
|
|
68
|
+
`bin`, `density`, `regression` and `contour` are named operations with real
|
|
69
|
+
implementations, and those belong where the mathematics lives —
|
|
70
|
+
`@ac-kit/math-stats`, `@ac-kit/math-grid`, `@ac-kit/algo`. This package says
|
|
71
|
+
which one to apply, not how.
|
|
72
|
+
|
|
73
|
+
See the
|
|
74
|
+
[generated API docs](https://anthochamp.github.io/node-essentials/api/model-chart/)
|
|
75
|
+
for the full reference.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./render/capabilities.js";
|
|
2
|
+
export * from "./spec/annotation.js";
|
|
3
|
+
export * from "./spec/channel.js";
|
|
4
|
+
export * from "./spec/coord.js";
|
|
5
|
+
export * from "./spec/encoding.js";
|
|
6
|
+
export * from "./spec/mark.js";
|
|
7
|
+
export * from "./spec/plot.js";
|
|
8
|
+
export * from "./spec/scale.js";
|
|
9
|
+
export * from "./spec/transform.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./render/capabilities.js";
|
|
2
|
+
export * from "./spec/annotation.js";
|
|
3
|
+
export * from "./spec/channel.js";
|
|
4
|
+
export * from "./spec/coord.js";
|
|
5
|
+
export * from "./spec/encoding.js";
|
|
6
|
+
export * from "./spec/mark.js";
|
|
7
|
+
export * from "./spec/plot.js";
|
|
8
|
+
export * from "./spec/scale.js";
|
|
9
|
+
export * from "./spec/transform.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Channel } from "../spec/channel.js";
|
|
2
|
+
import type { CoordKind } from "../spec/coord.js";
|
|
3
|
+
import type { Mark } from "../spec/mark.js";
|
|
4
|
+
import type { PlotSpec } from "../spec/plot.js";
|
|
5
|
+
import type { TransformSpec } from "../spec/transform.js";
|
|
6
|
+
/**
|
|
7
|
+
* What an output medium can actually draw.
|
|
8
|
+
*
|
|
9
|
+
* A terminal is a grid of character cells with roughly a one-to-two aspect
|
|
10
|
+
* ratio and, at best, two-by-four subcell resolution through braille; a canvas
|
|
11
|
+
* is continuous and unbounded. Rather than let each renderer discover it cannot
|
|
12
|
+
* honour a spec halfway through, it declares its limits up front and
|
|
13
|
+
* {@link resolvePlot} picks something it can draw.
|
|
14
|
+
*/
|
|
15
|
+
export type RendererCapabilities = {
|
|
16
|
+
marks: ReadonlySet<Mark>;
|
|
17
|
+
coords: ReadonlySet<CoordKind>;
|
|
18
|
+
channels: ReadonlySet<Channel>;
|
|
19
|
+
transforms: ReadonlySet<TransformSpec["kind"]>;
|
|
20
|
+
/** Bits of colour available. `0` means none, so schemes map to glyph ramps. */
|
|
21
|
+
colorDepth: 0 | 4 | 8 | 24;
|
|
22
|
+
/** `false` when positions quantise to discrete cells rather than to points. */
|
|
23
|
+
continuous: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Beyond this, a renderer would produce an unreadable result. Unbounded when
|
|
26
|
+
* absent.
|
|
27
|
+
*/
|
|
28
|
+
maxMarks?: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Everything in `spec` that `capabilities` cannot honour.
|
|
32
|
+
*
|
|
33
|
+
* @returns Human-readable reasons, empty when the spec is drawable. Intended
|
|
34
|
+
* for a diagnostic, not for control flow — use {@link canRender} for that.
|
|
35
|
+
*/
|
|
36
|
+
export declare function unsupportedFeatures(spec: PlotSpec, capabilities: RendererCapabilities): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Whether `capabilities` can honour every part of `spec`.
|
|
39
|
+
*
|
|
40
|
+
* The control-flow form of {@link unsupportedFeatures}, which is the one to
|
|
41
|
+
* call when you want to tell a reader _why_ not.
|
|
42
|
+
*
|
|
43
|
+
* O(channels + transforms) in the spec.
|
|
44
|
+
*/
|
|
45
|
+
export declare function canRender(spec: PlotSpec, capabilities: RendererCapabilities): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The first spec in `spec`'s fallback chain that `capabilities` can draw.
|
|
48
|
+
*
|
|
49
|
+
* @returns `null` when nothing in the chain is drawable, which is the signal to
|
|
50
|
+
* apply the universal fallback and render the underlying frame as a table.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolvePlot(spec: PlotSpec, capabilities: RendererCapabilities): PlotSpec | null;
|
|
53
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/render/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC/B,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,+EAA+E;IAC/E,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAC3B,+EAA+E;IAC/E,UAAU,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,oBAAoB,GAChC,MAAM,EAAE,CAyBV;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,oBAAoB,GAChC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,oBAAoB,GAChC,QAAQ,GAAG,IAAI,CAmBjB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything in `spec` that `capabilities` cannot honour.
|
|
3
|
+
*
|
|
4
|
+
* @returns Human-readable reasons, empty when the spec is drawable. Intended
|
|
5
|
+
* for a diagnostic, not for control flow — use {@link canRender} for that.
|
|
6
|
+
*/
|
|
7
|
+
export function unsupportedFeatures(spec, capabilities) {
|
|
8
|
+
const reasons = [];
|
|
9
|
+
if (!capabilities.marks.has(spec.mark)) {
|
|
10
|
+
reasons.push(`mark "${spec.mark}"`);
|
|
11
|
+
}
|
|
12
|
+
const coordKind = spec.coord?.kind ?? "cartesian";
|
|
13
|
+
if (!capabilities.coords.has(coordKind)) {
|
|
14
|
+
reasons.push(`coordinate system "${coordKind}"`);
|
|
15
|
+
}
|
|
16
|
+
for (const channel of Object.keys(spec.encoding)) {
|
|
17
|
+
if (!capabilities.channels.has(channel)) {
|
|
18
|
+
reasons.push(`channel "${channel}"`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const transform of spec.transform ?? []) {
|
|
22
|
+
if (!capabilities.transforms.has(transform.kind)) {
|
|
23
|
+
reasons.push(`transform "${transform.kind}"`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return reasons;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether `capabilities` can honour every part of `spec`.
|
|
30
|
+
*
|
|
31
|
+
* The control-flow form of {@link unsupportedFeatures}, which is the one to
|
|
32
|
+
* call when you want to tell a reader _why_ not.
|
|
33
|
+
*
|
|
34
|
+
* O(channels + transforms) in the spec.
|
|
35
|
+
*/
|
|
36
|
+
export function canRender(spec, capabilities) {
|
|
37
|
+
return unsupportedFeatures(spec, capabilities).length === 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The first spec in `spec`'s fallback chain that `capabilities` can draw.
|
|
41
|
+
*
|
|
42
|
+
* @returns `null` when nothing in the chain is drawable, which is the signal to
|
|
43
|
+
* apply the universal fallback and render the underlying frame as a table.
|
|
44
|
+
*/
|
|
45
|
+
export function resolvePlot(spec, capabilities) {
|
|
46
|
+
const pending = [spec];
|
|
47
|
+
// A fallback chain is plain data and could be built cyclically by mistake.
|
|
48
|
+
const seen = new Set();
|
|
49
|
+
while (pending.length > 0) {
|
|
50
|
+
const candidate = pending.shift();
|
|
51
|
+
if (seen.has(candidate)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
seen.add(candidate);
|
|
55
|
+
if (canRender(candidate, capabilities)) {
|
|
56
|
+
return candidate;
|
|
57
|
+
}
|
|
58
|
+
pending.push(...(candidate.fallback ?? []));
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/render/capabilities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;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAC1B,IAAc,EACd,YAAkC;IAElC,MAAM,OAAO,GAAe,CAAC,IAAI,CAAC,CAAC;IACnC,2EAA2E;IAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAY,CAAC;IAEjC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,EAAc,CAAC;QAC9C,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,SAAS;QACV,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEpB,IAAI,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Value } from "@ac-kit/model-dataset";
|
|
2
|
+
/**
|
|
3
|
+
* A reference mark that comes from the caller rather than from the data: a
|
|
4
|
+
* budget line, a target band, a highlighted point, a labelled event.
|
|
5
|
+
*
|
|
6
|
+
* Every real chart eventually needs "the threshold is here", and expressing it
|
|
7
|
+
* as a second data frame would misrepresent an assertion as an observation.
|
|
8
|
+
*/
|
|
9
|
+
export type AnnotationSpec = {
|
|
10
|
+
kind: "line";
|
|
11
|
+
channel: "x" | "y";
|
|
12
|
+
at: Value;
|
|
13
|
+
label?: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "band";
|
|
16
|
+
channel: "x" | "y";
|
|
17
|
+
from: Value;
|
|
18
|
+
to: Value;
|
|
19
|
+
label?: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "point";
|
|
22
|
+
x: Value;
|
|
23
|
+
y: Value;
|
|
24
|
+
label?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "text";
|
|
27
|
+
x: Value;
|
|
28
|
+
y: Value;
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=annotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/spec/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D;IACA,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,GAAG,GAAG,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CACd,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.js","sourceRoot":"","sources":["../../src/spec/annotation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A visual property a field can drive.
|
|
3
|
+
*
|
|
4
|
+
* The channel set is what makes the catalogue open: a heatmap needs no new
|
|
5
|
+
* type, only `x`/`y` categorical plus `color` quantitative.
|
|
6
|
+
*/
|
|
7
|
+
export type Channel = "x" | "x2" | "y" | "y2" | "z" | "theta" | "theta2" | "radius" | "radius2" | "longitude" | "latitude" | "geometry" | "color" | "fill" | "stroke" | "strokeWidth" | "size" | "shape" | "opacity" | "text" | "tooltip" | "source" | "target" | "detail" | "order" | "key" | "row" | "column";
|
|
8
|
+
/** Channels that place a mark rather than style it. */
|
|
9
|
+
/**
|
|
10
|
+
* The channels that place a mark rather than style it.
|
|
11
|
+
*
|
|
12
|
+
* A renderer uses this to tell "where does this go?" from "what does this look
|
|
13
|
+
* like?" — a missing position is an error, a missing colour is a default.
|
|
14
|
+
*/
|
|
15
|
+
export declare const POSITION_CHANNELS: readonly Channel[];
|
|
16
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/spec/channel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAIhB,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GAEH,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,SAAS,GAGT,WAAW,GACX,UAAU,GACV,UAAU,GAEV,OAAO,GACP,MAAM,GACN,QAAQ,GACR,aAAa,GACb,MAAM,GACN,OAAO,GACP,SAAS,GAET,MAAM,GACN,SAAS,GAET,QAAQ,GACR,QAAQ,GAER,QAAQ,GACR,OAAO,GACP,KAAK,GAEL,KAAK,GACL,QAAQ,CAAC;AAEZ,uDAAuD;AACvD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,OAAO,EAa/C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Channels that place a mark rather than style it. */
|
|
2
|
+
/**
|
|
3
|
+
* The channels that place a mark rather than style it.
|
|
4
|
+
*
|
|
5
|
+
* A renderer uses this to tell "where does this go?" from "what does this look
|
|
6
|
+
* like?" — a missing position is an error, a missing colour is a default.
|
|
7
|
+
*/
|
|
8
|
+
export const POSITION_CHANNELS = [
|
|
9
|
+
"x",
|
|
10
|
+
"x2",
|
|
11
|
+
"y",
|
|
12
|
+
"y2",
|
|
13
|
+
"z",
|
|
14
|
+
"theta",
|
|
15
|
+
"theta2",
|
|
16
|
+
"radius",
|
|
17
|
+
"radius2",
|
|
18
|
+
"longitude",
|
|
19
|
+
"latitude",
|
|
20
|
+
"geometry",
|
|
21
|
+
];
|
|
22
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/spec/channel.ts"],"names":[],"mappings":"AA+CA,uDAAuD;AACvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAuB;IACpD,GAAG;IACH,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,GAAG;IACH,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,UAAU;CACV,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named map projections, by the family a reader would ask for.
|
|
3
|
+
*
|
|
4
|
+
* The projection mathematics is cartography and belongs in a `math/*` package;
|
|
5
|
+
* this is the reference a spec carries so that a renderer able to project can
|
|
6
|
+
* find one, and a renderer unable to project can decline cleanly.
|
|
7
|
+
*/
|
|
8
|
+
export type ProjectionKind = "equirectangular" | "mercator" | "transverse-mercator" | "albers" | "albers-usa" | "conic-conformal" | "conic-equal-area" | "conic-equidistant" | "azimuthal-equal-area" | "azimuthal-equidistant" | "gnomonic" | "orthographic" | "stereographic" | "natural-earth" | "equal-earth";
|
|
9
|
+
/**
|
|
10
|
+
* A projection, plus the parameters that decide what it centres on and where it
|
|
11
|
+
* is least distorted.
|
|
12
|
+
*
|
|
13
|
+
* Every projection trades one kind of accuracy for another; `rotate`, `center`
|
|
14
|
+
* and `parallels` choose which part of the map pays.
|
|
15
|
+
*/
|
|
16
|
+
export type ProjectionSpec = {
|
|
17
|
+
kind: ProjectionKind;
|
|
18
|
+
/** Rotation about the three axes, in degrees. */
|
|
19
|
+
rotate?: readonly [number, number] | readonly [number, number, number];
|
|
20
|
+
/** Standard parallels, for the conic families. */
|
|
21
|
+
parallels?: readonly [number, number];
|
|
22
|
+
/** Centre of the projection, as `[longitude, latitude]`. */
|
|
23
|
+
center?: readonly [number, number];
|
|
24
|
+
};
|
|
25
|
+
/** How a tree's nodes are turned into positions. */
|
|
26
|
+
/**
|
|
27
|
+
* How a tree is laid out in the plane: nested rectangles (`squarify`,
|
|
28
|
+
* `partition`), a node-link diagram (`tidy`, `cluster`), or nested circles
|
|
29
|
+
* (`pack`).
|
|
30
|
+
*/
|
|
31
|
+
export type HierarchyLayout =
|
|
32
|
+
/** Nested rectangles, area-proportional: treemap. */
|
|
33
|
+
"squarify"
|
|
34
|
+
/** Stacked bars along one axis: icicle, flamegraph, sunburst. */
|
|
35
|
+
| "partition"
|
|
36
|
+
/** Node-link, tidy: dendrogram. */
|
|
37
|
+
| "tidy"
|
|
38
|
+
/** Node-link, leaves aligned: cluster. */
|
|
39
|
+
| "cluster"
|
|
40
|
+
/** Nested circles. */
|
|
41
|
+
| "pack";
|
|
42
|
+
/** How a graph's nodes are turned into positions. */
|
|
43
|
+
/**
|
|
44
|
+
* How a graph is laid out: by simulated repulsion (`force`), by dependency
|
|
45
|
+
* depth (`layered`), or by placing nodes on a fixed path (`circular`, `arc`,
|
|
46
|
+
* `flow`).
|
|
47
|
+
*/
|
|
48
|
+
export type NetworkLayout =
|
|
49
|
+
/** Force-directed, velocity Verlet. */
|
|
50
|
+
"force"
|
|
51
|
+
/** Layered, for a directed acyclic graph. */
|
|
52
|
+
| "layered"
|
|
53
|
+
/** Nodes on a circle, edges as chords. */
|
|
54
|
+
| "circular"
|
|
55
|
+
/** Nodes on a line, edges as arcs. */
|
|
56
|
+
| "arc"
|
|
57
|
+
/** Flow-conserving ribbons: Sankey, alluvial. */
|
|
58
|
+
| "flow";
|
|
59
|
+
/**
|
|
60
|
+
* The space marks are placed in.
|
|
61
|
+
*
|
|
62
|
+
* Cartesian is the default and covers most of the catalogue. The other four
|
|
63
|
+
* exist because they need something cartesian cannot supply: an angular sweep,
|
|
64
|
+
* a map projection, one axis per field, or a layout algorithm that derives
|
|
65
|
+
* positions from structure rather than from values.
|
|
66
|
+
*/
|
|
67
|
+
export type CoordSpec = {
|
|
68
|
+
kind: "cartesian";
|
|
69
|
+
transpose?: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
kind: "polar";
|
|
72
|
+
innerRadius?: number;
|
|
73
|
+
startAngle?: number;
|
|
74
|
+
endAngle?: number;
|
|
75
|
+
} | {
|
|
76
|
+
kind: "geographic";
|
|
77
|
+
projection: ProjectionSpec;
|
|
78
|
+
crs?: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "parallel";
|
|
81
|
+
} | {
|
|
82
|
+
kind: "hierarchy";
|
|
83
|
+
layout: HierarchyLayout;
|
|
84
|
+
padding?: number;
|
|
85
|
+
} | {
|
|
86
|
+
kind: "network";
|
|
87
|
+
layout: NetworkLayout;
|
|
88
|
+
};
|
|
89
|
+
/** The discriminant of {@link CoordSpec}, for a renderer declaring its limits. */
|
|
90
|
+
export type CoordKind = CoordSpec["kind"];
|
|
91
|
+
//# sourceMappingURL=coord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coord.d.ts","sourceRoot":"","sources":["../../src/spec/coord.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACvB,iBAAiB,GACjB,UAAU,GACV,qBAAqB,GACrB,QAAQ,GACR,YAAY,GACZ,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,sBAAsB,GACtB,uBAAuB,GACvB,UAAU,GACV,cAAc,GACd,eAAe,GACf,eAAe,GACf,aAAa,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,M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AO,CAAC,EAAE,MAAM,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9C,kFAAkF;AAClF,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coord.js","sourceRoot":"","sources":["../../src/spec/coord.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Value } from "@ac-kit/model-dataset";
|
|
2
|
+
import type { ScaleSpec } from "./scale.js";
|
|
3
|
+
/** Whether and how a channel explains itself to a reader. */
|
|
4
|
+
export type LegendSpec = {
|
|
5
|
+
title?: string;
|
|
6
|
+
/** Suppresses the legend without dropping the encoding. */
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Whether and how a channel labels its own scale for a reader. */
|
|
10
|
+
export type AxisSpec = {
|
|
11
|
+
title?: string;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
/** Preferred tick count. A hint: the renderer owns the final choice. */
|
|
14
|
+
tickCount?: number;
|
|
15
|
+
/** Explicit tick positions, overriding any derived ones. */
|
|
16
|
+
tickValues?: readonly Value[];
|
|
17
|
+
grid?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Binds one field to one channel.
|
|
21
|
+
*
|
|
22
|
+
* A field reference, not a value: the frame owns the data, and the encoding
|
|
23
|
+
* owns only the claim that this field drives this visual property.
|
|
24
|
+
*/
|
|
25
|
+
export type FieldEncoding = {
|
|
26
|
+
field: string;
|
|
27
|
+
scale?: ScaleSpec;
|
|
28
|
+
axis?: AxisSpec;
|
|
29
|
+
legend?: LegendSpec;
|
|
30
|
+
/** Overrides the field's own `title` for this chart. */
|
|
31
|
+
title?: string;
|
|
32
|
+
/** Reorders a categorical domain by another field's aggregate. */
|
|
33
|
+
sort?: "ascending" | "descending" | null | {
|
|
34
|
+
field: string;
|
|
35
|
+
order?: "ascending" | "descending";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Pins a channel to a constant, with no field behind it — a fixed bar colour, a
|
|
40
|
+
* zero baseline, a uniform point size.
|
|
41
|
+
*/
|
|
42
|
+
export type ValueEncoding = {
|
|
43
|
+
value: Value;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* What drives one channel: a field from the frame, or a fixed value.
|
|
47
|
+
*
|
|
48
|
+
* Narrow it with {@link isFieldEncoding} before reading `field`.
|
|
49
|
+
*/
|
|
50
|
+
export type EncodingSpec = FieldEncoding | ValueEncoding;
|
|
51
|
+
/** Narrows an encoding to the field-backed form. */
|
|
52
|
+
export declare function isFieldEncoding(encoding: EncodingSpec): encoding is FieldEncoding;
|
|
53
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/spec/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,IAAI,CAAC,EACF,WAAW,GACX,YAAY,GACZ,IAAI,GACJ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAAA;KAAE,CAAC;CACzD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;AAEzD,oDAAoD;AACpD,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,YAAY,GACpB,QAAQ,IAAI,aAAa,CAE3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/spec/encoding.ts"],"names":[],"mappings":"AAwDA,oDAAoD;AACpD,MAAM,UAAU,eAAe,CAC9B,QAAsB;IAEtB,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The geometric primitive drawn once per datum.
|
|
3
|
+
*
|
|
4
|
+
* A chart type is not a mark: a heatmap is `rect` with categorical position and
|
|
5
|
+
* quantitative colour, a histogram is `bar` with a binned position, a
|
|
6
|
+
* flamegraph is `rect` in hierarchical coordinates. Naming the primitive rather
|
|
7
|
+
* than the chart is what keeps the catalogue open.
|
|
8
|
+
*/
|
|
9
|
+
export type Mark =
|
|
10
|
+
/** One symbol per datum: scatter, bubble, strip. */
|
|
11
|
+
"point"
|
|
12
|
+
/** Connected path through ordered data. */
|
|
13
|
+
| "line"
|
|
14
|
+
/** Filled region between a path and a baseline, or between two paths. */
|
|
15
|
+
| "area"
|
|
16
|
+
/** Rectangle anchored to a baseline. */
|
|
17
|
+
| "bar"
|
|
18
|
+
/** Rectangle defined by two positions on both axes: heatmap, raster, span. */
|
|
19
|
+
| "rect"
|
|
20
|
+
/** Circular sector: pie, donut, sunburst, gauge. */
|
|
21
|
+
| "arc"
|
|
22
|
+
/** Zero-width line: error bar, reference line, whisker. */
|
|
23
|
+
| "rule"
|
|
24
|
+
/** Short perpendicular dash: median marker, axis tick, event raster. */
|
|
25
|
+
| "tick"
|
|
26
|
+
/** A label positioned by the encoding. */
|
|
27
|
+
| "text"
|
|
28
|
+
/** An edge between two positions: node-link, arc diagram, Sankey ribbon. */
|
|
29
|
+
| "link"
|
|
30
|
+
/** A closed shape from a geometry field: choropleth, contour band. */
|
|
31
|
+
| "polygon"
|
|
32
|
+
/** A composite symbol whose form itself encodes data: wind barb, star plot. */
|
|
33
|
+
| "glyph";
|
|
34
|
+
//# sourceMappingURL=mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.d.ts","sourceRoot":"","sources":["../../src/spec/mark.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI;AACf,oDAAoD;AAClD,OAAO;AACT,2CAA2C;GACzC,MAAM;AACR,yEAAyE;GACvE,MAAM;AACR,wCAAwC;GACtC,KAAK;AACP,8EAA8E;GAC5E,MAAM;AACR,oDAAoD;GAClD,KAAK;AACP,2DAA2D;GACzD,MAAM;AACR,wEAAwE;GACtE,MAAM;AACR,0CAA0C;GACxC,MAAM;AACR,4EAA4E;GAC1E,MAAM;AACR,sEAAsE;GACpE,SAAS;AACX,+EAA+E;GAC7E,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.js","sourceRoot":"","sources":["../../src/spec/mark.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AnnotationSpec } from "./annotation.js";
|
|
2
|
+
import type { Channel } from "./channel.js";
|
|
3
|
+
import type { CoordSpec } from "./coord.js";
|
|
4
|
+
import type { EncodingSpec } from "./encoding.js";
|
|
5
|
+
import type { Mark } from "./mark.js";
|
|
6
|
+
import type { TransformSpec } from "./transform.js";
|
|
7
|
+
/** How consecutive points of a `line` or `area` mark are joined. */
|
|
8
|
+
/**
|
|
9
|
+
* The path drawn between consecutive points of a line or area.
|
|
10
|
+
*
|
|
11
|
+
* `linear` joins them directly and claims nothing the data does not say. The
|
|
12
|
+
* curved options assert that something continuous happened between the samples;
|
|
13
|
+
* the `step` options assert that nothing did until the next one.
|
|
14
|
+
*/
|
|
15
|
+
export type Interpolation = "linear" | "step" | "step-before" | "step-after" | "monotone" | "natural" | "basis" | "cardinal";
|
|
16
|
+
/**
|
|
17
|
+
* One layer of marks over one frame.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately free of geometry: no width, height, margin, pixel, cell, font or
|
|
20
|
+
* colour literal appears anywhere in this type. The spec states intent; the
|
|
21
|
+
* renderer owns every measurement. Anything expressed in output units would
|
|
22
|
+
* make the spec renderable by exactly one adapter.
|
|
23
|
+
*/
|
|
24
|
+
export type PlotSpec = {
|
|
25
|
+
mark: Mark;
|
|
26
|
+
encoding: Partial<Record<Channel, EncodingSpec>>;
|
|
27
|
+
/** Default `{ kind: "cartesian" }`. */
|
|
28
|
+
coord?: CoordSpec;
|
|
29
|
+
/** Applied in order, before the encoding is resolved. */
|
|
30
|
+
transform?: readonly TransformSpec[];
|
|
31
|
+
interpolate?: Interpolation;
|
|
32
|
+
annotations?: readonly AnnotationSpec[];
|
|
33
|
+
title?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Prose describing what the chart shows.
|
|
36
|
+
*
|
|
37
|
+
* Alt text for SVG and HTML, a screen-reader string, and the sentence a
|
|
38
|
+
* renderer emits when it declines the chart entirely — which is what makes
|
|
39
|
+
* declining acceptable rather than silent.
|
|
40
|
+
*/
|
|
41
|
+
description?: string;
|
|
42
|
+
/** Preferred width-to-height ratio. A hint, never a size. */
|
|
43
|
+
aspectRatio?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Specs to try, in order, when a renderer cannot draw this one.
|
|
46
|
+
*
|
|
47
|
+
* A pie falls back to a normalized stacked bar, a scatter to a binned
|
|
48
|
+
* heatmap. When the list is exhausted the universal fallback applies: render
|
|
49
|
+
* the underlying frame as a table.
|
|
50
|
+
*/
|
|
51
|
+
fallback?: readonly PlotSpec[];
|
|
52
|
+
};
|
|
53
|
+
/** Small multiples: one plot repeated over the distinct values of a field. */
|
|
54
|
+
export type FacetSpec = {
|
|
55
|
+
kind: "facet";
|
|
56
|
+
row?: string;
|
|
57
|
+
column?: string;
|
|
58
|
+
plot: PlotSpec;
|
|
59
|
+
/** Whether facets share one scale per channel. Default `true`. */
|
|
60
|
+
sharedScales?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/** Several marks in one coordinate space, sharing scales. */
|
|
63
|
+
export type LayerSpec = {
|
|
64
|
+
kind: "layer";
|
|
65
|
+
layers: readonly PlotSpec[];
|
|
66
|
+
coord?: CoordSpec;
|
|
67
|
+
title?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
};
|
|
70
|
+
/** Independent plots side by side, each with its own scales. */
|
|
71
|
+
export type ConcatSpec = {
|
|
72
|
+
kind: "concat";
|
|
73
|
+
direction: "horizontal" | "vertical" | "wrap";
|
|
74
|
+
views: readonly ViewSpec[];
|
|
75
|
+
title?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
};
|
|
78
|
+
/** A single plot, or any composition of them. */
|
|
79
|
+
export type ViewSpec = ({
|
|
80
|
+
kind: "plot";
|
|
81
|
+
} & PlotSpec) | LayerSpec | FacetSpec | ConcatSpec;
|
|
82
|
+
//# sourceMappingURL=plot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/spec/plot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IAAI,EAAE,QAAQ,CAAC;IACf,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IAC9C,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GACjB,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC,GAC7B,SAAS,GACT,SAAS,GACT,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/spec/plot.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Value } from "@ac-kit/model-dataset";
|
|
2
|
+
/**
|
|
3
|
+
* How a field's values map onto a channel's positions.
|
|
4
|
+
*
|
|
5
|
+
* A scale declares a **domain** and never a range: the range is pixels, cells
|
|
6
|
+
* or radians, and only the renderer knows which. This is the single rule that
|
|
7
|
+
* lets one spec drive a canvas and an eighty-column terminal.
|
|
8
|
+
*/
|
|
9
|
+
export type ScaleKind = "linear" | "log" | "pow" | "sqrt" | "symlog" | "time"
|
|
10
|
+
/** Discrete input, discrete output: a colour per category. */
|
|
11
|
+
| "ordinal"
|
|
12
|
+
/** Discrete input, contiguous bands: the usual bar-chart position scale. */
|
|
13
|
+
| "band"
|
|
14
|
+
/** Discrete input, points with no width: a categorical scatter axis. */
|
|
15
|
+
| "point"
|
|
16
|
+
/** Continuous input, discrete output, by equal-count buckets. */
|
|
17
|
+
| "quantile"
|
|
18
|
+
/** Continuous input, discrete output, by equal-width buckets. */
|
|
19
|
+
| "quantize"
|
|
20
|
+
/** Continuous input, discrete output, at caller-supplied cut points. */
|
|
21
|
+
| "threshold"
|
|
22
|
+
/** Values pass through unmapped; the field is already in output terms. */
|
|
23
|
+
| "identity";
|
|
24
|
+
/**
|
|
25
|
+
* A colour ramp named by intent, never by hex.
|
|
26
|
+
*
|
|
27
|
+
* A terminal with no colour maps a sequential scheme to a glyph ramp; a canvas
|
|
28
|
+
* maps it to RGB. A literal colour in the spec forbids the first.
|
|
29
|
+
*/
|
|
30
|
+
export type ColorSchemeSpec = {
|
|
31
|
+
kind: "categorical" | "sequential" | "diverging" | "cyclic";
|
|
32
|
+
/** Well-known ramp name, e.g. `"viridis"`, `"tableau10"`, `"rdbu"`. */
|
|
33
|
+
name?: string;
|
|
34
|
+
reverse?: boolean;
|
|
35
|
+
/** Where a diverging scheme's neutral colour sits. Default `0`. */
|
|
36
|
+
midpoint?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* One channel's mapping from data values to visual positions.
|
|
40
|
+
*
|
|
41
|
+
* Every field is optional: an omitted `kind` lets the renderer infer one from
|
|
42
|
+
* the field's type, and an omitted `domain` lets it read the extent off the
|
|
43
|
+
* data. Nothing here is expressed in output units — see {@link ScaleKind}.
|
|
44
|
+
*/
|
|
45
|
+
export type ScaleSpec = {
|
|
46
|
+
kind?: ScaleKind;
|
|
47
|
+
/**
|
|
48
|
+
* Explicit domain. Absent means "derive it from the data", which is what a
|
|
49
|
+
* renderer normally does.
|
|
50
|
+
*/
|
|
51
|
+
domain?: readonly Value[];
|
|
52
|
+
/** Extends a derived numeric domain to include zero. */
|
|
53
|
+
zero?: boolean;
|
|
54
|
+
/** Rounds a derived numeric domain outward to human-readable bounds. */
|
|
55
|
+
nice?: boolean;
|
|
56
|
+
/** Clamps out-of-domain values to the nearest bound instead of dropping them. */
|
|
57
|
+
clamp?: boolean;
|
|
58
|
+
/** Reverses the direction of the mapping. */
|
|
59
|
+
reverse?: boolean;
|
|
60
|
+
/** Exponent for `"pow"`. Default `1`. */
|
|
61
|
+
exponent?: number;
|
|
62
|
+
/** Base for `"log"`. Default `10`. */
|
|
63
|
+
base?: number;
|
|
64
|
+
/** Fraction of a band left empty between adjacent bands. `0` to `1`. */
|
|
65
|
+
padding?: number;
|
|
66
|
+
/** Colour channels only. */
|
|
67
|
+
scheme?: ColorSchemeSpec;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=scale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/spec/scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAClB,QAAQ,GACR,KAAK,GACL,KAAK,GACL,MAAM,GACN,QAAQ,GACR,MAAM;AACR,8DAA8D;GAC5D,SAAS;AACX,4EAA4E;GAC1E,MAAM;AACR,wEAAwE;GACtE,OAAO;AACT,iEAAiE;GAC/D,UAAU;AACZ,iEAAiE;GAC/D,UAAU;AACZ,wEAAwE;GACtE,WAAW;AACb,0EAA0E;GACxE,UAAU,CAAC;AAEd;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC5D,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAC1B,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iFAAiF;IACjF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale.js","sourceRoot":"","sources":["../../src/spec/scale.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Value } from "@ac-kit/model-dataset";
|
|
2
|
+
/** Reductions a transform may apply to a group of rows. */
|
|
3
|
+
export type AggregateOp = "count" | "distinct" | "sum" | "mean" | "median" | "min" | "max" | "variance" | "stdev" | "q1" | "q3";
|
|
4
|
+
/**
|
|
5
|
+
* Binning is declared, never pre-applied.
|
|
6
|
+
*
|
|
7
|
+
* A frame that already carries buckets cannot be re-fitted: an eighty-column
|
|
8
|
+
* terminal, a 1200 px canvas and an eight-cell sparkline each want a different
|
|
9
|
+
* bucket count. Carrying the raw values plus this intent lets each renderer
|
|
10
|
+
* choose.
|
|
11
|
+
*/
|
|
12
|
+
export type BinTransform = {
|
|
13
|
+
kind: "bin";
|
|
14
|
+
field: string;
|
|
15
|
+
/** Upper bound on bucket count. The renderer picks a nice width under it. */
|
|
16
|
+
maxBins?: number;
|
|
17
|
+
/** Exact bucket width, overriding `maxBins`. */
|
|
18
|
+
step?: number;
|
|
19
|
+
/** Bucket-width rule when neither is given. Default `"freedman-diaconis"`. */
|
|
20
|
+
rule?: "sturges" | "scott" | "freedman-diaconis";
|
|
21
|
+
/** Names for the two bound fields the transform produces. */
|
|
22
|
+
as?: readonly [string, string];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Collapses each group of rows to one row, applying the named reductions.
|
|
26
|
+
*
|
|
27
|
+
* `groupBy` names the fields that define a group; an empty list reduces the
|
|
28
|
+
* whole frame to a single row.
|
|
29
|
+
*/
|
|
30
|
+
export type AggregateTransform = {
|
|
31
|
+
kind: "aggregate";
|
|
32
|
+
/** Fields to group by. Empty groups the whole frame into one row. */
|
|
33
|
+
groupBy: readonly string[];
|
|
34
|
+
ops: readonly {
|
|
35
|
+
op: AggregateOp;
|
|
36
|
+
field?: string;
|
|
37
|
+
as: string;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Turns overlapping values into contiguous ones: the difference between a
|
|
42
|
+
* grouped bar chart and a stacked one, and between an area chart and a
|
|
43
|
+
* streamgraph.
|
|
44
|
+
*/
|
|
45
|
+
export type StackTransform = {
|
|
46
|
+
kind: "stack";
|
|
47
|
+
field: string;
|
|
48
|
+
groupBy: readonly string[];
|
|
49
|
+
/** `"zero"` stacks from a baseline, `"normalize"` to a share of one. */
|
|
50
|
+
offset?: "zero" | "normalize" | "center";
|
|
51
|
+
as?: readonly [string, string];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Reorders rows, which for a categorical axis is also what orders the axis.
|
|
55
|
+
*
|
|
56
|
+
* Declared rather than pre-applied, because a frame sorted for one chart is
|
|
57
|
+
* sorted wrongly for the next one drawn from it.
|
|
58
|
+
*/
|
|
59
|
+
export type SortTransform = {
|
|
60
|
+
kind: "sort";
|
|
61
|
+
by: readonly {
|
|
62
|
+
field: string;
|
|
63
|
+
order?: "ascending" | "descending";
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Keeps only the rows matching one comparison.
|
|
68
|
+
*
|
|
69
|
+
* `value` is omitted for `not-null`, and is an array for `in`.
|
|
70
|
+
*/
|
|
71
|
+
export type FilterTransform = {
|
|
72
|
+
kind: "filter";
|
|
73
|
+
field: string;
|
|
74
|
+
op: "=" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-null";
|
|
75
|
+
value?: Value | readonly Value[];
|
|
76
|
+
};
|
|
77
|
+
/** Kernel density estimate over one continuous field. */
|
|
78
|
+
export type DensityTransform = {
|
|
79
|
+
kind: "density";
|
|
80
|
+
field: string;
|
|
81
|
+
groupBy?: readonly string[];
|
|
82
|
+
bandwidth?: number;
|
|
83
|
+
/** Sample count across the domain. Default is renderer-chosen. */
|
|
84
|
+
steps?: number;
|
|
85
|
+
as?: readonly [string, string];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Fits a trend line through a scatter of points.
|
|
89
|
+
*
|
|
90
|
+
* `method` names the shape being fitted, `order` the degree when that shape is
|
|
91
|
+
* a polynomial. The fit is an assertion about the data, not a reading of it,
|
|
92
|
+
* which is why it is a transform and not a second frame.
|
|
93
|
+
*/
|
|
94
|
+
export type RegressionTransform = {
|
|
95
|
+
kind: "regression";
|
|
96
|
+
x: string;
|
|
97
|
+
y: string;
|
|
98
|
+
method?: "linear" | "log" | "exp" | "pow" | "quad" | "poly" | "loess";
|
|
99
|
+
order?: number;
|
|
100
|
+
groupBy?: readonly string[];
|
|
101
|
+
};
|
|
102
|
+
/** Running reduction over an ordered window: cumulative sums, moving averages. */
|
|
103
|
+
export type WindowTransform = {
|
|
104
|
+
kind: "window";
|
|
105
|
+
ops: readonly {
|
|
106
|
+
op: AggregateOp | "rank" | "lag" | "lead";
|
|
107
|
+
field?: string;
|
|
108
|
+
as: string;
|
|
109
|
+
}[];
|
|
110
|
+
sort?: readonly {
|
|
111
|
+
field: string;
|
|
112
|
+
order?: "ascending" | "descending";
|
|
113
|
+
}[];
|
|
114
|
+
groupBy?: readonly string[];
|
|
115
|
+
/** `[before, after]` row counts; `null` means unbounded on that side. */
|
|
116
|
+
frame?: readonly [number | null, number | null];
|
|
117
|
+
};
|
|
118
|
+
/** Isolines or isobands over a two-dimensional scalar field. */
|
|
119
|
+
export type ContourTransform = {
|
|
120
|
+
kind: "contour";
|
|
121
|
+
x: string;
|
|
122
|
+
y: string;
|
|
123
|
+
weight?: string;
|
|
124
|
+
thresholds?: readonly number[];
|
|
125
|
+
as?: string;
|
|
126
|
+
};
|
|
127
|
+
/** Bins scattered points into equal-area cells, resolving overplotting. */
|
|
128
|
+
export type SpatialBinTransform = {
|
|
129
|
+
kind: "spatial-bin";
|
|
130
|
+
x: string;
|
|
131
|
+
y: string;
|
|
132
|
+
shape?: "rect" | "hex";
|
|
133
|
+
/** Cell radius in domain units. */
|
|
134
|
+
radius?: number;
|
|
135
|
+
as?: readonly [string, string, string];
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* A declarative step between the frame and the encoding.
|
|
139
|
+
*
|
|
140
|
+
* Transforms are data operations with names and complexities, so their
|
|
141
|
+
* implementations live in `@ac-kit/math-stats`, `@ac-kit/math-grid` and
|
|
142
|
+
* `@ac-kit/algo`; this vocabulary only says which one to apply.
|
|
143
|
+
*/
|
|
144
|
+
export type TransformSpec = BinTransform | AggregateTransform | StackTransform | SortTransform | FilterTransform | DensityTransform | RegressionTransform | WindowTransform | ContourTransform | SpatialBinTransform;
|
|
145
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/spec/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GACpB,OAAO,GACP,UAAU,GACV,KAAK,GACL,MAAM,GACN,QAAQ,GACR,KAAK,GACL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SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAAA;KAAE,EAAE,CAAC;IACxE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CAChD,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACtB,YAAY,GACZ,kBAAkB,GAClB,cAAc,GACd,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/spec/transform.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ac-kit/model-chart",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A description of a chart, independent of the medium it will be drawn in.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"chart",
|
|
7
|
+
"grammar-of-graphics",
|
|
8
|
+
"plot",
|
|
9
|
+
"visualization"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://anthochamp.github.io/node-essentials/api/model-chart/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/anthochamp/node-essentials/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "BSD-3-Clause",
|
|
16
|
+
"author": "Anthony Champagne <dev@anthonychampagne.fr>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/anthochamp/node-essentials.git",
|
|
20
|
+
"directory": "packages/model-chart"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"compile": "tsc -p ./tsconfig.build.json -outDir dist",
|
|
40
|
+
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
41
|
+
"clean": "rimraf dist",
|
|
42
|
+
"build": "yarn clean && yarn compile",
|
|
43
|
+
"test": "yarn run -T vitest run",
|
|
44
|
+
"prepack": "yarn build"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@ac-kit/model-dataset": "^0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@ac-kit/tsconfig": "0.1.0",
|
|
51
|
+
"@ac-kit/typedoc-config": "0.1.0",
|
|
52
|
+
"@ac-kit/vitest-config": "0.1.0",
|
|
53
|
+
"@typescript/native": "typescript@7.0.2",
|
|
54
|
+
"rimraf": "6.1.3",
|
|
55
|
+
"typedoc": "0.28.20",
|
|
56
|
+
"typescript": "@typescript/typescript6@6.0.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=24"
|
|
60
|
+
}
|
|
61
|
+
}
|