@jarenjs/charts 0.34.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/README.md +293 -0
- package/dist/types/component/index.d.ts +95 -0
- package/dist/types/core/axis.d.ts +77 -0
- package/dist/types/core/cartesian.d.ts +127 -0
- package/dist/types/core/chart.d.ts +58 -0
- package/dist/types/core/domain.d.ts +96 -0
- package/dist/types/core/marks.d.ts +86 -0
- package/dist/types/core/palette.d.ts +72 -0
- package/dist/types/core/scale.d.ts +59 -0
- package/dist/types/core/session.d.ts +85 -0
- package/dist/types/core/stream-adapter.d.ts +187 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/transforms/benchmark-adapter.d.ts +169 -0
- package/dist/types/transforms/mermaid-adapter.d.ts +30 -0
- package/dist/types/types/bar.d.ts +213 -0
- package/dist/types/types/boxplot.d.ts +116 -0
- package/dist/types/types/candlestick.d.ts +218 -0
- package/dist/types/types/gauge.d.ts +68 -0
- package/dist/types/types/heatmap.d.ts +104 -0
- package/dist/types/types/line.d.ts +272 -0
- package/dist/types/types/map.d.ts +137 -0
- package/dist/types/types/pie.d.ts +146 -0
- package/dist/types/types/radar.d.ts +89 -0
- package/dist/types/types/sankey.d.ts +100 -0
- package/dist/types/types/scatter.d.ts +80 -0
- package/dist/types/types/streamgraph.d.ts +75 -0
- package/dist/types/types/treemap.d.ts +118 -0
- package/package.json +76 -0
- package/schemas/chart-definition.schema.json +448 -0
- package/src/component/index.js +125 -0
- package/src/core/axis.js +221 -0
- package/src/core/cartesian.js +192 -0
- package/src/core/chart.js +101 -0
- package/src/core/domain.js +123 -0
- package/src/core/marks.js +110 -0
- package/src/core/palette.js +126 -0
- package/src/core/scale.js +106 -0
- package/src/core/session.js +0 -0
- package/src/core/stream-adapter.js +613 -0
- package/src/index.js +40 -0
- package/src/transforms/benchmark-adapter.js +298 -0
- package/src/transforms/mermaid-adapter.js +19 -0
- package/src/types/bar.js +276 -0
- package/src/types/boxplot.js +216 -0
- package/src/types/candlestick.js +274 -0
- package/src/types/gauge.js +140 -0
- package/src/types/heatmap.js +176 -0
- package/src/types/line.js +349 -0
- package/src/types/map.js +378 -0
- package/src/types/pie.js +163 -0
- package/src/types/radar.js +224 -0
- package/src/types/sankey.js +391 -0
- package/src/types/scatter.js +148 -0
- package/src/types/streamgraph.js +158 -0
- package/src/types/treemap.js +322 -0
- package/styles/charts.css +83 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The map chart type: GeoJSON drawn in Web Mercator, optionally
|
|
3
|
+
* shaded by a feature property (a choropleth). Data shape:
|
|
4
|
+
*
|
|
5
|
+
* data = { features: <FeatureCollection | Feature[] | Feature>,
|
|
6
|
+
* points?: [{ at: [lon, lat], label?, value? }] }
|
|
7
|
+
* config = { type:'map', title?, value?, label?, log?, simplify?, aspect? }
|
|
8
|
+
*
|
|
9
|
+
* `value` names the feature property to shade by and `label` the one to
|
|
10
|
+
* name features by (default `'name'`); `points` is the convenience path
|
|
11
|
+
* for a caller holding a list of places rather than GeoJSON, and folds
|
|
12
|
+
* into the same shape list at build time so the AST has one.
|
|
13
|
+
*
|
|
14
|
+
* The AST is unit-space rings, lines and dots plus a normalized
|
|
15
|
+
* magnitude per shape — the projection and the simplification happen in
|
|
16
|
+
* the build (they are geometry *of the data*, not of the drawing), the
|
|
17
|
+
* colors, the stroke widths and the ramp legend in the render.
|
|
18
|
+
*
|
|
19
|
+
* Two things are worth knowing about the projection. It is Web Mercator
|
|
20
|
+
* because that is what every reader's mental model of a map already is,
|
|
21
|
+
* and it is applied **only here**: nothing measures on the result, and
|
|
22
|
+
* `@jarenjs/core/geo` keeps its area and distance functions on the
|
|
23
|
+
* sphere for exactly that reason. And it is fitted uniformly — the map
|
|
24
|
+
* is centred in whichever axis has room left over rather than stretched
|
|
25
|
+
* to fill the frame, which is the single most common way to make a map
|
|
26
|
+
* look wrong.
|
|
27
|
+
*/
|
|
28
|
+
export type MapShapeAST = {
|
|
29
|
+
label: string;
|
|
30
|
+
/**
|
|
31
|
+
* the shading property, when the feature had one
|
|
32
|
+
*/
|
|
33
|
+
value: number | null;
|
|
34
|
+
/**
|
|
35
|
+
* normalized magnitude (0..1), null when unshaded
|
|
36
|
+
*/
|
|
37
|
+
t: number | null;
|
|
38
|
+
/**
|
|
39
|
+
* polygon rings in unit space,
|
|
40
|
+
* exterior first then holes; `[u, v]` with v growing downward
|
|
41
|
+
*/
|
|
42
|
+
rings: Array<Array<number[]>>;
|
|
43
|
+
/**
|
|
44
|
+
* line strings in unit space
|
|
45
|
+
*/
|
|
46
|
+
lines: Array<Array<number[]>>;
|
|
47
|
+
/**
|
|
48
|
+
* point positions in unit space
|
|
49
|
+
*/
|
|
50
|
+
dots: Array<number[]>;
|
|
51
|
+
};
|
|
52
|
+
export type MapAST = {
|
|
53
|
+
type: 'map';
|
|
54
|
+
title: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* layout width:height ratio
|
|
57
|
+
*/
|
|
58
|
+
aspect: number;
|
|
59
|
+
/**
|
|
60
|
+
* the geographic extent drawn, `[w,s,e,n]`
|
|
61
|
+
*/
|
|
62
|
+
bbox: number[] | null;
|
|
63
|
+
shapes: MapShapeAST[];
|
|
64
|
+
/**
|
|
65
|
+
* shading extent (null = unshaded)
|
|
66
|
+
*/
|
|
67
|
+
domain: {
|
|
68
|
+
min: number;
|
|
69
|
+
max: number;
|
|
70
|
+
} | null;
|
|
71
|
+
/**
|
|
72
|
+
* positions read vs kept
|
|
73
|
+
*/
|
|
74
|
+
vertices: {
|
|
75
|
+
source: number;
|
|
76
|
+
drawn: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {object} MapShapeAST
|
|
81
|
+
* @property {string} label
|
|
82
|
+
* @property {number|null} value the shading property, when the feature had one
|
|
83
|
+
* @property {number|null} t normalized magnitude (0..1), null when unshaded
|
|
84
|
+
* @property {Array<Array<number[]>>} rings polygon rings in unit space,
|
|
85
|
+
* exterior first then holes; `[u, v]` with v growing downward
|
|
86
|
+
* @property {Array<Array<number[]>>} lines line strings in unit space
|
|
87
|
+
* @property {Array<number[]>} dots point positions in unit space
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {object} MapAST
|
|
91
|
+
* @property {'map'} type
|
|
92
|
+
* @property {string|null} title
|
|
93
|
+
* @property {number} aspect layout width:height ratio
|
|
94
|
+
* @property {number[]|null} bbox the geographic extent drawn, `[w,s,e,n]`
|
|
95
|
+
* @property {MapShapeAST[]} shapes
|
|
96
|
+
* @property {{min: number, max: number}|null} domain shading extent (null = unshaded)
|
|
97
|
+
* @property {{source: number, drawn: number}} vertices positions read vs kept
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Default simplification tolerance, as a fraction of the frame's width.
|
|
101
|
+
* At the default 560px-wide chart this is about a third of a pixel, so
|
|
102
|
+
* the simplification is invisible by construction: it can only remove
|
|
103
|
+
* vertices that would have landed on a neighbour's pixel anyway. A
|
|
104
|
+
* caller drawing much larger passes a smaller number, and `false`
|
|
105
|
+
* switches it off. Exported because the streaming map accumulator
|
|
106
|
+
* simplifies on arrival with the same default.
|
|
107
|
+
*/
|
|
108
|
+
export declare const MAP_SIMPLIFY = 0.0006;
|
|
109
|
+
/**
|
|
110
|
+
* Build the geometry-free map AST.
|
|
111
|
+
* @param {any} data
|
|
112
|
+
* @param {any} [config]
|
|
113
|
+
* @returns {MapAST}
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildMapAST(data: any, config?: any): MapAST;
|
|
116
|
+
/**
|
|
117
|
+
* Render a map AST to a pure-vnode SVG: one filled path per shape (all
|
|
118
|
+
* its rings as subpaths, `evenodd` so holes punch through whichever way
|
|
119
|
+
* the producer wound them), stroked paths for lines, dots for points,
|
|
120
|
+
* and a ramp key in the legend slot when the map is shaded.
|
|
121
|
+
* @param {MapAST} ast
|
|
122
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
123
|
+
* @param {string} hash
|
|
124
|
+
* @param {{rootClass?: string, keyPrefix?: string, ramp?: readonly string[], width?: number,
|
|
125
|
+
* tooltip?: import('../core/marks.js').ChartTooltipSpec}} [options]
|
|
126
|
+
* @returns {any}
|
|
127
|
+
*/
|
|
128
|
+
export declare function renderMapAST(ast: MapAST, theme: {
|
|
129
|
+
tokens: Record<string, string>;
|
|
130
|
+
cssVars: Record<string, string>;
|
|
131
|
+
}, hash: string, options?: {
|
|
132
|
+
rootClass?: string;
|
|
133
|
+
keyPrefix?: string;
|
|
134
|
+
ramp?: readonly string[];
|
|
135
|
+
width?: number;
|
|
136
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
137
|
+
}): any;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The pie chart type, split into the geometry-free AST build and
|
|
3
|
+
* the SVG render (the two-stage contract every chart type follows).
|
|
4
|
+
* This is the extraction of the mermaid pie: `@jarenjs/mermaid` now
|
|
5
|
+
* delegates its `pie` diagrams here, passing its own class names,
|
|
6
|
+
* palette and theme through `render` options so its output is unchanged
|
|
7
|
+
* — charts never imports mermaid (the dependency arrow is one-way).
|
|
8
|
+
*/
|
|
9
|
+
export type PieSliceAST = {
|
|
10
|
+
label: string;
|
|
11
|
+
value: number;
|
|
12
|
+
/**
|
|
13
|
+
* fraction of the total (0..1)
|
|
14
|
+
*/
|
|
15
|
+
frac: number;
|
|
16
|
+
/**
|
|
17
|
+
* start angle (radians, 12 o'clock = -π/2)
|
|
18
|
+
*/
|
|
19
|
+
start: number;
|
|
20
|
+
/**
|
|
21
|
+
* end angle (radians)
|
|
22
|
+
*/
|
|
23
|
+
end: number;
|
|
24
|
+
};
|
|
25
|
+
export type PieAST = {
|
|
26
|
+
type: 'pie';
|
|
27
|
+
title: string | null;
|
|
28
|
+
total: number;
|
|
29
|
+
/**
|
|
30
|
+
* donut hole radius as a fraction of the outer radius (null = solid pie)
|
|
31
|
+
*/
|
|
32
|
+
inner: number | null;
|
|
33
|
+
slices: PieSliceAST[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {object} PieSliceAST
|
|
37
|
+
* @property {string} label
|
|
38
|
+
* @property {number} value
|
|
39
|
+
* @property {number} frac fraction of the total (0..1)
|
|
40
|
+
* @property {number} start start angle (radians, 12 o'clock = -π/2)
|
|
41
|
+
* @property {number} end end angle (radians)
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {object} PieAST
|
|
45
|
+
* @property {'pie'} type
|
|
46
|
+
* @property {string|null} title
|
|
47
|
+
* @property {number} total
|
|
48
|
+
* @property {number|null} inner donut hole radius as a fraction of the outer radius (null = solid pie)
|
|
49
|
+
* @property {PieSliceAST[]} slices
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Build the geometry-free pie AST: labels/values → fractions and
|
|
53
|
+
* accumulated start/end angles, starting at 12 o'clock. `config.donut`
|
|
54
|
+
* turns the pie into a donut: `true` uses the default hole fraction,
|
|
55
|
+
* a number in (0, 1) sets it directly.
|
|
56
|
+
* @param {{slices?: {label: string, value: number}[]}} data
|
|
57
|
+
* @param {{title?: string|null, donut?: boolean|number}} [config]
|
|
58
|
+
* @returns {PieAST}
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildPieAST(data: {
|
|
61
|
+
slices?: {
|
|
62
|
+
label: string;
|
|
63
|
+
value: number;
|
|
64
|
+
}[];
|
|
65
|
+
}, config?: {
|
|
66
|
+
title?: string | null;
|
|
67
|
+
donut?: boolean | number;
|
|
68
|
+
}): PieAST;
|
|
69
|
+
export type PieRenderOptions = {
|
|
70
|
+
/**
|
|
71
|
+
* the root `<svg>` class
|
|
72
|
+
*/
|
|
73
|
+
rootClass?: string;
|
|
74
|
+
/**
|
|
75
|
+
* vnode key prefix (`<prefix><hash>`)
|
|
76
|
+
*/
|
|
77
|
+
keyPrefix?: string;
|
|
78
|
+
/**
|
|
79
|
+
* class per slice `<path>`
|
|
80
|
+
*/
|
|
81
|
+
sliceClass?: string;
|
|
82
|
+
/**
|
|
83
|
+
* class per legend `<g>`
|
|
84
|
+
*/
|
|
85
|
+
legendClass?: string;
|
|
86
|
+
/**
|
|
87
|
+
* slice colors
|
|
88
|
+
*/
|
|
89
|
+
palette?: readonly string[];
|
|
90
|
+
/**
|
|
91
|
+
* title/legend text fill
|
|
92
|
+
*/
|
|
93
|
+
textColor?: string;
|
|
94
|
+
/**
|
|
95
|
+
* slice separator stroke
|
|
96
|
+
*/
|
|
97
|
+
sliceStroke?: string;
|
|
98
|
+
/**
|
|
99
|
+
* per-slice hover `<title>` (default true).
|
|
100
|
+
* `@jarenjs/mermaid` turns it off: a mermaid pie is a *diagram*, and
|
|
101
|
+
* its emitted SVG is a byte-stable contract that hover text would
|
|
102
|
+
* break — the delegation exists to share geometry, not to change what
|
|
103
|
+
* mermaid renders.
|
|
104
|
+
*/
|
|
105
|
+
titles?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* pointer bindings for a floating-tooltip host
|
|
108
|
+
*/
|
|
109
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* @typedef {object} PieRenderOptions
|
|
113
|
+
* @property {string} [rootClass] the root `<svg>` class
|
|
114
|
+
* @property {string} [keyPrefix] vnode key prefix (`<prefix><hash>`)
|
|
115
|
+
* @property {string} [sliceClass] class per slice `<path>`
|
|
116
|
+
* @property {string} [legendClass] class per legend `<g>`
|
|
117
|
+
* @property {readonly string[]} [palette] slice colors
|
|
118
|
+
* @property {string} [textColor] title/legend text fill
|
|
119
|
+
* @property {string} [sliceStroke] slice separator stroke
|
|
120
|
+
* @property {boolean} [titles] per-slice hover `<title>` (default true).
|
|
121
|
+
* `@jarenjs/mermaid` turns it off: a mermaid pie is a *diagram*, and
|
|
122
|
+
* its emitted SVG is a byte-stable contract that hover text would
|
|
123
|
+
* break — the delegation exists to share geometry, not to change what
|
|
124
|
+
* mermaid renders.
|
|
125
|
+
* @property {import('../core/marks.js').ChartTooltipSpec} [tooltip]
|
|
126
|
+
* pointer bindings for a floating-tooltip host
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Render a pie AST to a pure-vnode SVG: angles → arc paths, plus a
|
|
130
|
+
* swatch legend with percentages and an optional title. With
|
|
131
|
+
* `ast.inner === null` (no `donut` in the config) the slice path is
|
|
132
|
+
* emitted by the same wedge template as before the donut variant
|
|
133
|
+
* existed — solid-pie output is byte-stable, which is what keeps the
|
|
134
|
+
* mermaid delegation byte-identical; the annular geometry lives
|
|
135
|
+
* entirely in the other branch. Every slice carries a label/value
|
|
136
|
+
* `<title>` unless `options.titles` is false (mermaid's opt-out).
|
|
137
|
+
* @param {PieAST} ast
|
|
138
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
139
|
+
* @param {string} hash content hash for the vnode key
|
|
140
|
+
* @param {PieRenderOptions} [options]
|
|
141
|
+
* @returns {any} an SVG vnode
|
|
142
|
+
*/
|
|
143
|
+
export declare function renderPieAST(ast: PieAST, theme: {
|
|
144
|
+
tokens: Record<string, string>;
|
|
145
|
+
cssVars: Record<string, string>;
|
|
146
|
+
}, hash: string, options?: PieRenderOptions): any;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The radar chart type: N named axes as spokes from a shared
|
|
3
|
+
* center, one polygon per series over a common 0..top value domain.
|
|
4
|
+
* Data shape:
|
|
5
|
+
*
|
|
6
|
+
* data = { axes: string[], series: [{ name, values: number[] }] }
|
|
7
|
+
* config = { type:'radar', title?, max? }
|
|
8
|
+
*
|
|
9
|
+
* The AST stays polar and geometry-free: axis angles in radians
|
|
10
|
+
* (12 o'clock = -π/2, clockwise), ring and vertex radii as fractions of
|
|
11
|
+
* the (unknown) outer radius. Non-finite or negative samples become
|
|
12
|
+
* `null` vertices — the polygon simply skips them, mirroring how the
|
|
13
|
+
* line type breaks its path on unplottable samples.
|
|
14
|
+
*/
|
|
15
|
+
export type RadarAST = {
|
|
16
|
+
type: 'radar';
|
|
17
|
+
title: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* value at the outer ring
|
|
20
|
+
*/
|
|
21
|
+
top: number;
|
|
22
|
+
axes: {
|
|
23
|
+
label: string;
|
|
24
|
+
angle: number;
|
|
25
|
+
labeled: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
/**
|
|
28
|
+
* spoke-label stride (1 = label every axis)
|
|
29
|
+
*/
|
|
30
|
+
labelEvery: number;
|
|
31
|
+
/**
|
|
32
|
+
* tick fractions (0..1]
|
|
33
|
+
*/
|
|
34
|
+
rings: {
|
|
35
|
+
r: number;
|
|
36
|
+
label: string;
|
|
37
|
+
}[];
|
|
38
|
+
series: {
|
|
39
|
+
name: string;
|
|
40
|
+
points: ({
|
|
41
|
+
angle: number;
|
|
42
|
+
r: number;
|
|
43
|
+
} | null)[];
|
|
44
|
+
}[];
|
|
45
|
+
legend: {
|
|
46
|
+
name: string;
|
|
47
|
+
swatch: number;
|
|
48
|
+
}[] | null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {object} RadarAST
|
|
52
|
+
* @property {'radar'} type
|
|
53
|
+
* @property {string|null} title
|
|
54
|
+
* @property {number} top value at the outer ring
|
|
55
|
+
* @property {{label: string, angle: number, labeled: boolean}[]} axes
|
|
56
|
+
* @property {number} labelEvery spoke-label stride (1 = label every axis)
|
|
57
|
+
* @property {{r: number, label: string}[]} rings tick fractions (0..1]
|
|
58
|
+
* @property {{name: string, points: ({angle: number, r: number}|null)[]}[]} series
|
|
59
|
+
* @property {{name: string, swatch: number}[]|null} legend
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Build the geometry-free radar AST.
|
|
63
|
+
* `config.labelEvery` overrides the spoke-label stride; by default it
|
|
64
|
+
* is derived from the axis count (see {@link radarLabelEvery}).
|
|
65
|
+
* @param {any} data
|
|
66
|
+
* @param {any} [config]
|
|
67
|
+
* @returns {RadarAST}
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildRadarAST(data: any, config?: any): RadarAST;
|
|
70
|
+
/**
|
|
71
|
+
* Render a radar AST to a pure-vnode SVG: ring polygons and spokes for
|
|
72
|
+
* the scale, one translucent polygon with vertex dots per series, a
|
|
73
|
+
* swatch legend on the right.
|
|
74
|
+
* @param {RadarAST} ast
|
|
75
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
76
|
+
* @param {string} hash
|
|
77
|
+
* @param {{rootClass?: string, keyPrefix?: string, palette?: readonly string[],
|
|
78
|
+
* tooltip?: import('../core/marks.js').ChartTooltipSpec}} [options]
|
|
79
|
+
* @returns {any}
|
|
80
|
+
*/
|
|
81
|
+
export declare function renderRadarAST(ast: RadarAST, theme: {
|
|
82
|
+
tokens: Record<string, string>;
|
|
83
|
+
cssVars: Record<string, string>;
|
|
84
|
+
}, hash: string, options?: {
|
|
85
|
+
rootClass?: string;
|
|
86
|
+
keyPrefix?: string;
|
|
87
|
+
palette?: readonly string[];
|
|
88
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
89
|
+
}): any;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The sankey chart type: named nodes in flow layers joined by
|
|
3
|
+
* value-proportional ribbons. Data shape:
|
|
4
|
+
*
|
|
5
|
+
* data = { nodes?: (string | { name })[],
|
|
6
|
+
* links: [{ source, target, value }] } // by name or node index
|
|
7
|
+
* config = { type:'sankey', title? }
|
|
8
|
+
*
|
|
9
|
+
* Names referenced only by links are added as nodes automatically. A
|
|
10
|
+
* link that would close a cycle is dropped (a sankey is a DAG); so are
|
|
11
|
+
* self-links and non-positive values. Layout: a node's layer is its
|
|
12
|
+
* longest path from the sources; within a layer nodes stack in input
|
|
13
|
+
* order, sized by throughput (max of in-flow and out-flow) on one
|
|
14
|
+
* global scale, centered vertically. The AST is unit-square with `y`
|
|
15
|
+
* growing downward (no axes — reading order wins, as in the treemap).
|
|
16
|
+
*/
|
|
17
|
+
export type SankeyNodeAST = {
|
|
18
|
+
name: string;
|
|
19
|
+
layer: number;
|
|
20
|
+
x0: number;
|
|
21
|
+
x1: number;
|
|
22
|
+
y0: number;
|
|
23
|
+
y1: number;
|
|
24
|
+
};
|
|
25
|
+
export type SankeyLinkAST = {
|
|
26
|
+
/**
|
|
27
|
+
* node index
|
|
28
|
+
*/
|
|
29
|
+
source: number;
|
|
30
|
+
/**
|
|
31
|
+
* node index
|
|
32
|
+
*/
|
|
33
|
+
target: number;
|
|
34
|
+
value: number;
|
|
35
|
+
sy0: number;
|
|
36
|
+
/**
|
|
37
|
+
* ribbon extent at the source
|
|
38
|
+
*/
|
|
39
|
+
sy1: number;
|
|
40
|
+
ty0: number;
|
|
41
|
+
/**
|
|
42
|
+
* ribbon extent at the target
|
|
43
|
+
*/
|
|
44
|
+
ty1: number;
|
|
45
|
+
};
|
|
46
|
+
export type SankeyAST = {
|
|
47
|
+
type: 'sankey';
|
|
48
|
+
title: string | null;
|
|
49
|
+
nodes: SankeyNodeAST[];
|
|
50
|
+
links: SankeyLinkAST[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {object} SankeyNodeAST
|
|
54
|
+
* @property {string} name
|
|
55
|
+
* @property {number} layer
|
|
56
|
+
* @property {number} x0 @property {number} x1
|
|
57
|
+
* @property {number} y0 @property {number} y1
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {object} SankeyLinkAST
|
|
61
|
+
* @property {number} source node index @property {number} target node index
|
|
62
|
+
* @property {number} value
|
|
63
|
+
* @property {number} sy0 @property {number} sy1 ribbon extent at the source
|
|
64
|
+
* @property {number} ty0 @property {number} ty1 ribbon extent at the target
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* @typedef {object} SankeyAST
|
|
68
|
+
* @property {'sankey'} type
|
|
69
|
+
* @property {string|null} title
|
|
70
|
+
* @property {SankeyNodeAST[]} nodes
|
|
71
|
+
* @property {SankeyLinkAST[]} links
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Build the geometry-free sankey AST.
|
|
75
|
+
* @param {any} data
|
|
76
|
+
* @param {any} [config]
|
|
77
|
+
* @returns {SankeyAST}
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildSankeyAST(data: any, config?: any): SankeyAST;
|
|
80
|
+
/**
|
|
81
|
+
* Render a sankey AST to a pure-vnode SVG: categorical node bars,
|
|
82
|
+
* translucent muted ribbons with flow `<title>`s, node labels beside
|
|
83
|
+
* the bar on its open side.
|
|
84
|
+
* @param {SankeyAST} ast
|
|
85
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
86
|
+
* @param {string} hash
|
|
87
|
+
* @param {{rootClass?: string, keyPrefix?: string, palette?: readonly string[], width?: number,
|
|
88
|
+
* tooltip?: import('../core/marks.js').ChartTooltipSpec}} [options]
|
|
89
|
+
* @returns {any}
|
|
90
|
+
*/
|
|
91
|
+
export declare function renderSankeyAST(ast: SankeyAST, theme: {
|
|
92
|
+
tokens: Record<string, string>;
|
|
93
|
+
cssVars: Record<string, string>;
|
|
94
|
+
}, hash: string, options?: {
|
|
95
|
+
rootClass?: string;
|
|
96
|
+
keyPrefix?: string;
|
|
97
|
+
palette?: readonly string[];
|
|
98
|
+
width?: number;
|
|
99
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
100
|
+
}): any;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The scatter chart type: points over numeric or log axes,
|
|
3
|
+
* per-point semantic tone (win/loss), and an optional horizontal
|
|
4
|
+
* reference line (e.g. ratio = 1). Data shape:
|
|
5
|
+
*
|
|
6
|
+
* data = { points: [{x, y, tone?: 'win'|'loss'}] }
|
|
7
|
+
* config = { type:'scatter', title?, xLog?, yLog?, refY?, refLabel?,
|
|
8
|
+
* xLabel?, yLabel? }
|
|
9
|
+
*/
|
|
10
|
+
export type ScatterAST = {
|
|
11
|
+
type: 'scatter';
|
|
12
|
+
title: string | null;
|
|
13
|
+
x: {
|
|
14
|
+
ticks: {
|
|
15
|
+
pos: number;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
label: string | null;
|
|
19
|
+
};
|
|
20
|
+
y: {
|
|
21
|
+
ticks: {
|
|
22
|
+
pos: number;
|
|
23
|
+
label: string;
|
|
24
|
+
}[];
|
|
25
|
+
label: string | null;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* unit position plus the raw sample the hover text reports
|
|
29
|
+
*/
|
|
30
|
+
points: {
|
|
31
|
+
u: number;
|
|
32
|
+
v: number;
|
|
33
|
+
tone: 'win' | 'loss' | null;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
}[];
|
|
37
|
+
ref: {
|
|
38
|
+
v: number;
|
|
39
|
+
label: string | null;
|
|
40
|
+
} | null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {object} ScatterAST
|
|
44
|
+
* @property {'scatter'} type
|
|
45
|
+
* @property {string|null} title
|
|
46
|
+
* @property {{ticks: {pos:number,label:string}[], label: string|null}} x
|
|
47
|
+
* @property {{ticks: {pos:number,label:string}[], label: string|null}} y
|
|
48
|
+
* @property {{u:number,v:number,tone:'win'|'loss'|null,x:number,y:number}[]} points
|
|
49
|
+
* unit position plus the raw sample the hover text reports
|
|
50
|
+
* @property {{v: number, label: string|null}|null} ref
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Build the geometry-free scatter AST.
|
|
54
|
+
* @param {any} data
|
|
55
|
+
* @param {any} [config]
|
|
56
|
+
* @returns {ScatterAST}
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildScatterAST(data: any, config?: any): ScatterAST;
|
|
59
|
+
/**
|
|
60
|
+
* Render a scatter AST to a pure-vnode SVG. Each dot carries its raw
|
|
61
|
+
* `(x, y)` as a `<title>`: on a log axis a pixel position is not
|
|
62
|
+
* readable back to a value, so the hover text is the only honest way to
|
|
63
|
+
* name the sample.
|
|
64
|
+
* @param {ScatterAST} ast
|
|
65
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
66
|
+
* @param {string} hash
|
|
67
|
+
* @param {{rootClass?: string, keyPrefix?: string, palette?: readonly string[], width?: number,
|
|
68
|
+
* tooltip?: import('../core/marks.js').ChartTooltipSpec}} [options]
|
|
69
|
+
* @returns {any}
|
|
70
|
+
*/
|
|
71
|
+
export declare function renderScatterAST(ast: ScatterAST, theme: {
|
|
72
|
+
tokens: Record<string, string>;
|
|
73
|
+
cssVars: Record<string, string>;
|
|
74
|
+
}, hash: string, options?: {
|
|
75
|
+
rootClass?: string;
|
|
76
|
+
keyPrefix?: string;
|
|
77
|
+
palette?: readonly string[];
|
|
78
|
+
width?: number;
|
|
79
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
80
|
+
}): any;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The streamgraph chart type: stacked series as flowing bands
|
|
3
|
+
* around a silhouette baseline (the stack centered on its running
|
|
4
|
+
* total, so the outline stays symmetric). Data shape:
|
|
5
|
+
*
|
|
6
|
+
* data = { series: [{ name, values: number[] }], xs?: number[] }
|
|
7
|
+
* config = { type:'streamgraph', title?, xLabel? }
|
|
8
|
+
*
|
|
9
|
+
* `values` align by index across series; `xs` optionally places the
|
|
10
|
+
* samples on a numeric x axis (index positions otherwise). Negative
|
|
11
|
+
* and non-finite samples read as 0 — a streamgraph stacks
|
|
12
|
+
* non-negative magnitudes. The y axis is deliberately unlabeled:
|
|
13
|
+
* silhouette offsets make absolute y positions meaningless; band
|
|
14
|
+
* thickness is the encoding, and each band carries its name as hover
|
|
15
|
+
* text.
|
|
16
|
+
*/
|
|
17
|
+
export type StreamgraphAST = {
|
|
18
|
+
type: 'streamgraph';
|
|
19
|
+
title: string | null;
|
|
20
|
+
x: {
|
|
21
|
+
ticks: {
|
|
22
|
+
pos: number;
|
|
23
|
+
label: string;
|
|
24
|
+
}[];
|
|
25
|
+
label: string | null;
|
|
26
|
+
};
|
|
27
|
+
legend: {
|
|
28
|
+
name: string;
|
|
29
|
+
swatch: number;
|
|
30
|
+
}[] | null;
|
|
31
|
+
layers: {
|
|
32
|
+
name: string;
|
|
33
|
+
points: {
|
|
34
|
+
u: number;
|
|
35
|
+
lo: number;
|
|
36
|
+
hi: number;
|
|
37
|
+
}[];
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {object} StreamgraphAST
|
|
42
|
+
* @property {'streamgraph'} type
|
|
43
|
+
* @property {string|null} title
|
|
44
|
+
* @property {{ticks: {pos:number,label:string}[], label: string|null}} x
|
|
45
|
+
* @property {{name: string, swatch: number}[]|null} legend
|
|
46
|
+
* @property {{name: string, points: {u:number, lo:number, hi:number}[]}[]} layers
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Build the geometry-free streamgraph AST.
|
|
50
|
+
* @param {any} data
|
|
51
|
+
* @param {any} [config]
|
|
52
|
+
* @returns {StreamgraphAST}
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildStreamgraphAST(data: any, config?: any): StreamgraphAST;
|
|
55
|
+
/**
|
|
56
|
+
* Render a streamgraph AST to a pure-vnode SVG: one closed band path
|
|
57
|
+
* per layer (top edge forward, bottom edge back), separated by the
|
|
58
|
+
* slice-stroke hairline the pie uses between touching fills.
|
|
59
|
+
* @param {StreamgraphAST} ast
|
|
60
|
+
* @param {{tokens: Record<string,string>, cssVars: Record<string,string>}} theme
|
|
61
|
+
* @param {string} hash
|
|
62
|
+
* @param {{rootClass?: string, keyPrefix?: string, palette?: readonly string[], width?: number,
|
|
63
|
+
* tooltip?: import('../core/marks.js').ChartTooltipSpec}} [options]
|
|
64
|
+
* @returns {any}
|
|
65
|
+
*/
|
|
66
|
+
export declare function renderStreamgraphAST(ast: StreamgraphAST, theme: {
|
|
67
|
+
tokens: Record<string, string>;
|
|
68
|
+
cssVars: Record<string, string>;
|
|
69
|
+
}, hash: string, options?: {
|
|
70
|
+
rootClass?: string;
|
|
71
|
+
keyPrefix?: string;
|
|
72
|
+
palette?: readonly string[];
|
|
73
|
+
width?: number;
|
|
74
|
+
tooltip?: import('../core/marks.js').ChartTooltipSpec;
|
|
75
|
+
}): any;
|