import { type ReactNode } from 'react'; /** One reading, at the moment it was taken. Seconds, because that is the unit * an indexer dates a day in. */ export interface Point { at: number; value: number; } /** * A session in the four prices that close it. * * `value` is the close, so a candle IS a point that also knows what happened * between its ends — which is what lets the cursor, the bounds and the readout * treat both alike and only the drawing tell them apart. */ export interface Candle extends Point { open: number; high: number; low: number; } /** * A reading a drawing puts somewhere: a close, or the session that closed at * it. * * Not `Reading`, which this directory already spends on the other meaning — the * `reading | read | failed` a component takes instead of an array. Two senses * of one word inside one family is the ambiguity the family exists to remove, * so the datum is a datum. */ type Datum = Point | Candle; /** * What is known about a series. * * The shape rides on the answer rather than on the component, because a caller * does not choose a drawing — it says what it read. Closes are a line, the four * prices are candles, what crossed is bars. A failure carries no shape at all, * which is the point: there is nothing to draw and no way to say there is. * * Each of the four is drawn under its own name, so no two of them are ever the * same element in the same place. The stack primitive asks for one more hook * when it is given an element to render through, which the drawn state is and * the other three are not; reconciled as one element, moving between them * raises `Rendered more hooks than during the previous render` and takes the * screen down. Pressing a period control is exactly that move. */ export type Series = { at: 'reading'; } | { at: 'read'; shape: 'line' | 'bars'; points: readonly Point[]; } | { at: 'read'; shape: 'candle'; points: readonly Candle[]; } | { at: 'failed'; why: string; }; /** * What a drawing says in the states it has nothing to draw in. * * Props and not English written into this file, because a surface that reads a * chain in one language and says "Loading" in another has published a sentence * nobody translated — and a component that reaches into a catalog has taken * that dependency on the caller's behalf. */ export interface Blank { /** Said while a read is running. */ reading: ReactNode; /** The title over a read that failed. The reason is the reading's own. */ failed: ReactNode; /** * Where there is nothing to draw. Required for the reason a table's is: only * the caller knows whether that means the indexer has ingested nothing or * this asset has never traded, and those are different facts about a venue. */ nothing: ReactNode; } /** The drawing's own coordinates. */ export interface Box { width: number; height: number; } /** The lowest and highest value a box has to cover. */ export interface Bounds { low: number; high: number; } /** * The readings, oldest first and only the ones that carry numbers. * * In time order here rather than trusted to arrive in it. A line through rows * in the order they happened to be returned is a shape nothing happened in, and * it looks exactly like a chart. */ export declare const ordered:
(of: readonly P[]) => P[]; /** * What the readings span. A candle spans its own high and low, which are * outside its ends — a body scaled to the closes alone has wicks leaving the * box. * * The extremes of the middle ninety-eight per cent, not of everything. An * indexer's high and low are computed from whatever crossed that day, and a * single trade against an empty pool prints a number with no relation to the * asset. Scaled to one of those, a hundred real days occupy less than a pixel * and the drawing is a single vertical line: the outlier is the only thing * visible, and it is the one number that means nothing. * * The domain is trimmed, not the DATA. Every reading is still drawn, and one * outside the box is clamped to its edge rather than dropped, so the day it * happened is still there to reach. What changes is which points the vertical * scale is chosen for. */ export declare function bounds(of: readonly Datum[]): Bounds; /** * Where each reading sits across the box. * * Along the clock, not along the row of rows. An indexer closes a day only * where it saw something, so a series has gaps — spaced evenly, a fortnight of * silence and a busy Tuesday are drawn the same width, which is a different * shape from the one that happened. Where every reading shares one timestamp * there is no time to place them along, and they fall back to even spacing * rather than to a division by zero. */ export declare function spread(of: readonly Datum[], width: number): number[]; /** * Where a figure sits down the box. Down the screen is up the axis, since SVG * counts y from the top. * * A series that never moved sits through the middle. The obvious arithmetic * divides by a range of zero there and every coordinate comes out `NaN`, so the * drawing disappears exactly when the price held still. */ export declare const ordinate: (value: number, within: Bounds, height: number) => number; /** The line through the readings. */ export declare function trace(of: readonly Point[], box: Box, within: Bounds): string; /** * How wide one mark is drawn. * * The closest pair decides it, so marks never overlap however unevenly the * readings fall in time — a share of the average would draw two readings an * hour apart on top of each other and report a session that was never there. */ export declare function thickness(xs: readonly number[], box: Box): number; /** * Which reading a key selects, or nothing for a key that is not ours. * * It stops at both ends rather than wrapping. A series is time, and arriving at * the newest reading to land on the oldest is a jump the reader takes for a * series that loops. */ export declare function stepped(key: string, at: number, of: number): number | null; export interface ChartProps { /** What is drawn, as a short noun — "closing price", "volume each day". It * names the image for a screen reader and titles a failure. */ name: string; series: Series; say: Blank & { /** The two words under the drawing, naming what the box covers. Axes would * be four more figures claiming a precision an indexer has not earned. */ low: ReactNode; high: ReactNode; }; /** Taller where the drawing is what the screen is for. */ height?: number; /** * The figure, written. Required rather than defaulted: a number is not a * string until a locale has been applied to it, and a component that picks * one has pinned every reader to it. `figures().precise` is the usual answer. */ format: (value: number) => string; /** The moment, written. The indexer's own UTC day unless a caller says * otherwise. */ when?: (at: number) => string; } /** * A series over time. * * Three shapes, and each carries its value a different way. A line carries it * in POSITION, a bar in LENGTH, a candle in the two ends of a body. That is why * they are not one drawing with a style prop: a bar measured from anywhere but * zero is a length that means nothing, and a line forced down to zero flattens * a day spent between 0.000109 and 0.000111 into a grey rule. Each shape gets * the axis its own mark needs, and the range it was given is written under the * box, so what the box covers is read rather than inferred. * * Two readings, or none of it is drawn. One is not a series: a lone close is a * dot on an axis whose range it alone decided, a lone session is a body filling * the box top to bottom, and either reads as a chart of an asset that never * moved. */ export declare function Chart({ name, series, say, height, format, when }: ChartProps): import("react").JSX.Element; /** * A series in the width of a cell — the line and nothing else. * * No cursor, no readout, no range under it. A movement line is read down a * column against the rows either side of it, and forty of them carrying their * own figures is forty charts on one screen; the figure that matters sits in * the column beside this one. * * Nothing at all where there are fewer than two readings — the same rule the * full drawing keeps, and here it draws nothing rather than a line, because the * cell beside it already says which kind of nothing it is. */ export declare function Spark({ of, name, colour, }: { of: readonly Point[]; /** What the line is of, for a screen reader — "WLUX by day". */ name: string; /** The token layer's own name for a colour. A sign is a colour here and a * figure in the column beside it; never a colour alone. */ colour?: Hue; }): import("react").JSX.Element | null; /** One part of a whole. */ export interface Slice { /** What this part is, in the fewest words that stay unambiguous. */ name: string; /** How much of the whole it holds, in the unit the others are in. */ value: number; /** * What it is drawn in, as a token name. Unsaid, the parts take the ramp in * the order they were given. * * A part whose meaning is carried by hue — a vote for and a vote against — * says so with `paint.good` and `paint.bad`, which are the only two hues this * brand spends outside the achromatic ladder. * * A token name and not a colour. A literal cannot retune between one ground * and the other, so a bar that reads on black is invisible on white. * * The type asks for the shape of a name; it does not decide what is inside * one. `var(--anything, #ff0000)` satisfies it, and a fallback is exactly * where a literal gets in — it is the shape `tokens-referenced.spec.ts` was * written about. Inside this package the literal gate reads that back out of * the source; a caller's own slice is beyond anything a type can see. */ paint?: Hue; } /** * What is known about a division. * * `whole` is what the parts are parts OF, where that is more than they come to: * a quorum of a hundred thousand with forty thousand behind it is a bar that is * two fifths full, and the same forty thousand with no whole stated is a bar * that is entirely one part. Unsaid, the parts are the whole. */ export type Slices = { at: 'reading'; } | { at: 'failed'; why: string; } | { at: 'read'; of: readonly Slice[]; whole?: number; }; /** * A colour, as the token layer names one. * * Every value on `paint` is one of these, which is the point: the drawings take * a name rather than a colour, so what they are painted with moves when the * token set moves and cannot be pinned to one ground. */ export type Hue = `var(--${string})`; /** * What each part holds of the whole. * * The whole is what was stated, or what the parts come to. A stated whole * SMALLER than its parts is not a whole, so the larger of the two wins: a * quorum already passed draws a full bar rather than one that overflows its * own track. * * Nothing divided is not a division. Every part at zero comes back as a whole * of zero and no shares, which is what the drawing puts its empty words in the * room of — a bar of no length is a picture a reader takes for a reading. */ export declare function shares(of: readonly Slice[], whole?: number): { whole: number; each: readonly number[]; }; /** * A whole, and how it divides. * * One bar rather than a ring. A reader compares parts of a ring by angle, which * is the one measurement people read worst; along a bar the same parts are * lengths on a shared baseline, and the two largest can be told apart at a * glance. It is also the shape that survives a column three hundred pixels * wide, which is where a vote result and a quorum actually stand. * * The parts are drawn and then written out under the bar, because a length is * only ever an approximation of a figure and half the readers of this drawing * came for the figure. */ export declare function Split({ name, of, say, format, percent, }: { /** What is divided, as a short noun — "votes cast", "the treasury". It names * the drawing for a screen reader and titles a failure. */ name: string; of: Slices; say: Blank; /** A part's own figure, written. Required for the reason `Chart`'s is. */ format: (value: number) => string; /** The share a part holds, as this reader's percentage. `figures().rate` is * one: a share is not a movement and takes no sign. */ percent: (of: number) => string; }): import("react").JSX.Element; export {}; //# sourceMappingURL=chart.d.ts.map