Skip to Content
文档

迷你图

一个小型、简单的图表,没有轴或坐标,显示数据变化的大致形状,通常与文本内联使用或用于小空间。

Storybook

用法

¥Usage

import { Chart, useChart } from "@chakra-ui/charts"
import { Area, AreaChart } from "recharts"
<Chart.Root>
  <AreaChart>
    <Area />
  </AreaChart>
</Chart.Root>

示例

¥Examples

柱状图

¥Bar Chart

迷你图可以用柱状图制作。

¥Sparklines can be made with bar charts.

折线图

¥Line Chart

迷你图也可以用折线图制作。

¥Sparklines can also be made with line charts.

库存

¥Stock

以下是显示股票价格的迷你图组合图。

¥Here's a composition of a sparkline that shows stock prices.

AMZN
Amazon Inc.
$189.4630.28%

状态

¥Stat

以下是显示 SaaS 仪表板统计数据的迷你图组合图。

¥Here's a composition of a sparkline that shows a SaaS dashboard stat.

Unique visitors
192.1k

渐变

¥Gradient

使用 Chart.Gradient 组件创建渐变填充。

¥Use the Chart.Gradient component to create a gradient fill.

<defs>
  <Chart.Gradient
    id="custom-gradient"
    stops={[
      { offset: "0%", color: "teal.solid", opacity: 1 },
      { offset: "100%", color: "teal.solid", opacity: 0.01 },
    ]}
  />
</defs>

参考

¥Reference

要在迷你图上引用特定值,请使用 recharts 中的 Reference 组件。

¥To reference a specific value on the sparkline, use the Reference component from recharts.

交互

¥Interaction

这是一个模拟 NPM 下载统计信息的示例。

¥Here's an example that mimics the NPM download stats.

Weekly Downloads

345,000

合成

¥Composition

以下是显示股票价格迷你图的组合图。

¥Here's a composition that shows a sparkline for a stock price.

AMZN
Amazon Inc.
$189.4630.28%

Previous

散点图

Next

概述