小编fio*_*877的帖子

Ionic 5 中的 Chart.js

我一直在尝试通过查看本教程( https://ichi.pro/es/ionic-5-charts-graphs-usando-la-biblioteca-chartjs-102145521332905 )在Ionic 5中使用Chart.js,但我明白了错误: 在此输入图像描述

除了文件名之外,代码几乎相同。不太明白为什么会发生这种情况,欢迎任何帮助。

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

@Component({
  selector: 'app-tab3',
  templateUrl: 'tab3.page.html',
  styleUrls: ['tab3.page.scss']
})
export class Tab3Page implements AfterViewInit{
  @ViewChild('lineCanvas') private lineCanvas: ElementRef;

  lineChart: any;

  constructor() { }

  ngAfterViewInit() {
    this.lineChartMethod();
  }

  lineChartMethod() {
    this.lineChart = new Chart(this.lineCanvas.nativeElement, {
      type: 'line',
      data: {
        labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'November', 'December'],
        datasets: [
          {
            label: 'Sell per week',
            fill: false,
            //lineTension: 0.1,
            backgroundColor: …
Run Code Online (Sandbox Code Playgroud)

ionic-framework

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

标签 统计

ionic-framework ×1