本文へ移動

Taisen Brackets対戦

対戦の一覧から、トーナメント表をSVGで描きます。

対戦(たいせん)は、二者が向かい合って勝負することです。 名前について(英語)

目次

リファレンス · トーナメント表・表・決勝までの道を描く

BroadcastMedalOptions型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

What a broadcast medal table can be told: labels (the codes or the names), ranks, the sort and the rows, and the options of every broadcast board.

インポート

import type { BroadcastMedalOptions } from "@johnmorrisdotca/taisen-brackets";

定義

interface BroadcastMedalOptions extends BroadcastOptions, Pick<MedalTableOptions, "sort" | "ties" | "top" | "skipEmpty"> {
    labels?: "code" | "name";
    ranks?: boolean;
}

メンバー

名前型説明
labels (省略可)"name" | "code" | undefined

Write each row's code (the default where every row has one) or its name.

ranks (省略可)boolean | undefined

Write the rank before each row. Default true.

width (省略可)number | undefined

The width of the board; the height follows from the rows. Default 1280, from 320 to 4000.

look (省略可)BroadcastLook | undefined

blue (the default), night or paper.

icon (省略可)BroadcastIcon | undefined

The icon in the square at the left of the title: medal (the default), stopwatch, none, or an iconMark of your own.

iconMark (省略可)string | undefined

A mark of your own for that square (inline SVG or an image address), in place of icon.

flags (省略可)FlagRenderer | undefined

Draws a flag from its code, as for drawBracket; it is asked for the shape rect (Hata's "4:3").

flagHref (省略可)((code: string) => string | null | undefined) | undefined

The address of a flag as a picture to load, tried where flags gives none.

locale (省略可)string | Locale | undefined
words (省略可)Partial<Words> | undefined
title (省略可)string | undefined

The <title> of the drawing. Default: the board's own heading.

id (省略可)string | undefined
className (省略可)string | undefined
ties (省略可)boolean | undefined

Equal rows share a rank (1, 2, 2, 4). Default true; false numbers every row.

sort (省略可)"given" | "gold" | "total" | undefined

gold (the default): by gold, then silver, then bronze, as the Olympic Games rank. total: by the total of medals, then gold, then silver. given: the order given, ranked by the same rule as gold.

top (省略可)number | undefined

Only the first N rows, after sorting.

skipEmpty (省略可)boolean | undefined

Hide the rows with no medal at all. Default false.

例

import { broadcastMedalTable, type BroadcastMedalOptions } from "@johnmorrisdotca/taisen-brackets";

const options: BroadcastMedalOptions = { width: 960, labels: "name", ranks: true };
console.log(broadcastMedalTable({ subtitle: "Day 16", rows: [
  { name: "United States", code: "USA", flag: "US", gold: 46, silver: 29, bronze: 29 },
  { name: "China", code: "CHN", flag: "CN", gold: 38, silver: 27, bronze: 22 },
] }, options).startsWith("<svg"));
true

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/taisen-brackets 0.20.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。