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 and zoomable WebGPU line charts powered by ChartGPU.

ChartGPUPixiJS
ChartGPU renderer
Basic Chart

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.Line dataKey="mobile" opacity={0.8} />
</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
verticalbooleantrue

Brush

PropTypeDefault
startIndexnumber-
endIndexnumber-

Legend

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