小编jic*_*cke的帖子

Angular 5 和 chart.js ts 错误

在 Angular 5 中,我安装了 chartjs 及其类型,如下所示:

纱线添加chart.js --save

纱线添加@types/chartjs --dev

我有这样的图表,一切看起来都不错,但在终端中我有以下错误..我该如何解决这个问题,谢谢:

我的图表此代码在 ngAfterinit 中:

import * as Chart from 'chart.js';


new Chart(<HTMLCanvasElement>document.getElementById("user-rev-chart"), {
  type: 'horizontalBar',
  data: {
    labels: ["5 star", "4 start", "3 start", "2 star", "1 star"],
    datasets: [
      {
        fill: true,
        label: false,
        backgroundColor: ["#a1a7b3", "#a1a7b3", "#a1a7b3", "#a1a7b3", "#a1a7b3"],
        data: [10, 2, 5, 4, 5]
      }
    ]
  },
  options: {
    maintainAspectRatio: false,
    responsive: false,
    legend: {display: false},
    title: {
      display: false,
      text: ''
    },
    scales:
      {
        yAxes: [{ …
Run Code Online (Sandbox Code Playgroud)

typescript chart.js angular

5
推荐指数
1
解决办法
7771
查看次数

标签 统计

angular ×1

chart.js ×1

typescript ×1