无法读取未定义的属性“ toLocaleString”。角度5 ngx图

Nik*_*las 1 ngx-datatable angular ngx-charts angular5

控制台日志无法读取我component.ts 上未定义的属性“ toLocaleString”,我正在使用此方法从json获取数据

getChartProducts() {

        this.TicketService.getAlladminPage(this.number, this.size, this.sort, this.orderByColumn)
          .subscribe(
            (chart: any[]) => {

              let item = 0;

              if (chart['content']) {
                while(item < chart['content'].length){

                  let chartItem = {
                    'name' : chart['content'][item].name,
                    'price': chart['content'][item].price
                  };

                  this.chart.push(chartItem);
                  item ++;
                }

                console.log( this.chart);
              }
            });

      }`
Run Code Online (Sandbox Code Playgroud)

我也设定

`
     chart: { name :string, price :number}[] = [];
view: any[] = [700, 400];

  // options
  showXAxis = true;
  showYAxis = true;
  gradient = false;
  showLegend = true;
  showXAxisLabel = true;
  showYAxisLabel = true;`
Run Code Online (Sandbox Code Playgroud)

和我的HTML

` <ngx-charts-bar-vertical
                                [view]="view"
                                [scheme]="colorScheme"
                                [results]="chart"
                                [gradient]="gradient"
                                [xAxis]="showXAxis"
                                [yAxis]="showYAxis"
                                [legend]="showLegend"
                                [showXAxisLabel]="showXAxisLabel"
                                [showYAxisLabel]="showYAxisLabel"
                                [xAxisLabel]="xAxisLabel"
                                [yAxisLabel]="yAxisLabel"
                                (select)="onSelect($event)">
                              </ngx-charts-bar-vertical>`
Run Code Online (Sandbox Code Playgroud)

对这个错误有任何想法吗?我试过图表:{“ name”:string,“ price”:number} [] = []; 但是同样的错误

我正在使用Angular CLI:1.7.4节点:8.11.2操作系统:win32 x64 Angular:5.0.2“ @ swimlane / ngx-charts”:“ 7.4.0”,

Cou*_*ula 5

对于分组的垂直条形图,您需要使用:

ngx-charts-bar-vertical-2d
Run Code Online (Sandbox Code Playgroud)

而不是:

ngx-charts-bar-vertical
Run Code Online (Sandbox Code Playgroud)