@sckyzo/cosmos-charts

中文文档
0.6.0发布于 2026/11/02MITTypeScriptESM + CJS构建来源已验证

React chart components for the Cosmos design system — themeable Recharts wrappers (bar, line, area, donut, radial gauges, sparkline, treemap, realtime, heatmap, radar, scatter, bubble, box plot, range bar, mixed) that follow the Cosmos theme and accent.

原始使用文档
文档目录4 节
  1. Install
  2. Use
  3. Documentation
  4. License

@sckyzo/cosmos-charts

npm

Cosmos charts: opinionated chart wrappers themed for the Cosmos design system, drawn with Recharts. Kept in a dedicated package so that @sckyzo/cosmos-react consumers who don't render charts don't ship a chart library.

Each chart is a module of its own and the package declares no side effects, so a bundler ships the charts you import and leaves the others out.

Install

npm install @sckyzo/cosmos-charts
npm install react react-dom   # peers, react 19+

The three Cosmos packages share one version number: install the same version of each. The charts read their colors from the CSS variables of @sckyzo/cosmos-theme, so they follow its themes and accents; without the theme CSS they fall back to a built-in palette. To set the theme up, see Getting started. A few charts carry Tailwind 4 classes, so point Tailwind at this package too, in the CSS file that imports it, next to the @source line for @sckyzo/cosmos-react:

@source '../node_modules/@sckyzo/cosmos-charts/dist/**/*.{js,cjs}';

Use

import { LineAreaChart } from '@sckyzo/cosmos-charts';

<LineAreaChart
  series={[{ name: 'CPU', data: [12, 19, 23, 31, 22, 18, 25] }]}
  categories={['00h', '04h', '08h', '12h', '16h', '20h', '24h']}
/>;

Documentation

  • Charts guide: how the colors follow the theme, the props every chart shares, and each chart type.
  • Storybook: every chart with its stories.

License

MIT, see LICENSE.

The charts are drawn with Recharts (MIT), which pulls in modules of d3 (ISC, and BSD-3-Clause for d3-ease). WorldMap also uses d3-geo (ISC) and topojson-client (ISC). Their licenses apply to the code they ship. d3-geo ships ES modules only, so the CommonJS build carries it inside WorldMap.cjs, with the d3-array and internmap it pulls; THIRD_PARTY_NOTICES.md holds their licenses.

版本与发布记录

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

版本发布日期距今
0.6.0latest2026/11/021 天前
0.5.02026/11/012 天前
0.4.12026/11/012 天前
0.4.02026/10/313 天前
0.3.12026/10/313 天前
0.3.02026/10/277 天前

关于 @sckyzo/cosmos-charts 的常见问题

@sckyzo/cosmos-charts 是什么?

Cosmos设计系统的React图表组件-可主题的Recharts包装器(条形图、线形图、区域图、甜甜圈图、径向量规、火花线、树状图、实时图、热图、雷达、散点图、气泡图、框图、范围条、混合图),遵循Cosmos主题和重点。

如何安装 @sckyzo/cosmos-charts?

在项目目录运行 npm install @sckyzo/cosmos-charts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@sckyzo/cosmos-charts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@sckyzo/cosmos-charts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@sckyzo/cosmos-charts 可以商用吗?

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

@sckyzo/cosmos-charts 还在维护吗?

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