@martinomagnifico/tablechart 0.1.0 → 0.1.2
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 +35 -1
- package/dist/tablechart-core.d.ts +52 -187
- package/dist/tablechart-core.mjs +2 -2
- package/dist/tablechart-shared.mjs +437 -313
- package/dist/tablechart.css +1 -1
- package/dist/tablechart.d.ts +13 -54
- package/dist/tablechart.js +1 -1
- package/dist/tablechart.mjs +2 -2
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.1.
|
|
3
|
+
## [0.1.2] - 2026-10-07
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
- Smooth lines and areas: `data-chart-shape="smooth"`, or the `shape` option for every chart. The curve goes through every point and never overshoots them (monotone cubic interpolation), so it shows no peak or dip that is not in the data. A missing value still splits the line, and in a stack each area follows the curve of the one below it.
|
|
8
|
+
- The `shape` option: `"straight"` (the default), `"step"` or `"smooth"`. `data-chart-shape` on a figure overrides it, so `data-chart-shape="straight"` turns a chart back.
|
|
9
|
+
- Lines and areas that grow up from zero: `data-chart-animate="up"`, or `animate: "up"` for every chart. `data-chart-animate="across"` is the opposite. Other chart types are not affected.
|
|
10
|
+
- The moment a chart builds inside an element that animates in can be set: `data-chart-entrance` on a figure, or the `entrance` option, from `0` (when the element starts to move) to `1` (when it is in). It is `0.5`, halfway, by default, as before.
|
|
11
|
+
- With `debug: true`, the console says how long each chart takes to build and to lay out, with a warning above 50 ms.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- A step line (`data-chart-shape="step"`) now takes as long to build as other lines. Its rises and drops are drawn quickly, so the line no longer stops moving to the right while it goes up or down.
|
|
16
|
+
- A line or area with more than seven points takes no longer to build than one with seven: six stagger steps in all. It was one step per point, so a long line was much slower than a short one.
|
|
17
|
+
- The fill of an area fades in at an even speed while its line builds, so it is no longer there before the line.
|
|
18
|
+
- A line or bar chart with many rows lays out much faster. A layout now reads the size of every number and name at once, before it places anything: 10,000 rows took 23 to 65 seconds and now take well under a second.
|
|
19
|
+
- A chart with about 100,000 rows or more no longer stops with an error.
|
|
20
|
+
- After a resize, a line chart whose first number is hidden, such as on a line out of focus, keeps the room for the numbers above it.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [0.1.1] - 2026-10-05
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- The key under a donut is no longer made smaller when a name does not fit a column: its names are not in columns.
|
|
29
|
+
- Removed some comments
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [0.1.0] - 2026-10-04
|
|
34
|
+
|
|
35
|
+
### Added
|
|
7
36
|
|
|
8
37
|
- The legend of an area chart has a square in front of each name.
|
|
9
38
|
- Each line of a chart with several lines has its own point: a filled circle, an open circle, a filled square, an open square, a filled diamond and an open diamond, then from the start again. `data-marker` on a column header sets another, such as `square` or `diamond open`. The legend shows the same points. Points have `data-marker` with their shape, and `data-open` when they are open.
|
|
10
39
|
- `data-line="dashed"` or `data-line="dotted"` on a column header makes a dashed or dotted line. It is shown from left to right when the chart builds. The legend shows the same line. `--tablechart-dash` and `--tablechart-dot` set the pattern.
|
|
11
40
|
|
|
12
41
|
|
|
42
|
+
|
|
13
43
|
## [0.0.8]
|
|
14
44
|
|
|
15
45
|
### Changed
|
|
46
|
+
|
|
16
47
|
- The figure and the table of a chart get the chart's title as their name, with `aria-labelledby`, so a screen reader that jumps to the table reads the title and the unit too. A figure or table with a name of its own keeps it.
|
|
17
48
|
- If a donut has no total row, a hidden row with the sum is added to the bottom of its table, so screen readers read the total with a name. The `totallabel` option sets the name, "Total" by default.
|
|
18
49
|
- All text in the drawing is `inert`, so Safari with VoiceOver does not read it.
|
|
19
50
|
- A full stop, hidden from sight, is put before each line break in the title, so a screen reader pauses between the title and the subtitle.
|
|
20
51
|
- The drawing, its names and its legend have `aria-hidden="true"`. The names and the legend are also `inert`, because Safari with VoiceOver read them otherwise. Screen readers read the table, which has the same names and numbers, so they no longer read everything twice.
|
|
21
52
|
|
|
53
|
+
|
|
54
|
+
|
|
22
55
|
## [0.0.7]
|
|
23
56
|
|
|
24
57
|
### Added
|
|
@@ -39,6 +72,7 @@
|
|
|
39
72
|
- If a chart has numbers that were left out because there is no room for them, pointing at a row, or tapping it, shows the numbers of that row, with a faint band behind the row. The other numbers are hidden for that time. The `hover` option, or `data-chart-hover="false"` on a figure, turns it off. `--tablechart-pointer-color` sets the colour of the band. In a chart that can be pointed at, the numbers in the plot cannot be selected.
|
|
40
73
|
|
|
41
74
|
|
|
75
|
+
|
|
42
76
|
## [0.0.6]
|
|
43
77
|
|
|
44
78
|
### Added
|
|
@@ -1,63 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some Markdown tools put attributes on the table itself, so the table matches
|
|
3
|
-
* the selector, such as `{data-chart=column}` with markdown-it-attrs. A chart draws into its
|
|
4
|
-
* figure, and a table cannot hold a plot, so the table is wrapped in a `div` that
|
|
5
|
-
* takes over its chart attributes and classes.
|
|
6
|
-
*
|
|
7
|
-
* Markdown has no way to put anything inside it, so what belongs to the chart is
|
|
8
|
-
* taken in from beside the table: a caption paragraph just before or after it, and
|
|
9
|
-
* after that a list of annotations or a `.chart-annotations` block.
|
|
10
|
-
*
|
|
11
|
-
* A chart that reads its rows from a file has no table, so the attributes go on
|
|
12
|
-
* its caption instead. If they end up on the bold title inside the caption, the
|
|
13
|
-
* caption is taken to be the chart.
|
|
14
|
-
*/
|
|
1
|
+
/** A Markdown table, or a caption with chart attributes, is wrapped in a div with the caption and annotations beside it. */
|
|
15
2
|
export declare const adoptTables: (figures: HTMLElement[]) => HTMLElement[];
|
|
16
3
|
|
|
17
|
-
/**
|
|
18
|
-
* An annotation in two halves, because the two need different moments.
|
|
19
|
-
* `create` runs before anything is laid out, so anything translatable exists in the DOM
|
|
20
|
-
* by the time a translation plugin takes its one sweep of the page. `draw` runs
|
|
21
|
-
* once the figure has a width, and only ever places what `create` already made.
|
|
22
|
-
*/
|
|
4
|
+
/** `create` runs before layout, so a translation script finds its text; `draw` only places it. */
|
|
23
5
|
declare interface AnnotationType {
|
|
24
6
|
create: (spec: HTMLElement, plot: HTMLElement) => HTMLElement | null;
|
|
25
7
|
draw: (spec: HTMLElement, badge: HTMLElement | null, geo: Geometry) => void;
|
|
26
8
|
}
|
|
27
9
|
|
|
28
|
-
/**
|
|
29
|
-
* Translation keys, written onto the source table before anything is drawn, for
|
|
30
|
-
* a figure with `data-chart-keys`. Its value starts each key: `harvest-row1` for
|
|
31
|
-
* the name of the first row, `harvest-col1` for the header of the first value
|
|
32
|
-
* column. A cell that has a key already keeps it.
|
|
33
|
-
*
|
|
34
|
-
* The value has to be unique on the page. If two figures use
|
|
35
|
-
* the same value, the second one gets a number added, and a warning says so.
|
|
36
|
-
*
|
|
37
|
-
* Keys are written here, in a pass of its own, so that extraction never depends
|
|
38
|
-
* on whether a chart has been drawn yet.
|
|
39
|
-
*/
|
|
10
|
+
/** Writes translation keys such as `harvest-row1` onto a figure with `data-chart-keys`; a duplicate prefix gets a number. */
|
|
40
11
|
export declare const assignKeys: (figures: HTMLElement[], langattribute: string | false) => void;
|
|
41
12
|
|
|
42
|
-
/**
|
|
43
|
-
* Pass 2. Everything a reader will read, before a translation script looks.
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
13
|
+
/** Pass 2: everything a reader will read, before a translation script looks. */
|
|
46
14
|
export declare const build: (figure: HTMLElement, config: Config, asKind?: string | null) => ChartState | null;
|
|
47
15
|
|
|
48
|
-
/** One value cell of the source table. */
|
|
49
16
|
declare interface Cell {
|
|
50
|
-
/** The cell exactly as written. */
|
|
51
17
|
raw: string;
|
|
52
|
-
/**
|
|
53
|
-
* when the cell holds no number. */
|
|
18
|
+
/** As written, so its decimal places survive. Empty when the cell holds no number. */
|
|
54
19
|
number: string;
|
|
55
|
-
/**
|
|
56
|
-
* footnote. It is kept on the label, either side of the formatted number. */
|
|
20
|
+
/** Text around the number, such as `%` or a footnote `*`, kept either side of the formatted number. */
|
|
57
21
|
prefix: string;
|
|
58
22
|
suffix: string;
|
|
59
|
-
/**
|
|
60
|
-
* says what the cell does. Its value counts as zero wherever one is needed. */
|
|
23
|
+
/** No number, such as "n/a": no mark, and the label says what the cell says. Counts as zero. */
|
|
61
24
|
missing: boolean;
|
|
62
25
|
value: number;
|
|
63
26
|
}
|
|
@@ -74,76 +37,55 @@ export declare interface ChartState {
|
|
|
74
37
|
seriesValues: HTMLElement[][];
|
|
75
38
|
names: HTMLElement[];
|
|
76
39
|
categories: HTMLElement[];
|
|
77
|
-
/** The number in the middle of a donut. Null for a chart that has no middle. */
|
|
78
40
|
centre: HTMLElement | null;
|
|
79
41
|
stacked: boolean;
|
|
80
42
|
totals: HTMLElement[];
|
|
81
|
-
/** The cell of the total row Tablechart adds to a donut's table, if it adds one. */
|
|
82
43
|
totalCell: HTMLElement | null;
|
|
83
|
-
/**
|
|
84
|
-
* Set by the layout; null for a chart whose rows are not side by side. */
|
|
44
|
+
/** In screen pixels from the plot's corner. Null for a chart whose rows are not side by side. */
|
|
85
45
|
rowAt: ((x: number, y: number) => number | null) | null;
|
|
86
|
-
/**
|
|
46
|
+
/** As percentages: left, top, width and height. */
|
|
87
47
|
rowBox: ((index: number) => [number, number, number, number]) | null;
|
|
88
48
|
annotations: {
|
|
89
49
|
spec: HTMLElement;
|
|
90
50
|
type: AnnotationType;
|
|
91
51
|
badge: HTMLElement | null;
|
|
92
|
-
/**
|
|
52
|
+
/** From 0; `data-series` counts from 1. */
|
|
93
53
|
series: number;
|
|
94
|
-
/** How many stagger steps it waits, so it lands after the data. */
|
|
95
54
|
after: number;
|
|
96
55
|
}[];
|
|
97
56
|
checks: Check[];
|
|
98
57
|
}
|
|
99
58
|
|
|
100
|
-
/** A chart kind: it reserves room for its text, then draws its own marks. */
|
|
101
59
|
declare interface ChartType {
|
|
102
|
-
/** Height as a share of width, when the page's own aspect does not suit. A
|
|
103
|
-
* donut needs a squarer box than a row of columns does. */
|
|
104
60
|
aspect?: number;
|
|
105
|
-
/**
|
|
106
|
-
* than among the marks. */
|
|
61
|
+
/** A row marked as a total goes in the middle rather than among the marks. */
|
|
107
62
|
centre?: boolean;
|
|
108
|
-
/** A break in the scale
|
|
109
|
-
* or, for a waterfall, its totals do and its floating steps keep clear of the
|
|
110
|
-
* break, which the scale checks for. */
|
|
63
|
+
/** A break in the scale works here; a waterfall keeps its floating steps clear of it. */
|
|
111
64
|
breakable?: boolean;
|
|
112
|
-
/** `data-chart-stack` works for this kind. */
|
|
113
65
|
stackable?: boolean;
|
|
114
|
-
/** A stacked chart of this kind shows the total of each row. */
|
|
115
66
|
totals?: boolean;
|
|
116
|
-
/** The sample in front of a name
|
|
117
|
-
* with `legend` always has a legend; one with only `swatch` has one when asked. */
|
|
67
|
+
/** The sample in front of a legend name when it is not a line; the legend shows only when asked. */
|
|
118
68
|
swatch?: "box";
|
|
119
|
-
/** Where the category names go: in a row under the plot, or beside the marks,
|
|
120
|
-
* which is what a chart whose bars run sideways needs. */
|
|
121
69
|
categories?: "under" | "beside";
|
|
122
|
-
/** This kind draws every value column, not only the first. */
|
|
123
70
|
series?: boolean;
|
|
124
|
-
/** With several series,
|
|
125
|
-
* a sample of this shape: a square for bars. */
|
|
71
|
+
/** With several series, always a legend, with a sample of this shape. */
|
|
126
72
|
legend?: "box";
|
|
127
|
-
/** Extra headroom above the tallest bar, in viewBox units. */
|
|
128
73
|
headroom?: (geo: HeadroomInput) => number;
|
|
129
|
-
/** The least height this kind needs, in viewBox units, whatever its shape. */
|
|
130
74
|
minHeight?: (input: {
|
|
131
75
|
labelHeight: number;
|
|
132
|
-
/** The height of the tallest category name, which can wrap onto several lines. */
|
|
133
76
|
nameHeight: number;
|
|
134
77
|
unit: number;
|
|
135
78
|
rows: number;
|
|
136
79
|
series: number;
|
|
137
80
|
stacked: boolean;
|
|
138
81
|
}) => number;
|
|
139
|
-
/** Room under the baseline
|
|
82
|
+
/** Room under the baseline for numbers that hang below a mark near it. */
|
|
140
83
|
footroom?: (geo: HeadroomInput) => number;
|
|
141
|
-
/**
|
|
84
|
+
/** Default: one bar per row from the baseline. */
|
|
142
85
|
segments?: (rows: Row[]) => Segment[];
|
|
143
86
|
draw: (geo: Geometry) => void;
|
|
144
87
|
}
|
|
145
88
|
|
|
146
|
-
/** An authored figure next to the one the data implies. */
|
|
147
89
|
declare interface Check {
|
|
148
90
|
label: string;
|
|
149
91
|
computed: number;
|
|
@@ -160,32 +102,19 @@ export declare interface Config {
|
|
|
160
102
|
barfill: number;
|
|
161
103
|
/** Share of a donut's radius that the ring itself takes. */
|
|
162
104
|
ringfill: number;
|
|
163
|
-
/**
|
|
164
|
-
* Locale for number formatting. Left unset, the document's own language is
|
|
165
|
-
* used and followed when it changes, so a translated page reformats itself.
|
|
166
|
-
*/
|
|
105
|
+
/** Locale for numbers. Unset, the document's language is used and followed when it changes. */
|
|
167
106
|
locale?: string;
|
|
168
|
-
/** Animate a chart when it builds. */
|
|
169
|
-
animate: boolean;
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
* number keeps it outside. A figure says otherwise with `data-chart-labels`.
|
|
174
|
-
*/
|
|
107
|
+
/** Animate a chart when it builds. `"up"` grows lines and areas from zero instead of across; a figure overrides it with `data-chart-animate`. */
|
|
108
|
+
animate: boolean | "across" | "up";
|
|
109
|
+
/** 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`. */
|
|
110
|
+
entrance: number;
|
|
111
|
+
/** Where a column's number goes: on the bar, or inside it. A figure overrides it with `data-chart-labels`. */
|
|
175
112
|
labels: "outside" | "inside";
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
* chart. A figure says otherwise with `data-chart-legend`, or
|
|
180
|
-
* `data-chart-legend="false"`.
|
|
181
|
-
*/
|
|
113
|
+
/** How a line or area runs between points: `straight`, `step` or `smooth`. A figure overrides it with `data-chart-shape`. */
|
|
114
|
+
shape: "straight" | "step" | "smooth";
|
|
115
|
+
/** Names of several lines in a legend instead of at the end of each line. A figure overrides it with `data-chart-legend`. */
|
|
182
116
|
legend: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* If a chart has numbers that were left out because there is no room for them,
|
|
185
|
-
* pointing at a row, or tapping it, shows the numbers of that row. The other
|
|
186
|
-
* numbers are hidden for that time. A figure turns it off with
|
|
187
|
-
* `data-chart-hover="false"`.
|
|
188
|
-
*/
|
|
117
|
+
/** Pointing at a row shows numbers that were left out for lack of room. A figure turns it off with `data-chart-hover="false"`. */
|
|
189
118
|
hover: boolean;
|
|
190
119
|
/** The name of the total that a donut without a total row works out, for screen readers. */
|
|
191
120
|
totallabel: string;
|
|
@@ -193,10 +122,7 @@ export declare interface Config {
|
|
|
193
122
|
threshold: number;
|
|
194
123
|
/** Build again each time a chart scrolls back into view, not only the first time. */
|
|
195
124
|
replay: boolean;
|
|
196
|
-
/**
|
|
197
|
-
* The attribute that holds translation keys, for a translation script. A figure
|
|
198
|
-
* with `data-chart-keys` gets translation keys on its names. `false` turns them off.
|
|
199
|
-
*/
|
|
125
|
+
/** The attribute for translation keys, for a translation script. `false` turns keys off. */
|
|
200
126
|
langattribute: string | false;
|
|
201
127
|
/** Show messages in the console for whoever is working on the page. */
|
|
202
128
|
debug?: boolean;
|
|
@@ -204,65 +130,46 @@ export declare interface Config {
|
|
|
204
130
|
|
|
205
131
|
export declare const defaultConfig: Config;
|
|
206
132
|
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*/
|
|
133
|
+
/** How far an animated parent is in before the chart builds: the figure's `data-chart-entrance`, or else the option. */
|
|
134
|
+
export declare const entranceOf: (figure: HTMLElement, config: Config) => number;
|
|
135
|
+
|
|
136
|
+
/** Scales only, no pixel positions, so an annotation follows the data. */
|
|
211
137
|
declare interface Geometry {
|
|
212
138
|
rows: Row[];
|
|
213
139
|
segments: Segment[];
|
|
214
|
-
/** Centre of a band, in viewBox units. */
|
|
215
140
|
cx: (index: number) => number;
|
|
216
|
-
/** A value's height, in viewBox units. */
|
|
217
141
|
y: (value: number) => number;
|
|
218
|
-
/** Bar width, in viewBox units. */
|
|
219
142
|
barWidth: number;
|
|
220
|
-
/** The widest a bar may be, in viewBox units, from `--tablechart-bar-max`. */
|
|
221
143
|
barMax: number;
|
|
222
|
-
/** viewBox height. */
|
|
223
144
|
height: number;
|
|
224
|
-
/** viewBox units per screen pixel
|
|
145
|
+
/** viewBox units per screen pixel. */
|
|
225
146
|
unit: number;
|
|
226
|
-
/** Measured height of a value label, in viewBox units. */
|
|
227
147
|
labelHeight: number;
|
|
228
|
-
/** Measured height of a badge, in viewBox units. Zero when the chart has none. */
|
|
229
148
|
badgeHeight: number;
|
|
230
|
-
/** How many stagger steps the data
|
|
149
|
+
/** How many stagger steps the data takes, so commentary can land after it. */
|
|
231
150
|
after: number;
|
|
232
|
-
/**
|
|
233
|
-
* marks gets it as `data-note`. Zero for the chart itself. */
|
|
151
|
+
/** An annotation's number in the figure, from 1, set as `data-note` on its marks. Zero for the chart. */
|
|
234
152
|
note: number;
|
|
235
|
-
/** Where the break's mark goes, as a value
|
|
236
|
-
* when the scale runs straight through. */
|
|
153
|
+
/** Where the break's mark goes, as a value. Null when the scale runs straight through. */
|
|
237
154
|
breakAt: number | null;
|
|
238
|
-
/** Where the numbers on the marks go, by the figure's say or the page's. */
|
|
239
155
|
labels: "outside" | "inside";
|
|
240
|
-
/** `data-chart-stack` on the figure: the series of a row are drawn on top of
|
|
241
|
-
* each other, the first at the bottom. */
|
|
242
156
|
stacked: boolean;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
shape: "straight" | "step";
|
|
246
|
-
/** The total of each row of a stacked chart, in row order. Empty when the chart
|
|
247
|
-
* is not stacked or its kind shows no totals. */
|
|
157
|
+
shape: Shape;
|
|
158
|
+
/** Empty when the chart is not stacked or its kind shows no totals. */
|
|
248
159
|
totals: HTMLElement[];
|
|
249
160
|
svg: SVGSVGElement;
|
|
250
161
|
plot: HTMLElement;
|
|
251
|
-
/**
|
|
162
|
+
/** Made by `build`; a chart only places them. */
|
|
252
163
|
values: HTMLElement[];
|
|
253
|
-
/** The value columns. A chart kind that draws only one is given only one. */
|
|
254
164
|
series: Series[];
|
|
255
|
-
/** The value labels of each series, in row order. The first is `values`. */
|
|
256
165
|
seriesValues: HTMLElement[][];
|
|
257
|
-
/**
|
|
166
|
+
/** Empty with one series. */
|
|
258
167
|
names: HTMLElement[];
|
|
259
|
-
/**
|
|
260
|
-
* places these too; one that keeps them under the plot never touches them. */
|
|
168
|
+
/** A chart with its names beside the marks places these; one with them under the plot does not. */
|
|
261
169
|
categories: HTMLElement[];
|
|
262
|
-
/** The number in the middle, for a chart kind that has one. */
|
|
263
170
|
centre: HTMLElement | null;
|
|
264
171
|
config: Config;
|
|
265
|
-
/** Numbers an annotation worked out, against the
|
|
172
|
+
/** Numbers an annotation worked out, against the ones the author wrote. */
|
|
266
173
|
checks: Check[];
|
|
267
174
|
}
|
|
268
175
|
|
|
@@ -271,7 +178,6 @@ declare interface HeadroomInput {
|
|
|
271
178
|
badgeHeight: number;
|
|
272
179
|
hasAnnotations: boolean;
|
|
273
180
|
unit: number;
|
|
274
|
-
/** How many series the chart draws, and whether one of them is in focus. */
|
|
275
181
|
series: number;
|
|
276
182
|
focused: boolean;
|
|
277
183
|
stacked: boolean;
|
|
@@ -280,100 +186,60 @@ declare interface HeadroomInput {
|
|
|
280
186
|
/** Pass 3. Needs layout; makes no text, only places it. */
|
|
281
187
|
export declare const layout: (state: ChartState, config: Config) => boolean;
|
|
282
188
|
|
|
283
|
-
/**
|
|
284
|
-
* `data-chart-src` names a JSON file that holds the chart's rows. The file is the
|
|
285
|
-
* whole of the data: a table written inside the figure is removed, so there is
|
|
286
|
-
* never a question of which of the two is drawn. The file is either an array of
|
|
287
|
-
* rows or an object with a `rows` array.
|
|
288
|
-
*
|
|
289
|
-
* The file becomes an ordinary table before anything else happens, so a screen
|
|
290
|
-
* reader, a translation plugin and print all get the same table they would from
|
|
291
|
-
* HTML. A file that cannot be read leaves its chart empty and says why; the rest
|
|
292
|
-
* of the page goes on.
|
|
293
|
-
*/
|
|
189
|
+
/** `data-chart-src` replaces any table in the figure with one made from a JSON file; a file that fails is reported. */
|
|
294
190
|
export declare const loadSources: (figures: HTMLElement[]) => Promise<void>;
|
|
295
191
|
|
|
296
192
|
export declare const PLACED_CLASS = "is-placed";
|
|
297
193
|
|
|
298
194
|
export declare const PLOT_CLASS = "tablechart-plot";
|
|
299
195
|
|
|
300
|
-
/**
|
|
301
|
-
* Turns elements into figures with a table, ready to build: a table from Markdown
|
|
302
|
-
* is wrapped, a JSON file becomes a table, and translation keys are added. All at
|
|
303
|
-
* once, so two charts with the same `data-chart-keys` are found.
|
|
304
|
-
*/
|
|
196
|
+
/** Turns elements into figures with a table and translation keys, all at once, so duplicate keys are found. */
|
|
305
197
|
export declare const prepare: (found: HTMLElement[], config: Config) => Promise<HTMLElement[]>;
|
|
306
198
|
|
|
307
199
|
export declare const QUEUED_CLASS = "tablechart-queued";
|
|
308
200
|
|
|
309
|
-
/**
|
|
310
|
-
* A Markdown table has no header cells in its body and no attributes on its rows,
|
|
311
|
-
* so it says the same things differently. The first cell of a row is its label,
|
|
312
|
-
* and a label in **bold**, or in a `.total` span, makes the row a total, like
|
|
313
|
-
* `data-kind="total"` in HTML. A total is set in bold in most tables of figures
|
|
314
|
-
* already. The bold is taken off once read, so the label is plain text again.
|
|
315
|
-
* Rows written in HTML already have their `th` and are left as they are.
|
|
316
|
-
*
|
|
317
|
-
* The header over the value columns names the series. A name in bold is the
|
|
318
|
-
* series in focus, like `data-kind="focus"`.
|
|
319
|
-
*/
|
|
201
|
+
/** In a Markdown table, a bold label makes the row a total, and a bold header puts that series in focus. */
|
|
320
202
|
export declare const readMarkdownRows: (figures: HTMLElement[]) => void;
|
|
321
203
|
|
|
322
204
|
/** Numbers are reformatted in place, so a language change costs no redraw. */
|
|
323
205
|
export declare const relabel: (state: ChartState, config: Config) => void;
|
|
324
206
|
|
|
325
|
-
/** One row of the source table. Its own value is its first cell's. */
|
|
326
207
|
export declare interface Row extends Cell {
|
|
327
|
-
/** The category label, as authored. */
|
|
328
208
|
label: string;
|
|
329
|
-
/** Its translation key, authored or generated. */
|
|
330
209
|
key: string | null;
|
|
331
|
-
/** Every value cell in the row, one per series. The first is the row's own. */
|
|
332
210
|
cells: Cell[];
|
|
333
|
-
/**
|
|
334
|
-
* number and name, so one class styles everything drawn for the row. */
|
|
211
|
+
/** Copied to everything drawn for the row, so one class styles all of it. */
|
|
335
212
|
classes: string[];
|
|
336
|
-
/** A row marked `data-kind="total"` is a total. */
|
|
337
213
|
isTotal: boolean;
|
|
338
|
-
/**
|
|
214
|
+
/** The stagger counts from here. */
|
|
339
215
|
slot: number;
|
|
340
216
|
}
|
|
341
217
|
|
|
342
|
-
/** A row once a chart has worked out where it goes. */
|
|
343
218
|
declare interface Segment extends Row {
|
|
344
219
|
from: number;
|
|
345
220
|
to: number;
|
|
346
221
|
kind: "bar" | "up" | "down" | "total";
|
|
347
222
|
}
|
|
348
223
|
|
|
349
|
-
/**
|
|
350
|
-
* A value column of the source table. A table with one is a chart with one series,
|
|
351
|
-
* and its header is not read; with more, the header names each one.
|
|
352
|
-
*/
|
|
353
224
|
export declare interface Series {
|
|
354
|
-
/** The column's header, as authored. Empty when the table has no header. */
|
|
355
225
|
name: string;
|
|
356
|
-
/** Its translation key, authored or generated. */
|
|
357
226
|
key: string | null;
|
|
358
|
-
/** `data-kind="focus"
|
|
359
|
-
* chart is about. The others are shown fainter. */
|
|
227
|
+
/** `data-kind="focus"`, or bold in Markdown: the others are shown fainter. */
|
|
360
228
|
focus: boolean;
|
|
361
|
-
/** `data-marker` on the header
|
|
362
|
-
* `diamond open`. Null for the point its place gives it. */
|
|
229
|
+
/** `data-marker` on the header, such as `square` or `diamond open`. */
|
|
363
230
|
marker: string | null;
|
|
364
|
-
/** `data-line` on the header: a dashed or dotted line. Null for a solid one. */
|
|
365
231
|
line: "dashed" | "dotted" | null;
|
|
366
232
|
}
|
|
367
233
|
|
|
368
234
|
/** One class, `is-shown`, starts the whole build. */
|
|
369
235
|
export declare const setShown: (state: ChartState, shown: boolean) => void;
|
|
370
236
|
|
|
237
|
+
/** How a line or an area runs from one point to the next. */
|
|
238
|
+
declare type Shape = "straight" | "step" | "smooth";
|
|
239
|
+
|
|
371
240
|
export declare const SHOWN_CLASS = "is-shown";
|
|
372
241
|
|
|
373
|
-
/**
|
|
374
|
-
* Removes what `build` added to the figure, so it can be built again. The table
|
|
375
|
-
* and the figure's own attributes stay.
|
|
376
|
-
*/
|
|
242
|
+
/** Removes what `build` added, so the chart can be built again. */
|
|
377
243
|
export declare const unbuild: (state: ChartState) => void;
|
|
378
244
|
|
|
379
245
|
export { }
|
|
@@ -381,7 +247,6 @@ export { }
|
|
|
381
247
|
|
|
382
248
|
declare global {
|
|
383
249
|
interface HTMLElement {
|
|
384
|
-
/** The chart made of this element, by `init` or `create`. */
|
|
385
250
|
tablechart?: TablechartChart;
|
|
386
251
|
}
|
|
387
252
|
}
|
package/dist/tablechart-core.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l,
|
|
2
|
-
export {
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, s as p, u as m, v as h } from "./tablechart-shared.mjs";
|
|
2
|
+
export { l as PLACED_CLASS, o as PLOT_CLASS, a as QUEUED_CLASS, e as SHOWN_CLASS, t as adoptTables, f as assignKeys, n as build, h as defaultConfig, u as entranceOf, c as layout, d as loadSources, s as prepare, p as readMarkdownRows, m as relabel, r as setShown, i as unbuild };
|