Analyse
# altText function
packages/highcharts/src/analyse.ts:339altText(outcome: FitOutcome, labels?: SeriesFit['labels']): stringA short text alternative for a chart, suitable for an
aria-label.Uses terse rendering, so it stays to one clause per fact rather than the
paragraph
analyse puts on accessibility.description.Parameters
| Name | Type | Description |
|---|---|---|
| outcome | FitOutcome | — |
| labelsoptional | AxisLabels | undefined | — |
Returns
string
# analyse function
packages/highcharts/src/analyse.ts:194analyse<T extends ChartOptions>(chartOptions: T): AnalyseResult<T>Adds fitted curves, plot-line markers and accessible descriptions to a
Highcharts options object.
Any series carrying a fit property is analysed with @statili/stats,
described with @statili/forge, and given a companion series drawn from the
curve annotation the facts carry. The input options are not mutated.
Deliberately not curried, unlike the rest of the house style: curry erases
generic type parameters, which would collapse the caller’s own options type
down to {@link ChartOptions} on the way out. There is no configuration
argument to place first anyway.
Parameters
| Name | Type | Description |
|---|---|---|
| chartOptions | T | A Highcharts options object. |
Returns
AnalyseResult<T>The rewritten options plus one {@link FitOutcome} per fitted series.
Example
const { options, fits } = analyse({
series: [{ name: "Signups", data: [[1, 12], [2, 19]], fit: { method: "linear" } }],
});
Highcharts.chart("container", options);
console.log(fits[0].description);# toDataPoints function
packages/highcharts/src/analyse.ts:35toDataPoints(data: unknown): DataPoint[]Normalises the three shapes Highcharts accepts for series data into
[x, y]
pairs: [[x, y], …], [y, …] (index becomes X), and [{ x, y }, …].Returns a copy — the caller’s data is never written to.
Parameters
| Name | Type | Description |
|---|---|---|
| data | unknown | — |
Returns
DataPoint[]
# withFit function
packages/highcharts/src/analyse.ts:330withFit<T extends ChartOptions>(chartOptions: T): AnalysedOptions<T>Convenience wrapper returning only the rewritten options, for callers that
want the chart drawn and nothing else.
Parameters
| Name | Type | Description |
|---|---|---|
| chartOptions | T | — |
Returns
AnalysedOptions<T>