本文へ移動

Taisen Brackets対戦

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

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

目次

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

resultsBoard関数

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

The results board as a standalone SVG. Throws a RangeError for a board with no title or no rows, more than 24 rows, a row with no name, a value that is not a number, a text or null, a precision that is not a whole number from 0 to 6, an unknown option value, or a width outside 720 to 4000.

インポート

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

定義

function resultsBoard(source: ResultsBoardSource, options?: ResultsBoardOptions): string

引数

名前型説明
sourceResultsBoardSource

The title, the phase, the columns and the rows.

options (省略可)ResultsBoardOptions

The width, the look, the icon, the rank style, the language and the flags.

戻り値

string

The SVG, a string that begins with <svg.

例

import { resultsBoard, resultsBoardSize } from "@johnmorrisdotca/taisen-brackets";

const source = {
  title: "Men's 100m butterfly",
  phase: "Results · Final",
  columns: [{ precision: 2 }],
  rows: [
    { code: "USA", flag: "US", name: "Michael Phillips", values: [50.58], record: "OR" },
    { code: "HUN", flag: "HU", name: "Laszlo Czigany", values: [50.59] },
  ],
};
const svg = resultsBoard(source, { width: 960 });
console.log(svg.includes("MEN'S 100M BUTTERFLY"), svg.includes("50.58"), JSON.stringify(resultsBoardSize(source.rows.length, { width: 960 })));
true true {"width":960,"height":171}

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

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

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