@echarts-x/custom-word-cloud

中文文档
1.0.1发布于 2026/01/12Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 5460

Custom wordCloud series for Apache ECharts

原始使用文档
文档目录7 节
  1. Usage
  2. Browser Environment
  3. UMD (Universal Module Definition)
  4. ESM (ES Modules)
  5. API
  6. series.data
  7. series.itemPayload

@echarts-x/custom-word-cloud

wordCloud is a custom series for Apache ECharts. It's typically used to display text data where the size of each word indicates its frequency or importance.

wordCloud

Source Code

Usage

Browser Environment

For browser usage, use the auto-registration version that automatically installs the custom series when loaded:

<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>

See examples for more details.

UMD (Universal Module Definition)

For environments that need manual registration or when using AMD/CommonJS loaders:

// 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);

See examples for more details.

ESM (ES Modules)

For modern module bundlers or native ES module environments:

npm install @echarts-x/custom-word-cloud
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);

See examples for more details.

API

series.data

The data of the series is an array of arrays. Each sub-array represents a word and its weight.

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

series.itemPayload

The itemPayload is an object that contains the following properties:

PropertyTypeDefaultDescription
leftnumber | string0Distance between word cloud component and the left side of the container.
topnumber | string0Distance between word cloud component and the top side of the container.
rightnumber | string0Distance between word cloud component and the right side of the container.
bottomnumber | string0Distance between word cloud component and the bottom side of the container.
gridSizenumber8Size of the grid in pixels for marking the availability of the canvas. The larger the grid size, the bigger the gap between words.
sizeRange[number, number][12, 60]Size range which the text size will be mapped to.
rotationRange[number, number][-90, 90]Text rotation range.
rotationStepnumber45The degree of rotation step.
maskImageHTMLImageElement | HTMLCanvasElementThe shape of the "cloud" to draw. White pixels will be ignored, and non-white pixels will be used as the area to draw text.
keepAspectbooleanfalseWhether to keep the aspect ratio of maskImage or 1:1 for other shapes.
shapestring'circle'The shape of the "cloud" to draw. Available presents are circle (default), cardioid, diamond, triangle-forward, triangle, pentagon, and star.
shrinkToFitbooleanfalseWhether to shrink the text to fit the container.
drawOutOfBoundbooleanfalseWhether to allow the text to be drawn out of the container.

版本与发布记录

@echarts-x/custom-word-cloud 共发布 3 个版本,首次发布于 2026/01/12;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.1latest2026/01/1210 个月前
1.0.02026/01/1210 个月前
1.0.0-beta.0beta2026/01/1210 个月前

关于 @echarts-x/custom-word-cloud 的常见问题

@echarts-x/custom-word-cloud 是什么?

Custom wordCloud series for Apache ECharts

如何安装 @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 和提交记录判断。