@martinomagnifico/tablechart 1.0.3 → 1.0.5
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/CHANGELOG.md +53 -0
- package/README.md +7 -2
- package/dist/tablechart-core.d.mts +26 -0
- package/dist/tablechart-core.mjs +1 -2
- package/dist/tablechart-shared.d.mts +324 -0
- package/dist/tablechart-shared.mjs +1001 -794
- package/dist/tablechart.css +1 -1
- package/dist/tablechart.d.mts +2 -0
- package/dist/tablechart.js +1 -1
- package/dist/tablechart.mjs +1 -2
- package/package.json +12 -8
- package/dist/tablechart-core.d.ts +0 -313
- package/dist/tablechart.d.ts +0 -85
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.5] - 2026-10-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Tooltips: on a chart that leaves some (or all) numbers out, hovering or tapping, shows tooltips now. `tooltip` and `data-chart-tooltip`: `"auto"` by default, `true` always, `false` never.
|
|
8
|
+
- `--tablechart-tooltip-surface`, `-color`, `-border`, `-radius`, `-padding` and `-shadow`.
|
|
9
|
+
- The `table` option and `data-chart-table`: the table under the chart, always, in print, or in print when the chart does not show all its numbers.
|
|
10
|
+
- `PRINTING_CLASS` in the building blocks, to get a chart ready for print. See the API reference.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- A number left out for lack of room is shown in the tooltip, not on the chart.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Every chart is printed whole, also one that had not scrolled into view or was still building, in every browser. A chart is not split over two pages.
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
|
|
22
|
+
- The band behind a row that is pointed at, and `--tablechart-pointer-color`: the tooltip shows the row.
|
|
23
|
+
|
|
24
|
+
### Deprecated
|
|
25
|
+
|
|
26
|
+
- The `hover` option and `data-chart-hover`, now `tooltip` and `data-chart-tooltip`. Removed in the next minor version.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [1.0.4] - 2026-10-14
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- `--tablechart-animation-element-duration`, `--tablechart-animation-stagger` and `--tablechart-animation-max`: the time of one element, when the next one starts, and a ceiling for a whole chart, which is 4x the standard element duration, so 2s by default.
|
|
34
|
+
- `data-chart-animate="sweep"` on a donut draws the ring in one sweep, and on a waterfall builds it at one speed.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- A large chart builds within 2s: the starts of its elements move closer together.
|
|
39
|
+
- A waterfall grows column by column, one after the other: its stagger is 0.6 by default. Under the maximum its columns get shorter.
|
|
40
|
+
- CSS variables that set the same part of a chart now start there variable name in the same way, such as `--tablechart-animation-` and `--tablechart-name-`. See the list of old and new names on the CSS variables page.
|
|
41
|
+
- `--tablechart-name-size` now sets all names, also those under the bars.
|
|
42
|
+
- The callout of an annotation is now called the badge in the docs, like its variables.
|
|
43
|
+
- `data-chart-animate` and the `animate` option take `grow` and `sweep`, the same on every chart type. `up` and `across` are the old names.
|
|
44
|
+
- The types are now `tablechart.d.mts` and `tablechart-core.d.mts`, next to the ES modules, and share `tablechart-shared.d.mts` like the modules share their code. They are made with rolldown-plugin-dts instead of API Extractor.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- With steps, the closing total of a waterfall grows from the baseline if the column before it is not there yet.
|
|
49
|
+
- Importing `@martinomagnifico/tablechart/core` in TypeScript no longer fails with "Cannot find name 'TablechartChart'".
|
|
50
|
+
|
|
51
|
+
### Deprecated
|
|
52
|
+
|
|
53
|
+
- The old variable names and the animate values `up` and `across`, removed in the next minor version. The console lists the ones a page still uses.
|
|
54
|
+
|
|
55
|
+
|
|
3
56
|
## [1.0.3] - 2026-10-11
|
|
4
57
|
|
|
5
58
|
### Added
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Tablechart
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@martinomagnifico/tablechart)
|
|
4
|
+
[]()
|
|
4
5
|
|
|
5
6
|
[<img src="screenshot.png" width="100%" alt="Tablechart: a column chart, a donut and a waterfall">](https://martinomagnifico.github.io/tablechart/)
|
|
6
7
|
|
|
@@ -14,7 +15,9 @@ Tablechart makes simple charts from a table: an HTML table, a Markdown table or
|
|
|
14
15
|
* **The table stays:** it is hidden from sight, but screen readers, search engines and translation scripts still read it. Without JavaScript, the table is all there is.
|
|
15
16
|
* **Real text:** names and numbers are HTML, so they use the font of the page and do not scale with the drawing.
|
|
16
17
|
* **CSS for the looks:** colours, sizes and animation are CSS variables. Light and dark mode follow the page.
|
|
17
|
-
* **Annotations:**
|
|
18
|
+
* **Annotations:** badges, brackets, trend arrows and a break in the scale
|
|
19
|
+
* **Tooltips:** when a chart leaves numbers out, point at a row, or tap it, to see all its values
|
|
20
|
+
* **Print and PDF:** every chart prints whole, and the table can be shown under a chart that leaves numbers out
|
|
18
21
|
* **Step by step:** show the rows one at a time, with Previous and Next buttons
|
|
19
22
|
* **Animation:** a chart builds when it scrolls into view
|
|
20
23
|
|
|
@@ -70,10 +73,12 @@ Use `bar`, `line`, `area`, `waterfall` or `donut` for the other types. With more
|
|
|
70
73
|
|
|
71
74
|
```js
|
|
72
75
|
init({
|
|
73
|
-
animate: true, // Animate a chart when it builds: true, false, "
|
|
76
|
+
animate: true, // Animate a chart when it builds: true, false, "grow" or "sweep"
|
|
74
77
|
threshold: 0.5, // How much of a chart must be in view before it builds
|
|
75
78
|
replay: false, // Build again each time a chart scrolls back into view
|
|
76
79
|
controls: true, // Previous and Next buttons on a chart that steps
|
|
80
|
+
tooltip: "auto", // Tooltips: "auto" only when a chart leaves numbers out, true or false
|
|
81
|
+
table: "never", // The table under the chart: "never", "auto" (in print, if numbers are left out), "print" or "always"
|
|
77
82
|
locale: undefined, // Locale for numbers; the language of the page if not set
|
|
78
83
|
});
|
|
79
84
|
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { _ as StepPlan, c as PLACED_CLASS, d as QUEUED_CLASS, f as SHOWN_CLASS, g as Series, h as Row, i as entranceOf, l as PLOT_CLASS, m as ChartState, o as prepare, p as defaultConfig, s as Config, u as PRINTING_CLASS, v as stepTo } from "./tablechart-shared.mjs";
|
|
2
|
+
//#region src/js/core.d.ts
|
|
3
|
+
/** Pass 2: everything a reader will read, before a translation script looks. */
|
|
4
|
+
export declare const build: (figure: HTMLElement, config: Config, asKind?: string | null) => ChartState | null;
|
|
5
|
+
/** Pass 3. Needs layout; makes no text, only places it. */
|
|
6
|
+
export declare const layout: (state: ChartState, config: Config) => boolean;
|
|
7
|
+
/** Numbers are reformatted in place, so a language change costs no redraw. */
|
|
8
|
+
export declare const relabel: (state: ChartState, config: Config) => void;
|
|
9
|
+
/** Removes what `build` added, so the chart can be built again. */
|
|
10
|
+
export declare const unbuild: (state: ChartState) => void;
|
|
11
|
+
/** One class, `is-shown`, starts the whole build. */
|
|
12
|
+
export declare const setShown: (state: ChartState, shown: boolean) => void;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/js/functions/sources.d.ts
|
|
15
|
+
/** A Markdown table, or a caption with chart attributes, is wrapped in a div with the caption and annotations beside it. */
|
|
16
|
+
export declare const adoptTables: (figures: HTMLElement[]) => HTMLElement[];
|
|
17
|
+
/** `data-chart-src` fills the figure's table with the rows of a JSON file, keeping a header row the author wrote; a file that fails is reported. */
|
|
18
|
+
export declare const loadSources: (figures: HTMLElement[]) => Promise<void>;
|
|
19
|
+
/** In a Markdown table, a bold label makes the row a total, and a bold header puts that series in focus. */
|
|
20
|
+
export declare const readMarkdownRows: (figures: HTMLElement[]) => void;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/js/functions/read-table.d.ts
|
|
23
|
+
/** Writes translation keys such as `harvest-row1` onto a figure with `data-chart-keys`; a duplicate prefix gets a number. */
|
|
24
|
+
export declare const assignKeys: (figures: HTMLElement[], langattribute: string | false) => void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { type ChartState, type Config, PLACED_CLASS, PLOT_CLASS, PRINTING_CLASS, QUEUED_CLASS, type Row, SHOWN_CLASS, type Series, type StepPlan, defaultConfig, entranceOf, prepare, stepTo };
|
package/dist/tablechart-core.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { o as PLACED_CLASS, a as PLOT_CLASS, e as QUEUED_CLASS, h as SHOWN_CLASS, t as adoptTables, l as assignKeys, n as build, g as defaultConfig, u as entranceOf, c as layout, d as loadSources, s as prepare, p as readMarkdownRows, m as relabel, r as setShown, f as stepTo, i as unbuild };
|
|
1
|
+
export { h as PLACED_CLASS, g as PLOT_CLASS, _ as PRINTING_CLASS, v as QUEUED_CLASS, y as SHOWN_CLASS, a as adoptTables, m as assignKeys, c as build, b as defaultConfig, n as entranceOf, l as layout, o as loadSources, i as prepare, s as readMarkdownRows, u as relabel, d as setShown, p as stepTo, f as unbuild } from "./tablechart-shared.mjs";
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
//#region src/js/functions/scale.d.ts
|
|
2
|
+
/** A break in the scale: values from `lo` to `hi` get `share` of the length, and the cut is at `gap`. */
|
|
3
|
+
interface Squeeze {
|
|
4
|
+
lo: number;
|
|
5
|
+
hi: number;
|
|
6
|
+
gap: number;
|
|
7
|
+
share: number;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/js/steps.d.ts
|
|
11
|
+
/** The steps of one chart: which step shows each row, column and annotation, and how many steps there are. */
|
|
12
|
+
interface StepPlan {
|
|
13
|
+
rows: {
|
|
14
|
+
step: number | null;
|
|
15
|
+
slot: number;
|
|
16
|
+
}[];
|
|
17
|
+
series: {
|
|
18
|
+
step: number | null;
|
|
19
|
+
}[];
|
|
20
|
+
/** A cell on a step of its own, by row and then by column. */
|
|
21
|
+
cells: {
|
|
22
|
+
step: number | null;
|
|
23
|
+
slot: number;
|
|
24
|
+
}[][];
|
|
25
|
+
notes: {
|
|
26
|
+
step: number | null;
|
|
27
|
+
after: number;
|
|
28
|
+
}[];
|
|
29
|
+
count: number;
|
|
30
|
+
/** The `data-fragment-index` of each step, if it asked for one, so a presentation can make a fragment for each. */
|
|
31
|
+
indexes: (string | null)[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Shows the chart up to step `step`, from 0 (only what has no step) to the number of steps (all of it).
|
|
35
|
+
* Says so with a `tablechart:step` event on the figure, unless `quietly`.
|
|
36
|
+
*/
|
|
37
|
+
declare const stepTo: (state: ChartState, step: number, quietly?: boolean) => void;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/js/types.d.ts
|
|
40
|
+
/** How a line or an area runs from one point to the next. */
|
|
41
|
+
type Shape = "straight" | "step" | "smooth";
|
|
42
|
+
/** How a chart builds: each element grows from zero, or the chart is revealed in one movement. */
|
|
43
|
+
type Motion = "grow" | "sweep";
|
|
44
|
+
interface Cell {
|
|
45
|
+
raw: string;
|
|
46
|
+
/** As written, so its decimal places survive. Empty when the cell holds no number. */
|
|
47
|
+
number: string;
|
|
48
|
+
/** Text around the number, such as `%` or a footnote `*`, kept either side of the formatted number. */
|
|
49
|
+
prefix: string;
|
|
50
|
+
suffix: string;
|
|
51
|
+
/** No number, such as "n/a": no mark, and the label says what the cell says. Counts as zero. */
|
|
52
|
+
missing: boolean;
|
|
53
|
+
value: number;
|
|
54
|
+
}
|
|
55
|
+
interface Row extends Cell {
|
|
56
|
+
label: string;
|
|
57
|
+
key: string | null;
|
|
58
|
+
cells: Cell[];
|
|
59
|
+
/** Copied to everything drawn for the row, so one class styles all of it. */
|
|
60
|
+
classes: string[];
|
|
61
|
+
isTotal: boolean;
|
|
62
|
+
/** The stagger counts from here. */
|
|
63
|
+
slot: number;
|
|
64
|
+
}
|
|
65
|
+
interface Series {
|
|
66
|
+
name: string;
|
|
67
|
+
key: string | null;
|
|
68
|
+
/** `data-kind="focus"`, or bold in Markdown: the others are shown fainter. */
|
|
69
|
+
focus: boolean;
|
|
70
|
+
/** `data-marker` on the header, such as `square` or `diamond open`. */
|
|
71
|
+
marker: string | null;
|
|
72
|
+
line: "dashed" | "dotted" | null;
|
|
73
|
+
}
|
|
74
|
+
interface Segment extends Row {
|
|
75
|
+
from: number;
|
|
76
|
+
to: number;
|
|
77
|
+
kind: "bar" | "up" | "down" | "total";
|
|
78
|
+
}
|
|
79
|
+
/** Scales only, no pixel positions, so an annotation follows the data. */
|
|
80
|
+
interface Geometry {
|
|
81
|
+
rows: Row[];
|
|
82
|
+
segments: Segment[];
|
|
83
|
+
cx: (index: number) => number;
|
|
84
|
+
y: (value: number) => number;
|
|
85
|
+
barWidth: number;
|
|
86
|
+
barMax: number;
|
|
87
|
+
height: number;
|
|
88
|
+
/** viewBox units per screen pixel. */
|
|
89
|
+
unit: number;
|
|
90
|
+
labelHeight: number;
|
|
91
|
+
badgeHeight: number;
|
|
92
|
+
/** How many stagger steps the data takes, so commentary can land after it. */
|
|
93
|
+
after: number;
|
|
94
|
+
/** An annotation's number in the figure, from 1, set as `data-note` on its marks. Zero for the chart. */
|
|
95
|
+
note: number;
|
|
96
|
+
/** Where the break's mark goes, as a value. Null when the scale runs straight through. */
|
|
97
|
+
breakAt: number | null;
|
|
98
|
+
/** The break itself, for a chart that makes a scale of its own, such as a bar chart. */
|
|
99
|
+
squeeze: Squeeze | null;
|
|
100
|
+
/** The empty space where the scale jumps, in viewBox units. */
|
|
101
|
+
breakGap: number;
|
|
102
|
+
/** Where a bar chart is cut across, in viewBox units; set by its drawing. */
|
|
103
|
+
breakX?: number;
|
|
104
|
+
labels: "outside" | "inside";
|
|
105
|
+
/** Where a number inside its bar goes, from `--tablechart-value-align`; null for the chart's own default. */
|
|
106
|
+
insideAlign: "start" | "center" | "end" | null;
|
|
107
|
+
stacked: boolean;
|
|
108
|
+
shape: Shape;
|
|
109
|
+
/** Empty when the chart is not stacked or its kind shows no totals. */
|
|
110
|
+
totals: HTMLElement[];
|
|
111
|
+
svg: SVGSVGElement;
|
|
112
|
+
plot: HTMLElement;
|
|
113
|
+
/** Made by `build`; a chart only places them. */
|
|
114
|
+
values: HTMLElement[];
|
|
115
|
+
series: Series[];
|
|
116
|
+
seriesValues: HTMLElement[][];
|
|
117
|
+
/** Empty with one series. */
|
|
118
|
+
names: HTMLElement[];
|
|
119
|
+
/** A chart with its names beside the marks places these; one with them under the plot does not. */
|
|
120
|
+
categories: HTMLElement[];
|
|
121
|
+
centre: HTMLElement | null;
|
|
122
|
+
config: Config;
|
|
123
|
+
/** Numbers an annotation worked out, against the ones the author wrote. */
|
|
124
|
+
checks: Check[];
|
|
125
|
+
}
|
|
126
|
+
interface Check {
|
|
127
|
+
label: string;
|
|
128
|
+
computed: number;
|
|
129
|
+
stated: number;
|
|
130
|
+
agrees: boolean;
|
|
131
|
+
}
|
|
132
|
+
interface ChartType {
|
|
133
|
+
aspect?: number;
|
|
134
|
+
/** A row marked as a total goes in the middle rather than among the marks. */
|
|
135
|
+
centre?: boolean;
|
|
136
|
+
/** A break in the scale works here; a waterfall keeps its floating steps clear of it. */
|
|
137
|
+
breakable?: boolean;
|
|
138
|
+
stackable?: boolean;
|
|
139
|
+
/** A stack is a running sum, so each line follows the one under it; otherwise values below zero stack down from zero. */
|
|
140
|
+
running?: boolean;
|
|
141
|
+
totals?: boolean;
|
|
142
|
+
/** The sample in front of a legend name when it is not a line; the legend shows only when asked. */
|
|
143
|
+
swatch?: "box";
|
|
144
|
+
categories?: "under" | "beside";
|
|
145
|
+
series?: boolean;
|
|
146
|
+
/** With several series, always a legend, with a sample of this shape. */
|
|
147
|
+
legend?: "box";
|
|
148
|
+
headroom?: (geo: HeadroomInput) => number;
|
|
149
|
+
minHeight?: (input: {
|
|
150
|
+
labelHeight: number;
|
|
151
|
+
nameHeight: number;
|
|
152
|
+
unit: number;
|
|
153
|
+
rows: number;
|
|
154
|
+
series: number;
|
|
155
|
+
stacked: boolean;
|
|
156
|
+
}) => number;
|
|
157
|
+
/** Room under the baseline for numbers that hang below a mark near it. */
|
|
158
|
+
footroom?: (geo: HeadroomInput) => number;
|
|
159
|
+
/** Default: one bar per row from the baseline. */
|
|
160
|
+
segments?: (rows: Row[]) => Segment[];
|
|
161
|
+
draw: (geo: Geometry) => void;
|
|
162
|
+
/** The lines of the tooltip of a row. Default: each value with the name of its series, and the total of a stack. */
|
|
163
|
+
tooltip?: (state: ChartState, index: number, config: Config) => TooltipLine[];
|
|
164
|
+
}
|
|
165
|
+
/** One line of a tooltip, under the name of the row. */
|
|
166
|
+
interface TooltipLine {
|
|
167
|
+
/** The name of the series; empty for a chart with one series. */
|
|
168
|
+
name: string;
|
|
169
|
+
value: string;
|
|
170
|
+
/** A small key in the colour of the series. */
|
|
171
|
+
colour?: string;
|
|
172
|
+
/** The shape of that key, as in the legend: a line with its point, or a box. */
|
|
173
|
+
sample?: {
|
|
174
|
+
marker: string | null;
|
|
175
|
+
open: boolean;
|
|
176
|
+
line: string | null;
|
|
177
|
+
box: boolean;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
interface HeadroomInput {
|
|
181
|
+
labelHeight: number;
|
|
182
|
+
badgeHeight: number;
|
|
183
|
+
hasAnnotations: boolean;
|
|
184
|
+
unit: number;
|
|
185
|
+
series: number;
|
|
186
|
+
focused: boolean;
|
|
187
|
+
stacked: boolean;
|
|
188
|
+
}
|
|
189
|
+
/** `create` runs before layout, so a translation script finds its text; `draw` only places it. */
|
|
190
|
+
interface AnnotationType {
|
|
191
|
+
create: (spec: HTMLElement, plot: HTMLElement) => HTMLElement | null;
|
|
192
|
+
draw: (spec: HTMLElement, badge: HTMLElement | null, geo: Geometry) => void;
|
|
193
|
+
}
|
|
194
|
+
interface ChartState {
|
|
195
|
+
figure: HTMLElement;
|
|
196
|
+
plot: HTMLElement;
|
|
197
|
+
svg: SVGSVGElement;
|
|
198
|
+
rows: Row[];
|
|
199
|
+
decimals: number;
|
|
200
|
+
type: ChartType;
|
|
201
|
+
values: HTMLElement[];
|
|
202
|
+
series: Series[];
|
|
203
|
+
seriesValues: HTMLElement[][];
|
|
204
|
+
names: HTMLElement[];
|
|
205
|
+
categories: HTMLElement[];
|
|
206
|
+
centre: HTMLElement | null;
|
|
207
|
+
stacked: boolean;
|
|
208
|
+
totals: HTMLElement[];
|
|
209
|
+
totalCell: HTMLElement | null;
|
|
210
|
+
/** In screen pixels from the plot's corner. Null for a chart whose rows are not side by side. */
|
|
211
|
+
rowAt: ((x: number, y: number) => number | null) | null;
|
|
212
|
+
/** As percentages: left, top, width and height. */
|
|
213
|
+
rowBox: ((index: number) => [number, number, number, number]) | null;
|
|
214
|
+
annotations: {
|
|
215
|
+
spec: HTMLElement;
|
|
216
|
+
type: AnnotationType;
|
|
217
|
+
badge: HTMLElement | null;
|
|
218
|
+
/** From 0; `data-series` counts from 1. */
|
|
219
|
+
series: number;
|
|
220
|
+
after: number;
|
|
221
|
+
}[];
|
|
222
|
+
/** The steps of a chart that steps (`data-fragment`); null for one that does not. */
|
|
223
|
+
plan: StepPlan | null;
|
|
224
|
+
/** How many steps are shown. */
|
|
225
|
+
step: number;
|
|
226
|
+
/** The Previous and Next buttons, if Tablechart made them. */
|
|
227
|
+
controls: HTMLElement | null;
|
|
228
|
+
checks: Check[];
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/js/config.d.ts
|
|
232
|
+
declare const PLOT_CLASS = "tablechart-plot";
|
|
233
|
+
declare const PLACED_CLASS = "is-placed";
|
|
234
|
+
declare const SHOWN_CLASS = "is-shown";
|
|
235
|
+
declare const PRINTING_CLASS = "is-printing";
|
|
236
|
+
declare const QUEUED_CLASS = "tablechart-queued";
|
|
237
|
+
interface Config {
|
|
238
|
+
/** Which elements Tablechart turns into charts. */
|
|
239
|
+
selector: string;
|
|
240
|
+
/** Height of the plot as a share of its width. */
|
|
241
|
+
aspect: number;
|
|
242
|
+
/** Share of a band that a bar fills. */
|
|
243
|
+
barfill: number;
|
|
244
|
+
/** Share of a donut's radius that the ring itself takes. */
|
|
245
|
+
ringfill: number;
|
|
246
|
+
/** Locale for numbers. Unset, the document's language is used and followed when it changes. */
|
|
247
|
+
locale?: string;
|
|
248
|
+
/** Animate a chart when it builds. `"grow"` grows each element from zero, `"sweep"` reveals the chart in one movement; a figure overrides it with `data-chart-animate`. `"up"` and `"across"` are their old names. */
|
|
249
|
+
animate: boolean | Motion | "across" | "up";
|
|
250
|
+
/** How far an animated parent is in before its chart builds: 0 when it starts moving, 1 when it is in. A figure overrides it with `data-chart-entrance`. */
|
|
251
|
+
entrance: number;
|
|
252
|
+
/** Where a column's number goes: on the bar, or inside it. A figure overrides it with `data-chart-labels`. */
|
|
253
|
+
labels: "outside" | "inside";
|
|
254
|
+
/** How a line or area runs between points: `straight`, `step` or `smooth`. A figure overrides it with `data-chart-shape`. */
|
|
255
|
+
shape: "straight" | "step" | "smooth";
|
|
256
|
+
/** Names of several lines in a legend instead of at the end of each line. A figure overrides it with `data-chart-legend`. */
|
|
257
|
+
legend: boolean;
|
|
258
|
+
/** A tooltip with the values of a row that is pointed at or tapped: `"auto"`, the default, only on a chart that does not show all its numbers; `true` always; `false` never. A figure overrides it with `data-chart-tooltip`. */
|
|
259
|
+
tooltip: boolean | "auto";
|
|
260
|
+
/** The old name of `tooltip`, until the next minor version. */
|
|
261
|
+
hover?: boolean;
|
|
262
|
+
/** The table under the chart: `"always"`, only in `"print"`, in print when numbers are left out (`"auto"`), or `"never"`. A figure overrides it with `data-chart-table`. */
|
|
263
|
+
table: "never" | "auto" | "print" | "always";
|
|
264
|
+
/** The name of the total that a donut without a total row works out, for screen readers. */
|
|
265
|
+
totallabel: string;
|
|
266
|
+
/** Previous and Next buttons under a chart that steps (`data-fragment`). `false` leaves them out, for buttons of your own. */
|
|
267
|
+
controls: boolean;
|
|
268
|
+
/** The text of the Previous button. */
|
|
269
|
+
previouslabel: string;
|
|
270
|
+
/** The text of the Next button. */
|
|
271
|
+
nextlabel: string;
|
|
272
|
+
/** Read by screen readers after the text of each button, so they know it only changes the chart. */
|
|
273
|
+
stephint: string;
|
|
274
|
+
/** How much of a chart must be in view before it builds, from 0 to 1. */
|
|
275
|
+
threshold: number;
|
|
276
|
+
/** Build again each time a chart scrolls back into view, not only the first time. */
|
|
277
|
+
replay: boolean;
|
|
278
|
+
/** The attribute for translation keys, for a translation script. `false` turns keys off. */
|
|
279
|
+
langattribute: string | false;
|
|
280
|
+
/** Show messages in the console for whoever is working on the page. */
|
|
281
|
+
debug?: boolean;
|
|
282
|
+
}
|
|
283
|
+
declare const defaultConfig: Config;
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/js/init.d.ts
|
|
286
|
+
interface TablechartChart {
|
|
287
|
+
figure: HTMLElement;
|
|
288
|
+
/** Lays the chart out again, for example after a script has changed its text. */
|
|
289
|
+
refresh(): void;
|
|
290
|
+
/** Stops watching scroll, size and language. The chart stays as it is. */
|
|
291
|
+
destroy(): void;
|
|
292
|
+
/** On a chart that steps (`data-fragment`): shows one step more. */
|
|
293
|
+
next(): void;
|
|
294
|
+
/** On a chart that steps: shows one step less. */
|
|
295
|
+
previous(): void;
|
|
296
|
+
/** On a chart that steps: shows the chart up to `step`, from 0 to `steps`. */
|
|
297
|
+
stepTo(step: number): void;
|
|
298
|
+
/** How many steps are shown. */
|
|
299
|
+
readonly step: number;
|
|
300
|
+
/** How many steps the chart has; 0 for a chart that does not step. */
|
|
301
|
+
readonly steps: number;
|
|
302
|
+
}
|
|
303
|
+
interface TablechartInstance {
|
|
304
|
+
charts: TablechartChart[];
|
|
305
|
+
/** Lays out every chart again, for example after a script has changed its text. */
|
|
306
|
+
refresh(): void;
|
|
307
|
+
/** Stops watching scroll, size and language. The charts stay as they are. */
|
|
308
|
+
destroy(): void;
|
|
309
|
+
}
|
|
310
|
+
declare global {
|
|
311
|
+
interface HTMLElement {
|
|
312
|
+
tablechart?: TablechartChart;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/** How far an animated parent is in before the chart builds: the figure's `data-chart-entrance`, or else the option. */
|
|
316
|
+
declare const entranceOf: (figure: HTMLElement, config: Config) => number;
|
|
317
|
+
/** Turns elements into figures with a table and translation keys, all at once, so duplicate keys are found. */
|
|
318
|
+
declare const prepare: (found: HTMLElement[], config: Config) => Promise<HTMLElement[]>;
|
|
319
|
+
/** Makes a chart of one element; returns the existing chart if there is one, or null without data. */
|
|
320
|
+
declare const create: (element: HTMLElement, options?: Partial<Config>) => Promise<TablechartChart | null>;
|
|
321
|
+
/** Makes a chart of every element in `root` that matches the selector, skipping existing charts. */
|
|
322
|
+
declare const init: (options?: Partial<Config>, root?: ParentNode) => Promise<TablechartInstance>;
|
|
323
|
+
//#endregion
|
|
324
|
+
export { StepPlan as _, init as a, PLACED_CLASS as c, QUEUED_CLASS as d, SHOWN_CLASS as f, Series as g, Row as h, entranceOf as i, PLOT_CLASS as l, ChartState as m, TablechartInstance as n, prepare as o, defaultConfig as p, create as r, Config as s, TablechartChart as t, PRINTING_CLASS as u, stepTo as v };
|