@delacour/react-native-charts

中文文档
0.9.0发布于 2026/11/11MITES Module构建来源已验证近 30 天下载 9940

Headless Skia charting primitives for React Native — no tokens, no className

原始使用文档
文档目录4 节
  1. Install
  2. Use
  3. The maths on its own
  4. Licence

@delacour/react-native-charts

Headless charting primitives for React Native — Skia for drawing, Reanimated for animation, Gesture Handler for touch.

No tokens, no className, no theme. Every colour, font and size is a value you pass in. If you want charts already wearing a design system, use @delacour/react-native-ui/chart, which is this engine with the tokens attached.

Alpha. Both this package and @delacour/react-native-ui publish to npm's alpha tag, and every alpha is also latest.

Docs: ui.delacour.co.nz/docs/charts.

Install

bun add @delacour/react-native-charts
bunx expo install react-native-skia react-native-gesture-handler react-native-reanimated react-native-worklets

Peers: react-native-skia, react-native-reanimated, react-native-gesture-handler, react-native-worklets, react, react-native. The native four go through expo install, so the SDK picks versions it can build; react and react-native are already in any app.

Your app needs a GestureHandlerRootView at its root. This package does not render one — a nested root is dead weight, and every React Native app that handles touch already has one.

Use

import { CartesianChart, ChartArea, ChartLine } from "@delacour/react-native-charts";

<CartesianChart data={rows} xKey="day" yKeys={["revenue"]}>
  {({ points, bounds }) => (
    <>
      <ChartArea baseline={bounds.bottom} color="#0A84FF22" curve="monotone" points={points.revenue} />
      <ChartLine color="#0A84FF" curve="monotone" points={points.revenue} strokeWidth={2} />
    </>
  )}
</CartesianChart>

Marks also read the chart context, so they can be placed rather than called:

<CartesianChart data={rows} xKey="day" yKeys={["revenue"]}>
  <ChartLine color="#0A84FF" yKey="revenue" />
</CartesianChart>

Bars stand on zero and need half a step of x padding so the outermost ones sit inside the plot. Sibling series stack when the root is told which keys to stack, because only the root can size the y axis for the totals:

import { CartesianChart, ChartBar, ChartBarStack } from "@delacour/react-native-charts";

<CartesianChart data={rows} domainPadding={{ x: 0.5 }} includeZero xKey="month" yKeys={["revenue"]}>
  <ChartBar color="#0A84FF" roundedCorners={{ topLeft: 4, topRight: 4 }} yKey="revenue" />
</CartesianChart>

<CartesianChart data={rows} domainPadding={{ x: 0.5 }} stackKeys={["web", "ios", "android"]} xKey="month" yKeys={["web", "ios", "android"]}>
  <ChartBarStack colors={["#0A84FF", "#30D158", "#FF9F0A"]} yKeys={["web", "ios", "android"]} />
</CartesianChart>

Add orientation="horizontal" to the root and the categories run down the left with the bars growing rightward; nothing else changes.

A pie is its own root. Slices, labels and the hairline between them are marks, and a tap reports the slice under the finger:

import { PieInset, PieLabel, PieSlices, PolarChart } from "@delacour/react-native-charts";

<PolarChart data={rows} innerRadius="60%" labelKey="browser" onSlicePress={setSelected} selectedIndex={selected} valueKey="share">
  <PieSlices colors={["#0A84FF", "#30D158", "#FF9F0A", "#FF375F"]} />
  <PieInset color="#FFFFFF" strokeWidth={2} />
  <PieLabel color="#FFFFFF" font={font} formatLabel={(slice) => `${Math.round(slice.fraction * 100)}%`} minSweep={12} />
</PolarChart>

The maths on its own

@delacour/react-native-charts/core is every scale, tick, curve and solver in the package, importable with no Skia in the module graph:

import { closestIndex, invertValue, makeScale } from "@delacour/react-native-charts/core";

Licence

MIT

版本与发布记录

@delacour/react-native-charts 共发布 117 个版本,首次发布于 2026/09/22;过去 12 个月发布了 117 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.0latest2026/11/111 天前
0.9.0-alpha.20261110170610alpha2026/11/111 天前
0.9.0-alpha.202611092058422026/11/102 天前
0.9.0-alpha.202611092057322026/11/102 天前
0.9.0-alpha.202611092050532026/11/102 天前
0.9.0-alpha.202611092017592026/11/102 天前

关于 @delacour/react-native-charts 的常见问题

@delacour/react-native-charts 是什么?

Headless Skia charting primitives for React Native — no tokens, no className

如何安装 @delacour/react-native-charts?

在项目目录运行 npm install @delacour/react-native-charts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19)、react-native(>=0.81)、react-native-skia(>=3.7.3)、react-native-worklets(>=0.5)、react-native-reanimated(>=4)、react-native-gesture-handler(>=2.28)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@delacour/react-native-charts 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/delacour__react-native-charts 是否存在。

@delacour/react-native-charts 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@delacour/react-native-charts 可以商用吗?

@delacour/react-native-charts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@delacour/react-native-charts 的下载量有多少?

根据 npm 官方下载统计,@delacour/react-native-charts 在 2026/10/12 – 2026/11/10 这 30 天内被下载 9,940 次,日均约 331 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@delacour/react-native-charts 还在维护吗?

最新版本 0.9.0 发布于 2026/11/11(1 天前);至今共发布 117 个版本,其中过去 12 个月发布了 117 个;首次发布于 2026/09/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。