# @coreui/vue-chartjs 中文文档

规范地址：https://npmcn.com/package/%40coreui/vue-chartjs/

版本：3\.0\.0
npm 元数据更新时间：2025-12-11T13:15:15.492Z
中文译文更新时间：2026-11-10T19:20:14.811Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40coreui/vue-chartjs
原文对照：https://npmcn.com/package/%40coreui/vue-chartjs/?lang=original
项目主页：https://coreui.io/vue/
源码仓库：https://github.com/coreui/coreui-vue

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

- 包体积（解压后）：4.1 MB，14 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- peer 依赖：vue ^3\.2\.21
- 首次发布：2019-12-10T15:37:10.055Z
- 最新版本发布：2024-03-28T15:31:54.485Z
- 近 30 天下载量：101021（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：19（近 12 个月 0 个）

## 中文简介

图.js的 Vue 组件包装

## 安装

```sh
npm install @coreui/vue-chartjs
```

也可以使用：`pnpm add @coreui/vue-chartjs`、`yarn add @coreui/vue-chartjs`、`bun add @coreui/vue-chartjs`

## README

[![CoreUI logo](https://coreui.io/images/brand/coreui-signet.svg)](https://coreui.io/)

### CoreUI Vue.js 为图.js所包装

[**探索 @ coreui/vue- chartjs docs和示例 ”**](https://coreui.io/vue/docs/components/chart/)  
  
[报告错误](https://github.com/coreui/coreui-vue/issues/new?template=bug_report.md) • 妇女 [请求特性](https://github.com/coreui/coreui-vue/issues/new?template=feature_request.md) • 妇女 [博客](https://blog.coreui.io/)

## 状态

[![npm package](https://img.shields.io/npm/v/@coreui/vue-chartjs/latest?style=flat-square)](https://www.npmjs.com/package/@coreui/vue-chartjs) [![NPM downloads](https://img.shields.io/npm/dm/@coreui/vue-chartjs.svg?style=flat-square)](https://www.npmjs.com/package/@coreui/vue-chartjs)

##### 安装 :

```bash
npm install @coreui/vue-chartjs

# or

yarn add @coreui/vue-chartjs
```

##### 导入 :

```jsx
import { CChart } from '@coreui/vue-chartjs'
```

或者说

```js
import {
  CChart,
  CChartBar,
  CChartHorizontalBar,
  CChartLine,
  CChartDoughnut,
  CChartRadar,
  CChartPie,
  CChartPolarArea,
} from '@coreui/vue-chartjs'
```

##### 道具 :

```js
/**
 * Enables custom html based tooltips instead of standard tooltips.
 *
 * @default true
 */
customTooltips: {
  type: Boolean,
  default: true,
  required: false,
},
/**
 * The data object that is passed into the Chart.js chart (more info).
 */
data: {
  type: [Object, Function] as PropType<ChartData | ((canvas: HTMLCanvasElement) => ChartData)>,
  required: true,
},
/**
 * Height attribute applied to the rendered canvas.
 *
 * @default 150
 */
height: {
  type: Number,
  default: 150,
  required: false,
},
/**
 * ID attribute applied to the rendered canvas.
 */
id: {
  type: String,
  default: undefined,
  required: false,
},
/**
 * The options object that is passed into the Chart.js chart.
 *
 * {@link https://www.chartjs.org/docs/latest/general/options.html More Info}
 */
options: {
  type: Object as PropType<ChartOptions>,
  default: undefined,
  required: false,
},
/**
 * The plugins array that is passed into the Chart.js chart (more info)
 *
 * {@link https://www.chartjs.org/docs/latest/developers/plugins.html More Info}
 */
plugins: {
  type: Array as PropType<Plugin[]>,
  default: undefined,
},
/**
 * If true, will tear down and redraw chart on all updates.
 */
redraw: Boolean,
/**
 * Chart.js chart type.
 *
 * @type {'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble' | 'pie' | 'scatter'}
 */
type: {
  type: String as PropType<ChartType>,
  default: 'bar',
  required: false,
},
/**
 * Width attribute applied to the rendered canvas.
 *
 * @default 300
 */
width: {
  type: Number,
  default: 300,
  required: false,
},
/**
 * Put the chart into the wrapper div element.
 *
 * @default true
 */
wrapper: {
  type: Boolean,
  default: true,
  required: false,
},
```

##### 用途 :

```vue
<CChartLine
  :wrapper="false"
  :data="{
    labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
    datasets: [
      {
        label: 'My First dataset',
        backgroundColor: 'rgba(220, 220, 220, 0.2)',
        borderColor: 'rgba(220, 220, 220, 1)',
        pointBackgroundColor: 'rgba(220, 220, 220, 1)',
        pointBorderColor: '#fff',
        data: [40, 20, 12, 39, 10, 40, 39]
      },
      {
        label: 'My Second dataset',
        backgroundColor: 'rgba(151, 187, 205, 0.2)',
        borderColor: 'rgba(151, 187, 205, 1)',
        pointBackgroundColor: 'rgba(151, 187, 205, 1)',
        pointBorderColor: '#fff',
        data: [50, 12, 28, 29, 7, 25, 12]
      }
    ]
  }"
/>
```

## 常见问题

### @coreui/vue-chartjs 是什么？

图\.js的 Vue 组件包装

### 如何安装 @coreui/vue-chartjs？

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

### @coreui/vue-chartjs 支持 TypeScript 吗？

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

### @coreui/vue-chartjs 支持 ESM 还是 CommonJS？

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

### @coreui/vue-chartjs 可以商用吗？

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

### @coreui/vue-chartjs 的下载量有多少？

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

### @coreui/vue-chartjs 还在维护吗？

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

