在泳道/ ngx图表中显示数据Angular 4

时间:2017-12-19 16:43:34

标签: angular ngx-charts

我第一次使用" swimlane / ngx-charts"我想显示我运行代码时生成的数据。在控制台中,我没有收到任何错误,但我没有得到" ngx-charts-pie-chart"。

代码HTML:

<ngx-charts-pie-chart
         [view]="view"
         [scheme]="colorScheme"
         [results]="infoChartsFree"
         [explodeSlices]="explodeSlices"
         [labels]="showLabels"
         [doughnut]="doughnut"
         [gradient]="gradient">
       </ngx-charts-pie-chart>

代码状态-parking.ts:

view: any[] = [700, 400];

  // options

  colorScheme = {
    domain: ['#ff0909','#048506','#000274','#ff5309','#00ff04','#0004ff']
  };

  // pie
  showLabels = true;
  explodeSlices = false;
  doughnut = false;

public getFree(idZone:number){
    let freeObs=this._iTipologiazona.getnumberFree(idZone);
    freeObs.subscribe(data=>{
      this.status=data;
      let tipo_veicolo:string;
      let c:number=0;
      for(var i=0; i<this.status.length;i++){
        tipo_veicolo=this.status[i].tipo.charAt(0).toUpperCase()+this.status[i].tipo.slice(1).toLowerCase();
        c=c+this.status[i].occupati;
        this.status[i].tipo=tipo_veicolo;
        var free="Posti "+tipo_veicolo + " liberi";
        var notFree="Posti "+tipo_veicolo + " occupati";
        this.infoChartsFree.push(new InfoCharts());
        this.infoChartsFree[i].name=free;
        this.infoChartsFree[i].value=this.status[i].totale-c;
        this.InfoChartsNotFree.push(new InfoCharts());
        this.InfoChartsNotFree[i].name=notFree;
        this.InfoChartsNotFree[i].value=c;

        this.infocharts.push(this.infoChartsFree[i]);
        this.infocharts.push(this.InfoChartsNotFree[i]);
      }

      this.jsonInfoCharts=JSON.stringify(this.infocharts)
      Object.assign(this.infoChartsFree)

      console.log(this.jsonInfoCharts);
      this.total_notfree=c;
      this.total_free=this.totale-this.total_notfree;

    })
  }

这是我进入控制台: https://ibb.co/hymKum

0 个答案:

没有答案