---
title: "Chart"
description: "Chart from a table: first column = x, other columns = series."
---

> Documentation Index
> Fetch the complete documentation index at: https://gistui.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Chart

```gistui
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|23
```

The 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.

```gistui
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.

### React

```tsx
import { ui } from "@gistui/react/ui";

const lib = ui.extend({ Chart: MyChart });
<GistUI library={lib} stream={response.body} />;
```
### Vue

```vue
<GistUI :source="answer" :components="{ Chart: MyChart }" />
```
### Svelte

```svelte
<GistUI source={answer} components={{ Chart: MyChart }} />
```
### Solid

```tsx
<GistUI source={answer()} components={{ Chart: MyChart }} />
```
### Vanilla

```ts
import { ui } from "@gistui/vanilla/ui";

const lib = ui.extend({ Chart: (ctx) => ({ el: myElement(ctx) }) });
```

See [Custom components](/docs/guides/custom-components/) for the full contract. Style hook: `[data-gistui="Chart"]`.

Source: https://gistui.com/docs/components/data/chart/index.mdx
