Preview
Loading preview…
root = Grid(Card(Chart(rev, type:area, title:"Monthly revenue", y:"USD")), Card(Chart(mix, type:donut, title:"By channel")), cols:2)
rev = |Month|Starter|Pro
|Jul|38000|120000
|Aug|40200|131000
|Sep|43100|144000
|Oct|45800|158000
mix = |Channel|Share
|Organic|46
|Paid|31
|Partners|23The first column is the x axis or category; every other column is a series. type is one of bar, hbar, line, area, pie, donut or scatter.
Signature
This is the line a model reads in the system prompt.
Chart(data:data, type:bar|hbar|line|area|pie|donut|scatter, title:str, subtitle:str, x:str, y:str, height:num, select:point|range, bind:$var, stacked, zoom, legend)- Group: Data
- Children: No
- Positional arguments:
data(a trailing?means it may be left out)
Props
| Prop | Type | How to write it | Notes |
|---|---|---|---|
data |
table | positional, required | |
type |
bar · hbar · line · area · pie · donut · scatter |
named: type:… |
Default "bar". Also accepts column, doughnut. |
title |
string | named: title:… |
|
subtitle |
string | named: subtitle:… |
|
x |
string | named: x:… |
|
y |
string | named: y:… |
y-axis label |
height |
number | named: height:… |
|
select |
point · range |
named: select:… |
Default "point". |
bind |
$state variable |
bind:$name |
two-way binding to a $variable |
stacked |
flag | bare word: stacked |
|
zoom |
flag | bare word: zoom |
|
legend |
flag | bare word: legend |
Use your own component
Keep the name and schema, swap what is drawn. The prompt and the model’s output do not change.
import { ui } from "@gistui/react/ui";
const lib = ui.extend({ Chart: MyChart });
<GistUI library={lib} stream={response.body} />;<GistUI :source="answer" :components="{ Chart: MyChart }" /><GistUI source={answer} components={{ Chart: MyChart }} /><GistUI source={answer()} components={{ Chart: MyChart }} />import { ui } from "@gistui/vanilla/ui";
const lib = ui.extend({ Chart: (ctx) => ({ el: myElement(ctx) }) });See Custom components for the full contract. Style hook: [data-gistui="Chart"].