Repository navigation
Charts
Generated from the thetowersdk repository. Edits made here are overwritten on the next push — change the source file instead.
Charts are built on the formulas above and the catalogs — which is the whole reason this section follows that one. You need the numbers before you can plot them.
A level progression already is a series. The level is your x-axis and each measured field on
it is a line, so generating a chart is a map, not an integration. What the package adds is a name
for each one, so you can ask for it instead of finding the catalog and the field yourself:
import { getChartSeries, listChartSeries } from '@beardedunicorn/thetowersdk/charts'
listChartSeries({ family: 'lab', entity: 'damage' })
// [{ id: 'lab:damage:duration', … }, { id: 'lab:damage:cost', points: 100, … }]
getChartSeries('lab:damage:cost')?.data.slice(0, 3)
// [{ x: 1, y: 30 }, { x: 2, y: 71 }, { x: 3, y: 178 }]A series is its points and nothing else: x is the level, y is the catalog's own value — a
number where the catalog stores one, its text (x9.4, 119:26:00) where it does not. There is
still no opinion about rendering. unit is set only where the catalog states one.
The usual way a project ends up with charts is somebody makes a picture. Then the game rebalances, or a tier gets added, and now there is a PNG showing last patch's numbers with nothing anywhere to flag it. The image cannot tell you it is stale, so it stays wrong until a player notices.
Generating from the data inverts that. You never make a new image — you add rows to the array and every chart drawn from it regenerates. One new lab level, one rebalanced cost, one extra ultimate weapon, and every view over that data is correct at once: the cost curve, the comparison chart, the table, the tooltip. Charts stay consistent with each other because they are not separate artifacts that happen to agree — they are the same numbers rendered more than one way.
import { LAB_CATALOG } from '@beardedunicorn/thetowersdk/data'
const lab = LAB_CATALOG.find((l) => l.name === 'Attack Speed')
const costCurve = lab.levels.map((l) => ({ x: l.level, y: l.cost }))
const timeCurve = lab.levels.map((l) => ({ x: l.level, y: l.duration }))Hand those points to whatever already draws your charts — Chart.js, D3, Vega, a spreadsheet, an SVG path you build yourself. The same operation across a whole catalog gives you a comparison chart:
import { uwStoneChartData } from '@beardedunicorn/thetowersdk/data'
// One series per ultimate weapon: stone cost to reach each cooldown level.
const datasets = Object.values(uwStoneChartData).map((weapon) => {
const cooldown = weapon.stats.find((s) => s.name === 'Cooldown')
return {
label: weapon.name,
data: cooldown.levels
.filter((l) => typeof l.cost === 'number')
.map((l) => ({ x: l.level, y: l.cost })),
}
})Most of what players actually want is a table, not a curve — "what does the next level cost, and
what do I get for it". Same data, same map, different rendering:
import { uwStoneChartData } from '@beardedunicorn/thetowersdk/data'
import { formatNumberForDisplay } from '@beardedunicorn/thetowersdk/formatting'
const gt = Object.values(uwStoneChartData).find((w) => w.name === 'Golden Tower')
const multiplier = gt.stats.find((s) => s.name === 'Multiplier')
let running = 0
for (const level of multiplier.levels) {
if (typeof level.cost === 'number') running += level.cost
console.log(level.level, level.value, level.cost, formatNumberForDisplay(running))
}Golden Tower — every stat
Stat Levels To max Final
---------------- ------ --------- ------------
Multiplier 21 8.434K x21.0
Duration 39 14.052K 53s
Cooldown 21 4.7K 100s
Golden Combo 15 20.07K 0.45%
That table is emitted, not written. When a stat gains levels or a cost is rebalanced, the table and
every chart over the same array update together — which is the point of
generating rather than keeping images. The same loop emits
Markdown, so documentation tables regenerate instead of rotting.
See examples/05-generate-a-cost-table.ts.
How much is chartable. The shipped catalogs support 909 distinct series — one per measurable field that varies across a level range:
| Source | Series | What varies |
|---|---|---|
| Labs | 422 | Coin cost and research time, per lab |
| Workshop | 144 | Stat value, cash cost, coin cost |
| Cards | 64 | Level values and mastery values |
| Ultimate weapons | 72 | Stat value and stone cost, per stat |
| Guardians | 36 | Chip stat value and cost |
| Vault (v29) | 91 | Key cost per level, for upgrades with more than one |
| Vault (pre-v29 trees) | 33 | Key cost per tier, for nodes with more than one |
| Bots | 25 | Per-stat progressions, including plus variants |
| Workshop enhancements | 18 | Coin cost per level |
| Modules | 2 | Coin cost and shard cost per level |
| Unlock ladders | 2 | Stones for the next ultimate weapon and the next plus |
That is a floor, not a ceiling. It counts only series with at least two points — a lab with a single level has a cost and a research time, and they can be fetched by id, but one point is not a chart. It excludes catalogs with nothing to plot: relics carry a single flat value, module substats are cluster metadata, and a vault node bought once has no curve. Anything you derive from the formulas is additional.
@beardedunicorn/thetowersdk/charts adds a registry of ready-made chart definitions, for when you want
the same views rather than your own:
import { SHARED_CHART_REGISTRY, findChartByPathId } from '@beardedunicorn/thetowersdk/charts'It answers what charts exist and what is in them — never how they look. Rendering, styling and
localisation stay with your application. CHART_MECHANIC_LINKS maps each chart to the entities in
@beardedunicorn/thetowersdk/knowledge it documents, so a mechanic can find its chart and vice versa.
See examples/04-generate-a-chart.ts.
Generated from TheTowerSDK — do not edit here. Docs and live demos: https://beardedunicorn.github.io/TheTowerSDK/
- Workshop
- Workshop Enhancements
- Labs
- Cards
- Modules
- Module Rarities and Merging
- Module Substats
- Module Upgrade Costs
- Ultimate Weapons
- Ultimate Weapon Plus
- Bots
- Guardian
- Relics
- Themes
- Tiers
- Battle Conditions
- Enemies
- Perks
- Tournaments
- Milestones
- The Vault
- Daily Missions
- Guild
- Currencies
- Reference Tables
- Glossary
- Irreversible Upgrades
- Game Patch Notes
- Game Version History
SDK
- Quick Start
- Entry Points
- How It Fits Together
- Getting an Official Game Export
- Reading a Save
- Reading The Community Wiki
- Game 29.1 Data
- Formulas
- Builders
- Charts
- Effective Paths
- Examples
- Templates
- Building a Bot On This
- Google Sheets
- Desktop and Mobile
- Optional Add-ons
- Using It With An AI Agent
- Using Your Own Artwork
- Names And Acronyms
- Patch Notes
- Accuracy
- Versioning
- Where the Docs Live
- Contributing
- Credits
- License
Guides
Examples
- 01-browse-game-data.ts
- 02-read-a-save-file.ts
- 03-plan-upgrades-from-a-save.ts
- 04-generate-a-chart.ts
- 05-generate-a-cost-table.ts
- 06-read-the-community-wiki.ts
- 07-format-like-the-game.ts
- 08-build-a-calculator.ts
- 09-build-a-bot.ts
- 10-read-a-sheet.ts
- 11-build-a-knowledge-base.ts
- 12-show-module-and-card-art.ts
Templates