When to use a line chart
Use a line chart when the trend over an ordered axis (usually time) matters more than individual values.
- Weekly active users and sessions
- Response times or error rates over time
- Comparing a few metrics that share one scale
Data format
- Column 1 is the x-axis in order: dates, weeks, or any ordered label.
- Blank cells leave a gap in the line instead of dropping it to zero.
- Paste CSV, JSON from your API, TSV copied from Excel or Google Sheets, or a Markdown table. The generated component keeps your column names as its data keys.
Week,Users,Sessions
Week 1,1200,3400
Week 2,1450,4100
Week 3,1380,3900
Week 4,1620,4700
Week 5,1890,5200[
{"week": "Week 1", "users": 1200, "sessions": 3400},
{"week": "Week 2", "users": 1450, "sessions": 4100},
{"week": "Week 3", "users": 1380, "sessions": 3900},
…
]Options
- Smooth
- Monotone curves that never overshoot your data, or straight segments.
- Dots
- Show or hide a hollow dot at every data point.
- Tooltip
- Breakdown tooltip for multiple series, or shadcn's default.
How to add it to your project
- 1. Add the shadcn/ui chart component (it installs Recharts):
npx shadcn@latest add chart - 2. Paste your data above, pick the options, and copy the generated
chart.tsx. - 3. Save it in your project (e.g.
components/line-chart.tsx) and render<Chart />, or<Chart data={rows} />in Data as prop mode.
Line Chart FAQ
Add a column per line to your data. Each column becomes its own <Line> with its own color and legend entry in the generated code.
Blank cells stay blank (null), so the line shows a gap rather than a false drop to zero.
If column 1 contains dates like 2024-01-01 or 1/5/2024, the axis and tooltip are formatted as short dates automatically.