> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Draw a chart layer

You build `ladder`, a keyless Python plugin whose product is drawn on a chart as a profile in the dock at the price axis, recoloured by a shader you write, and read over the wire. You need a checkout [built from source](https://docs.taji.is/guide/install.md), `jq`, the network (the keyless kernel reads Yahoo's delayed bars) and Taji's Python from `make setup`, which runs the plugin and decodes the answers.

A layer is one `[[ui.layers]]` row of a plugin's manifest: it names one of the plugin's products and a renderer, and the window draws that product's rows over the chart. The renderer is a stock one (`taji.levels`, `taji.profile`, `taji.heatmap`, `taji.bubbles`, `taji.footprint`) or a builder you write. [GEX](https://docs.taji.is/catalog/taji-gex.md), `plugins/taji-gex`, draws three layers this way from a Rust plugin; `ladder` is the smallest of the same shape. The row's fields are in [the manifest reference](https://docs.taji.is/plugins/manifest.md).

## 1. Declare the product and the layer

Make a directory named for the plugin's id and write its manifest:

```toml file="examples/layer/ladder/taji-plugin.toml" title="taji-plugin.toml"
id = "ladder"
name = "Ladder"
version = "0.1.0"
taji = ">=0.7, <0.8"

[process]
run = ["ladder.py"]
python = {}

[[sources]]
id = "ladder"
reads = [
  { class = "equity", product = "ladder.strikes", span = "history" },
  { class = "equity", product = "ladder.strikes", span = "live", delay_s = 0 },
]

[[products]]
name = "strikes"
description = "A toy ladder: a bar at each whole price around a centre."
shape = "profile"
words = [{ name = "spot", type = "float", default = 100, min = 1, doc = "The price the ladder centres on." }]
columns = [
  { name = "ts_utc", type = "int" },
  { name = "price", type = "list<decimal>", unit = "price", doc = "The ladder's prices, ascending." },
  { name = "value", type = "list<float>", doc = "The bar at each price: positive above the centre, negative below." },
]

[[ui.layers]]
id = "ladder.strikes"
label = "Ladder"
product = "ladder.strikes"
renderer = "taji.profile"
shader = "ui/ladder.wgsl"
slot = "dock"
style = [{ name = "opacity", type = "float", default = 0.8, min = 0, max = 1 }]
```

1. **`[[sources]]`** serves `ladder.strikes` for `equity` items at `history` and `live`. The window reads a layer's product over the chart's view and streams it, so serve both; with `history` alone the layer's legend shows `!`.
2. **`[[products]]`** declares the product. Its `shape`, `profile`, says a row is a by-price distribution and requires the list columns `price` and `value`. `spot` is a word: the window puts each word of the product, at the binding's value or the default, on every read and stream of the layer.
3. **`[[ui.layers]]`** draws it. `product` is one of the plugin's own products that has a `shape`; `renderer` is the stock renderer of that shape; `slot = "dock"` puts it inside the plot at the price axis; `shader` recolours its bars; `style` rows declare what the user may change.

[Pick a renderer and a slot](#pick-a-renderer-and-a-slot) lists the choices for each of those.

## 2. Serve the rows

Write the program beside the manifest:

```python file="examples/layer/ladder/ladder.py" title="ladder.py"
import asyncio
import time

import taji

p = taji.plugin()
HOUR = 3600


def row(ts, spot):
    steps = range(-10, 11)
    return {
        "ts_utc": ts,
        "price": [str(round(spot) + k) for k in steps],
        "value": [float(k * (11 - abs(k)) * 10) for k in steps],
    }


@p.read("ladder.strikes")
def read(ask):
    spot = float(ask["words"]["spot"])
    hi = min(ask["to"] or 2**62, int(time.time()) + 1)
    lo = ask["from"] if ask["from"] is not None else hi - 24 * HOUR
    rows = [row(ts, spot) for ts in range((lo + HOUR - 1) // HOUR * HOUR, hi, HOUR)]
    return rows[: ask["limit"]] if ask["limit"] is not None else rows


@p.stream
async def stream(sub):
    spot = float(sub["words"]["spot"])
    while True:
        p.push(sub["sub"], [row(int(time.time()), spot)])
        await asyncio.sleep(60)


p.run()
```

1. **`row`** is one row: 21 prices around `spot`, a decimal string each, and a bar at each, growing from nothing at `spot` to 300 five prices out, then shrinking; positive above `spot`, negative below.
2. **`@p.read("ladder.strikes")`** answers `history`. A word reaches `ask["words"]` as a string, so `spot` is converted. It answers one row an hour in `[from, to)`, none after now, and at most `limit`. A shaped product has one row an instant (a second row at one instant is dropped), so each row has its own `ts_utc`.
3. **`@p.stream`** runs once per sub, the window's stream of the layer, and pushes a row stamped now every 60 s. The SDK cancels it when the sub leaves the set.
4. **`p.run()`** says hello to the kernel and serves calls until the kernel closes stdin. It refuses to start when a product of `[[sources]]` has no `@p.read`, or a `live` read has no `@p.stream`.

`taji.profile` draws the newest row it holds, so a row an hour old is still the dock's.

## 3. Shade the layer

A shader recolours the rects a renderer already draws; picking and tooltips are unchanged. Write the shader as `ladder.wgsl` in the plugin's `ui` directory:

```wgsl file="examples/layer/ladder/ui/ladder.wgsl" title="ui/ladder.wgsl"
// A bar deepens with its size, from the muted ink at the smallest to the renderer's colour at the peak.
fn shade(in: ShadeIn) -> vec4f {
  let rgb = mix(in.tokens.muted.rgb, in.base.rgb, 0.3 + 0.7 * in.t);
  return vec4f(rgb, in.base.a);
}
```

1. **`fn shade(in: ShadeIn) -> vec4f`** is the one function the file must hold. It returns the rect's colour as straight alpha.
2. **`in.t`** is the bar's size, `abs(row.value)` over the layer's largest, from 0 to 1.
3. **`in.base`** is the colour the renderer would draw: green for a positive bar, pink for a negative one.
4. **`mix(in.tokens.muted.rgb, in.base.rgb, …)`** runs each bar from the muted ink at the smallest to its own colour at the peak.

Taji generates `ShadeIn`:

| Field | Holds |
|---|---|
| `row` | an `f32` for each non-nullable number or list column of the rect's row except `ts_utc` and `ts_ms`, named for it; a list column gives the element at the rect's `cell`, 0 where none. At most 31 columns, and at least one |
| `style` | `opacity` and each number or bool `style` word of the layer, as `f32`; a bool is 0 or 1 |
| `tokens` | the theme's `up`, `down`, `ink`, `accent` and `muted`, each a `vec4f` |
| `uv` | `uv.x` runs 0 at the rect's left edge on screen to 1 at its right, whichever of `x0` and `x1` is larger |
| `size_px` | the rect's size in device pixels |
| `t` | `abs(row.value)` over the largest `abs(value)` among the layer's drawn rects, 0 to 1; 0 where the product has no `value` column |
| `base` | the colour the renderer would draw |

The manifest refuses a shader on `taji.levels`, whose lines a shader does not recolour, and on `taji.heatmap`, `taji.bubbles` and `taji.footprint`. A WGSL keyword or a `__` name is refused as a column or style word. The module takes no loop, module `var`, binding, entry point, `override`, directive, texture or atomic, and at most 16 functions, 2,000 expressions and 64 KiB; `plugin check`'s `shader` step prints each refusal's sentence, led by `line N:`. The shader runs on WebGPU only; on WebGL2, or once turned off, the layer draws the renderer's colours.

## 4. Load it and bind it to a chart

Copy the plugin into a plugins directory, then boot a headless kernel on throwaway state with `TAJI_PLUGINS` naming that directory, as [your first plugin](https://docs.taji.is/plugins/first-plugin.md#4-boot-a-kernel-with-your-plugin) does. A debug kernel runs Python plugins on the checkout's `.python`. Every command runs from the repository root, in one shell:

```sh
W=$(mktemp -d)
mkdir -p "$W/plugins" && cp -R docs/plugins/examples/layer/ladder "$W/plugins/"
boot() {
  mkdir -p "$W/state" "$W/store" "$W/home"
  export TAJI_NO_UPDATE_CHECK=1 TAJI_NO_REPORT=1 TAJI_STATE_DIR=$W/state TAJI_STORE_DIR=$W/store TAJI_HOME=$W/home
  TAJI_PLUGINS=$W/plugins TAJI_HEADLESS=1 TAJI_WIRE=0 target/debug/taji > "$W/boot.log" 2>&1 &
  until [ -s "$W/state/wire-token" ] && curl -sf -o /dev/null -H "x-taji-token: $(cat "$W/state/wire-token")" "localhost:$(cat "$W/state/wire-port")/"; do sleep 1; done
  PORT=$(cat "$W/state/wire-port"); TOKEN=$(cat "$W/state/wire-token")
}
get() { curl -s -H "x-taji-token: $TOKEN" "localhost:$PORT/$1"; echo; }
v() { curl -s -H "x-taji-token: $TOKEN" -H 'content-type: application/json' -X POST "localhost:$PORT/verb/$1" --data-binary "$2"; echo; }
boot
get read/plugins | jq '.[] | select(.id == "ladder") | {enabled, layers: [.layers[].id]}'
```

You see `enabled: true` and `layers: ["ladder.strikes"]`. A chart lists the layer as an indicator named for its id; `get read/catalog/ladder.strikes` shows it, `category` `Plugins`.

Put chart 1 on SPY at 15 minutes, centre the ladder on SPY's last close and bind the layer. `spot` rides in the binding's `params`:

```sh
DESK=$(get "" | jq -r .active)
v desk/$DESK/chart/1/set_symbol '{"symbol":"equity:SPY"}'
v desk/$DESK/chart/1/set_timeframe '{"timeframe":"15m"}'
SPOT=$(curl -s -H "x-taji-token: $TOKEN" "localhost:$PORT/get/bars?symbols=equity:SPY&timeframe=15m&limit=1" \
  | .python/python -c "import sys, pyarrow as pa; print(round(pa.ipc.open_stream(sys.stdin.buffer).read_all().column('close')[0].as_py()))")
v desk/$DESK/chart/1/add_indicator "{\"pane_id\":1,\"definition\":\"ladder.strikes\",\"params\":{\"spot\":$SPOT}}"
```

You see the binding's node, whose last segment is its id, and `seq`:

```json file="examples/layer/bind.json"
{
  "node": "desk/01a2426c-8518-7452-bf65-dcafdbf0d5d0/chart/indicators/01a2426c-8e2b-77fd-a767-07b907533ffc",
  "seq": 1796410737668982
}
```

A layer computes nothing in the kernel: its binding holds no rows, and the window reads the product and draws it. Read the same rows over the wire, the oldest hour of the last day (`limit=1`):

```sh
curl -s -H "x-taji-token: $TOKEN" "localhost:$PORT/get/ladder.strikes?symbols=equity:SPY&spot=$SPOT&limit=1" \
  | .python/python -c "import sys, pyarrow as pa; print(pa.ipc.open_stream(sys.stdin.buffer).read_all().to_pylist())"
```

The row is the plugin's, with the three columns the kernel adds to every plugin row:

```json file="examples/layer/strikes.json"
[
  {
    "ts_utc": 1796324400,
    "price": [
      132,
      133,
      134,
      135,
      136,
      137,
      138,
      139,
      140,
      141,
      142,
      143,
      144,
      145,
      146,
      147,
      148,
      149,
      150,
      151,
      152
    ],
    "value": [
      -100.0,
      -180.0,
      -240.0,
      -280.0,
      -300.0,
      -300.0,
      -280.0,
      -240.0,
      -180.0,
      -100.0,
      0.0,
      100.0,
      180.0,
      240.0,
      280.0,
      300.0,
      300.0,
      280.0,
      240.0,
      180.0,
      100.0
    ],
    "knowable_utc": 1796410740,
    "recorded": false,
    "version": "0.1.0"
  }
]
```

*Captured 2026-12-04 on a headless kernel reading made-up 15-minute bars for SPY.*

The window, were it open, now draws Ladder in the dock at the right edge of the chart:

![A 15-minute SPY chart with a Ladder profile in the dock at the price axis: green bars above 142 running off the top of the pane, pink bars below it running off the bottom, with a zero line down the dock's middle](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/plugins/examples/layer/shot.png)

*Captured 2026-12-04 on a headless kernel reading made-up 15-minute bars for SPY.*

- The legend names the layer and its plugin, `Ladder` and `ladder`.
- `taji.profile` draws one bar a price, green where `value` is positive and pink where it is negative, from the dock's middle line outward. The bars run off the pane's top and bottom: the price scale shows what the candles need.
- Where the window can run the shader, the smallest bars draw in the muted ink and the largest in the full colour; elsewhere all draw in the renderer's colours.

Stop the kernel:

```sh
v ui/quit '{}'
wait
rm -rf "$W"
```

## 5. Prove it with `plugin check`

`taji plugin check <dir>` holds a plugin to its manifest with no kernel state, key or network, answering its `get` and `stream` from `<dir>/fixtures/<product>.jsonl`; `plugins/taji-gex/fixtures/` and `plugins/taji-gex/golden/` are a worked set. A layer is held in three steps:

- `shader` writes the validated text to `target/check/shader/<word>.wgsl`, `<word>` being the layer id after its last dot.
- `draw` draws each layer alone and compares it with `golden/<layer>.png`; a shaded layer must also draw on WebGPU, time its frames and differ from itself drawn with no shader. A heatmap must change at least 2% of the plot's pixels, bubbles must draw a circle, and a footprint must change at least 2% of the plot and draw a number; the fixture's first batches need a `spot`. A `main` layer is drawn over the fixture's bars alone, so its numbers have room at 960×600.
- `budget` redraws each shaded layer 100 times in a 2560×1440 page at scale 2, the largest chart the window draws, and fails over 2 ms a frame, naming that size; it skips without `timestamp-query`. A heatmap, bubbles or footprint layer prints `pan p95` over 100 one-pixel pans at that size.

`taji plugin check <dir> --bless` writes each layer's `golden/<layer>.png`, the first time and after a look you meant to change; open it, then commit it.

## Pick a renderer and a slot

The product's `shape` fixes the stock renderer:

| `shape` | `renderer` | One row is |
|---|---|---|
| `values` | `taji.levels` | an instant with price columns, drawn as horizontal levels |
| `profile` | `taji.profile` | the strikes of one snapshot, list columns `price` and `value` |
| `cells` | `taji.heatmap`, `taji.footprint` | one time column of a price grid, [below](#draw-a-heatmap-and-bubbles) and [the footprint](#draw-a-footprint) |
| `marks` | `taji.bubbles` | one event, [below](#draw-a-heatmap-and-bubbles) |

`taji-gex.walls` is a `taji.levels` layer and `taji-gex.profile` a `taji.profile` one. A stock renderer is a builder in `packages/plugin/layer/stock/`, listed in `STOCK` (`packages/plugin/layer/stock/index.ts`): a pure function from the served rows, the view and the colour tokens to `Shapes`. `build` runs when the rows, the style or the zoom change, never per frame.

`slot` says where the layer draws; every layer is clipped to the plot:

| `slot` | Draws |
|---|---|
| `behind` | under the candles |
| `above` | over them (the default) |
| `dock` | inside the plot at the price axis |
| `main` | after the `behind` layers and under the candles, which narrow to a thin body; [the footprint](#draw-a-footprint) draws there |

Declare `style` rows for what the user may change. A stock renderer reads these keys, and ignores a key it does not read:

| Renderer | Keys |
|---|---|
| `taji.levels` | `columns` (which price columns draw), `emphasis` (which is solid in the accent) |
| `taji.profile` | `buckets` (stack each strike by days to expiry), `opacity` (the bars' alpha), `anchor` (where the bars start: `center`, the default, the dock's middle, or `edge`, the dock's edge at the price axis with no zero line) |
| `taji.heatmap` | `ramp`, `scale`, `lower`, `upper`, `opacity` |
| `taji.bubbles` | `min_size`, `size_ref` |
| `taji.footprint` | none |

`taji.profile` draws the newest row; one older than the read's end by more than two of its own row intervals draws in `muted`, its note `as of <time>`. The legend names a layer's delay (`15 min delayed`) while its stream says `delayed`, and `as of <time>` once a layer reading to now has had no row for 2 minutes, never on a `marks` product; a builder never draws a time. A `dock` layer draws nothing while its stream's feed is shut or lapsed, until its next row.

## Draw a heatmap and bubbles

`taji.heatmap` draws a `cells` product: a row is one time column, `ts_utc` (`ts_ms` where declared), `span_ms` its width, a scalar `step` its cells' height in price, and `price` and `value` lists of one length; without `step` the build fails. It returns one `raster`: a column a row from the first row in view, at most 4,000, a texel row a price step (past 1,000 steps, the max of `n` of them). The GPU colours it from a ramp between two cut-offs: nothing at or under the lower, the top colour at or over the upper. They are the 30th and 98th percentiles of the positive cells in view, retaken when the view moves 20% of its width or height, its zoom bucket changes or 10 s of appends pass; the legend names the column span and both sizes, then a `note`: where rows carry `venues` (string) and `levels` (int), `<venues> · <levels> levels · since <first instant held>`, each part only where served, from the newest row stating it. A column with no row inside the span the window has read is not recorded: 45° hatching, never a ramp colour, and its tooltip says "Not recorded". A column past the newest row is empty. A column's cells below the lowest or above the highest price its rows list are outside the book, never empty: nothing, never a ramp colour or a cut-off sample, a 1 px edge where they meet the book, and the tooltip "Outside the book's <levels> levels" (where the row states `levels`, else "Outside the book").

| Key | Holds |
|---|---|
| `ramp` | `thermal` (default) or `mono` |
| `scale` | `linear`, `sqrt` or `log` (default) |
| `lower`, `upper` | a size standing for a cut-off; 0 keeps the percentile |
| `opacity` | 0 to 1, default 1 |

`thermal` runs blue to red, and no entry is brighter than the candle inks.

`taji.bubbles` draws a `marks` product: `ts_ms`, `price`, `size` and `side` (an int: 1 a buyer-initiated print, -1 a seller's, 0 or absent unknown). Prints in one 8 px cell of time and price are one circle at the largest, its radius 3 to 16 px, its area linear in size from the smallest group drawn to `size_ref`. A group whose circle would touch a larger one's is not drawn. Its ring splits clockwise from 12 o'clock, the buyers' share in `up`, the rest in `down`; a group with no sided size is `muted`, unsplit. `min_size` hides groups under it, 0 none; `size_ref` is the size drawn at 16 px, 0 the view's largest. A style row cannot state "absent", so a manifest's `min_size` has a default; absent, the builder hides groups under the view's 60th percentile.

The tooltip lists the product's declared columns in manifest order, never its times. A `cells` product's `span_ms`, `step`, `levels` and `venues` are not listed and its `value` reads "Size"; a `marks` product's `side` reads Buy, Sell or Unknown. A column with no unit prints with its trailing zeros trimmed.

## Draw a footprint

`taji.footprint` draws a `cells` product of one bar's traded size at each price, by side: a row is one bar, `ts_utc`, `span_ms` its width, and the list columns `price`, `sell` and `buy` of one length (`taji-orderflow.footprint` also serves `value`, `unknown` and `gap`). It sits in the `main` slot and reads the chart's own intraday bars ([What a layer reads](#what-a-layer-reads)), so each row is one bar of the chart. It takes no style keys and no shader.

At each price a bar has a sell cell on the left and a buy cell on the right, a thin candle between them: the cells span 4% to 46% and 54% to 96% of the bar's width, and a row's height is the smallest gap between two consecutive prices of any bar served (14 px where no bar lists two prices). A cell is drawn only where its size is above 0, in `down` for a sell and `up` for a buy. Its alpha steps with its share of the bar's largest size on the same side: under 25%, 14%; under 50%, 26%; under 75%, 40%; else 56%.

While a `main` layer draws, the candle body narrows to 8% of its bar's slot and the wick stays. Off an intraday timeframe (D, W, M) the layer reads nothing, the candles keep their width and the legend's note reads "Draws on intraday charts".

Each cell carries a box label whose text is its size, `sell[row][cell]` or `buy[row][cell]`, a zero printed as `0`. The number is drawn in the cell's row when the row leaves room: its size is the smaller of 12 CSS px and 0.75 of the row's height, rounded down, shrunk to fit the half-bar's width less 2 px each side, and the number is dropped where that leaves it under 9 px. Zoomed out the colours alone draw. `plugin check`'s `draw` counts the numbers drawn.

Past 500,000 instances the builder keeps the newest bars that fit, with the `note` `Newest <n> bars`.

## What a layer reads

The window asks every layer's product over its view, a `history` read, so a layer's product is read at `history` for each class it is read `live`, or stored (`store = true`); `check` fails the manifest otherwise. The ask has the word `every` as wide as the zoom needs, 1 s to an hour, and holds the row before the view's left edge (the as-of row), so a level drawn at the left edge is the one in force there. You never send `every` and your backend never hears it. The kernel folds each slice of that step on the UTC grid into one row, stamped at the slice start, by the product's shape. A `main` layer's ask has `timeframe` (and the pane's `session`) in place of `every`: the slices are then the chart's own intraday bars, [below](#fold-onto-a-charts-bars).

| Shape | A slice's row |
|---|---|
| `cells` | the max per price of every list column, the last row's scalars, `span_ms` the step; a column declaring `fold = "sum"` is summed instead, a list per price and a scalar over the slice, a null adding nothing and a price or scalar no row states staying null |
| `values`, `profile` | the slice's last row |
| `marks` | `size` summed per price and side (per price where there is no `side`), every other column the group's last row's |

A slice with no row yields none. A folded `values` or `profile` read starts with the slice of the newest row before `from`. The newest `cells`, `values` or `profile` slice is `forming` until a row at or past its end is recorded; the window replaces a `forming` row by its final one, never the reverse. A `marks` slice is served once closed, a row past its end or its end at or before now, never `forming`; the stream sends the same, a `marks` slice once, when closed. A script's `data.product` reads base rows. `every` is `400 bad_ask` on a product with no `shape`, and on a `cells` product under a row's `span_ms`; a read of more than 10,000 slices is `422`. The manifest refuses `every` as a word and `forming` as a column.

### Fold onto a chart's bars

`GET /get/<product>` and a stream of a shaped feature product take `timeframe` and `session` in place of `every`, and both together are `400 bad_ask`. The kernel folds onto the bars the chart draws for that item: a row falls in the bar holding its instant, and a row the chart's bars leave out (outside `session`, which defaults to the item's bars default) is in none. The step is the bar's period, so `span_ms` of a framed row is that period. `timeframe` is intraday (`1m` up to `4h` and their multiples): `D`, `W` and `M` are `400 bad_ask`. A read widens `from` back to its bar's start and `to` on to the end of the bar holding its last second, never past `at`, so no bar is read in part; the newest bar is `forming` until a row at or past its end is recorded.

A per-second product folds onto a bar this way: [`taji-orderflow.footprint`](https://docs.taji.is/catalog/taji-orderflow.md) pushes a row a second and declares its sizes `fold = "sum"`, so `GET /get/taji-orderflow.footprint?symbols=future:ESZ26&timeframe=5m&from=<start>` answers each 5-minute bar's size at every price.

## Say what it needs

Declare the data your sources read to compute the product as its `needs` ([the manifest reference](https://docs.taji.is/plugins/manifest.md#needs)): `taji-darkpool`'s prints need `trades` live with `off_exchange` and `size`, which not every provider fills. The kernel checks them against your user's linked providers and serves `readiness` on each layer of `GET /read/plugins`: one entry per class your sources read the product on, each need no linked provider serves there with the providers that would. The window's Indicators list and legend show it, so a user sees "needs a link" and a Link act, not a refused read. A class with no entry is not one the layer draws on. You compute none of it.

## What a builder returns

`Shapes` (`packages/plugin/layer/contract.ts`) holds data-space marks: `x` is UTC milliseconds (a dock's `x` runs 0 to 1 across the dock), `y` a price.

| Mark | Fields |
|---|---|
| `rects` | `x0`, `x1`, `y0`, `y1`, `rgba`, `row`, optional `cell` |
| `circles` | `x`, `y`, `rPx`, `rgba`, `row`, optional `cell`; `share` and `rgba2` together or neither |
| `segments` | a list of sets, each `x0`, `y0`, `x1`, `y1`, `rgba`, `row`, optional `cell`, one `widthPx` of 1 to 3, optional `dash` |
| `labels` | a list of sets: `x`, `y`, `row`, `column`, optional `x1` and `y1` together, optional `cell`, optional `align: "start"`; the text is that column's served cell, `rows[column][row]`, or `rows[column][row][cell]` where `column` is a list column. With `x1` and `y1` a label is a box, `x` to `x1` by `y` to `y1`, its text centred inside (from the left edge with `align: "start"`) and dropped where it does not fit |
| `raster` | `x0`, `x1`, `y0`, `y1`, `w`, `h`, `value`, `row` |
| `note` | one line of text, the legend row's quiet words after the layer's name |

A circle's ring, `share` of it (0 to 1) clockwise from 12 o'clock, draws in `rgba` and the rest in `rgba2`, over a fill at half the alpha. A raster's `value` is row-major from `y0` (`value[r * w + c]`): 0 or more a size, `NOT_RECORDED` (-1) hatched, `OUT_OF_BOOK` (-2) outside the book; `raster.row[c]` is the served row column `c` draws, or `NO_ROW`; the host colours it as above.

`row` is the index of the served row a mark stands for; the tooltip and the legend read their figures from it, so a builder never draws a number. `cell` is the index within that row's list columns: the strike a `taji.profile` bar is, set in `packages/plugin/layer/stock/profile.ts`, and the price a `taji.footprint` cell and its label are, in `packages/plugin/layer/stock/footprint.ts`.

The host names and refuses what `checkShapes` finds wrong: more than 500,000 instances a layer, a raster over 4,000,000 cells, arrays of one set that differ in length, a `row` past the rows served, a `cell` past its row's lists, a `widthPx` outside 1 to 3, a `share` outside 0 to 1 or without `rgba2`, a raster side over 8,192 or `row` not `w` long, a label `column` the product does not serve, a label of a list column without `cell` or of a scalar column with one, or a `note` that is not one line.

## Write a custom builder

When no stock renderer draws what you need, set `renderer = "ui/<name>.js"` and write `ui/<name>.ts`, whose default export is `defineLayer({ build })` from `@taji/plugin/layer`. `build` gets what a stock renderer gets (`Input`, `packages/plugin/layer/contract.ts`): the served `rows` as columns, `units`, the `view`, the level of detail `lod`, the layer's `style`, the colour `tokens`, `zone` and `read`; it returns the same `Shapes`. Rows hold a scalar `string` column as a `string[]` (`""` where null), and `zone` is the display time zone, an IANA name, for a `note` that states a time.

A stock builder may add `append(was, input, from)`: `was` is its build on the first `from` rows, and `append` writes rows `from` on in place, returning the raster columns written (`{ first, last }`) or null where a whole build is due. The host calls it while the read, style, view and zoom bucket hold and only rows arrived or the last was rewritten, then uploads those columns, not the layer. `taji.heatmap` has one; a custom builder takes `build` alone.

Pack it with `bun run ui/pack.ts <dir>`: you get `ui/<name>.js`, one script without React, which the kernel serves; never commit it.

`ui/walk/frame/outsider/ui/heavy.ts` is the one builder in the tree. It is a test fixture for a shader's budget, not a chart: it returns eight opaque rects over the whole view on the newest row (none when there are no rows), so a shader runs eight times on every plot pixel, and `ui/walk/frame/outsider/ui/heavy.wgsl` is a deliberately costly shader that `check`'s `budget` step must fail. `engine/crates/taji/scripts/outsider_gate.sh` copies both beside a copy of `plugins/taji-gex` and appends this layer to the copy's manifest:

```diff
+[[ui.layers]]
+id = "taji-gex.heavy"
+label = "Heavy"
+product = "taji-gex.levels"
+renderer = "ui/heavy.js"
+shader = "ui/heavy.wgsl"
+slot = "behind"
```

It shows the wiring a builder needs: the `.ts` source under `ui/`, `renderer` naming the packed `.js`, and `defineLayer({ build })` returning `Shapes`.

Your builder runs in a hidden sandboxed frame with no token and no network; the port the window hands it is its only line out, and it sees only what the window already holds. The window checks every answer as above and refuses one that fails, or a throw from `build`, with its message. `build` cannot fetch, store anything or reach the window's page.

## What the window does with them

- Levels at one price draw one label naming each (`Call wall · Magnet 6,000`) and one axis tag with the price alone.
- The default frame keeps the newest bar clear of the dock layers; a pan may move bars under them.

## If it fails

The legend shows `!` beside a layer the window cannot draw as declared, with the reason on hover, in that window alone:

- **The kernel's words, for a refused stream or read:** a layer whose source serves `history` and no `live` row shows `!` this way. Serve both, as step 1 does.
- **`shader off: over budget (3.4ms/2ms)`:** the median of 30 shaded frames, then the budget; three windows over it turn the shader off, and the layer draws the renderer's colours.
- **`shader off: <sentence>`:** the module was refused or failed to compile; cut to 120 characters.
- **`shader off: device lost`:** the GPU device was lost.
- **`shader off: at most 4 shader layers a chart`:** the fifth onward, in binding order.
- **`shader off: it recolours rects and this layer drew none`:** the build drew circles, segments or a raster and no rects.

## Next

- [Build a feature plugin](https://docs.taji.is/plugins/feature.md): a product from Taji's option chains, a layer and a script, from the scaffold to a clean `check`.
- [The manifest reference](https://docs.taji.is/plugins/manifest.md): every field of `[[products]]` and `[[ui.layers]]`.
- [GEX](https://docs.taji.is/catalog/taji-gex.md): three layers, one shaded, from a Rust plugin.
- [Write a pane](https://docs.taji.is/plugins/pane.md): a plugin's own pane, drawn in the window.
