相关疑难解决方法(0)

Angular2更新带有标签的ng2图表

我现在开始使用Angular2工作,并对框架ng2-charts有疑问.

这是我的component.ts代码:

import { Component } from '@angular/core';
import { ChartsModule } from 'ng2-charts';
import { PredictionService } from './prediction.service'

@Component({
  selector: 'prediction-result-chart',
  templateUrl: './predictionResultChart.component.html'
})

export class PredictionResultChartComponent{

  public pieChartLabels:string[] = [];
  public pieChartData:number[] = [];
  public pieChartType:string = 'pie';
  public JSONobject = {}

  constructor(private predictionService: PredictionService){
    this.getPredictions();
  }

  public getPredictions() {
    this.predictionService.getPredictions('hello').do(result => this.populateChart(result)).subscribe();
  }

  public populateChart(obj): void{
    let labels:string[] = [];
    let data:number[] = [];
    for (var i = 0; i …
Run Code Online (Sandbox Code Playgroud)

javascript charts chart.js ng2-charts angular

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

标签 统计

angular ×1

chart.js ×1

charts ×1

javascript ×1

ng2-charts ×1