@tectra-ng/charts 0.3.1 → 0.4.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/fesm2022/tectra-ng-charts-bar-list.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-boxplot.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-bullet.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-candlestick.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-column.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-combo.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-core.mjs +3 -16
- package/fesm2022/tectra-ng-charts-core.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-funnel.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-gantt.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-gauge.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-heatmap.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-org-chart.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-pie.mjs +1 -1
- package/fesm2022/tectra-ng-charts-pie.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-radar.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-radial-bar.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-rank-line.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-sankey.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-scatter.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-segmented-bar.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-sunburst.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-treemap.mjs +5 -5
- package/fesm2022/tectra-ng-charts-treemap.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts-waterfall.mjs.map +1 -1
- package/fesm2022/tectra-ng-charts.mjs +1 -1
- package/fesm2022/tectra-ng-charts.mjs.map +1 -1
- package/package.json +9 -9
- package/pie/README.md +1 -1
- package/treemap/README.md +1 -1
- package/types/tectra-ng-charts-bar-list.d.ts +32 -634
- package/types/tectra-ng-charts-bar-list.d.ts.map +1 -1
- package/types/tectra-ng-charts-boxplot.d.ts +77 -634
- package/types/tectra-ng-charts-boxplot.d.ts.map +1 -1
- package/types/tectra-ng-charts-bullet.d.ts +66 -634
- package/types/tectra-ng-charts-bullet.d.ts.map +1 -1
- package/types/tectra-ng-charts-candlestick.d.ts +62 -634
- package/types/tectra-ng-charts-candlestick.d.ts.map +1 -1
- package/types/tectra-ng-charts-column.d.ts +81 -634
- package/types/tectra-ng-charts-column.d.ts.map +1 -1
- package/types/tectra-ng-charts-combo.d.ts +98 -634
- package/types/tectra-ng-charts-combo.d.ts.map +1 -1
- package/types/tectra-ng-charts-core.d.ts +451 -6
- package/types/tectra-ng-charts-core.d.ts.map +1 -1
- package/types/tectra-ng-charts-funnel.d.ts +73 -634
- package/types/tectra-ng-charts-funnel.d.ts.map +1 -1
- package/types/tectra-ng-charts-gantt.d.ts +97 -634
- package/types/tectra-ng-charts-gantt.d.ts.map +1 -1
- package/types/tectra-ng-charts-gauge.d.ts +56 -634
- package/types/tectra-ng-charts-gauge.d.ts.map +1 -1
- package/types/tectra-ng-charts-heatmap.d.ts +102 -634
- package/types/tectra-ng-charts-heatmap.d.ts.map +1 -1
- package/types/tectra-ng-charts-line.d.ts +74 -634
- package/types/tectra-ng-charts-line.d.ts.map +1 -1
- package/types/tectra-ng-charts-org-chart.d.ts +161 -634
- package/types/tectra-ng-charts-org-chart.d.ts.map +1 -1
- package/types/tectra-ng-charts-pie.d.ts +91 -634
- package/types/tectra-ng-charts-pie.d.ts.map +1 -1
- package/types/tectra-ng-charts-radar.d.ts +82 -634
- package/types/tectra-ng-charts-radar.d.ts.map +1 -1
- package/types/tectra-ng-charts-radial-bar.d.ts +69 -634
- package/types/tectra-ng-charts-radial-bar.d.ts.map +1 -1
- package/types/tectra-ng-charts-range-area.d.ts +61 -634
- package/types/tectra-ng-charts-range-area.d.ts.map +1 -1
- package/types/tectra-ng-charts-rank-line.d.ts +55 -634
- package/types/tectra-ng-charts-rank-line.d.ts.map +1 -1
- package/types/tectra-ng-charts-sankey.d.ts +85 -634
- package/types/tectra-ng-charts-sankey.d.ts.map +1 -1
- package/types/tectra-ng-charts-scatter.d.ts +98 -634
- package/types/tectra-ng-charts-scatter.d.ts.map +1 -1
- package/types/tectra-ng-charts-segmented-bar.d.ts +39 -634
- package/types/tectra-ng-charts-segmented-bar.d.ts.map +1 -1
- package/types/tectra-ng-charts-sunburst.d.ts +57 -634
- package/types/tectra-ng-charts-sunburst.d.ts.map +1 -1
- package/types/tectra-ng-charts-treemap.d.ts +77 -634
- package/types/tectra-ng-charts-treemap.d.ts.map +1 -1
- package/types/tectra-ng-charts-waterfall.d.ts +69 -634
- package/types/tectra-ng-charts-waterfall.d.ts.map +1 -1
- package/types/tectra-ng-charts.d.ts +2 -1
- package/types/tectra-ng-charts.d.ts.map +1 -1
|
@@ -3,129 +3,226 @@ import { ElementRef, Signal, TemplateRef } from "@angular/core";
|
|
|
3
3
|
import { TxPassThroughPart, TxTranslations } from "@tectra-ng/core/config";
|
|
4
4
|
import { TxOverlayRef, TxPlacement } from "@tectra-ng/core/overlay";
|
|
5
5
|
import { TxIconName } from "@tectra-ng/icons";
|
|
6
|
+
/** A `[from, to]` pair of numbers: a domain or a pixel range. */
|
|
6
7
|
export type TxRange = [number, number];
|
|
8
|
+
/** A scale that maps numbers (values, times) to pixels and back, with round tick values. */
|
|
7
9
|
export interface TxContinuousScale {
|
|
10
|
+
/** Which scale it is: `linear`, `log` or `time`. */
|
|
8
11
|
kind: 'linear' | 'log' | 'time';
|
|
12
|
+
/** Value range the scale reads, `[min, max]`. */
|
|
9
13
|
domain: TxRange;
|
|
14
|
+
/** Pixel range the scale writes, `[from, to]`. */
|
|
10
15
|
range: TxRange;
|
|
16
|
+
/** Maps a value to its pixel position. */
|
|
11
17
|
map(value: number): number;
|
|
18
|
+
/** Maps a pixel position back to a value. */
|
|
12
19
|
invert(position: number): number;
|
|
20
|
+
/** Round tick values inside the domain; `count` is the wanted number of ticks. */
|
|
13
21
|
ticks(count?: number): number[];
|
|
14
22
|
}
|
|
23
|
+
/** Calendar unit of a time tick step. */
|
|
15
24
|
export type TxTimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
25
|
+
/** A calendar step between time ticks, for example every 6 hours. */
|
|
16
26
|
export interface TxTimeInterval {
|
|
27
|
+
/** Calendar unit of the step. */
|
|
17
28
|
unit: TxTimeUnit;
|
|
29
|
+
/** How many units one step covers. */
|
|
18
30
|
step: number;
|
|
31
|
+
/** Approximate length of one step, in ms. */
|
|
19
32
|
duration: number;
|
|
20
33
|
}
|
|
34
|
+
/** A continuous scale over time in ms that also reports the calendar step of its ticks. */
|
|
21
35
|
export interface TxTimeScale extends TxContinuousScale {
|
|
36
|
+
/** Always `time`. */
|
|
22
37
|
kind: 'time';
|
|
38
|
+
/** The calendar step the ticks use for the wanted number of ticks. */
|
|
23
39
|
interval(count?: number): TxTimeInterval;
|
|
24
40
|
}
|
|
41
|
+
/** A scale of equal bands, one per category. */
|
|
25
42
|
export interface TxBandScale {
|
|
43
|
+
/** Always `band`. */
|
|
26
44
|
kind: 'band';
|
|
45
|
+
/** Number of bands. */
|
|
27
46
|
count: number;
|
|
47
|
+
/** Pixel range the bands share, `[from, to]`. */
|
|
28
48
|
range: TxRange;
|
|
49
|
+
/** Distance between the starts of two neighbour bands, in px. */
|
|
29
50
|
step: number;
|
|
51
|
+
/** Width of one band without the inner padding, in px. */
|
|
30
52
|
bandwidth: number;
|
|
53
|
+
/** Pixel position where the band at `index` starts. */
|
|
31
54
|
start(index: number): number;
|
|
55
|
+
/** Pixel position of the middle of the band at `index`. */
|
|
32
56
|
center(index: number): number;
|
|
57
|
+
/** Index of the band under a pixel position, clamped to the first and last band. */
|
|
33
58
|
indexAt(position: number): number;
|
|
34
59
|
}
|
|
60
|
+
/** A scale of evenly spaced points from one edge to the other, one per category. */
|
|
35
61
|
export interface TxPointScale {
|
|
62
|
+
/** Always `point`. */
|
|
36
63
|
kind: 'point';
|
|
64
|
+
/** Number of points. */
|
|
37
65
|
count: number;
|
|
66
|
+
/** Pixel range the points are spread over, `[from, to]`. */
|
|
38
67
|
range: TxRange;
|
|
68
|
+
/** Distance between two neighbour points, in px; `0` for a single point. */
|
|
39
69
|
step: number;
|
|
70
|
+
/** Pixel position of the point at `index`. */
|
|
40
71
|
at(index: number): number;
|
|
72
|
+
/** Index of the point nearest to a pixel position. */
|
|
41
73
|
indexAt(position: number): number;
|
|
42
74
|
}
|
|
75
|
+
/** An x value of a point: a category label, a number or a date. */
|
|
43
76
|
export type TxChartX = string | number | Date;
|
|
77
|
+
/** One point of a series with its own x value. */
|
|
44
78
|
export interface TxChartPoint {
|
|
79
|
+
/** Category label, number or date of the point. */
|
|
45
80
|
x: TxChartX;
|
|
81
|
+
/** Value of the point; `null` leaves a gap. */
|
|
46
82
|
y: number | null;
|
|
47
83
|
}
|
|
84
|
+
/** One series of a chart: a name and numbers (one per category) or `{ x, y }` points. */
|
|
48
85
|
export interface TxChartSeries {
|
|
86
|
+
/** Name shown in the legend and the tooltip. */
|
|
49
87
|
name: string;
|
|
88
|
+
/** Values: numbers matched to the categories by index, or `{ x, y }` points; `null` leaves a gap. */
|
|
50
89
|
data: readonly (number | null)[] | readonly TxChartPoint[];
|
|
90
|
+
/** Colour of the series; a palette colour by series index when not set. */
|
|
51
91
|
color?: string;
|
|
52
92
|
}
|
|
93
|
+
/** Turns a value into the text shown for it. */
|
|
53
94
|
export type TxChartValueFormatter = (value: number) => string;
|
|
95
|
+
/** How values are written: `number`, `integer`, `compact`, `percent` or an own formatter function. */
|
|
54
96
|
export type TxChartValueFormat = 'number' | 'integer' | 'compact' | 'percent' | TxChartValueFormatter;
|
|
97
|
+
/** Which point a tooltip value belongs to. */
|
|
55
98
|
export interface TxChartTooltipContext {
|
|
99
|
+
/** Index of the series. */
|
|
56
100
|
seriesIndex: number;
|
|
101
|
+
/** Index of the point inside the series. */
|
|
57
102
|
dataPointIndex: number;
|
|
58
103
|
}
|
|
104
|
+
/** Turns a tooltip value into text; gets the series and point index as context. */
|
|
59
105
|
export type TxChartTooltipFormatter = (value: number, context: TxChartTooltipContext) => string;
|
|
106
|
+
/** Side of the chart where the legend sits. */
|
|
60
107
|
export type TxChartLegendPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
108
|
+
/** How the legend items are aligned along their side. */
|
|
61
109
|
export type TxChartLegendAlign = 'start' | 'center' | 'end';
|
|
110
|
+
/** Look of a legend item: `dot`, `line`, `pill` or `stat` (the value in large type). */
|
|
62
111
|
export type TxChartLegendVariant = 'dot' | 'line' | 'pill' | 'stat';
|
|
112
|
+
/** Shape of the colour marker of a legend item. */
|
|
63
113
|
export type TxChartLegendMarker = 'dot' | 'line';
|
|
114
|
+
/** One legend entry: a colour marker, a label and optional values. */
|
|
64
115
|
export interface TxChartLegendItem {
|
|
116
|
+
/** Identifies the item in `toggled` and `hovered` events. */
|
|
65
117
|
key: string;
|
|
118
|
+
/** Text of the item. */
|
|
66
119
|
label: string;
|
|
120
|
+
/** Colour of the marker. */
|
|
67
121
|
color: string;
|
|
122
|
+
/** Shows the item as switched off (its series is hidden). */
|
|
68
123
|
hidden?: boolean;
|
|
124
|
+
/** Marker shape, `dot` or `line`. */
|
|
69
125
|
marker?: TxChartLegendMarker;
|
|
126
|
+
/** Value text next to the label; the large figure in the `stat` variant. */
|
|
70
127
|
value?: string;
|
|
128
|
+
/** Share text shown after the value. */
|
|
71
129
|
percent?: string;
|
|
130
|
+
/** Small text under the value in the `stat` variant. */
|
|
72
131
|
caption?: string;
|
|
73
132
|
}
|
|
133
|
+
/** Context of an own legend item template: the item and its index. */
|
|
74
134
|
export interface TxChartLegendContext {
|
|
135
|
+
/** The legend item to draw. */
|
|
75
136
|
$implicit: TxChartLegendItem;
|
|
137
|
+
/** Position of the item in the legend. */
|
|
76
138
|
index: number;
|
|
77
139
|
}
|
|
140
|
+
/** One line of a tooltip: a colour marker, a name and a formatted value. */
|
|
78
141
|
export interface TxChartTooltipRow {
|
|
142
|
+
/** Series or category name. */
|
|
79
143
|
label: string;
|
|
144
|
+
/** Formatted value text. */
|
|
80
145
|
value: string;
|
|
146
|
+
/** Colour of the marker. */
|
|
81
147
|
color: string;
|
|
148
|
+
/** Value as a number; `null` when there is none. */
|
|
82
149
|
raw: number | null;
|
|
150
|
+
/** Index of the series the row belongs to. */
|
|
83
151
|
seriesIndex: number;
|
|
152
|
+
/** Marks the row of the hovered series. */
|
|
84
153
|
active?: boolean;
|
|
154
|
+
/** Formatted share of the whole, for example a percent. */
|
|
85
155
|
share?: string;
|
|
86
156
|
}
|
|
157
|
+
/** Content and position of a chart tooltip. */
|
|
87
158
|
export interface TxChartTooltipData {
|
|
159
|
+
/** Heading of the tooltip, usually the category or date. */
|
|
88
160
|
title: string;
|
|
161
|
+
/** Lines of the tooltip. */
|
|
89
162
|
rows: TxChartTooltipRow[];
|
|
163
|
+
/** Index of the category the tooltip shows. */
|
|
90
164
|
index: number;
|
|
165
|
+
/** Horizontal anchor of the tooltip inside the chart box, in px. */
|
|
91
166
|
x: number;
|
|
167
|
+
/** Vertical anchor of the tooltip inside the chart box, in px. */
|
|
92
168
|
y: number;
|
|
169
|
+
/** Side of the anchor the tooltip opens on; `tooltipPlacement` of the frame when not set. */
|
|
93
170
|
placement?: TxChartTooltipPlacement;
|
|
171
|
+
/** Formatted total shown below the rows. */
|
|
94
172
|
total?: string;
|
|
173
|
+
/** Extra line of text shown below the rows. */
|
|
95
174
|
note?: string;
|
|
96
175
|
}
|
|
176
|
+
/** Side of the anchor a tooltip opens on. */
|
|
97
177
|
export type TxChartTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
178
|
+
/** Context of an own tooltip template. */
|
|
98
179
|
export interface TxChartTooltipTemplateContext {
|
|
180
|
+
/** The tooltip data to draw. */
|
|
99
181
|
$implicit: TxChartTooltipData;
|
|
100
182
|
}
|
|
183
|
+
/** What a tooltip shows: every series at the category (`shared`) or only the hovered one (`single`). */
|
|
101
184
|
export type TxChartTooltipMode = 'shared' | 'single';
|
|
185
|
+
/** What to do with category labels that do not fit: `auto`, `rotate` or `skip`. */
|
|
102
186
|
export type TxChartLabelMode = 'auto' | 'rotate' | 'skip';
|
|
187
|
+
/** Side of the plot an axis sits on. */
|
|
103
188
|
export type TxChartAxisPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
189
|
+
/** Side of the plot the x axis sits on. */
|
|
104
190
|
export type TxChartXAxisPosition = 'bottom' | 'top';
|
|
191
|
+
/** Side of the plot the y axis sits on. */
|
|
105
192
|
export type TxChartYAxisPosition = 'left' | 'right';
|
|
193
|
+
/** A tick of an axis: its value, pixel position and text. */
|
|
106
194
|
export interface TxChartTick {
|
|
195
|
+
/** Tick value. */
|
|
107
196
|
value: number;
|
|
197
|
+
/** Pixel position along the axis. */
|
|
108
198
|
position: number;
|
|
199
|
+
/** Formatted tick text. */
|
|
109
200
|
label: string;
|
|
110
201
|
}
|
|
202
|
+
/** A text of an axis placed in the SVG: tick label with its anchor and rotation. */
|
|
111
203
|
export interface TxChartAxisLabel {
|
|
204
|
+
/** Text of the label, shortened when it is too long. */
|
|
112
205
|
text: string;
|
|
206
|
+
/** Horizontal position, in px. */
|
|
113
207
|
x: number;
|
|
208
|
+
/** Vertical position, in px. */
|
|
114
209
|
y: number;
|
|
210
|
+
/** SVG `text-anchor` of the text. */
|
|
115
211
|
anchor: 'start' | 'middle' | 'end';
|
|
212
|
+
/** SVG `dominant-baseline` of the text. */
|
|
116
213
|
baseline: 'auto' | 'middle' | 'hanging';
|
|
214
|
+
/** Rotation around the label position, in degrees. */
|
|
117
215
|
rotate: number;
|
|
216
|
+
/** Full text for a tooltip when `text` was shortened. */
|
|
118
217
|
title?: string;
|
|
119
218
|
}
|
|
219
|
+
/** One axis ready to draw: its side, labels and title. */
|
|
120
220
|
export interface TxChartAxisModel {
|
|
221
|
+
/** Side of the plot the axis sits on. */
|
|
121
222
|
position: TxChartAxisPosition;
|
|
223
|
+
/** Tick labels of the axis. */
|
|
122
224
|
labels: TxChartAxisLabel[];
|
|
123
|
-
|
|
124
|
-
x1: number;
|
|
125
|
-
y1: number;
|
|
126
|
-
x2: number;
|
|
127
|
-
y2: number;
|
|
128
|
-
} | null;
|
|
225
|
+
/** Axis title with its position and rotation in degrees. */
|
|
129
226
|
title?: {
|
|
130
227
|
text: string;
|
|
131
228
|
x: number;
|
|
@@ -133,233 +230,463 @@ export interface TxChartAxisModel {
|
|
|
133
230
|
rotate: number;
|
|
134
231
|
};
|
|
135
232
|
}
|
|
233
|
+
/** A straight line of the grid or the zero line, in px. */
|
|
136
234
|
export interface TxChartGridLine {
|
|
235
|
+
/** Start, horizontal position. */
|
|
137
236
|
x1: number;
|
|
237
|
+
/** Start, vertical position. */
|
|
138
238
|
y1: number;
|
|
239
|
+
/** End, horizontal position. */
|
|
139
240
|
x2: number;
|
|
241
|
+
/** End, vertical position. */
|
|
140
242
|
y2: number;
|
|
243
|
+
/** Marks the line at the value zero. */
|
|
141
244
|
zero?: boolean;
|
|
142
245
|
}
|
|
246
|
+
/** Everything `tx-chart-axes` draws: axes, grid lines and the zero line. */
|
|
143
247
|
export interface TxChartAxesModel {
|
|
248
|
+
/** Axes with their labels and titles. */
|
|
144
249
|
axes: TxChartAxisModel[];
|
|
250
|
+
/** Grid lines. */
|
|
145
251
|
grid: TxChartGridLine[];
|
|
252
|
+
/** Line at the value zero, or `null` when zero is outside the domain. */
|
|
146
253
|
zero: TxChartGridLine | null;
|
|
147
254
|
}
|
|
255
|
+
/** The plot area inside the chart box, in px. */
|
|
148
256
|
export interface TxChartPlot {
|
|
257
|
+
/** Distance from the left edge of the box. */
|
|
149
258
|
left: number;
|
|
259
|
+
/** Distance from the top edge of the box. */
|
|
150
260
|
top: number;
|
|
261
|
+
/** Width of the plot area. */
|
|
151
262
|
width: number;
|
|
263
|
+
/** Height of the plot area. */
|
|
152
264
|
height: number;
|
|
153
265
|
}
|
|
266
|
+
/** Size of a chart box, in px. */
|
|
154
267
|
export interface TxChartSize {
|
|
268
|
+
/** Width in px. */
|
|
155
269
|
width: number;
|
|
270
|
+
/** Height in px. */
|
|
156
271
|
height: number;
|
|
157
272
|
}
|
|
273
|
+
/** A column of the hidden data table (one series). */
|
|
158
274
|
export interface TxChartTableColumn {
|
|
275
|
+
/** Identifies the column. */
|
|
159
276
|
key: string;
|
|
277
|
+
/** Column heading, usually the series name. */
|
|
160
278
|
label: string;
|
|
161
279
|
}
|
|
280
|
+
/** The hidden data table that gives screen readers the values of a chart. */
|
|
162
281
|
export interface TxChartTable {
|
|
282
|
+
/** Columns, one per series. */
|
|
163
283
|
columns: TxChartTableColumn[];
|
|
284
|
+
/** Rows, one per category, with a text per column. */
|
|
164
285
|
rows: {
|
|
165
286
|
label: string;
|
|
166
287
|
cells: string[];
|
|
167
288
|
}[];
|
|
168
289
|
}
|
|
290
|
+
/** Name of a part of the chart frame that takes pass-through attributes. */
|
|
169
291
|
export type TxChartPart = 'root' | 'legend' | 'legendItem' | 'plot' | 'svg' | 'grid' | 'axis' | 'series' | 'hoverBand' | 'tooltip' | 'empty' | 'skeleton';
|
|
292
|
+
/** A rectangle in px. */
|
|
170
293
|
export interface TxChartRect {
|
|
294
|
+
/** Left edge. */
|
|
171
295
|
x: number;
|
|
296
|
+
/** Top edge. */
|
|
172
297
|
y: number;
|
|
298
|
+
/** Width. */
|
|
173
299
|
width: number;
|
|
300
|
+
/** Height. */
|
|
174
301
|
height: number;
|
|
175
302
|
}
|
|
303
|
+
/** Chart height: a number of px or a CSS `px` string. */
|
|
176
304
|
export type TxChartHeight = number | string;
|
|
305
|
+
/** A pointer event of the frame, with the position inside the plot. */
|
|
177
306
|
export interface TxChartPointerEvent {
|
|
307
|
+
/** Horizontal position inside the plot, in px. */
|
|
178
308
|
x: number;
|
|
309
|
+
/** Vertical position inside the plot, in px. */
|
|
179
310
|
y: number;
|
|
311
|
+
/** What happened: `move`, `leave`, `click`, `down` or `up`. */
|
|
180
312
|
type: 'move' | 'leave' | 'click' | 'down' | 'up';
|
|
313
|
+
/** Element under the pointer. */
|
|
181
314
|
target: Element | null;
|
|
315
|
+
/** Pressed buttons bitmask of the DOM event. */
|
|
182
316
|
buttons?: number;
|
|
317
|
+
/** Kind of pointer: `mouse`, `touch` or `pen`. */
|
|
183
318
|
pointerType?: string;
|
|
184
319
|
}
|
|
320
|
+
/** A zoom request from Ctrl + wheel or a pinch. */
|
|
185
321
|
export interface TxChartZoomEvent {
|
|
322
|
+
/** Horizontal position of the zoom centre inside the plot, in px. */
|
|
186
323
|
x: number;
|
|
324
|
+
/** Zoom factor; above 1 zooms in, below 1 zooms out. */
|
|
187
325
|
factor: number;
|
|
188
326
|
}
|
|
327
|
+
/** A sideways pan request from a swipe. */
|
|
189
328
|
export interface TxChartPanEvent {
|
|
329
|
+
/** Horizontal move since the last event, in px. */
|
|
190
330
|
dx: number;
|
|
191
331
|
}
|
|
332
|
+
/** A key press forwarded from the frame. */
|
|
192
333
|
export interface TxChartKeyEvent {
|
|
334
|
+
/** Value of `KeyboardEvent.key`. */
|
|
193
335
|
key: string;
|
|
336
|
+
/** The original keyboard event. */
|
|
194
337
|
event: KeyboardEvent;
|
|
195
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Round step (1, 2, 5 times a power of ten) that gives about `count` ticks between two numbers; `0`
|
|
341
|
+
* when it cannot.
|
|
342
|
+
*/
|
|
196
343
|
export declare function tickStep(start: number, stop: number, count: number): number;
|
|
344
|
+
/** Number of decimals a step needs to be written exactly. */
|
|
197
345
|
export declare function decimalsOf(step: number): number;
|
|
346
|
+
/** Widens a range to round numbers, for example `[3, 97]` to `[0, 100]`. */
|
|
198
347
|
export declare function niceDomain(min: number, max: number, count?: number): TxRange;
|
|
348
|
+
/** Round tick values between `min` and `max`, about `count` of them. */
|
|
199
349
|
export declare function linearTicks(min: number, max: number, count?: number): number[];
|
|
350
|
+
/** Linear scale from a value domain to a pixel range. */
|
|
200
351
|
export declare function linearScale(domain: TxRange, range: TxRange): TxContinuousScale;
|
|
352
|
+
/** Widens a range to whole powers of ten for a logarithmic scale. */
|
|
201
353
|
export declare function logDomain(min: number, max: number): TxRange;
|
|
354
|
+
/** Tick values of a logarithmic scale: powers of ten, with 2 and 5 between them when there is room. */
|
|
202
355
|
export declare function logTicks(min: number, max: number, count?: number): number[];
|
|
356
|
+
/** Logarithmic scale from a value domain to a pixel range. */
|
|
203
357
|
export declare function logScale(domain: TxRange, range: TxRange): TxContinuousScale;
|
|
358
|
+
/**
|
|
359
|
+
* Equal bands for `count` categories inside a pixel range, with optional inner and outer padding as a
|
|
360
|
+
* share of a band.
|
|
361
|
+
*/
|
|
204
362
|
export declare function bandScale(count: number, range: TxRange, paddingInner?: number, paddingOuter?: number): TxBandScale;
|
|
363
|
+
/** `count` evenly spaced points from the start to the end of a pixel range. */
|
|
205
364
|
export declare function pointScale(count: number, range: TxRange): TxPointScale;
|
|
365
|
+
/** Calendar steps a time axis chooses from, from one second to one year. */
|
|
206
366
|
export declare const TX_TIME_INTERVALS: readonly TxTimeInterval[];
|
|
367
|
+
/** Picks the calendar step that gives about `count` ticks between two times. */
|
|
207
368
|
export declare function timeInterval(start: number, stop: number, count?: number): TxTimeInterval;
|
|
369
|
+
/** Rounds a time down to the start of the calendar step in local time. */
|
|
208
370
|
export declare function floorTime(time: number, interval: TxTimeInterval): Date;
|
|
371
|
+
/** Moves a date forward by one calendar step. */
|
|
209
372
|
export declare function addTime(date: Date, interval: TxTimeInterval): Date;
|
|
373
|
+
/** Tick times on calendar steps between two times, with the step used. */
|
|
210
374
|
export declare function timeTicks(start: number, stop: number, count?: number): {
|
|
211
375
|
ticks: number[];
|
|
212
376
|
interval: TxTimeInterval;
|
|
213
377
|
};
|
|
378
|
+
/** Scale from time in ms to a pixel range, with calendar ticks. */
|
|
214
379
|
export declare function timeScale(domain: TxRange, range: TxRange): TxTimeScale;
|
|
380
|
+
/**
|
|
381
|
+
* Reads an ISO string (a date-only string is local midnight), a `Date` or a timestamp as ms; `null`
|
|
382
|
+
* when it is not a valid time.
|
|
383
|
+
*/
|
|
215
384
|
export declare function toTime(value: string | number | Date | null | undefined): number | null;
|
|
385
|
+
/** Smallest and largest finite number of a list; `null` when there is none. */
|
|
216
386
|
export declare function extent(values: Iterable<number | null | undefined>): TxRange | null;
|
|
387
|
+
/** Cached `Intl.NumberFormat` for a locale and options. */
|
|
217
388
|
export declare function numberFormat(intl: string, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
389
|
+
/** Cached `Intl.DateTimeFormat` for a locale and options. */
|
|
218
390
|
export declare function dateFormat(intl: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
391
|
+
/**
|
|
392
|
+
* Builds the value formatter of a chart for a locale and a `TxChartValueFormat`; `percent` takes
|
|
393
|
+
* values already in percent.
|
|
394
|
+
*/
|
|
219
395
|
export declare function chartNumberFormatter(intl: string, format?: TxChartValueFormat): TxChartValueFormatter;
|
|
396
|
+
/**
|
|
397
|
+
* Like `chartNumberFormatter` but writes `number` and `integer` ticks with as many decimals as the
|
|
398
|
+
* tick step needs.
|
|
399
|
+
*/
|
|
220
400
|
export declare function tickFormatter(intl: string, ticks: readonly number[], format?: TxChartValueFormat): TxChartValueFormatter;
|
|
401
|
+
/** Writes a number in compact form, for example `1234567` as `1.2M`. */
|
|
221
402
|
export declare function compactNumber(value: number, intl?: string): string;
|
|
403
|
+
/** `Intl.DateTimeFormat` options for tick labels of a time step over a time span in ms. */
|
|
222
404
|
export declare function timeTickOptions(interval: TxTimeInterval, span: number): Intl.DateTimeFormatOptions;
|
|
405
|
+
/** Formats time axis ticks for a calendar step and the time span in ms. */
|
|
223
406
|
export declare function timeTickFormatter(intl: string, interval: TxTimeInterval, span: number): (time: number) => string;
|
|
407
|
+
/** Formats the time in a tooltip: a full date, with hours and minutes for steps below a day. */
|
|
224
408
|
export declare function timeTooltipFormatter(intl: string, interval: TxTimeInterval): (time: number) => string;
|
|
409
|
+
/** The 12 month names of a locale, capitalised, in `long` or `short` form. */
|
|
225
410
|
export declare function chartMonthNames(intl: string, month?: 'long' | 'short'): string[];
|
|
411
|
+
/**
|
|
412
|
+
* Estimates the width of a text in px without measuring, so the layout is the same on the server and
|
|
413
|
+
* in the browser.
|
|
414
|
+
*/
|
|
226
415
|
export declare function textWidth(text: string, fontSize?: number): number;
|
|
416
|
+
/** Shortens a text with an ellipsis so that its estimated width fits `maxWidth`. */
|
|
227
417
|
export declare function truncateText(text: string, maxWidth: number, fontSize?: number): string;
|
|
418
|
+
/** How a line connects its points: `smooth` (monotone), `straight` or `step`. */
|
|
228
419
|
export type TxChartCurve = 'smooth' | 'straight' | 'step';
|
|
420
|
+
/** A point in px. */
|
|
229
421
|
export interface TxXY {
|
|
422
|
+
/** Horizontal position. */
|
|
230
423
|
x: number;
|
|
424
|
+
/** Vertical position. */
|
|
231
425
|
y: number;
|
|
232
426
|
}
|
|
427
|
+
/** Slopes of the monotone curve at each point; the curve never overshoots the data. */
|
|
233
428
|
export declare function monotoneTangents(points: readonly TxXY[]): number[];
|
|
429
|
+
/** Splits a list of points at `null` into runs of connected points. */
|
|
234
430
|
export declare function splitGaps(points: readonly (TxXY | null)[]): TxXY[][];
|
|
431
|
+
/** SVG path of a line through the points; a `null` point breaks the line. */
|
|
235
432
|
export declare function linePath(points: readonly (TxXY | null)[], curve?: TxChartCurve): string;
|
|
433
|
+
/** SVG path of the area between a top and a bottom line; runs split at `null` points. */
|
|
236
434
|
export declare function areaPath(top: readonly (TxXY | null)[], bottom: readonly (TxXY | null)[], curve?: TxChartCurve): string;
|
|
435
|
+
/** Full circle in radians. */
|
|
237
436
|
export declare const TX_FULL_CIRCLE: number;
|
|
437
|
+
/** Converts degrees to radians. */
|
|
238
438
|
export declare function toRadians(degrees: number): number;
|
|
439
|
+
/**
|
|
440
|
+
* Point at a radius and an angle from a centre; the angle is in radians, `0` is straight up and it
|
|
441
|
+
* grows clockwise.
|
|
442
|
+
*/
|
|
239
443
|
export declare function polar(cx: number, cy: number, radius: number, angle: number): {
|
|
240
444
|
x: number;
|
|
241
445
|
y: number;
|
|
242
446
|
};
|
|
447
|
+
/**
|
|
448
|
+
* Largest corner radius that fits an arc segment with the given inner and outer radius and sweep in
|
|
449
|
+
* radians.
|
|
450
|
+
*/
|
|
243
451
|
export declare function maxCornerRadius(inner: number, outer: number, sweep: number): number;
|
|
452
|
+
/**
|
|
453
|
+
* SVG path of a pie or donut segment from `start` to `end` radians, with optional rounded corners;
|
|
454
|
+
* `inner` of `0` makes a pie slice.
|
|
455
|
+
*/
|
|
244
456
|
export declare function arcPath(cx: number, cy: number, inner: number, outer: number, start: number, end: number, corner?: number): string;
|
|
457
|
+
/** Bounding box of a unit-circle arc between two angles in radians. */
|
|
245
458
|
export declare function arcBounds(start: number, end: number): {
|
|
246
459
|
minX: number;
|
|
247
460
|
maxX: number;
|
|
248
461
|
minY: number;
|
|
249
462
|
maxY: number;
|
|
250
463
|
};
|
|
464
|
+
/** Centre and radius that fit an arc into a box. */
|
|
251
465
|
export interface TxArcFit {
|
|
466
|
+
/** Horizontal centre, in px. */
|
|
252
467
|
cx: number;
|
|
468
|
+
/** Vertical centre, in px. */
|
|
253
469
|
cy: number;
|
|
470
|
+
/** Outer radius, in px. */
|
|
254
471
|
radius: number;
|
|
255
472
|
}
|
|
473
|
+
/** Start and end of an arc in radians from angles in degrees; the sweep is limited to 360 degrees. */
|
|
256
474
|
export declare function arcSpan(startAngle: number, endAngle: number): [number, number];
|
|
475
|
+
/**
|
|
476
|
+
* Centre and radius that fit the arc between two angles in degrees into a box, leaving `padding` px
|
|
477
|
+
* around it.
|
|
478
|
+
*/
|
|
257
479
|
export declare function fitArc(width: number, height: number, startAngle: number, endAngle: number, padding: number): TxArcFit;
|
|
480
|
+
/** SVG path of an arc line (no fill) on a circle between two angles in radians. */
|
|
258
481
|
export declare function strokeArc(cx: number, cy: number, radius: number, start: number, end: number): string;
|
|
482
|
+
/**
|
|
483
|
+
* Angle in radians of a point as seen from a centre, in the range from `start` to `start` plus a full
|
|
484
|
+
* circle.
|
|
485
|
+
*/
|
|
259
486
|
export declare function angleFrom(x: number, y: number, cx: number, cy: number, start: number): number;
|
|
487
|
+
/** How series stack: `normal` adds values, `100%` turns each category into shares. */
|
|
260
488
|
export type TxChartStackType = 'normal' | '100%';
|
|
489
|
+
/** `[from, to]` of a stacked value, or `null` for a gap. */
|
|
261
490
|
export type TxStackedValue = [number, number] | null;
|
|
491
|
+
/** Stacks series on top of each other; positive and negative values stack apart. */
|
|
262
492
|
export declare function stackValues(series: readonly (readonly (number | null)[])[], type?: TxChartStackType): TxStackedValue[][];
|
|
493
|
+
/** Smallest and largest edge of all stacked values, zero included. */
|
|
263
494
|
export declare function stackExtent(stacked: readonly TxStackedValue[][]): [number, number];
|
|
495
|
+
/**
|
|
496
|
+
* Index of the topmost series with a positive (`1`) or negative (`-1`) value at a category; `-1` when
|
|
497
|
+
* none.
|
|
498
|
+
*/
|
|
264
499
|
export declare function topOfStack(stacked: readonly TxStackedValue[][], index: number, sign: 1 | -1): number;
|
|
500
|
+
/** A point of a series with its index in the original data. */
|
|
265
501
|
export interface TxDecimatePoint {
|
|
502
|
+
/** Horizontal value. */
|
|
266
503
|
x: number;
|
|
504
|
+
/** Vertical value. */
|
|
267
505
|
y: number;
|
|
506
|
+
/** Index in the original series. */
|
|
268
507
|
index: number;
|
|
269
508
|
}
|
|
509
|
+
/** Thins points down to `threshold` and keeps the shape of the line (largest-triangle-three-buckets). */
|
|
270
510
|
export declare function largestTriangleThreeBuckets(points: readonly TxDecimatePoint[], threshold: number): TxDecimatePoint[];
|
|
511
|
+
/** Thins a series that has gaps down to about `threshold` points, run by run; `null` gaps stay. */
|
|
271
512
|
export declare function decimateSeries(points: readonly ({
|
|
272
513
|
x: number;
|
|
273
514
|
y: number;
|
|
274
515
|
} | null)[], threshold: number): (TxDecimatePoint | null)[];
|
|
516
|
+
/** Number of colours in the series palette. */
|
|
275
517
|
export declare const TX_CHART_PALETTE_SIZE = 7;
|
|
518
|
+
/**
|
|
519
|
+
* Palette colour for a series index, as `var(--tx-chart-series-colorN)`; it repeats after the palette
|
|
520
|
+
* size.
|
|
521
|
+
*/
|
|
276
522
|
export declare function chartColor(index: number): string;
|
|
523
|
+
/** The first `count` palette colours. */
|
|
277
524
|
export declare function chartPalette(count?: number): string[];
|
|
525
|
+
/** Own colour of a series, or the palette colour for its index. */
|
|
278
526
|
export declare function seriesColor(color: string | undefined, index: number): string;
|
|
527
|
+
/** How the category axis is built: `band`, `point`, `time` or `linear`. */
|
|
279
528
|
export type TxCategoryKind = 'band' | 'point' | 'time' | 'linear';
|
|
529
|
+
/** Scale of the value axis: `linear` or `log`. */
|
|
280
530
|
export type TxValueScaleKind = 'linear' | 'log';
|
|
531
|
+
/** Which grid lines to draw: at `value` ticks, at `category` ticks, `both` or `none`. */
|
|
281
532
|
export type TxChartGridMode = 'value' | 'category' | 'both' | 'none';
|
|
533
|
+
/** Options of the category axis for `cartesianLayout`. */
|
|
282
534
|
export interface TxCategoryAxisOptions {
|
|
535
|
+
/** Scale kind of the axis. */
|
|
283
536
|
kind: TxCategoryKind;
|
|
537
|
+
/** Texts of the categories for `band` and `point` axes. */
|
|
284
538
|
labels?: readonly string[];
|
|
539
|
+
/** Number of categories; the number of labels when not set. */
|
|
285
540
|
count?: number;
|
|
541
|
+
/** Value domain of a `time` or `linear` axis. */
|
|
286
542
|
domain?: TxRange;
|
|
543
|
+
/** Formats the tick values of a `time` or `linear` axis. */
|
|
287
544
|
format?: (value: number) => string;
|
|
545
|
+
/** What to do with labels that do not fit (default `auto`). */
|
|
288
546
|
labelMode?: TxChartLabelMode;
|
|
547
|
+
/** Most labels to show; every n-th is kept when there are more. */
|
|
289
548
|
maxLabels?: number;
|
|
549
|
+
/** Longest label, in px; longer ones are shortened (default 220). */
|
|
290
550
|
maxLabelWidth?: number;
|
|
551
|
+
/** Gap between `band` bands as a share of a band (default 0). */
|
|
291
552
|
paddingInner?: number;
|
|
553
|
+
/** Title of the axis. */
|
|
292
554
|
title?: string;
|
|
293
555
|
}
|
|
556
|
+
/** Options of a value axis for `cartesianLayout`. */
|
|
294
557
|
export interface TxValueAxisOptions {
|
|
558
|
+
/** Smallest and largest data value; `null` when there is no data. */
|
|
295
559
|
extent: TxRange | null;
|
|
560
|
+
/** `linear` or `log` (default `linear`). */
|
|
296
561
|
scale?: TxValueScaleKind;
|
|
562
|
+
/** How tick labels are written. */
|
|
297
563
|
format?: TxChartValueFormat;
|
|
564
|
+
/** Keeps zero inside the domain (default `true`). */
|
|
298
565
|
includeZero?: boolean;
|
|
566
|
+
/** Fixed lower bound of the axis. */
|
|
299
567
|
min?: number;
|
|
568
|
+
/** Fixed upper bound of the axis. */
|
|
300
569
|
max?: number;
|
|
570
|
+
/** Wanted number of ticks; chosen from the chart size when not set. */
|
|
301
571
|
tickCount?: number;
|
|
572
|
+
/** Title of the axis. */
|
|
302
573
|
title?: string;
|
|
303
574
|
}
|
|
575
|
+
/** Input of `cartesianLayout`: chart size, locale and the two axes. */
|
|
304
576
|
export interface TxCartesianOptions {
|
|
577
|
+
/** Chart box width, in px. */
|
|
305
578
|
width: number;
|
|
579
|
+
/** Chart box height, in px. */
|
|
306
580
|
height: number;
|
|
581
|
+
/** Locale code for number and date formats. */
|
|
307
582
|
intl: string;
|
|
583
|
+
/** Swaps the axes: categories run down the left side and values along the bottom. */
|
|
308
584
|
horizontal?: boolean;
|
|
585
|
+
/** Options of the category axis. */
|
|
309
586
|
category: TxCategoryAxisOptions;
|
|
587
|
+
/** Options of the value axis. */
|
|
310
588
|
value: TxValueAxisOptions;
|
|
589
|
+
/** Options of a second value axis on the opposite side; ignored when `horizontal`. */
|
|
311
590
|
secondaryValue?: TxValueAxisOptions;
|
|
591
|
+
/** Which grid lines to draw (default `value`). */
|
|
312
592
|
grid?: TxChartGridMode;
|
|
593
|
+
/** Font size of the labels, in px (default 12). */
|
|
313
594
|
fontSize?: number;
|
|
595
|
+
/** Draws the category axis (default `true`). */
|
|
314
596
|
showCategoryAxis?: boolean;
|
|
597
|
+
/** Draws the value axis (default `true`). */
|
|
315
598
|
showValueAxis?: boolean;
|
|
599
|
+
/** Puts the x axis at the `bottom` (default) or `top`. */
|
|
316
600
|
xAxisPosition?: TxChartXAxisPosition;
|
|
601
|
+
/** Puts the y axis at the `left` (default) or `right`. */
|
|
317
602
|
yAxisPosition?: TxChartYAxisPosition;
|
|
318
603
|
}
|
|
604
|
+
/** Scale of the category axis. */
|
|
319
605
|
export type TxCategoryScale = TxBandScale | TxPointScale | TxContinuousScale | TxTimeScale;
|
|
606
|
+
/** Result of `cartesianLayout`: plot area, scales, ticks and the axes model, ready to draw. */
|
|
320
607
|
export interface TxCartesianLayout {
|
|
608
|
+
/** Plot area inside the chart box. */
|
|
321
609
|
plot: TxChartPlot;
|
|
610
|
+
/** Scale of the primary value axis. */
|
|
322
611
|
value: TxContinuousScale;
|
|
612
|
+
/** Scale of the secondary value axis, or `null`. */
|
|
323
613
|
secondaryValue: TxContinuousScale | null;
|
|
614
|
+
/** Scale of the category axis. */
|
|
324
615
|
category: TxCategoryScale;
|
|
616
|
+
/** Tick values of the primary value axis. */
|
|
325
617
|
valueTicks: number[];
|
|
618
|
+
/** Tick values of the secondary value axis. */
|
|
326
619
|
secondaryValueTicks: number[];
|
|
620
|
+
/** Axes, grid and zero line for `tx-chart-axes`. */
|
|
327
621
|
axes: TxChartAxesModel;
|
|
622
|
+
/** Whether categories run vertically. */
|
|
328
623
|
horizontal: boolean;
|
|
624
|
+
/** Pixel position of a category along its axis; `x` is the value on a `time` or `linear` axis. */
|
|
329
625
|
categoryPosition(index: number, x?: number): number;
|
|
626
|
+
/** Index of the category nearest to a pixel position; `xs` are the x values of `time` and `linear` axes. */
|
|
330
627
|
categoryIndexAt(position: number, xs?: readonly number[]): number;
|
|
331
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* Domain and ticks of a secondary axis with the same number of intervals as the primary one, so the
|
|
631
|
+
* grid lines match; `null` when it cannot be aligned.
|
|
632
|
+
*/
|
|
332
633
|
export declare function alignedDomain(options: TxValueAxisOptions, intervals: number, zeroAt?: number | null): {
|
|
333
634
|
domain: TxRange;
|
|
334
635
|
ticks: number[];
|
|
335
636
|
} | null;
|
|
637
|
+
/**
|
|
638
|
+
* Lays out a cartesian chart: plot area, scales, tick labels (skipped or rotated when they collide),
|
|
639
|
+
* grid and zero line.
|
|
640
|
+
*/
|
|
336
641
|
export declare function cartesianLayout(options: TxCartesianOptions): TxCartesianLayout;
|
|
642
|
+
/** Width used for the first render before the chart is measured, in px. */
|
|
337
643
|
export declare const TX_CHART_FALLBACK_WIDTH = 640;
|
|
644
|
+
/** Height used when a chart height is not a usable pixel value, in px. */
|
|
338
645
|
export declare const TX_CHART_FALLBACK_HEIGHT = 350;
|
|
646
|
+
/** Height of a legend or toolbar row above or below the plot, in px. */
|
|
339
647
|
export declare const TX_CHART_LEGEND_ROW = 31;
|
|
648
|
+
/** Width taken by a legend on the left or right side, in px. */
|
|
340
649
|
export declare const TX_CHART_LEGEND_SIDE = 175;
|
|
650
|
+
/** Chart height in px from a number or a `px` string; the fallback for anything else. */
|
|
341
651
|
export declare function chartHeightValue(height: TxChartHeight, fallback?: number): number;
|
|
652
|
+
/** Height of the plot box: the chart height without the legend and toolbar rows. */
|
|
342
653
|
export declare function chartBoxHeight(height: TxChartHeight, legend: TxChartLegendPosition | null, toolbar?: boolean): number;
|
|
654
|
+
/** Size of the plot box for the first render, before the chart is measured. */
|
|
343
655
|
export declare function initialChartSize(height: TxChartHeight, legend: TxChartLegendPosition | null, width?: number, toolbar?: boolean): TxChartSize;
|
|
656
|
+
/** Length of the entrance animation of a chart, in ms. */
|
|
344
657
|
export declare const TX_CHART_ENTER_MS = 1100;
|
|
658
|
+
/** Entrance animation state of a chart. */
|
|
345
659
|
export interface TxChartEntrance {
|
|
660
|
+
/** `true` while the entrance animation runs. */
|
|
346
661
|
readonly active: Signal<boolean>;
|
|
662
|
+
/** Starts the entrance animation; does nothing on the server or with reduced motion. */
|
|
347
663
|
play(): void;
|
|
348
664
|
}
|
|
665
|
+
/** Whether the user asked for reduced motion. */
|
|
349
666
|
export declare function prefersReducedMotion(document: Document): boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Entrance animation for the chart in the current injection context; plays once when the chart renders
|
|
669
|
+
* in the browser.
|
|
670
|
+
*/
|
|
350
671
|
export declare function injectChartEntrance(): TxChartEntrance;
|
|
672
|
+
/**
|
|
673
|
+
* Marks an `ng-template` as the item template of a chart legend: `<ng-template txChartLegend let-item
|
|
674
|
+
* let-index="index">`.
|
|
675
|
+
*/
|
|
351
676
|
export declare class TxChartLegendTemplate {
|
|
352
677
|
readonly template: TemplateRef<TxChartLegendContext>;
|
|
353
678
|
static ngTemplateContextGuard(_directive: TxChartLegendTemplate, context: unknown): context is TxChartLegendContext;
|
|
354
679
|
static ɵfac: i0.ɵɵFactoryDeclaration<TxChartLegendTemplate, never>;
|
|
355
680
|
static ɵdir: i0.ɵɵDirectiveDeclaration<TxChartLegendTemplate, "ng-template[txChartLegend]", never, {}, {}, never, never, true, never>;
|
|
356
681
|
}
|
|
682
|
+
/** Marks an `ng-template` as the tooltip content of a chart: `<ng-template txChartTooltip let-data>`. */
|
|
357
683
|
export declare class TxChartTooltipTemplate {
|
|
358
684
|
readonly template: TemplateRef<TxChartTooltipTemplateContext>;
|
|
359
685
|
static ngTemplateContextGuard(_directive: TxChartTooltipTemplate, context: unknown): context is TxChartTooltipTemplateContext;
|
|
360
686
|
static ɵfac: i0.ɵɵFactoryDeclaration<TxChartTooltipTemplate, never>;
|
|
361
687
|
static ɵdir: i0.ɵɵDirectiveDeclaration<TxChartTooltipTemplate, "ng-template[txChartTooltip]", never, {}, {}, never, never, true, never>;
|
|
362
688
|
}
|
|
689
|
+
/** The legend of a chart: items that toggle series, with arrow-key navigation. */
|
|
363
690
|
export declare class TxChartLegend {
|
|
364
691
|
private readonly coreTheme;
|
|
365
692
|
private host;
|
|
@@ -417,6 +744,7 @@ export declare class TxChartLegend {
|
|
|
417
744
|
"hovered": "hovered";
|
|
418
745
|
}, never, never, true, never>;
|
|
419
746
|
}
|
|
747
|
+
/** Draws the grid, zero line, tick labels and titles of a cartesian chart from `cartesianLayout().axes`. */
|
|
420
748
|
export declare class TxChartAxes {
|
|
421
749
|
private readonly coreTheme;
|
|
422
750
|
readonly model: import("@angular/core").InputSignal<TxChartAxesModel>;
|
|
@@ -441,11 +769,19 @@ export declare class TxChartAxes {
|
|
|
441
769
|
};
|
|
442
770
|
}, {}, never, never, true, never>;
|
|
443
771
|
}
|
|
772
|
+
/** Last shown band of `tx-chart-hover-band` and whether it slides from the previous one. */
|
|
444
773
|
interface TxBandState {
|
|
774
|
+
/** Band rectangle kept while the band fades out. */
|
|
445
775
|
rect: TxChartRect | null;
|
|
776
|
+
/** `true` when the band moves from an earlier position instead of fading in. */
|
|
446
777
|
slide: boolean;
|
|
447
778
|
}
|
|
779
|
+
/** Rectangle of the hover band behind the category at `index`; `inset` is the gap at its sides in px. */
|
|
448
780
|
export declare function chartBandRect(band: TxBandScale, index: number, plot: TxChartPlot, horizontal?: boolean, inset?: number): TxChartRect;
|
|
781
|
+
/**
|
|
782
|
+
* The soft band under the hovered category of a bar-like chart; it fades in and slides between
|
|
783
|
+
* categories.
|
|
784
|
+
*/
|
|
449
785
|
export declare class TxChartHoverBand {
|
|
450
786
|
private readonly coreTheme;
|
|
451
787
|
readonly rect: import("@angular/core").InputSignal<TxChartRect | null>;
|
|
@@ -465,54 +801,96 @@ export declare class TxChartHoverBand {
|
|
|
465
801
|
};
|
|
466
802
|
}, {}, never, never, true, never>;
|
|
467
803
|
}
|
|
804
|
+
/** Colour role of an annotation, from the `chart.annotation` tokens. */
|
|
468
805
|
export type TxChartAnnotationTone = 'neutral' | 'primary' | 'success' | 'info' | 'warn' | 'danger';
|
|
806
|
+
/** Options every annotation has: label and colour. */
|
|
469
807
|
interface TxChartAnnotationBase {
|
|
808
|
+
/** Text shown in a pill at the annotation. */
|
|
470
809
|
label?: string;
|
|
810
|
+
/** Colour role (default `neutral`). */
|
|
471
811
|
tone?: TxChartAnnotationTone;
|
|
812
|
+
/** Own colour; replaces `tone`. */
|
|
472
813
|
color?: string;
|
|
473
814
|
}
|
|
815
|
+
/** A line at one x value. */
|
|
474
816
|
export interface TxChartXLine extends TxChartAnnotationBase {
|
|
817
|
+
/** Always `x-line`. */
|
|
475
818
|
type: 'x-line';
|
|
819
|
+
/** Category or value where the line stands. */
|
|
476
820
|
x: TxChartX;
|
|
477
821
|
}
|
|
822
|
+
/** A line at one y value. */
|
|
478
823
|
export interface TxChartYLine extends TxChartAnnotationBase {
|
|
824
|
+
/** Always `y-line`. */
|
|
479
825
|
type: 'y-line';
|
|
826
|
+
/** Value where the line stands. */
|
|
480
827
|
y: number;
|
|
828
|
+
/** Value axis the value belongs to (default `primary`). */
|
|
481
829
|
axis?: 'primary' | 'secondary';
|
|
482
830
|
}
|
|
831
|
+
/** A band between two x values. */
|
|
483
832
|
export interface TxChartXBand extends TxChartAnnotationBase {
|
|
833
|
+
/** Always `x-band`. */
|
|
484
834
|
type: 'x-band';
|
|
835
|
+
/** Start of the band. */
|
|
485
836
|
from: TxChartX;
|
|
837
|
+
/** End of the band. */
|
|
486
838
|
to: TxChartX;
|
|
487
839
|
}
|
|
840
|
+
/** A band between two y values. */
|
|
488
841
|
export interface TxChartYBand extends TxChartAnnotationBase {
|
|
842
|
+
/** Always `y-band`. */
|
|
489
843
|
type: 'y-band';
|
|
844
|
+
/** Lower value of the band. */
|
|
490
845
|
from: number;
|
|
846
|
+
/** Upper value of the band. */
|
|
491
847
|
to: number;
|
|
848
|
+
/** Value axis the values belong to (default `primary`). */
|
|
492
849
|
axis?: 'primary' | 'secondary';
|
|
493
850
|
}
|
|
851
|
+
/** A marked point at an x and a y value. */
|
|
494
852
|
export interface TxChartPointAnnotation extends TxChartAnnotationBase {
|
|
853
|
+
/** Always `point`. */
|
|
495
854
|
type: 'point';
|
|
855
|
+
/** Category or value of the point. */
|
|
496
856
|
x: TxChartX;
|
|
857
|
+
/** Value of the point. */
|
|
497
858
|
y: number;
|
|
859
|
+
/** Value axis the value belongs to (default `primary`). */
|
|
498
860
|
axis?: 'primary' | 'secondary';
|
|
499
861
|
}
|
|
862
|
+
/** A line, band or point drawn over the plot of a cartesian chart. */
|
|
500
863
|
export type TxChartAnnotation = TxChartXLine | TxChartYLine | TxChartXBand | TxChartYBand | TxChartPointAnnotation;
|
|
864
|
+
/** How a chart maps annotation values to pixels; `null` means the value is not on the chart. */
|
|
501
865
|
export interface TxChartAnnotationMapping {
|
|
866
|
+
/** Plot area the shapes are placed in. */
|
|
502
867
|
plot: TxChartPlot;
|
|
868
|
+
/** Pixel position of an x value. */
|
|
503
869
|
x(value: TxChartX): number | null;
|
|
870
|
+
/** Pixel start and end of the category at an x value; bands use it to cover the whole bar slot. */
|
|
504
871
|
xSpan?(value: TxChartX): [number, number] | null;
|
|
872
|
+
/** Pixel position of a y value on the given axis. */
|
|
505
873
|
y(value: number, axis: 'primary' | 'secondary'): number | null;
|
|
874
|
+
/** Categories run vertically, so x annotations become horizontal. */
|
|
506
875
|
horizontal?: boolean;
|
|
507
876
|
}
|
|
877
|
+
/** An annotation placed in pixels, ready for `tx-chart-annotations`. */
|
|
508
878
|
export interface TxChartAnnotationShape {
|
|
879
|
+
/** Identifies the shape. */
|
|
509
880
|
key: string;
|
|
881
|
+
/** Whether it is a `line`, a `band` or a `point`. */
|
|
510
882
|
kind: 'line' | 'band' | 'point';
|
|
883
|
+
/** Colour of the shape. */
|
|
511
884
|
color: string;
|
|
885
|
+
/** Left or start x, in px. */
|
|
512
886
|
x1: number;
|
|
887
|
+
/** Top or start y, in px. */
|
|
513
888
|
y1: number;
|
|
889
|
+
/** Right or end x, in px. */
|
|
514
890
|
x2: number;
|
|
891
|
+
/** Bottom or end y, in px. */
|
|
515
892
|
y2: number;
|
|
893
|
+
/** Label pill with its box and text anchor, or `null` without a label. */
|
|
516
894
|
label: {
|
|
517
895
|
text: string;
|
|
518
896
|
x: number;
|
|
@@ -522,8 +900,14 @@ export interface TxChartAnnotationShape {
|
|
|
522
900
|
anchor: 'start' | 'end' | 'middle';
|
|
523
901
|
} | null;
|
|
524
902
|
}
|
|
903
|
+
/** Index of an x value among the category labels; `-1` when it is not one of them. */
|
|
525
904
|
export declare function chartCategoryIndex(value: TxChartX, labels: readonly string[]): number;
|
|
905
|
+
/**
|
|
906
|
+
* Places annotations inside the plot: maps their values to pixels, drops those outside it and fits the
|
|
907
|
+
* label pills.
|
|
908
|
+
*/
|
|
526
909
|
export declare function chartAnnotationShapes(list: readonly TxChartAnnotation[] | null | undefined, mapping: TxChartAnnotationMapping): TxChartAnnotationShape[];
|
|
910
|
+
/** Draws lines, bands, points and their labels over the plot of a cartesian chart. */
|
|
527
911
|
export declare class TxChartAnnotations {
|
|
528
912
|
private readonly coreTheme;
|
|
529
913
|
readonly shapes: import("@angular/core").InputSignal<readonly TxChartAnnotationShape[]>;
|
|
@@ -549,28 +933,52 @@ export declare class TxChartAnnotations {
|
|
|
549
933
|
};
|
|
550
934
|
}, {}, never, never, true, never>;
|
|
551
935
|
}
|
|
936
|
+
/** File format of a chart export. */
|
|
552
937
|
export type TxChartExportFormat = 'svg' | 'png' | 'csv';
|
|
938
|
+
/** Options of the exported SVG. */
|
|
553
939
|
export interface TxChartSvgOptions {
|
|
940
|
+
/** Legend items drawn above the chart; hidden items are left out. */
|
|
554
941
|
legend?: readonly TxChartLegendItem[];
|
|
942
|
+
/** Background colour of the image; transparent when not set. */
|
|
555
943
|
background?: string;
|
|
944
|
+
/** Colour of the legend text (default `currentColor`). */
|
|
556
945
|
textColor?: string;
|
|
946
|
+
/** Font family of the image (default `sans-serif`). */
|
|
557
947
|
fontFamily?: string;
|
|
558
948
|
}
|
|
949
|
+
/**
|
|
950
|
+
* CSV text of a chart table with a byte order mark, so spreadsheets read it as UTF-8; `categoryLabel`
|
|
951
|
+
* heads the first column.
|
|
952
|
+
*/
|
|
559
953
|
export declare function chartCsv(table: TxChartTable, categoryLabel?: string): string;
|
|
954
|
+
/**
|
|
955
|
+
* File name for an export: the chart name as a safe slug (up to 60 characters) with the format as
|
|
956
|
+
* extension.
|
|
957
|
+
*/
|
|
560
958
|
export declare function chartFileName(name: string, format: TxChartExportFormat): string;
|
|
959
|
+
/** Standalone SVG markup of a chart with computed styles inlined and the legend drawn above it. */
|
|
561
960
|
export declare function chartSvgString(svg: SVGSVGElement, options?: TxChartSvgOptions): string;
|
|
961
|
+
/** Width and height read from the `viewBox` of exported SVG markup. */
|
|
562
962
|
export declare function chartSvgSize(markup: string): {
|
|
563
963
|
width: number;
|
|
564
964
|
height: number;
|
|
565
965
|
};
|
|
966
|
+
/** Renders exported SVG markup to a PNG blob; `scale` is the pixel ratio (default 2). */
|
|
566
967
|
export declare function chartPngBlob(document: Document, markup: string, scale?: number): Promise<Blob>;
|
|
968
|
+
/** Saves a blob as a file through a temporary download link. */
|
|
567
969
|
export declare function downloadChartFile(document: Document, data: Blob, filename: string): void;
|
|
970
|
+
/** One entry of the chart export menu. */
|
|
568
971
|
export interface TxChartMenuItem {
|
|
972
|
+
/** Identifies the entry in the `selected` output. */
|
|
569
973
|
id: string;
|
|
974
|
+
/** Text of the entry. */
|
|
570
975
|
label: string;
|
|
976
|
+
/** Name of an icon shown before the text. */
|
|
571
977
|
icon?: string;
|
|
978
|
+
/** Makes the entry inactive. */
|
|
572
979
|
disabled?: boolean;
|
|
573
980
|
}
|
|
981
|
+
/** The export menu of a chart: a list of actions with arrow-key navigation. */
|
|
574
982
|
export declare class TxChartMenu {
|
|
575
983
|
private readonly coreTheme;
|
|
576
984
|
readonly items: import("@angular/core").InputSignal<readonly TxChartMenuItem[]>;
|
|
@@ -601,6 +1009,10 @@ export declare class TxChartMenu {
|
|
|
601
1009
|
"selected": "selected";
|
|
602
1010
|
}, never, never, true, never>;
|
|
603
1011
|
}
|
|
1012
|
+
/**
|
|
1013
|
+
* The box of every chart: measures itself, places the legend, shows the tooltip, "No data" and the
|
|
1014
|
+
* skeleton, gives screen readers a summary and a data table, and forwards pointer and key events.
|
|
1015
|
+
*/
|
|
604
1016
|
export declare class TxChartFrame {
|
|
605
1017
|
private readonly coreTheme;
|
|
606
1018
|
private host;
|
|
@@ -835,31 +1247,64 @@ export declare class TxChartFrame {
|
|
|
835
1247
|
"zoomReset": "zoomReset";
|
|
836
1248
|
}, never, ["*"], true, never>;
|
|
837
1249
|
}
|
|
1250
|
+
/** How x values are read: as `category` labels, as `time` or as `linear` numbers. */
|
|
838
1251
|
export type TxChartXType = 'category' | 'time' | 'linear';
|
|
1252
|
+
/** Series reduced to a common x axis: labels, x values and one row of values per series. */
|
|
839
1253
|
export interface TxSeriesTable {
|
|
1254
|
+
/** Text of each x position. */
|
|
840
1255
|
labels: string[];
|
|
1256
|
+
/** Numeric x of each position: the index for categories, ms for time. */
|
|
841
1257
|
xs: number[];
|
|
1258
|
+
/** Values per series, one per position; `null` where a series has none. */
|
|
842
1259
|
values: (number | null)[][];
|
|
843
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Turns series of numbers or `{ x, y }` points into labels, x values and a value table on one shared x
|
|
1263
|
+
* axis.
|
|
1264
|
+
*/
|
|
844
1265
|
export declare function normalizeSeries(series: readonly TxChartSeries[], categories?: readonly (string | number | Date)[], type?: TxChartXType): TxSeriesTable;
|
|
1266
|
+
/** Whether any value is not `null`. */
|
|
845
1267
|
export declare function hasChartData(values: readonly (readonly (number | null)[])[]): boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Text for screen readers that sums up a chart: type, number of series and points and, when given, the
|
|
1270
|
+
* value range.
|
|
1271
|
+
*/
|
|
846
1272
|
export declare function chartSummary(translations: TxTranslations, intl: string, type: string, seriesCount: number, pointCount: number, range: [string, string] | null): string;
|
|
1273
|
+
/** Most rows of the hidden data table (250). */
|
|
847
1274
|
export declare const TX_CHART_TABLE_ROWS = 250;
|
|
1275
|
+
/** Indexes of the rows to put in the data table; long data is thinned evenly down to `limit`. */
|
|
848
1276
|
export declare function tableRows(count: number, limit?: number): number[];
|
|
1277
|
+
/** Builds the hidden data table from labels and series values; a missing value shows as a dash. */
|
|
849
1278
|
export declare function chartTable(labels: readonly string[], series: readonly {
|
|
850
1279
|
name: string;
|
|
851
1280
|
values: readonly (number | null)[];
|
|
852
1281
|
}[], format: (value: number, seriesIndex: number) => string, limit?: number): TxChartTable;
|
|
1282
|
+
/** The category and series a chart currently highlights. */
|
|
853
1283
|
export interface TxChartActive {
|
|
1284
|
+
/** Index of the category. */
|
|
854
1285
|
index: number;
|
|
1286
|
+
/** Index of the series. */
|
|
855
1287
|
series: number;
|
|
1288
|
+
/** Pointer y inside the plot, in px; `null` for the keyboard. */
|
|
856
1289
|
pointerY: number | null;
|
|
1290
|
+
/** `true` when the keyboard, not the pointer, set it. */
|
|
857
1291
|
keyboard: boolean;
|
|
858
1292
|
}
|
|
1293
|
+
/** Copy of a set with the key added, or removed if it was there; used to hide and show series. */
|
|
859
1294
|
export declare function toggleKey(keys: ReadonlySet<string>, key: string): Set<string>;
|
|
1295
|
+
/** Next index for an arrow, `Home` or `End` key; `-1` when there is nothing to step through. */
|
|
860
1296
|
export declare function stepIndex(key: string, index: number, count: number, forward?: string, back?: string): number;
|
|
1297
|
+
/** Moves `step` places through the allowed indexes and wraps around; `-1` when none are allowed. */
|
|
861
1298
|
export declare function cycleIndex(index: number, step: number, allowed: readonly number[]): number;
|
|
1299
|
+
/**
|
|
1300
|
+
* Reads a number or percent (as a ratio) from a CSS custom property of an element; the fallback when
|
|
1301
|
+
* it is missing.
|
|
1302
|
+
*/
|
|
862
1303
|
export declare function readTokenNumber(element: Element | null | undefined, name: string, fallback: number): number;
|
|
1304
|
+
/**
|
|
1305
|
+
* Reads a number or a percent string such as `40%` as a ratio (`0.4`); the fallback when it is not a
|
|
1306
|
+
* number.
|
|
1307
|
+
*/
|
|
863
1308
|
export declare function parseRatio(raw: string | number | null | undefined, fallback: number): number;
|
|
864
1309
|
export {};
|
|
865
1310
|
//# sourceMappingURL=tectra-ng-charts-core.d.ts.map
|