# Chart

> A simple native bar chart.

- Category: [Data display](https://tarve.dev/docs.md#data)
- Import: `import { Chart } from "@tarve/core";`
- Props type: `ChartProps`
- Source: [packages/core/src/advanced-controls.ts:74](https://github.com/omarcosr/tarve/blob/main/packages/core/src/advanced-controls.ts#L74)

## Usage

```tsx title="Chart.tsx"
import { Chart } from "@tarve/core";

<Chart
  height={200}
  barWidth={48}
  style={{ width: 300 }}
  data={[
    { label: "Jan", value: 186 },
    { label: "Feb", value: 305 },
    { label: "Mar", value: 237, color: "#7c5cff" },
    { label: "Apr", value: 73 },
  ]}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data` (required) | `readonly ChartDatum[]` | — |  |
| `barWidth` | `number` | `36` |  |
| `height` | `number` | `180` |  |
| `max` | `number` | — |  |
| `showLabels` | `boolean` | `true` |  |
| `showValues` | `boolean` | `true` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="ChartDatum"
interface ChartDatum {
  label: string;
  value: number;
  color?: string;
}
```

Previous: [TreeView](https://tarve.dev/docs/components/TreeView.md) · Next: [Markdown](https://tarve.dev/docs/components/Markdown.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Chart · Index for agents: https://tarve.dev/llms.txt
