Skip to Content
文档

散点图

用于显示两组数据之间的关系

StorybookRecharts

用法

¥Usage

import { Chart, useChart } from "@chakra-ui/charts"
import { Scatter, ScatterChart, XAxis, YAxis } from "recharts"
<Chart.Root>
  <ScatterChart>
    <XAxis />
    <YAxis />
    <Scatter />
  </ScatterChart>
</Chart.Root>

示例

¥Examples

多个

¥Multiple

这是一个包含多个系列的散点图示例。

¥Here's an example of a scatter chart with multiple series.

图例

¥Legend

渲染 Chart.Legend 组件以显示散点图的图例。

¥Render the Chart.Legend component to display a legend for the scatter chart.

趋势线

¥Trend Line

这是一个使用最小二乘回归方法在图表上显示趋势线的示例。

¥Here's an example that shows a trend line on the chart using the least squares regression method.

为了显示趋势线,我们使用了 recharts 库中的 Scatter 组件。

¥To show the trend line, we're using the Scatter component from the recharts library.

<Scatter data={trendLine} shape={() => <Fragment />} />

连接点

¥Connect Dots

要在点之间画一条线,请将 line 属性传递给 Scatter 组件。

¥To draw a line between the dots, pass the line prop to the Scatter component.

<Scatter line={{ stroke: "red" }} />

Previous

雷达图

Next

迷你图