> ## Documentation Index
> Fetch the complete documentation index at: https://npm-packages.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Synchronized charts

> Share a tooltip and date range across two separate charts.

Package: [`recharts`](https://www.npmjs.com/package/recharts).

## Try it

Move across either chart. Both tooltips follow the same date, while each chart keeps its own scale and unit.

Narrow the range with the brush under the response-time chart. Both plots zoom to that range. Use the arrow keys when a brush handle is focused.

## Code

```jsx synchronized-charts.jsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { useId } from "react";
import {
  Area, AreaChart, Brush, CartesianGrid, Line, LineChart,
  ResponsiveContainer, Tooltip, XAxis, YAxis,
} from "recharts";

const data = [
  { day: "Oct 1", requests: 16600, latency: 142 },
  { day: "Oct 2", requests: 21900, latency: 154 },
  { day: "Oct 3", requests: 18800, latency: 148 },
  { day: "Oct 4", requests: 25800, latency: 182 },
  { day: "Oct 5", requests: 28200, latency: 176 },
  { day: "Oct 6", requests: 19700, latency: 136 },
  { day: "Oct 7", requests: 22900, latency: 151 },
];

export function SynchronizedCharts() {
  const syncId = useId();

  return (
    <div>
      <div style={{ width: "100%", height: 200 }}>
        <ResponsiveContainer width="100%" height="100%" minWidth={0}>
          <AreaChart data={data} syncId={syncId} accessibilityLayer>
            <CartesianGrid vertical={false} />
            <XAxis dataKey="day" />
            <YAxis width={54} />
            <Tooltip isAnimationActive={false} />
            <Area dataKey="requests" name="Requests" type="monotone"
              stroke="#3e6553" fill="#dce9df" fillOpacity={1}
              isAnimationActive={false} />
          </AreaChart>
        </ResponsiveContainer>
      </div>
      <div style={{ width: "100%", height: 250 }}>
        <ResponsiveContainer width="100%" height="100%" minWidth={0}>
          <LineChart data={data} syncId={syncId} accessibilityLayer>
            <CartesianGrid vertical={false} />
            <XAxis dataKey="day" />
            <YAxis width={54} domain={[0, 240]}
              tickFormatter={(value) => `${value} ms`} />
            <Tooltip isAnimationActive={false} />
            <Line dataKey="latency" name="Latency" type="monotone"
              stroke="#ae674c" dot={false} isAnimationActive={false} />
            <Brush dataKey="day" height={28} travellerWidth={10}
              ariaLabel="Shared visible date range" />
          </LineChart>
        </ResponsiveContainer>
      </div>
    </div>
  );
}
```

## Key props

| Prop | What it does here |
| - | - |
| `syncId` | Joins both charts to the same tooltip and brush group. |
| `useId()` | Gives each pair its own group when multiple examples share a page. |
| `dataKey="day"` | Gives both X axes matching dates in matching order. |
| `Brush` | Changes the visible indexes for every chart in the group. |

These datasets have matching dates and indexes. If your datasets differ, check `syncMethod` before sharing a group.

## Next

Place both units on one plot with a [composed chart](https://npm-packages.mintlify.site/recharts/composed-chart.md).

See the [AreaChart synchronization props](https://recharts.github.io/en-US/api/AreaChart/) and [Brush reference](https://recharts.github.io/en-US/api/Brush/).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.