import { ScatterChart, Scatter, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts';
import { RechartsDevtools } from '@recharts/devtools';
// #region Sample data
const data01 = [
{ x: 100, y: 200, z: 200 },
{ x: 120, y: 100, z: 260 },
{ x: 170, y: 300, z: 400 },
{ x: 140, y: 250, z: 280 },
{ x: 150, y: 400, z: 500 },
{ x: 110, y: 280, z: 200 },
];
const data02 = [
{ x: 300, y: 300, z: 200 },
{ x: 400, y: 500, z: 260 },
{ x: 200, y: 700, z: 400 },
{ x: 340, y: 350, z: 280 },
{ x: 560, y: 500, z: 500 },
{ x: 230, y: 780, z: 200 },
{ x: 500, y: 400, z: 200 },
{ x: 300, y: 500, z: 260 },
{ x: 240, y: 300, z: 400 },
{ x: 320, y: 550, z: 280 },
{ x: 500, y: 400, z: 500 },
{ x: 420, y: 280, z: 200 },
];
// #endregion
const MultipleYAxesScatterChart = () => {
return (
<ScatterChart
style={{ width: '100%', maxWidth: '700px', maxHeight: '70vh', aspectRatio: 1.618 }}
responsive
margin={{
top: 20,
right: 0,
bottom: 0,
left: 0,
}}
>
<CartesianGrid />
<XAxis type="number" dataKey="x" name="stature" unit="cm" />
<YAxis yAxisId="left" type="number" dataKey="y" name="weight" unit="kg" width="auto" />
<YAxis yAxisId="right" type="number" dataKey="y" name="weight" unit="kg" orientation="right" width="auto" />
<Tooltip />
<Scatter yAxisId="left" name="A school" data={data01} dataKey="x" />
<Scatter yAxisId="right" name="A school" data={data02} dataKey="y" />
<RechartsDevtools />
</ScatterChart>
);
};
export default MultipleYAxesScatterChart;