# @echarts-x/custom-word-cloud 中文文档

规范地址：https://npmcn.com/package/%40echarts-x/custom-word-cloud/

版本：1\.0\.1
npm 元数据更新时间：2026-05-08T15:09:21.994Z
中文译文更新时间：2026-11-13T04:56:20.674Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40echarts-x/custom-word-cloud
原文对照：https://npmcn.com/package/%40echarts-x/custom-word-cloud/?lang=original
项目主页：https://github.com/apache/echarts-custom-series/tree/main/custom-series/wordCloud
源码仓库：https://github.com/apache/echarts-custom-series

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：191 kB，14 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：echarts ^6\.0\.0
- 首次发布：2026-01-12T03:28:18.477Z
- 最新版本发布：2026-01-12T03:36:10.222Z
- 近 30 天下载量：5460（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 3 个）

## 中文简介

Apache ECharts 自定义单词 Cloud 系列

## 安装

```sh
npm install @echarts-x/custom-word-cloud
```

也可以使用：`pnpm add @echarts-x/custom-word-cloud`、`yarn add @echarts-x/custom-word-cloud`、`bun add @echarts-x/custom-word-cloud`

## README

# @ echarts- x/ 习惯字云

`wordCloud` 是一个自定义序列,用于 [Apache ECharts (英语)](https://github.com/apache/echarts),通常用于显示文本数据,其中每个单词的大小表明其频率或重要性.

![wordCloud](https://raw.githubusercontent.com/apache/echarts-custom-series/main/custom-series/wordCloud/screenshots/wordCloud.png)

[源代码](https://github.com/apache/echarts-custom-series/tree/main/custom-series/wordCloud)

## 使用量

### 浏览器环境

对于浏览器的使用,使用自动注册版本,在加载时自动安装自定义序列:

```html
<script src="./node_modules/echarts/dist/echarts.js"></script>
<script src="./node_modules/@echarts-x/custom-word-cloud/dist/word-cloud.auto.js"></script>
<script>
  // No need to call echarts.use(), automatically registered
  const chart = echarts.init(...);
  const option = {
    series: [{
      type: 'custom',
      renderItem: 'wordCloud',
      // ...
    }]
  }
  chart.setOption(option);
</script>
```

见 [实例](https://npmcn.com/package/%40echarts-x/custom-word-cloud/examples) 更多细节.

### UMD( 通用模块定义)

对于需要人工注册或使用AMD/CommonJS加载器的环境:

```js
// CommonJS
const echarts = require('echarts');
const wordCloudInstaller = require('@echarts-x/custom-word-cloud');
echarts.use(wordCloudInstaller);
const chart = echarts.init(...);

const option = {
  series: [{
    type: 'custom',
    renderItem: 'wordCloud',
    // ...
  }]
}
chart.setOption(option);
```

见 [实例](https://npmcn.com/package/%40echarts-x/custom-word-cloud/examples) 更多细节.

### 无害环境管理(ES模块)

对于现代模块捆绑器或本地ES模块环境:

```bash
npm install @echarts-x/custom-word-cloud
```

```js
import * as echarts from 'echarts';
import wordCloudCustomSeriesInstaller from '@echarts-x/custom-word-cloud';

echarts.use(wordCloudCustomSeriesInstaller);
const chart = echarts.init(...);

const option = {
  series: [{
    type: 'custom',
    renderItem: 'wordCloud',
    // ...
  }]
}
chart.setOption(option);
```

见 [实例](https://npmcn.com/package/%40echarts-x/custom-word-cloud/examples) 更多细节.

## API 密码

### 序列.数据

该系列的数据是数组. 每个子阵列代表一个字及其重量.

```js
const data = [
  ['Visual Studio Code', 1000],
  ['ECharts', 800],
  ['TypeScript', 600],
  // ...
];
```

### 序列。项目付费负荷

这个 `itemPayload` 是一个包含下列属性的对象:

| 财产 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `left` | `number | string` | `0` | 字云组件与容器左侧相距. |
| `top` | `number | string` | `0` | 字云组件与容器上方的相距. |
| `right` | `number | string` | `0` | 字云组件与容器右侧相距. |
| `bottom` | `number | string` | `0` | 字云元件与容器下方相距. |
| `gridSize` | `number` | `8` | 网格的大小,以像素表示画布的可用性。 网格大小越大,字相差越大. |
| `sizeRange` | `[number, number]` | `[12, 60]` | 绘图文本大小的大小范围 . |
| `rotationRange` | `[number, number]` | `[-90, 90]` | 文本旋转范围. |
| `rotationStep` | `number` | `45` | 轮回的程度 步. |
| `maskImage` | `HTMLImageElement | HTMLCanvasElement` |  | 取出"云"所取之形. 白像素会被忽略,而非白像素将被用作绘制文字的区域. |
| `keepAspect` | `boolean` | `false` | 是否保持宽比 `maskImage` 或者说 `1:1` 其他形状. |
| `shape` | `string` | `'circle'` | 取出"云"所取之形. 现有礼物是: `circle` (违约), `cardioid`, (中文(简体) ), `diamond`, (中文(简体) ), `triangle-forward`, (中文(简体) ), `triangle`, (中文(简体) ), `pentagon`,以及 `star`。 。 。 . |
| `shrinkToFit` | `boolean` | `false` | 是否缩小文本以适应容器 . |
| `drawOutOfBound` | `boolean` | `false` | 是否允许将文本从容器中抽出 . |

## 常见问题

### @echarts-x/custom-word-cloud 是什么？

Apache ECharts 自定义单词 Cloud 系列

### 如何安装 @echarts-x/custom-word-cloud？

在项目目录运行 npm install @echarts-x/custom-word-cloud，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：echarts（^6\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @echarts-x/custom-word-cloud 支持 TypeScript 吗？

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

### @echarts-x/custom-word-cloud 支持 ESM 还是 CommonJS？

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

### @echarts-x/custom-word-cloud 可以商用吗？

@echarts-x/custom-word-cloud 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @echarts-x/custom-word-cloud 的下载量有多少？

根据 npm 官方下载统计，@echarts-x/custom-word-cloud 在 2026/10/13 – 2026/11/11 这 30 天内被下载 5,460 次，日均约 182 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @echarts-x/custom-word-cloud 还在维护吗？

最新版本 1\.0\.1 发布于 2026/01/12（10 个月前）；至今共发布 3 个版本，其中过去 12 个月发布了 3 个；首次发布于 2026/01/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

