@classic-homes/charts-core 0.1.37 → 0.3.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/dist/{chunk-JM72YHZD.js → chunk-WAHMKXRF.js} +13 -3
- package/dist/index.cjs +1126 -34
- package/dist/index.d.cts +542 -6
- package/dist/index.d.ts +542 -6
- package/dist/index.js +1053 -34
- package/dist/theme/index.cjs +12 -2
- package/dist/theme/index.d.cts +10 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.js +1 -1
- package/dist/types/index.d.cts +734 -29
- package/dist/types/index.d.ts +734 -29
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
export { ChartSemanticColors, EChartsTheme, THEME_DARK, THEME_LIGHT, colorWithAlpha, darkChartColors, darkTheme, generateDarkTheme, generateLightTheme, getChartColors, lightChartColors, lightTheme } from './theme/index.js';
|
|
2
|
-
import { BarChartData, LineChartData, PieSliceData, ScatterChartData } from './types/index.js';
|
|
3
|
-
export { AreaChartData, AreaChartProps, AreaSeriesData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams,
|
|
2
|
+
import { ValueFormat, CategoryChartData, BarChartData, BoxPlotStats, BulletItem, HistogramBucket, LineChartData, PieSliceData, ScatterChartData, WaterfallStep, ChartFormatter, LabelFormatterParams, TooltipFormatterParams, AxisConfig, ChartLegendConfig, ReferenceBand, ReferenceLine, LegendItem, HistogramBin, CategorySeriesData, ChartDataTable, CandlestickData, HeatmapData, RadarChartData, RadarIndicator, SankeyData, TreemapNode } from './types/index.js';
|
|
3
|
+
export { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BulletChartProps, CandlestickChartProps, CandlestickEventParams, CandlestickItem, ChartEventHandlers, ChartExportConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapEventParams, HistogramChartProps, LabelChartProps, LegendChartProps, LegendRenderProps, LineChartProps, LineSeriesData, PieChartProps, RadarChartProps, RadarSeriesData, ReferenceChartProps, RowHeightProps, SankeyChartProps, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TreemapChartProps, TreemapEventParams, TreemapLevel, ValueFormatPreset, WaterfallChartProps, ZoomChartProps } from './types/index.js';
|
|
4
|
+
import 'echarts';
|
|
5
|
+
import 'echarts/core';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Formatting utilities for chart values
|
|
7
9
|
*/
|
|
10
|
+
|
|
8
11
|
/**
|
|
9
12
|
* Format a number with thousand separators
|
|
10
13
|
*/
|
|
11
|
-
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
14
|
+
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions, locale?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Turn a `valueFormat` prop into a formatter function. Returns undefined when
|
|
17
|
+
* no format is set, so callers can fall back to ECharts' defaults.
|
|
18
|
+
*/
|
|
19
|
+
declare function resolveValueFormatter(format: ValueFormat | undefined, locale?: string): ((value: number) => string) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Format a possibly-missing value: numbers through the formatter (or with
|
|
22
|
+
* thousand separators), null and non-finite values as `empty`
|
|
23
|
+
*/
|
|
24
|
+
declare function formatValue(value: number | string | null | undefined, formatter?: (value: number) => string, empty?: string): string;
|
|
12
25
|
/**
|
|
13
26
|
* Format a number as currency
|
|
14
27
|
*/
|
|
@@ -48,14 +61,27 @@ declare function createTooltipFormatter(options?: {
|
|
|
48
61
|
* Accessibility utilities for charts
|
|
49
62
|
*/
|
|
50
63
|
|
|
64
|
+
type Formatter = ((value: number) => string) | undefined;
|
|
51
65
|
/**
|
|
52
66
|
* Generate an accessible description for a line chart
|
|
53
67
|
*/
|
|
54
|
-
declare function generateLineChartDescription(title: string, data: LineChartData): string;
|
|
68
|
+
declare function generateLineChartDescription(title: string, data: LineChartData, format?: Formatter): string;
|
|
69
|
+
/**
|
|
70
|
+
* Generate an accessible description for an area chart
|
|
71
|
+
*/
|
|
72
|
+
declare function generateAreaChartDescription(title: string, data: CategoryChartData, format?: Formatter): string;
|
|
73
|
+
/**
|
|
74
|
+
* Generate an accessible description for a combo chart
|
|
75
|
+
*/
|
|
76
|
+
declare function generateComboChartDescription(title: string, data: CategoryChartData, format?: Formatter): string;
|
|
55
77
|
/**
|
|
56
78
|
* Generate an accessible description for a bar chart
|
|
57
79
|
*/
|
|
58
|
-
declare function generateBarChartDescription(title: string, data: BarChartData): string;
|
|
80
|
+
declare function generateBarChartDescription(title: string, data: BarChartData, format?: Formatter): string;
|
|
81
|
+
/**
|
|
82
|
+
* Generate an accessible description for a dot plot
|
|
83
|
+
*/
|
|
84
|
+
declare function generateDotPlotDescription(title: string, data: CategoryChartData, format?: Formatter): string;
|
|
59
85
|
/**
|
|
60
86
|
* Generate an accessible description for a pie/donut chart
|
|
61
87
|
*/
|
|
@@ -64,6 +90,25 @@ declare function generatePieChartDescription(title: string, data: PieSliceData[]
|
|
|
64
90
|
* Generate an accessible description for a scatter chart
|
|
65
91
|
*/
|
|
66
92
|
declare function generateScatterChartDescription(title: string, data: ScatterChartData): string;
|
|
93
|
+
/**
|
|
94
|
+
* Generate an accessible description for a histogram
|
|
95
|
+
*/
|
|
96
|
+
declare function generateHistogramDescription(title: string, buckets: HistogramBucket[], total: number): string;
|
|
97
|
+
/**
|
|
98
|
+
* Generate an accessible description for a box plot
|
|
99
|
+
*/
|
|
100
|
+
declare function generateBoxPlotDescription(title: string, groups: {
|
|
101
|
+
name: string;
|
|
102
|
+
stats: BoxPlotStats | null;
|
|
103
|
+
}[], format?: Formatter): string;
|
|
104
|
+
/**
|
|
105
|
+
* Generate an accessible description for a waterfall chart
|
|
106
|
+
*/
|
|
107
|
+
declare function generateWaterfallDescription(title: string, steps: WaterfallStep[], final: number, format?: Formatter): string;
|
|
108
|
+
/**
|
|
109
|
+
* Generate an accessible description for a bullet chart
|
|
110
|
+
*/
|
|
111
|
+
declare function generateBulletDescription(title: string, items: BulletItem[], format?: Formatter): string;
|
|
67
112
|
/**
|
|
68
113
|
* Generate a data table for screen readers (hidden visually)
|
|
69
114
|
*/
|
|
@@ -90,5 +135,496 @@ declare function generateDataTable(headers: string[], rows: (string | number)[][
|
|
|
90
135
|
* returns true are listed; pass `echarts.ComponentModel.hasClass`.
|
|
91
136
|
*/
|
|
92
137
|
declare function getReplaceMerge(prev: object | null | undefined, next: object, isComponentType: (mainType: string) => boolean): string[];
|
|
138
|
+
/**
|
|
139
|
+
* Deep-merge a user-supplied ECharts option over a chart's generated option.
|
|
140
|
+
*
|
|
141
|
+
* Plain objects merge key by key. Top-level component arrays (`series`,
|
|
142
|
+
* `xAxis`, `grid`, ...) merge index by index, matching how ECharts merges
|
|
143
|
+
* options, so `{ series: [{ label: { show: true } }] }` patches only the
|
|
144
|
+
* first series. Nested arrays (`data`, `center`, ...) and any other value
|
|
145
|
+
* (functions, class instances such as gradients, primitives) replace the
|
|
146
|
+
* generated one; `undefined` leaves it untouched.
|
|
147
|
+
*/
|
|
148
|
+
declare function mergeChartOption<T extends object>(generated: T, override: object | undefined): T;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Builders for the label, axis, tooltip and legend parts of a chart option.
|
|
152
|
+
*
|
|
153
|
+
* Chart components pass the block they generate by default; with no
|
|
154
|
+
* customisation each builder returns that block unchanged.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
type AnyObject = Record<string, unknown>;
|
|
158
|
+
/** Looks up the per-point label text for a data point */
|
|
159
|
+
type PointLabelLookup = (seriesIndex: number, dataIndex: number, name: string) => string | undefined;
|
|
160
|
+
interface BuildLegendOptions {
|
|
161
|
+
/** Whether the built-in legend is shown (the `showLegend` prop) */
|
|
162
|
+
show: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* A custom legend replaces the built-in one: it is kept with `show: false`
|
|
165
|
+
* so legend selection actions keep working.
|
|
166
|
+
*/
|
|
167
|
+
custom?: boolean;
|
|
168
|
+
/** Extra keys for the default bottom legend, e.g. `{ orient: 'horizontal' }` */
|
|
169
|
+
defaults?: AnyObject;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Build the ECharts `legend` component for a list of item names
|
|
173
|
+
*/
|
|
174
|
+
declare function buildLegend(names: string[], config: ChartLegendConfig | undefined, { show, custom, defaults }: BuildLegendOptions): AnyObject | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Grid edges to move so a built-in legend and centred axis titles do not
|
|
177
|
+
* overlap the plot or its tick labels (`containLabel` only reserves room for
|
|
178
|
+
* tick labels). Returns a partial `grid` to spread over the default one, or
|
|
179
|
+
* nothing when no room is needed.
|
|
180
|
+
*/
|
|
181
|
+
declare function gridInset(legend: ChartLegendConfig | undefined, showLegend: boolean, xAxis?: AxisConfig, yAxis?: AxisConfig): AnyObject | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Centre for a pie, donut or radar that leaves room for a built-in legend
|
|
184
|
+
*/
|
|
185
|
+
declare function legendCenter(config: ChartLegendConfig | undefined, show: boolean, fallback: [string, string]): [string, string];
|
|
186
|
+
/**
|
|
187
|
+
* Re-anchor a centre graphic group (a donut's centre label) on a pie centre
|
|
188
|
+
* moved by `legendCenter`. `defaultCenter` is where the group's `left: 'center'`
|
|
189
|
+
* / `top` placement assumes the pie sits; the group is returned unchanged
|
|
190
|
+
* when the centre has not moved. A raw bounding positions the group by its
|
|
191
|
+
* origin, so children centred on x = 0 sit on the new centre.
|
|
192
|
+
*/
|
|
193
|
+
declare function anchorCenterGraphic(group: AnyObject, center: [string, string], defaultCenter: [string, string]): AnyObject;
|
|
194
|
+
/**
|
|
195
|
+
* Legend entries with the colour the chart draws each in: an explicit
|
|
196
|
+
* override, else the theme palette by index
|
|
197
|
+
*/
|
|
198
|
+
declare function getLegendItems(names: string[], palette: string[], overrides: (string | undefined)[], visible: Record<string, boolean>): LegendItem[];
|
|
199
|
+
/**
|
|
200
|
+
* Apply an axis customisation to a generated axis
|
|
201
|
+
*/
|
|
202
|
+
declare function buildAxis<T extends AnyObject>(base: T, config: AxisConfig | undefined): T;
|
|
203
|
+
interface BuildDataLabelOptions {
|
|
204
|
+
/** Whether data labels are shown */
|
|
205
|
+
show: boolean;
|
|
206
|
+
/** The `labelFormatter` prop */
|
|
207
|
+
formatter?: ChartFormatter<LabelFormatterParams>;
|
|
208
|
+
/** Per-point label lookup, exposed to formatter functions as `label` */
|
|
209
|
+
getLabel?: PointLabelLookup;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Build a series `label` block. `base` is the block the chart shows by
|
|
213
|
+
* default; `hidden` is what it uses when labels are off.
|
|
214
|
+
*/
|
|
215
|
+
declare function buildDataLabel(base: AnyObject, hidden: AnyObject | undefined, { show, formatter, getLabel }: BuildDataLabelOptions): AnyObject | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* A per-data-item label override, for points with their own label text.
|
|
218
|
+
* When a formatter function is set it receives the text instead, so the
|
|
219
|
+
* item only switches its label on. `base` carries placement (e.g.
|
|
220
|
+
* `{ position: 'top' }`) for when the series' own labels are off.
|
|
221
|
+
*/
|
|
222
|
+
declare function pointLabel(text: string | null | undefined, formatter: ChartFormatter<LabelFormatterParams> | undefined, base?: AnyObject): AnyObject | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Turn a plain value array into data items, attaching a label override to
|
|
225
|
+
* each point that has label text. Returns the values unchanged when none do.
|
|
226
|
+
*/
|
|
227
|
+
declare function withPointLabels<V>(values: V[], labels: (string | null | undefined)[] | undefined, formatter: ChartFormatter<LabelFormatterParams> | undefined, base?: AnyObject): (V | {
|
|
228
|
+
value: V;
|
|
229
|
+
label: AnyObject;
|
|
230
|
+
})[];
|
|
231
|
+
/**
|
|
232
|
+
* Lookup for series-based per-point labels
|
|
233
|
+
*/
|
|
234
|
+
declare function seriesLabelLookup(series: {
|
|
235
|
+
labels?: (string | null | undefined)[];
|
|
236
|
+
}[]): PointLabelLookup;
|
|
237
|
+
/**
|
|
238
|
+
* Lookup for item-based per-point labels (pie slices, funnel stages)
|
|
239
|
+
*/
|
|
240
|
+
declare function itemLabelLookup(items: {
|
|
241
|
+
label?: string;
|
|
242
|
+
}[]): PointLabelLookup;
|
|
243
|
+
/**
|
|
244
|
+
* Lookup for per-point labels keyed by name, for nodes whose data index does
|
|
245
|
+
* not follow the input order (treemap, sankey). Walks `children` recursively.
|
|
246
|
+
*/
|
|
247
|
+
declare function nameLabelLookup(nodes: {
|
|
248
|
+
name: string;
|
|
249
|
+
label?: string;
|
|
250
|
+
children?: unknown[];
|
|
251
|
+
}[]): PointLabelLookup;
|
|
252
|
+
/**
|
|
253
|
+
* Whether any series has per-point label text
|
|
254
|
+
*/
|
|
255
|
+
declare function hasPointLabels(series: {
|
|
256
|
+
labels?: (string | null | undefined)[];
|
|
257
|
+
}[]): boolean;
|
|
258
|
+
interface BuildTooltipOptions {
|
|
259
|
+
/** Whether the tooltip is shown */
|
|
260
|
+
show: boolean;
|
|
261
|
+
/** The `tooltipFormatter` prop */
|
|
262
|
+
formatter?: ChartFormatter<TooltipFormatterParams[]>;
|
|
263
|
+
/** The `tooltipValueFormatter` prop */
|
|
264
|
+
valueFormatter?: (value: number) => string;
|
|
265
|
+
/** Per-point label lookup, exposed to formatter functions as `label` */
|
|
266
|
+
getLabel?: PointLabelLookup;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Build the `tooltip` component. `base` is the chart's default tooltip.
|
|
270
|
+
*/
|
|
271
|
+
declare function buildTooltip(base: AnyObject, { show, formatter, valueFormatter, getLabel }: BuildTooltipOptions): AnyObject | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Format a value with `tooltipValueFormatter`, for charts whose default
|
|
274
|
+
* tooltip is custom HTML (where ECharts' `valueFormatter` does not apply)
|
|
275
|
+
*/
|
|
276
|
+
declare function formatTooltipValue(value: unknown, valueFormatter: ((value: number) => string) | undefined): string;
|
|
277
|
+
/**
|
|
278
|
+
* A data label formatter that writes values with a value format, keeping any
|
|
279
|
+
* per-point label text
|
|
280
|
+
*/
|
|
281
|
+
declare function valueLabelFormatter(format: (value: number) => string): (params: LabelFormatterParams) => string;
|
|
282
|
+
/**
|
|
283
|
+
* Give a value axis tick formatter from a value format, unless the axis
|
|
284
|
+
* config sets its own
|
|
285
|
+
*/
|
|
286
|
+
declare function valueAxisConfig(config: AxisConfig | undefined, format: ((value: number) => string) | undefined): AxisConfig | undefined;
|
|
287
|
+
interface ChartFormatterOptions {
|
|
288
|
+
/** The `valueFormat` prop */
|
|
289
|
+
valueFormat?: ValueFormat;
|
|
290
|
+
/** The `locale` prop */
|
|
291
|
+
locale?: string;
|
|
292
|
+
/** The `tooltipValueFormatter` prop */
|
|
293
|
+
tooltipValueFormatter?: (value: number) => string;
|
|
294
|
+
/** The `labelFormatter` prop */
|
|
295
|
+
labelFormatter?: ChartFormatter<LabelFormatterParams>;
|
|
296
|
+
}
|
|
297
|
+
interface ChartFormatters {
|
|
298
|
+
/** The resolved value format, if any */
|
|
299
|
+
format: ((value: number) => string) | undefined;
|
|
300
|
+
/** Formatter for tooltip values */
|
|
301
|
+
tooltip: ((value: number) => string) | undefined;
|
|
302
|
+
/** Formatter for data labels */
|
|
303
|
+
label: ChartFormatter<LabelFormatterParams> | undefined;
|
|
304
|
+
/** Apply the value format to a value axis config */
|
|
305
|
+
axis: (config: AxisConfig | undefined) => AxisConfig | undefined;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Resolve `valueFormat` into the tooltip, label and axis formatters a chart
|
|
309
|
+
* uses; the explicit formatter props win over it
|
|
310
|
+
*/
|
|
311
|
+
declare function chartFormatters({ valueFormat, locale, tooltipValueFormatter, labelFormatter, }: ChartFormatterOptions): ChartFormatters;
|
|
312
|
+
interface ReferenceMarkOptions {
|
|
313
|
+
/** Which axis carries values: 'y' for vertical charts, 'x' for horizontal ones */
|
|
314
|
+
valueAxis: 'x' | 'y';
|
|
315
|
+
/** Formats the default line label */
|
|
316
|
+
format?: (value: number) => string;
|
|
317
|
+
/** Default line colour */
|
|
318
|
+
color: string;
|
|
319
|
+
/** Default band colour */
|
|
320
|
+
bandColor: string;
|
|
321
|
+
/**
|
|
322
|
+
* Whether the category axis runs top to bottom (horizontal bars, dot
|
|
323
|
+
* plots), so a vertical line's far end is at the bottom
|
|
324
|
+
*/
|
|
325
|
+
inverse?: boolean;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Build a series `markLine` for reference lines
|
|
329
|
+
*/
|
|
330
|
+
declare function buildMarkLine(lines: ReferenceLine[] | undefined, { valueAxis, format, color, inverse }: ReferenceMarkOptions): AnyObject | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* Build a series `markArea` for reference bands
|
|
333
|
+
*/
|
|
334
|
+
declare function buildMarkArea(bands: ReferenceBand[] | undefined, { valueAxis, bandColor }: ReferenceMarkOptions): AnyObject | undefined;
|
|
335
|
+
/**
|
|
336
|
+
* Attach reference lines and bands to the series they name (the first series
|
|
337
|
+
* by default). Returns the series unchanged when there are none.
|
|
338
|
+
*/
|
|
339
|
+
declare function withReferenceMarks<S extends AnyObject>(series: S[], lines: ReferenceLine[] | undefined, bands: ReferenceBand[] | undefined, options: ReferenceMarkOptions): (S & {
|
|
340
|
+
markLine?: AnyObject;
|
|
341
|
+
markArea?: AnyObject;
|
|
342
|
+
})[];
|
|
343
|
+
/**
|
|
344
|
+
* Build `dataZoom` components for a category axis
|
|
345
|
+
*/
|
|
346
|
+
declare function buildDataZoom(mode: boolean | 'inside' | 'slider' | undefined, axis: 'x' | 'y',
|
|
347
|
+
/** Room taken by a bottom legend, so a slider sits above it */
|
|
348
|
+
bottomOffset?: number): AnyObject[] | undefined;
|
|
349
|
+
/**
|
|
350
|
+
* Grid room for a data zoom slider, added to a `gridInset` result
|
|
351
|
+
*/
|
|
352
|
+
declare function withZoomInset(inset: AnyObject | undefined, mode: boolean | 'inside' | 'slider' | undefined, axis: 'x' | 'y'): AnyObject | undefined;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Data preparation for distribution, waterfall and stacked charts, and
|
|
356
|
+
* chart sizing helpers
|
|
357
|
+
*/
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* A "nice" step (1, 2, 2.5 or 5 times a power of ten) at least `rough`
|
|
361
|
+
*/
|
|
362
|
+
declare function niceStep(rough: number): number;
|
|
363
|
+
interface BinValuesOptions {
|
|
364
|
+
/** A bucket count, or explicit buckets (defaults to Sturges' rule) */
|
|
365
|
+
bins?: number | HistogramBin[];
|
|
366
|
+
/** Width of equal buckets (takes precedence over a bucket count) */
|
|
367
|
+
binWidth?: number;
|
|
368
|
+
/** Formats bucket bounds in generated labels */
|
|
369
|
+
format?: (value: number) => string;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Count values into histogram buckets. Each bucket includes its start and
|
|
373
|
+
* excludes its end, except the last, which includes both. Non-finite values
|
|
374
|
+
* are ignored.
|
|
375
|
+
*/
|
|
376
|
+
declare function binValues(values: number[], options?: BinValuesOptions): HistogramBucket[];
|
|
377
|
+
/**
|
|
378
|
+
* Quantile of sorted values by linear interpolation (the method spreadsheets
|
|
379
|
+
* and NumPy use by default)
|
|
380
|
+
*/
|
|
381
|
+
declare function quantile(sorted: number[], q: number): number;
|
|
382
|
+
/**
|
|
383
|
+
* Five-number summary with Tukey whiskers (1.5 IQR) and outliers. Returns
|
|
384
|
+
* null when there are no finite values.
|
|
385
|
+
*/
|
|
386
|
+
declare function boxplotStats(values: number[]): BoxPlotStats | null;
|
|
387
|
+
/**
|
|
388
|
+
* Where one waterfall step's bar sits
|
|
389
|
+
*/
|
|
390
|
+
interface WaterfallBar {
|
|
391
|
+
/** Running total before the step (0 for totals) */
|
|
392
|
+
start: number;
|
|
393
|
+
/** Running total after the step */
|
|
394
|
+
end: number;
|
|
395
|
+
/** The step's change, or the total for total steps */
|
|
396
|
+
value: number;
|
|
397
|
+
/** How the bar is coloured */
|
|
398
|
+
kind: 'increase' | 'decrease' | 'total';
|
|
399
|
+
/**
|
|
400
|
+
* Stacking pieces: an invisible `base`, then the `positive` part (above
|
|
401
|
+
* zero) and `negative` part (below zero) of the visible bar. ECharts stacks
|
|
402
|
+
* positive and negative values separately, so bars that cross zero draw
|
|
403
|
+
* correctly.
|
|
404
|
+
*/
|
|
405
|
+
base: number;
|
|
406
|
+
positive: number;
|
|
407
|
+
negative: number;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Lay out waterfall steps as stacked bar pieces
|
|
411
|
+
*/
|
|
412
|
+
declare function waterfallLayout(steps: WaterfallStep[]): WaterfallBar[];
|
|
413
|
+
/**
|
|
414
|
+
* Convert stacked series to each category's share of 100%. Missing values
|
|
415
|
+
* stay missing; a category whose values sum to zero gets zeros.
|
|
416
|
+
*/
|
|
417
|
+
declare function toPercentStack<S extends {
|
|
418
|
+
data: (number | null)[];
|
|
419
|
+
}>(series: S[]): S[];
|
|
420
|
+
/**
|
|
421
|
+
* Pair category labels with values for a time or value x-axis, which reads
|
|
422
|
+
* [x, y] points rather than values by category index
|
|
423
|
+
*/
|
|
424
|
+
declare function pairWithCategories<V>(categories: (string | number)[], values: V[], axisType: string | undefined): (V | [string | number, V])[];
|
|
425
|
+
interface AutoHeightOptions {
|
|
426
|
+
/** Height per row (defaults to 28) */
|
|
427
|
+
rowHeight?: number;
|
|
428
|
+
/** Fixed space for axes and padding (defaults to 56) */
|
|
429
|
+
chrome?: number;
|
|
430
|
+
/** Lower bound (defaults to 160) */
|
|
431
|
+
minHeight?: number;
|
|
432
|
+
/** Upper bound */
|
|
433
|
+
maxHeight?: number;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Resolve a chart height: 'auto' sizes to the row count within the min and
|
|
437
|
+
* max bounds; any other height is returned unchanged
|
|
438
|
+
*/
|
|
439
|
+
declare function resolveChartHeight(height: number | string | undefined, rows: number, { rowHeight, chrome, minHeight, maxHeight }?: AutoHeightOptions): number | string | undefined;
|
|
440
|
+
/**
|
|
441
|
+
* Whether every series is empty or holds only missing values
|
|
442
|
+
*/
|
|
443
|
+
declare function allSeriesEmpty(series: Pick<CategorySeriesData, 'data'>[] | undefined): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Least-squares trend line through points, as its two end points. Returns
|
|
446
|
+
* null for fewer than two points or when every x is the same.
|
|
447
|
+
*/
|
|
448
|
+
declare function trendLine(points: [number, number][]): [[number, number], [number, number]] | null;
|
|
449
|
+
/**
|
|
450
|
+
* A change between two values
|
|
451
|
+
*/
|
|
452
|
+
interface Delta {
|
|
453
|
+
/** current - previous */
|
|
454
|
+
change: number;
|
|
455
|
+
/** The change relative to |previous|, or null when previous is 0 */
|
|
456
|
+
ratio: number | null;
|
|
457
|
+
/** Which way the value moved */
|
|
458
|
+
direction: 'up' | 'down' | 'flat';
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Compare a value with a previous one. Returns null when either is missing.
|
|
462
|
+
*/
|
|
463
|
+
declare function computeDelta(current: number | null | undefined, previous: number | null | undefined): Delta | null;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Adapters from arrays of records (rows from an API or query) to chart data
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
/** A field name or a function reading a value from a record */
|
|
470
|
+
type Accessor<T, V> = keyof T | ((row: T) => V);
|
|
471
|
+
/** How values that share a category (and series) are combined */
|
|
472
|
+
type Aggregate = 'sum' | 'count' | 'avg' | 'min' | 'max' | 'first' | 'last';
|
|
473
|
+
interface FromRecordsOptions<T> {
|
|
474
|
+
/** Field (or function) giving each record's category */
|
|
475
|
+
category: Accessor<T, unknown>;
|
|
476
|
+
/** Field (or function) giving each record's value; omit with `aggregate: 'count'` */
|
|
477
|
+
value?: Accessor<T, unknown>;
|
|
478
|
+
/**
|
|
479
|
+
* Field (or function) splitting records into series (long data). Omit for a
|
|
480
|
+
* single series named by `seriesName`.
|
|
481
|
+
*/
|
|
482
|
+
series?: Accessor<T, unknown>;
|
|
483
|
+
/**
|
|
484
|
+
* Several value fields, each becoming a series (wide data), as
|
|
485
|
+
* `{ 'Series name': field }`. Replaces `value` and `series`.
|
|
486
|
+
*/
|
|
487
|
+
measures?: Record<string, Accessor<T, unknown>>;
|
|
488
|
+
/** Name of the single series when neither `series` nor `measures` is given */
|
|
489
|
+
seriesName?: string;
|
|
490
|
+
/** How records sharing a category and series combine (defaults to 'sum') */
|
|
491
|
+
aggregate?: Aggregate;
|
|
492
|
+
/**
|
|
493
|
+
* Category order: by total descending ('total'), ascending ('total-asc'),
|
|
494
|
+
* alphabetically ('category'), first appearance ('none', the default), or
|
|
495
|
+
* a comparator of category labels
|
|
496
|
+
*/
|
|
497
|
+
sort?: 'total' | 'total-asc' | 'category' | 'none' | ((a: string, b: string) => number);
|
|
498
|
+
/** Explicit category order; listed categories come first, the rest follow */
|
|
499
|
+
categoryOrder?: string[];
|
|
500
|
+
/** Keep only the first N categories after sorting (sorts by total when `sort` is unset) */
|
|
501
|
+
topN?: number;
|
|
502
|
+
/**
|
|
503
|
+
* Fold the categories beyond `topN` into one with this label (only for
|
|
504
|
+
* 'sum' and 'count', where folding is meaningful). Omit to drop them.
|
|
505
|
+
*/
|
|
506
|
+
otherLabel?: string;
|
|
507
|
+
/** Explicit series order; listed series come first, the rest follow in first-appearance order */
|
|
508
|
+
seriesOrder?: string[];
|
|
509
|
+
/** Label for missing categories and series (defaults to 'Unknown') */
|
|
510
|
+
nullLabel?: string;
|
|
511
|
+
/** Value for category and series combinations with no records (defaults to null, a gap) */
|
|
512
|
+
fill?: number | null;
|
|
513
|
+
/** Series colours by series name */
|
|
514
|
+
colors?: Record<string, string>;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Pivot records into the categories x series shape used by line, bar, area,
|
|
518
|
+
* combo and dot plot charts
|
|
519
|
+
*
|
|
520
|
+
* ```ts
|
|
521
|
+
* fromRecords(rows, { category: 'builder', series: 'status', value: 'homes', sort: 'total', topN: 10 })
|
|
522
|
+
* fromRecords(rows, { category: 'month', measures: { Started: 'starts', Closed: 'closings' } })
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
declare function fromRecords<T>(rows: T[], options: FromRecordsOptions<T>): CategoryChartData;
|
|
526
|
+
interface ToSliceDataOptions<T> {
|
|
527
|
+
/** Field (or function) giving each slice's name */
|
|
528
|
+
name: Accessor<T, unknown>;
|
|
529
|
+
/** Field (or function) giving each slice's value; omit to count records */
|
|
530
|
+
value?: Accessor<T, unknown>;
|
|
531
|
+
/** How records sharing a name combine (defaults to 'sum') */
|
|
532
|
+
aggregate?: Aggregate;
|
|
533
|
+
/** Drop slices whose value is zero or missing (defaults to true) */
|
|
534
|
+
dropZero?: boolean;
|
|
535
|
+
/** Slice order (defaults to 'desc', largest first) */
|
|
536
|
+
sort?: 'desc' | 'asc' | 'none';
|
|
537
|
+
/** Keep only the largest N slices */
|
|
538
|
+
topN?: number;
|
|
539
|
+
/** Fold slices beyond `topN` into one with this label; omit to drop them */
|
|
540
|
+
otherLabel?: string;
|
|
541
|
+
/** Label for a missing name (defaults to 'Unknown') */
|
|
542
|
+
nullLabel?: string;
|
|
543
|
+
/** Slice colours by name */
|
|
544
|
+
colors?: Record<string, string>;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Aggregate records into pie, donut or funnel slices
|
|
548
|
+
*/
|
|
549
|
+
declare function toSliceData<T>(rows: T[], options: ToSliceDataOptions<T>): PieSliceData[];
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Chart data as tables, for the accessible data table and CSV export
|
|
553
|
+
*/
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Categories x series as a table: one row per category, one column per series
|
|
557
|
+
*/
|
|
558
|
+
declare function categoryTable(data: CategoryChartData, categoryHeader?: string): ChartDataTable;
|
|
559
|
+
/**
|
|
560
|
+
* Slices as a table with each slice's share of the total
|
|
561
|
+
*/
|
|
562
|
+
declare function sliceTable(slices: PieSliceData[], nameHeader?: string): ChartDataTable;
|
|
563
|
+
/**
|
|
564
|
+
* Scatter points as a table
|
|
565
|
+
*/
|
|
566
|
+
declare function scatterTable(data: ScatterChartData, xHeader?: string, yHeader?: string): ChartDataTable;
|
|
567
|
+
/**
|
|
568
|
+
* Radar series as a table: one row per indicator
|
|
569
|
+
*/
|
|
570
|
+
declare function radarTable(data: RadarChartData, indicators: RadarIndicator[]): ChartDataTable;
|
|
571
|
+
/**
|
|
572
|
+
* Heatmap cells as a grid: one row per y label, one column per x label
|
|
573
|
+
*/
|
|
574
|
+
declare function heatmapTable(data: HeatmapData, xAxis: string[], yAxis: string[]): ChartDataTable;
|
|
575
|
+
/**
|
|
576
|
+
* Treemap leaves as a table with their full path
|
|
577
|
+
*/
|
|
578
|
+
declare function treemapTable(nodes: TreemapNode[]): ChartDataTable;
|
|
579
|
+
/**
|
|
580
|
+
* Sankey links as a table
|
|
581
|
+
*/
|
|
582
|
+
declare function sankeyTable(data: SankeyData): ChartDataTable;
|
|
583
|
+
/**
|
|
584
|
+
* Candlestick prices as a table
|
|
585
|
+
*/
|
|
586
|
+
declare function candlestickTable(data: CandlestickData): ChartDataTable;
|
|
587
|
+
/**
|
|
588
|
+
* Histogram buckets as a table
|
|
589
|
+
*/
|
|
590
|
+
declare function histogramTable(buckets: HistogramBucket[]): ChartDataTable;
|
|
591
|
+
/**
|
|
592
|
+
* Box plot summaries as a table
|
|
593
|
+
*/
|
|
594
|
+
declare function boxPlotTable(groups: {
|
|
595
|
+
name: string;
|
|
596
|
+
stats: BoxPlotStats | null;
|
|
597
|
+
}[]): ChartDataTable;
|
|
598
|
+
/**
|
|
599
|
+
* Waterfall steps as a table with the running total
|
|
600
|
+
*/
|
|
601
|
+
declare function waterfallTable(steps: WaterfallStep[], bars: WaterfallBar[]): ChartDataTable;
|
|
602
|
+
/**
|
|
603
|
+
* Bullet rows as a table
|
|
604
|
+
*/
|
|
605
|
+
declare function bulletTable(items: BulletItem[]): ChartDataTable;
|
|
606
|
+
/**
|
|
607
|
+
* Format a table cell for display
|
|
608
|
+
*/
|
|
609
|
+
declare function formatTableCell(table: ChartDataTable, cell: string | number | null, column: number, format?: (value: number) => string): string;
|
|
610
|
+
/**
|
|
611
|
+
* Serialise a table as CSV (RFC 4180). Numbers stay raw so spreadsheets can
|
|
612
|
+
* work with them; pass `format` to write formatted values instead.
|
|
613
|
+
*/
|
|
614
|
+
declare function tableToCsv(table: ChartDataTable, format?: (value: number) => string): string;
|
|
615
|
+
/**
|
|
616
|
+
* A file name from a chart title: lowercase words joined by hyphens
|
|
617
|
+
*/
|
|
618
|
+
declare function chartFilename(title: string): string;
|
|
619
|
+
/**
|
|
620
|
+
* Trigger a browser download of text or a data URL. Does nothing outside a
|
|
621
|
+
* browser.
|
|
622
|
+
*/
|
|
623
|
+
declare function downloadFile(content: string, filename: string, mimeType?: string): void;
|
|
624
|
+
/**
|
|
625
|
+
* Download a table as a CSV file. A byte order mark makes Excel read it as
|
|
626
|
+
* UTF-8.
|
|
627
|
+
*/
|
|
628
|
+
declare function downloadCsv(table: ChartDataTable, filename: string): void;
|
|
93
629
|
|
|
94
|
-
export { BarChartData, LineChartData, PieSliceData, ScatterChartData, abbreviateNumber, createTooltipFormatter, escapeHtml, formatCurrency, formatDate, formatNumber, formatPercent, generateBarChartDescription, generateDataTable, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, getReplaceMerge };
|
|
630
|
+
export { type Accessor, type Aggregate, type AutoHeightOptions, AxisConfig, BarChartData, type BinValuesOptions, BoxPlotStats, type BuildDataLabelOptions, type BuildLegendOptions, type BuildTooltipOptions, BulletItem, CandlestickData, CategoryChartData, CategorySeriesData, ChartDataTable, ChartFormatter, type ChartFormatterOptions, type ChartFormatters, ChartLegendConfig, type Delta, type FromRecordsOptions, HeatmapData, HistogramBin, HistogramBucket, LabelFormatterParams, LegendItem, LineChartData, PieSliceData, type PointLabelLookup, RadarChartData, RadarIndicator, ReferenceBand, ReferenceLine, type ReferenceMarkOptions, SankeyData, ScatterChartData, type ToSliceDataOptions, TooltipFormatterParams, TreemapNode, ValueFormat, type WaterfallBar, WaterfallStep, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, downloadCsv, downloadFile, escapeHtml, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, gridInset, hasPointLabels, heatmapTable, histogramTable, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, seriesLabelLookup, sliceTable, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withPointLabels, withReferenceMarks, withZoomInset };
|