import type { LineSeriesWire } from '../types/line.type'; import { type NumericFormat } from './v2.util'; /** Apollo rule: the series are named at the end of their line up to this many. */ export declare const END_LABEL_MAX_SERIES = 4; /** X labels longer than this are cut with an ellipsis on the axis. */ export declare const MAX_X_LABEL_LENGTH = 28; export type LineRow = Record; /** The line wire has no per-series format yet: integers or one decimal. */ export type LineFormat = NumericFormat; export type LineSeries = LineSeriesWire & { /** How its values are written: `number`, or `decimal` when any has decimals. */ format: LineFormat; }; export type LineDatum = { /** The period, always text. */ x: string; /** One finite number or `null` per series, in series order. */ values: (number | null)[]; }; export type LineModel = { /** Rows in the order the pipeline delivered them (time order). */ data: LineDatum[]; series: LineSeries[]; /** Series indexes sorted by their last non-null value, descending. */ legendOrder: number[]; showLegend: boolean; /** Whether the series are few enough to be named at the end of their line. */ showEndLabels: boolean; /** Format of the value axis ticks (decimal if any series is). */ axisFormat: LineFormat; firstX: string; lastX: string; }; /** Shortest cut of an x label, ellipsis included, however narrow the chart. */ export declare const MIN_X_LABEL_LENGTH = 6; /** * Estimated width in px of one character of a 12 px x tick. An estimate, not * a measure: the layout stays pure and the same in tests and in the browser. * It errs wide so a label never takes more room than planned. */ export declare const X_TICK_CHAR_WIDTH = 7; /** Least free space in px between two x labels. */ export declare const X_TICK_GAP = 12; /** Cuts a long x label for the axis; the full text stays in the tooltip and the table. */ export declare const truncateX: (x: string, maxLength?: number) => string; export type XTickLayout = { /** Indexes of the rows whose x label is drawn, in order. */ indexes: number[]; /** Length at which every drawn label is cut, ellipsis included. */ maxChars: number; }; /** * Which x labels to draw so no two overlap, and where to cut them. The first * and last are always kept; the rest are one of every `step` rows with the * smallest step (at least `minStep`) that fits. Labels are cut so that the * first and the last fit side by side. */ export declare const layoutXTicks: (labels: readonly string[], plotWidth: number, minStep?: number) => XTickLayout; /** Index of the last row with a value for the series, or `-1` when it has none. */ export declare const lastValueIndex: (data: readonly LineDatum[], seriesIndex: number) => number; /** * Rows whose value has no non-null neighbour: with gaps left open (never * joined) a lone point draws no segment, so the view marks it with a dot. */ export declare const isolatedIndexes: (data: readonly LineDatum[], seriesIndex: number) => number[]; /** * Reads only the fields the wire declares (`x` and each series `field`) from * the rows, as own properties. Periods are text; values are finite numbers or * `null` (a gap, never 0). */ export declare const toLineModel: (wire: { x: string; series: readonly LineSeriesWire[]; }, rows: readonly LineRow[]) => LineModel; /** Recharts data key of a series: `s`, so no column name can collide. */ export declare const seriesKey: (index: number) => string; /** The series index of a key made by `seriesKey`, or `null` for any other key. */ export declare const seriesIndexFromKey: (dataKey: string) => number | null; /** * Format of a Recharts data key: series are keyed with `seriesKey`; anything * else takes the axis format. */ export declare const formatForKey: (model: Pick, dataKey: string) => LineFormat;