@coreui/vue-chartjs

中文文档
3.0.0发布于 2024/03/28MITTypeScriptESM + CJS近 30 天下载 10.1万

图.js的 Vue 组件包装

中文使用文档

CoreUI logo

CoreUI Vue.js 为图.js所包装

探索 @ coreui/vue- chartjs docs和示例 ”

报告错误 • 妇女 请求特性 • 妇女 博客

状态

npm package NPM downloads

安装 :
npm install @coreui/vue-chartjs

# or

yarn add @coreui/vue-chartjs
导入 :
import { CChart } from '@coreui/vue-chartjs'

或者说

import {
  CChart,
  CChartBar,
  CChartHorizontalBar,
  CChartLine,
  CChartDoughnut,
  CChartRadar,
  CChartPie,
  CChartPolarArea,
} from '@coreui/vue-chartjs'
道具 :
/**
 * 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,
},
用途 :
<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 共发布 19 个版本,首次发布于 2019/12/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2024/03/282 年前
3.0.0-rc.0next2023/11/152 年前
3.0.0-beta.02023/11/043 年前
2.2.02023/11/043 年前
2.1.02023/06/133 年前
2.0.12022/01/254 年前

关于 @coreui/vue-chartjs 的常见问题

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