# Line Linear

> A linear 16-week revenue performance line chart built with TanStack Charts.

A shadcn/ui block from the [@paceui](https://paceui.com/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/paceui/tanstack-charts-line-linear).

- Page, with a live preview: https://shadcn.exchange/r/paceui/tanstack-charts-line-linear
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/paceui/tanstack-charts-line-linear-light-930ba3b30a8edd20.png
- Registry item: https://paceui.com/r/tanstack-charts-line-linear.json
- Listed: 2026-10-21, source last changed 2026-10-21

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/paceui/tanstack-charts-line-linear.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `@tanstack/charts`, `@tanstack/react-charts`, `d3-array`, `d3-scale`
- Registry items: `card`

## Files

### `components/tanstack-charts/line/line-linear.tsx`

```tsx
import { defineChart, lineY } from "@tanstack/charts";
import { motion } from "@tanstack/charts/motion";
import { tooltip } from "@tanstack/charts/tooltip";
import { Chart } from "@tanstack/react-charts/core";
import { useMemo } from "react";

import { max } from "d3-array";
import { scaleLinear, scalePoint } from "d3-scale";

import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";

const motionRenderer = motion({
    initial: "always",
    transition: { type: "spring", stiffness: 170, damping: 18, mass: 1 },
});

const chartData = [
    { week: "W1", revenue: 120 },
    { week: "W2", revenue: 145 },
    { week: "W3", revenue: 130 },
    { week: "W4", revenue: 170 },
    { week: "W5", revenue: 160 },
    { week: "W6", revenue: 195 },
    { week: "W7", revenue: 210 },
    { week: "W8", revenue: 185 },
    { week: "W9", revenue: 240 },
    { week: "W10", revenue: 230 },
    { week: "W11", revenue: 280 },
    { week: "W12", revenue: 310 },
];

export function LineLinear() {
    const definition = useMemo(() => {
        const yMax = max(chartData, (d) => d.revenue) ?? 0;

        return defineChart({
            renderer: motionRenderer,
            motion: {
                transition: { type: "spring", stiffness: 170, damping: 18, mass: 1 },
            },
            focus: "group-x",
            tooltip: {
                use: tooltip,
                motion: { type: "spring", stiffness: 170, damping: 18 },
                className: "font-sans! shadow-none! capitalize!",
                content: (points) => {
                    const datum = points[0]?.datum as (typeof chartData)[number];
                    if (!datum) return { rows: [] };
                    return {
                        title: `Week ${datum.week}`,
                        rows: [
                            {
                                label: "Revenue",
                                value: `$${datum.revenue}`,
                                color: "var(--chart-1)",
                            },
                        ],
                    };
                },
            },
            marks: [
                lineY(chartData, {
                    id: "revenue",
                    x: (d) => d.week,
                    y: (d) => d.revenue,
                    stroke: "var(--chart-1)",
                    strokeWidth: 2,
                    points: false,
                }),
            ],
            scales: {
                x: {
                    scale: scalePoint().domain(chartData.map((d) => d.week)),
                },
                y: {
                    scale: scaleLinear().domain([0, yMax]).nice(),
                    grid: true,
                },
            },
        });
    }, []);

    return (
        <Card className="gap-0">
            <CardHeader>
                <CardTitle className="text-lg">Weekly Gross ARR Growth</CardTitle>
                <CardDescription>16-week cumulative revenue expansion tracking</CardDescription>
            </CardHeader>
            <CardContent>
                <Chart
                    definition={definition}
                    renderer={motionRenderer}
                    height={250}
                    ariaLabel="Linear line chart showing 16-week revenue growth"
                />
            </CardContent>
        </Card>
    );
}
```
