Angular2 highcharts无法动态地将数据呈现给图表

时间:2017-08-23 05:07:19

标签: javascript charts highcharts

使用来自http请求的数据创建饼图,但数据永远不会在饼图中呈现

我试过了

在html中

  <div class="col-md-4" *ngIf="overallready">
    <chart [options]="overallinsp" class="chart"></chart>
  </div>
我有打字稿代码

this._reportService.getOverview(utctime:number) //performs http request
.subscribe(
   let dtaval = JSON.parse(JSON.stringify(res.totalinspectiondata));
     console.log(dtval)
      this.overallinsp = {
        credits: {
            enabled: false
          },
          chart: {
                 ...
                  type: 'pie'
              },
              title: {
                  text: ...
              },

              series: [{
                 name: 'Brands',
                 colorByPoint: true,
                 data:dtval
            }]  

  }

  this.overallready = true;
  )

上面的console.log()生成

[{"name":"Bulker delivered","y":0},{"name":"Normal delivered truck","y":4}]

系列作品中手动设置值
        series: [{
         name: 'Brands',
          colorByPoint: true,
          data:[{"name":"Bulker delivered","y":0},{"name":"Normal delivered truck","y":4}]
            }]

由于手动设置数据输出有效但引用它无法正常工作会出现什么问题?

0 个答案:

没有答案