Documentation

Analyse

@statili/highcharts ·v0.0.1-beta.0 ·4 exports

signature
altText(outcome: FitOutcome, labels?: SeriesFit['labels']): string
A 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

NameTypeDescription
outcome FitOutcome
labelsoptional AxisLabels | undefined

Returns

string
signature
analyse<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

NameTypeDescription
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);
signature
toDataPoints(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

NameTypeDescription
data unknown

Returns

DataPoint[]
signature
withFit<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

NameTypeDescription
chartOptions T

Returns

AnalysedOptions<T>