Skip to the content

Taisen Brackets対戦

Knockout brackets as SVG, from a list of ties.

Taisen (対戦, たいせん) is Japanese for a matchup: two sides facing each other. About the name

Contents

Reference · Draw a bracket, a table or a road to the final

resultsBoardfunction

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 it

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

Definition

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

Parameters

NameTypeDescription
sourceResultsBoardSource

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

options (optional)ResultsBoardOptions

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

Returns

string

The SVG, a string that begins with <svg.

Examples

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}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/taisen-brackets 0.20.0.