---
title: Line Chart
description:
Used to display data points connected by straight line segments, showing
trends and patterns in continuous data over time or sequences
links:
storybook: charts-line-chart--basic
recharts: https://recharts.org/en-US/api/LineChart
---
## Usage
```tsx
import { Chart, useChart } from "@chakra-ui/charts"
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
```
```tsx
```
## Examples
### Axes Label
To add labels to the x and y axes, use the `Label` component from `recharts`.
```tsx
```
### No Dots
Set `dot` and `activeDot` to `false` to hide the dots completely.
```tsx
```
### Point Labels
Render the `LabelList` component from `recharts` inside the `Line` component to
show labels at each data point.
```tsx
```
### Gradient
Use the `Chart.Gradient` component to create a gradient. Ensure the `id` is
unique and used in the `stroke` prop of the `Line` component.
```tsx
```
### Dashed
Set the `strokeDasharray` prop in the `series` object to create a dashed line.
```ts /strokeDasharray: "5 5"/
const chart = useChart({
data: [
{ windows: 186, mac: 165, month: "January" },
//...
],
series: [
{ name: "windows", color: "teal.solid", strokeDasharray: "5 5" },
{ name: "mac", color: "purple.solid" },
],
})
```
### Multiple
Here's an example of a line chart with multiple series.
### Legend Interaction
Adding interactivity to the chart legends make it come to life. To enable this
feature, set the `interaction` prop to `"hover"` or `"click"` in the
`Chart.Legend` component.
```tsx
```
### Start and End Tick
By default, the chart shows the label for each tick. To show just the start and
end ticks, pass the `ticks` prop to the `XAxis` component from `recharts`.
> You can optionally pass a `label` prop to the `XAxis` component to show a
> label at the bottom of the axis.
```tsx
```
### Value Formatter
To format the value axis ticks, pass the `tickFormatter` prop to the `YAxis`
component from `recharts`.
```tsx
```
### Biaxial
Use the `yAxisId` prop in the `series` object and `YAxis` component to create a
chart with two y-axes.
```tsx
```
### Custom Tooltip
In event you need to customize the tooltip entirely, replace the `Chart.Tooltip`
component with your own. The basic signature of a custom tooltip looks like:
```tsx
function CustomTooltip(props: TooltipProps) {
const { active, payload, label } = props
if (!active || !payload || payload.length === 0) return null
return {/* Your custom tooltip content */}
}
```
### Series Label
To add a custom label to the series, set the `label` prop in the `series`
object.
```tsx /label: "Mac sales"/ /label: "Linux sales"/
const chart = useChart({
data: [
{ mac: 10, linux: 120, month: "January" },
//...
],
series: [
{ name: "mac", label: "Mac sales", color: "purple.solid" },
{ name: "linux", label: "Linux sales", color: "blue.solid" },
],
})
```
### Reference Point
Use the reference components from `recharts` to highlight a specific data point.
```tsx
```
### Value Domain
Pass the `domain` prop to the `YAxis` component to set the domain (upper and
lower bounds) of the value axis.
```tsx /domain: [0, 100]/
```
### Connect Nulls
To connect the null values, set the `connectNulls` prop to `true` in the `Line`
component.
```tsx
```
### Composition
Here's an example of composing the `Card`, `State` and `Chart` components
together to create a stunning visualization.
### Line Types
Recharts provides flexible support for various kinds of line charts.
Below are the different types of line charts you can create: