Live Charts
The chart schema element renders a live, auto-refreshing chart (line, bar, area, or
pie) backed by Recharts. It works like staticText with
isDynamic: true — it polls a retriever script on an interval — except instead of a
retriever generating pre-rendered HTML, it returns small JSON samples that the
component renders declaratively. No JSX or hand-written JS is ever required in the
schema; every aspect of the chart is a plain JSON property.
See the Form Components reference for the full property list. This page covers the retriever contract, the exact data format, and example retriever scripts.
Why not staticText?
The existing pattern for something like GPU utilization has the batch script poll
nvidia-smi in the background and append to a file; staticText then re-reads that
whole file on every poll and regenerates a full HTML graph from scratch, which the
browser swaps in via dangerouslySetInnerHTML. That works, but cost grows with job
runtime (the whole file is re-read every poll) and there's no incremental update — the
backend re-renders the whole graph image/HTML each time. chart fixes this by moving
rendering client-side: the retriever only needs to emit small, tail-sized JSON, and
Recharts handles drawing.
Retriever output contract
The retriever script's stdout must be valid JSON, in one of two shapes:
1. A JSON array of samples (recommended)
[
{ "timestamp": 1758221400, "gpu0": 87, "gpu1": 45 },
{ "timestamp": 1758221410, "gpu0": 89, "gpu1": 44 },
{ "timestamp": 1758221420, "gpu0": 91, "gpu1": 46 }
]
Each poll's array replaces the chart's rolling window entirely. This is the
"tail -n <window>" pattern: the backend keeps a growing JSONL log (one sample per
line) and the retriever just tails the last maxDataPoints lines and wraps them in
[ ]. Backend cost per poll is constant regardless of how long the job has been
running, since it's always tailing the same number of lines. It's also self-healing —
if a poll is missed (network blip, tab backgrounded) or the page is reloaded mid-job,
the very next poll brings back the full window, not just one point. Use this shape
whenever the retriever already has a log file to tail.
2. A single JSON sample object
{ "timestamp": 1758221400, "gpu0": 87, "gpu1": 45 }
The component appends this to an in-memory rolling buffer capped at maxDataPoints
(oldest points drop off). Simpler retriever — no windowing logic needed server-side —
but a missed poll or a page reload loses whatever history isn't currently in the
browser's memory, since nothing is replayed from a log. Reasonable when there's no
convenient log file to tail, or the metric is cheap to compute point-in-time (e.g. a
single squeue/sstat query per poll).
Either shape works with every chartType. For chartType: "pie", only the last
sample in the buffer is used — a pie shows a snapshot, not a time series — and each
series key in that sample becomes one slice.
Data format reference
- Every sample is a flat JSON object. One key is the x-axis (
xAxis.key, default"timestamp"); every other key is a potential series. - Values must be numbers (or
null/omitted, which Recharts treats as a gap andconnectNullsbridges over on line/area charts). - Timestamps are plain numbers — Unix seconds by default (
xAxis.unit: "s"), or passxAxis.unit: "ms"if the retriever emits milliseconds. SetxAxis.format: "time"/"date"/"datetime"to get a formatted axis tick and tooltip label instead of the raw number. - Keys don't need to be declared anywhere if
series: "auto"(the default) — see below.
How the data reaches Recharts
Internally, Chart.js (src/schemaRendering/schemaElements/Chart.js) does exactly
this on every successful poll:
useRetriever(the same hookdynamicVieweruses) fetches and JSON-parses the retriever's stdout.- If the result is an array, it becomes the new buffer (sliced to
maxDataPoints). If it's a single object, it's appended to the existing buffer (then sliced). (With zoom on, the buffer is not sliced.) - The buffer — an array of flat sample objects — is passed directly as
Recharts'
dataprop:<LineChart data={buffer}>. - One
<Line>/<Bar>/<Area>is rendered per series, each pointing at one key viadataKey:<Line dataKey="gpu0" />. Recharts pullssample.gpu0out of every object indataitself — the component never reshapes rows into per-series arrays. - For a pie chart, the last sample is transformed into Recharts' pie shape,
[{ name, value }, ...]— one entry per series key.
This is why the sample shape matters: it's not an intermediate format that gets transformed before use, it's (almost) exactly what Recharts consumes.
Zooming (enableZoom)
Live views show a rolling window of the last maxDataPoints samples. For a finished
run you usually want the whole history, and the ability to zoom into a spike. enableZoom
adds that, and is off by default — charts without it behave exactly as described above.
| Property | Description |
|---|---|
enableZoom | true (always on) or a condition string with the same syntax as refreshWhile, e.g. "drona_status.DONE". Zoom turns on once the condition is true. |
zoomRetrieverParams | Params merged over retrieverParams for the fetch made when zoom turns on, e.g. {"MAX_POINTS": 0}. |
{
"type": "chart",
"name": "cpu_chart",
"retriever": "drona_cpu_chart_data.sh",
"retrieverParams": { "JOB_DIR": "$drona_job_dir", "MAX_POINTS": 120 },
"refreshInterval": 10,
"refreshWhile": "!drona_status.DONE",
"maxDataPoints": 120,
"enableZoom": "drona_status.DONE",
"zoomRetrieverParams": { "MAX_POINTS": 0 }
}
Live and zoom never overlap. While enableZoom is false the chart polls and keeps
its rolling window; there are no zoom controls. The moment it turns true:
- Polling stops.
- The chart makes one fetch with
zoomRetrieverParamsmerged overretrieverParams. The retriever returns the full data set in that single response. - The chart keeps every returned point (
maxDataPointsno longer applies).
The environment creator decides what "finished" means, so the same property works for
a job-state check, a training run ending, or true for a chart whose data is static.
Using it. Drag across a chart to select a range; all panels of a multi-panel chart
zoom together. A "Zoomed: … Reset zoom" line appears above the chart, and double-clicking
the chart also resets. Zoom needs a numeric x-axis (timestamps, epochs, step counts) and
applies to line, area and bar charts — pie charts are never zoomable. With showTable,
the table lists the visible range (at most the last 1000 rows).
Downsampling. A chart a few hundred pixels wide cannot show 20,000 points, and drawing them makes the page slow. When the visible range holds more than ~800 rows, the chart splits it into consecutive buckets and keeps, per bucket, the first and last row plus each series' minimum and maximum row. Short spikes are therefore never averaged away. The full data stays in the browser, and downsampling is redone for the visible range, so zooming in reveals progressively finer detail until every row is drawn.
Retriever support. The retriever must be able to return everything when asked.
The built-in drona_cpu_chart_data.sh and drona_gpu_chart_data.sh treat
MAX_POINTS=0 as "all samples". Without zoomRetrieverParams, zoom still works but only
over what the retriever already returns (typically the tail). The full response is one
JSON document: roughly 1–2 MB for a 48-hour job sampled every 10 s.
Array vs. single-object retrievers. Zoom is designed for the array (tail) shape,
where the zoom fetch replaces the tail with the full history. A retriever that returns a
single object has no history to return: the zoom fetch appends one more sample and zoom
covers only what the browser accumulated (up to maxDataPoints). Don't set
zoomRetrieverParams for those.
Dynamic series (series: "auto")
Set series: "auto" (the default — you can omit series entirely) when the set of
metrics isn't known until runtime, e.g. a job might get 1, 2, 4, or 8 GPUs and the
schema author can't hardcode gpu0..gpu7 ahead of time. The retriever just emits
whatever keys are relevant to that job:
// 1-GPU job
{ "timestamp": 1758221400, "gpu0": 87 }
// 4-GPU job — same schema, no changes needed
{ "timestamp": 1758221400, "gpu0": 87, "gpu1": 45, "gpu2": 12, "gpu3": 6 }
The component watches the buffer, collects every key it's seen (excluding the x-axis
key) in first-seen order, and assigns each a color from a fixed, colorblind-validated
8-color sequence — in that fixed order, never reassigned by rank, so a series keeps
its color across the component's lifetime even if it temporarily stops reporting (e.g.
a GPU idles and drops out of the log, then comes back). A 9th+ series wraps back to
the start of the color sequence but gets a distinct dash pattern so it doesn't become
visually identical to an earlier one. Auto-derived labels title-case the key and split
trailing digits (gpu0 → Gpu 0); override with seriesLabelMap: { "gpu0": "GPU 0" }
if you want exact casing.
Use an explicit series array instead when metric names are fixed and known ahead of
time (e.g. loss/accuracy for a training run) — this gives per-key control over
label and color:
"series": [
{ "key": "loss", "label": "Loss", "color": "#e34948" },
{ "key": "accuracy", "label": "Accuracy", "color": "#1baf7a" }
]
Multi-panel charts (panels / seriesPerPanel)
A single poll can be split across multiple side-by-side panels instead of one combined chart. Both still poll the retriever exactly once per interval regardless of panel count — this only changes how the same buffer gets rendered, not how data is fetched.
There are two ways to split, and they don't compose — if both are given, panels
wins and seriesPerPanel is ignored:
Explicit panels — grouping by meaning
Use this when you know ahead of time that some keys belong together semantically and
others don't — e.g. GPU utilization (%) and memory usage (GB) share a poll but need
their own y-axis scale, so cramming them into one chart would squash one series flat.
Count-based splitting (seriesPerPanel) can't do this — it only knows discovery
order, not what a key means.
{
"type": "chart",
"name": "gpuAndMemory",
"label": "GPU & Memory",
"retriever": "retrievers/gpu_and_memory_retriever.sh",
"refreshInterval": 10,
"xAxis": { "key": "timestamp", "label": "Time", "format": "time" },
"panels": [
{
"title": "GPU Utilization",
"series": [{ "key": "gpu0" }, { "key": "gpu1" }],
"yAxis": { "label": "Utilization (%)", "min": 0, "max": 100 }
},
{
"title": "Memory Usage",
"chartType": "area",
"series": [{ "key": "mem0" }, { "key": "mem1" }],
"yAxis": { "label": "Memory (GB)", "min": 0, "max": 80 }
}
]
}
Each panel entry accepts title, series (required — usually an explicit
{key, label, color} array per panel, since the point is hand-grouping known keys),
seriesMatch, seriesLabelMap, colors, chartType, yAxis, stacked, showLegend, showGrid,
and height. Anything a panel omits falls back to the matching top-level prop — in the
example above, both panels inherit the top-level xAxis, but the second panel
overrides chartType to "area" and both override yAxis.
When the keys aren't known ahead of time (e.g. one per GPU), give a panel
"series": "auto" plus seriesMatch, a regex tested against each key, so it only picks
up matching keys. The built-in GPU chart does this to split gpu0 (utilization) from
gpu0_mem (memory) with "^(?!.*_mem$)" and "_mem$".
seriesPerPanel — capping how many lines land in one panel
Use this instead when the series count isn't known ahead of time (typically paired
with series: "auto") and you just want to keep any one panel from getting crowded —
e.g. an 8-GPU job would otherwise put 8 lines on one chart. seriesPerPanel chunks the
series list (in first-seen order) into fixed-size groups, one panel per group, and
panel count adjusts automatically as new keys show up in the data:
{
"type": "chart",
"name": "gpuUtilizationSplit",
"label": "GPU Utilization (split)",
"retriever": "retrievers/gpu_utilization_retriever.sh",
"refreshInterval": 10,
"xAxis": { "key": "timestamp", "label": "Time", "format": "time" },
"yAxis": { "label": "Utilization (%)", "min": 0, "max": 100 },
"series": "auto",
"seriesPerPanel": 2
}
An 8-GPU job's data produces 4 panels of 2 lines each here; a 1-GPU job produces a
single panel with 1 line. Unlike panels, every generated panel shares the same
chartType/yAxis/stacked/showLegend/showGrid/height from the top-level props
— there's no per-panel override, since the groups themselves aren't hand-authored.
showTable still works with either mode — it renders one combined table covering
every series across all panels (deduped by key), not a separate table per panel.
Suggested retriever scripts
GPU utilization, tail-based (recommended pattern)
Pair this with a background srun loop in the generated batch script that already
appends one JSON line per sample to a log file, e.g.
$DRONA_WF_DIR/gpu_util.jsonl:
#!/bin/bash
# In the batch script's background polling loop, once per interval:
nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits |
awk -v ts="$(date +%s)" '
{ printf "%s\"gpu%d\":%s", (NR>1?",":""), NR-1, $1 }
END { printf "\n" }
' | sed "s/^/{\"timestamp\":$ts,/;s/$/}/" >> "$DRONA_WF_DIR/gpu_util.jsonl"
The retriever script the chart element actually calls just tails that log and wraps
it as a JSON array:
#!/bin/bash
# retrievers/gpu_utilization_retriever.sh
LOG="$DRONA_WF_DIR/gpu_util.jsonl"
WINDOW="${MAX_POINTS:-120}"
[ -f "$LOG" ] || { echo "[]"; exit 0; }
tail -n "$WINDOW" "$LOG" | paste -sd ',' - | sed 's/^/[/;s/$/]/'
Schema:
{
"type": "chart",
"name": "gpuUtilization",
"label": "GPU Utilization",
"chartType": "line",
"retriever": "retrievers/gpu_utilization_retriever.sh",
"retrieverParams": { "jobId": "$jobId", "MAX_POINTS": 120 },
"refreshInterval": 10,
"maxDataPoints": 120,
"xAxis": { "key": "timestamp", "label": "Time", "format": "time" },
"yAxis": { "label": "Utilization (%)", "min": 0, "max": 100 },
"series": "auto"
}
A 10s refreshInterval (not sub-second) is the right default for this kind of
job-monitoring chart — see Refresh Interval.
Single-object mode, per-poll query (no log file needed)
#!/bin/bash
# retrievers/queue_wait_retriever.sh — one live number, no history to tail
WAIT_SECONDS=$(squeue -j "$JOBID" -h -o "%M" 2>/dev/null | head -1)
echo "{\"timestamp\": $(date +%s), \"waitTime\": ${WAIT_SECONDS:-0}}"
Explicit series — training metrics from a log
#!/bin/bash
# retrievers/training_log_retriever.sh
LOG="$DRONA_WF_DIR/training.log" # lines like: epoch=3 loss=0.42 accuracy=0.88
WINDOW="${MAX_POINTS:-200}"
[ -f "$LOG" ] || { echo "[]"; exit 0; }
tail -n "$WINDOW" "$LOG" | awk -F'[= ]' '
{ printf "%s{\"epoch\":%s,\"loss\":%s,\"accuracy\":%s}", (NR>1?",":""), $2, $4, $6 }
END { print "" }
' | sed 's/^/[/;s/$/]/'
Pie snapshot — per-rank memory, rank count unknown
#!/bin/bash
# retrievers/memory_by_rank_retriever.sh
RANKS=$(scontrol show hostnames "$(squeue -j "$JOBID" -h -o "%N")")
i=0
FIELDS="\"timestamp\": $(date +%s)"
for HOST in $RANKS; do
MB=$(srun --jobid="$JOBID" -w "$HOST" --overlap --ntasks=1 \
ps -u "$USER" -o rss= 2>/dev/null | awk '{s+=$1} END {printf "%.0f", s/1024}')
FIELDS="$FIELDS, \"rank$i\": ${MB:-0}"
i=$((i+1))
done
echo "{ $FIELDS }"
{
"type": "chart",
"name": "memoryByRank",
"label": "Memory Usage by Rank",
"chartType": "pie",
"retriever": "retrievers/memory_by_rank_retriever.sh",
"retrieverParams": { "jobId": "$jobId" },
"refreshInterval": 10,
"series": "auto"
}
Best practices
- Keep
refreshIntervalat 10s or higher for job-monitoring charts — there's rarely a reason to redraw more often than that, and it keeps retriever load (andsrunoverhead for anything that queries live processes) low. See the general Best Practices for retrievers. - Add
"refreshWhile": "!drona_status.DONE"to job-monitoring charts so they stop polling once the job ends (after one final fetch that picks up the last samples) instead of polling a finished job for as long as the page is open. See Stopping refreshes withrefreshWhile. - A failed poll keeps the current chart on screen with an inline "Refresh failed" note rather than clearing it; see When a refresh fails.
- Prefer the tail-based array shape whenever a log file already exists or is cheap to maintain — it survives missed polls and page reloads for free.
- Cap
maxDataPointsto what's actually useful to see (the component enforces this client-side as a safety net regardless of what the retriever returns). - Pass
showTableto add a "view as table" toggle below the chart — useful as an accessible fallback and for copying exact values out.