小编KuR*_*uVI的帖子

使用 Chart.js 和 Angular 显示图表的问题

我想使用 chart.js 以角度显示图表。我第一次尝试实现网上的一个例子,编译过程中没有问题。这是我的 .ts 中的代码:

import { Component, OnInit } from '@angular/core';
import { Chart } from "chart.js";

@Component({ 
   ...
})

export class MyChartComponent implements OnInit {
    constructor(){
    }

    ngOnInit(): void {
      new Chart("myChart", {
      type: 'bar',
      data: {
        labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
        datasets: [{
          label: '# of Votes',
          data: [12, 19, 3, 5, 2, 3],
          backgroundColor: [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(255, 206, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
            'rgba(153, 102, 255, …
Run Code Online (Sandbox Code Playgroud)

chart.js angular

3
推荐指数
3
解决办法
1395
查看次数

标签 统计

angular ×1

chart.js ×1