For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
/
0
Sponsor

Line Chart

Animated, stepped, and zoomable line charts.

Installation

$ pnpm dlx shadcn@latest add @chartcn/chartgpu/line-chart

Usage

import {
  ChartcnLineChart,
  type ChartConfig,
} from "@/components/chart/line-chart";
<ChartcnLineChart data={data} config={chartConfig} xDataKey="month">
  <ChartcnLineChart.XAxis dataKey="month" />
  <ChartcnLineChart.Brush />
  <ChartcnLineChart.Legend />
  <ChartcnLineChart.Tooltip />
  <ChartcnLineChart.Line dataKey="desktop" strokeWidth={2.5}>
    <ChartcnLineChart.Dot variant="border" />
    <ChartcnLineChart.ActiveDot variant="colored-border" />
  </ChartcnLineChart.Line>
  <ChartcnLineChart.Line dataKey="mobile" opacity={0.8}>
    <ChartcnLineChart.Dot variant="border" />
    <ChartcnLineChart.ActiveDot variant="colored-border" />
  </ChartcnLineChart.Line>
</ChartcnLineChart>

Examples

Data transitions

Animated data updates

Step lines

curveType='step'

Loading state

isLoading='true'
Loading

API Reference

ChartcnLineChart

PropTypeDefault
dataData[]required
configChartConfigrequired
childrenReactNode-
xDataKeystring-
curveType"linear" | "step" | "step-before" | "step-after""linear"
animationboolean | AnimationConfig{ duration: 650, easing: "cubicOut" }
isLoadingbooleanfalse
showBrushbooleanfalse
startIndexnumber-
endIndexnumber-
onBrushChange({ startIndex: number; endIndex: number }) => void-

Line

PropTypeDefault
dataKeystringrequired
strokeWidthnumber2.25
opacitynumber1
curveType"linear" | "step" | "step-before" | "step-after"-
connectNullsbooleanfalse

Shared parts

XAxis

PropTypeDefault
dataKeystring-
tickFormatter(value: string, index?: number) => ReactNode-

YAxis

PropTypeDefault
tickFormatter(value: string, index?: number) => ReactNode-

Grid

PropTypeDefault
horizontalbooleantrue
verticalbooleanfalse

Brush

PropTypeDefault
startIndexnumber-
endIndexnumber-

Legend

PropTypeDefault
position"top" | "bottom" | "left" | "right""bottom"