DocsComponentsTemplatesThemesGitHub

LineChart

Trend over time: 2px lines, crosshair + tooltip on hover, optional area for one series, table view.

Code

import * as React from 'react';
import { LineChart } from '@fruit-labs/design';

export default function Demo() {
  return (
    <LineChart
      title="Active users"
      subtitle="Weekly · sample data"
      area
      labels={['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8']}
      series={[
        {
          name: 'Active users',
          data: [820, 910, 880, 1040, 1120, 1090, 1260, 1340],
        },
      ]}
    />
  );
}

Area

import { LineChart } from '@fruit-labs/design';

export default function Example() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560 }}>
      <LineChart area title="Active users" labels={['Jan', 'Feb', 'Mar', 'Apr']} series={[{ name: 'Users', data: [120, 180, 160, 240] }]} />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { LineChart } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/line-chart.json

Guidelines

  • One y-axis only; two measures of different scale → two charts.

Props

PropTypeRequired
widthnumberNo
labelsstring[]Yes
seriesArray<{ name: string; data: number[]; color?: string }>Yes
areabooleanNo
heightnumberNo
titleReact.ReactNodeNo
subtitleReact.ReactNodeNo
format(v: number) => stringNo
allowTablebooleanNo
classNamestringNo

Edit this example on GitHub