import { type Frame } from "./frames.ts"; import { isNum } from "./layers.env.ts"; import type { Layer, LayerBase, MarkDatum, OutcomeStyle } from "./layers.types.ts"; import { type KyogijoWords } from "./strings.ts"; import type { Chart, ChartOptions, KeyItem, NbaShot, NbaShotOptions, NbaTotals, NflPass, NflPassOptions, NflTotals, NhlShot, NhlShotOptions, NhlTotals, ZoneTotal } from "./charts.types.ts"; import type { Language, Sport, SurfaceOptions } from "./types.ts"; import type { ZonesLayer } from "./heat.types.ts"; /** The language of a chart's words. */ export declare const languageOf: (o: ChartOptions) => Language; /** The words of a chart. */ export declare const wordsOf: (language: Language) => KyogijoWords; export { isNum }; /** An object without the properties that are `undefined`, so that a layer is plain data and the same input gives the same JSON. */ export declare function clean(value: T): T; /** The ground round each surface that a chart draws, in feet: room above the surface for the key. */ export declare const MARGIN: Readonly>>; /** A frame by name, or the frame given. */ export declare const frameOf: (from: Frame | string | undefined, fallback: string) => Frame; /** What a layer's `from` is: the frame given, or the name of the one asked for (a name stays a name in the layer's JSON). */ export declare const fromOf: (given: Frame | string | undefined, frame: Frame) => Frame | string; /** The outcome words of a chart and the look of each: the shape, whether it is open, a multiple of the size. */ export type Look = OutcomeStyle; /** One entry of a key: what it says and the outcome whose mark it shows. */ export interface KeyEntry { label: string; outcome?: string; } /** The drawing's options for a chart: the sport, the language, the title and the ground round the surface, then whatever the caller laid over them. */ export declare function drawingOptions(sport: Sport, options: ChartOptions, title: string, extra?: Partial): SurfaceOptions; /** * The key of a chart: one row of marks and their names in the margin above the surface (drawn over the ground round it), as two layers: * the marks, in the look the chart's own marks have, and their words. `extra` is more words with no mark (the size of a mark, a total). */ export declare function keyLayers(o: SurfaceOptions, entries: readonly KeyEntry[], looks: Readonly>, all: KyogijoWords, extra?: readonly string[], at?: KeyPlace): Layer[]; /** Where a key is put when it is not centred above the whole surface: the part of the surface it is centred on (`x`, `w`) and the height of the row (`y`), in feet. */ export interface KeyPlace { x?: number; w?: number; y?: number; } /** The layers of the key are named `key-marks` and `key-text`. */ export declare const isKey: (layer: Layer) => boolean; /** The key of a chart as data, from its entries and looks. */ export declare function keyItems(entries: readonly KeyEntry[], looks: Readonly>): KeyItem[]; /** * The picture of an entry's flag: the `flag` it gives, else the flag of its `country` code by the renderer of flags the chart's `surface.flags` (or `useFlags`) plugs in, in its own proportions; * `undefined` where there is none, so that a chart without a renderer lays out as it always did. */ export declare function entryFlag(entry: { flag?: string; country?: string; }, options: ChartOptions): string | undefined; /** Put a chart together: the options, the layers and the ways to draw them. */ export declare function assemble(options: SurfaceOptions, layers: Layer[], parts: { title: string; summary: string; totals: T; tableLayers?: readonly string[]; }): Chart & { key: KeyItem[]; }; /** `shot`s counted by outcome, as the words of the key and in the key's order, for a layer's description: "Made 3, Missed 5." */ export declare function describeCounts(entries: readonly KeyEntry[], counts: ReadonlyMap, words: KyogijoWords): string; /** Round to a number of decimal places. */ export declare const round: (value: number, places?: number) => number; /** A percent, one decimal, or null with nothing to divide. */ export declare const percentOf: (part: number, whole: number) => number | null; /** The marks counted into the zones of a layer, as zone totals. */ export declare function zoneTotals(o: SurfaceOptions, layer: ZonesLayer): ZoneTotal[]; /** Count marks by outcome, skipping the ones with no place. */ export declare function countOutcomes(rows: readonly { x?: number | null; y?: number | null; outcome?: string; }[]): { counts: Map; placed: number; skipped: number; }; /** True when a mark carries a place. */ export declare const hasPlace: (d: MarkDatum & { x?: number | null; y?: number | null; }) => boolean; /** * Turn the shots at the left end of a surface a half turn so that every one is at the right end, in the numbers of the frame they are in. * Rounded to hundredths of the frame's unit, so that a shot at the right end comes back as it was given. */ export declare function foldToRight(rows: readonly T[], frame: Frame, o: SurfaceOptions): T[]; /** The marks' places on the surface, in feet, in the same frame and ends as a layer will draw them. */ export declare function placed(o: SurfaceOptions, layer: LayerBase, rows: readonly { x?: number | null; y?: number | null; }[]): ([number, number] | undefined)[]; /** * A shot chart for the NBA from stats.nba.com's shot data: each shot as a mark (filled when it went in, an open x when it missed), and the * six shot zones coloured by their field-goal percentage, with the percentage and made over taken written on each, a legend and a table. Give * `league` (the league's percentage) and the zones are coloured by how far they are above or below it, on a diverging ramp. * @example * ```ts * import { nbaShotChart } from "@johnmorrisdotca/kyogijo-stadiums/charts"; * const chart = nbaShotChart( * [ * { x: 0, y: 12, made: true }, * { x: -231, y: 18, made: false }, * { x: 120, y: 140, made: true }, * { x: -30, y: 70, made: true }, * ], * { league: 46, minShots: 1 }, * ); * console.log(chart.totals.shots, chart.totals.made, chart.layers.map((layer) => layer.kind).join(" ")); * console.log(chart.draw().startsWith(" & { key: KeyItem[]; }; /** Per-team totals of shots, goals and expected goals. */ export declare function teamTotals(rows: readonly { x?: number | null; y?: number | null; outcome?: string; team?: string; value?: number | null; }[]): Record; /** * A shot map for the NHL from play-by-play shots: each shot a mark (a goal a star, a save an open circle, a miss an open x, a block an open * triangle) sized by its chance of scoring, with an optional count of the shots into the slot zones or hexagons, a legend, a key and a table. * With `fold` the shots at the left end are turned a half turn, so that every shot is at the right end. * @example * ```ts * import { nhlShotMap } from "@johnmorrisdotca/kyogijo-stadiums/charts"; * const chart = nhlShotMap( * [ * { x: 75, y: 4, outcome: "goal", xg: 0.31 }, * { x: -60, y: -12, outcome: "saved", xg: 0.07 }, * { x: 40, y: 20, outcome: "missed", xg: 0.03 }, * ], * { fold: true, zones: true }, * ); * console.log(chart.totals.shots, chart.totals.goals, chart.totals.xg); * console.log(chart.layers.map((layer) => layer.id).join(" ")); * // 3 1 0.41 * // zones shots key-marks key-text * ``` */ export declare function nhlShotMap(shots: readonly NhlShot[], options?: NhlShotOptions): Chart & { key: KeyItem[]; }; /** * A pass chart for the NFL from tracking data: where each pass came down as a mark (a completion filled, an incompletion open, a touchdown a * star, an interception an x), the line of scrimmage, and the pass grid (short and deep by left, middle and right) coloured by completion * percentage with the air yards of each pass in its table. The offence goes to the right whichever way `direction` says it went in the data. * @example * ```ts * import { nflPassChart } from "@johnmorrisdotca/kyogijo-stadiums/charts"; * const chart = nflPassChart( * [ * { x: 72, y: 26, outcome: "complete" }, * { x: 88, y: 14, outcome: "incomplete" }, * { x: 104, y: 30, outcome: "touchdown" }, * ], * { los: 65, minPasses: 1 }, * ); * console.log(chart.totals.passes, chart.totals.complete, chart.totals.airYards); * // 3 2 23 * ``` */ export declare function nflPassChart(passes: readonly NflPass[], options?: NflPassOptions): Chart & { key: KeyItem[]; };