# Line Chart

ASCII line chart with axes and multi-series support



<ComponentPreview base="opentui" name="line-chart-demo" />

Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @termcn/opentui/line-chart
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @opentui/react
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource src="registry/bases/opentui/ui/types.ts" title="components/ui/types.ts" />

      <ComponentSource src="registry/bases/opentui/themes/default.ts" title="lib/terminal-themes/default.ts" />

      <ComponentSource base="opentui" name="theme-provider" title="components/ui/theme-provider.tsx" />

      <ComponentSource base="opentui" name="line-chart" title="components/ui/line-chart.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

Usage [#usage]

```tsx
import { LineChart } from "@/components/ui/line-chart";
```

```tsx
<LineChart
  data={[
    { label: "Jan", value: 30 },
    { label: "Feb", value: 45 },
    { label: "Mar", value: 28 },
  ]}
  width={40}
  height={10}
  title="Monthly Sales"
/>
```

API Reference [#api-reference]

LineChart [#linechart]

| Prop       | Type                                              | Default    |
| ---------- | ------------------------------------------------- | ---------- |
| `data`     | `(number \| { label?: string; value: number })[]` | `required` |
| `width`    | `number`                                          | `40`       |
| `height`   | `number`                                          | `10`       |
| `title`    | `string`                                          | -          |
| `color`    | `string`                                          | -          |
| `showAxes` | `boolean`                                         | `true`     |
