Reference · Draw a bracket, a table or a road to the final
MedalTableOptionstype
What a medal table can be told: the sort (gold, total or given), ties, how many rows, columns, highlighting, and the options of every board.
Import it
import type { MedalTableOptions } from "@johnmorrisdotca/taisen-brackets";
Definition
interface MedalTableOptions extends BoardOptions {
sort?: "gold" | "total" | "given";
ties?: boolean;
rankStyle?: "plain" | "hash";
top?: number;
rows?: number;
page?: number;
columns?: 1 | 2;
highlight?: boolean;
skipEmpty?: boolean;
}
Members
| Name | Type | Description |
|---|---|---|
sort (optional) | "given" | "gold" | "total" | undefined |
|
ties (optional) | boolean | undefined | Equal rows share a rank ( |
rankStyle (optional) | "plain" | "hash" | undefined |
|
top (optional) | number | undefined | Only the first N rows, after sorting. |
rows (optional) | number | undefined | The most rows drawn, from the first of the page, and which page (0 is the first). Default: as many as fit at a readable size. |
page (optional) | number | undefined | |
columns (optional) | 2 | 1 | undefined | One column or two (the first column runs down before the second starts). Default 1, and 2 on a wide board with more than 10 rows. |
highlight (optional) | boolean | undefined | Mark the first three ranks with a bar in gold, silver and bronze. Default true. |
skipEmpty (optional) | boolean | undefined | Hide the rows with no medal at all. Default false. |
size (optional) | BoardSizeName | { width: number; height: number; } | undefined | One of |
theme (optional) | "auto" | "light" | "dark" | undefined |
|
flags (optional) | FlagRenderer | undefined | Draws a flag from its code, as for |
flagHref (optional) | ((code: string) => string | null | undefined) | undefined | The address of a flag as a picture to load, tried where |
flagShape (optional) | "round" | "square" | undefined |
|
locale (optional) | string | Locale | undefined | The language: |
words (optional) | Partial<Words> | undefined | |
title (optional) | string | undefined | The |
id (optional) | string | undefined | Prefix for the drawing's ids. Default: a hash of the state and the options. |
className (optional) | string | undefined |
Examples
import { medalTable, type MedalTableOptions } from "@johnmorrisdotca/taisen-brackets";
const options: MedalTableOptions = { sort: "total", top: 10, columns: 2 };
console.log(medalTable({ rows: [
{ name: "France", flag: "FR", gold: 6, silver: 1, bronze: 3 },
{ name: "Japan", flag: "JP", gold: 5, silver: 3, bronze: 2 },
] }, options).startsWith("<svg"));trueWhat it prints (run when this page was built)