angular - 无法读取未定义的属性“toLocaleString”。Angular 5 ngx 图表
问题描述
控制台日志无法读取我的 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);
}
});
}`
我也设置
`
chart: { name :string, price :number}[] = [];
view: any[] = [700, 400];
// options
showXAxis = true;
showYAxis = true;
gradient = false;
showLegend = true;
showXAxisLabel = true;
showYAxisLabel = true;`
和我的 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>`
对这个错误有什么想法吗?我试过图表:{“名称”:字符串,“价格”:数字} [] = []; 但同样的错误
我正在使用 Angular CLI:1.7.4 节点:8.11.2 操作系统:win32 x64 Angular:5.0.2 “@swimlane/ngx-charts”:“7.4.0”,
解决方案
对于分组垂直条形图,您需要使用:
ngx-charts-bar-vertical-2d
而不是:
ngx-charts-bar-vertical
推荐阅读
- python - PyCharm 终端将软件包安装到 anaconda 基础而不是 venv
- azure-managed-identity - 为 Azure 资源创建用户分配的托管标识的最佳做法是什么?
- python - 即使条件满足 if 语句,我的 else 语句也会被执行
- apache - submain 中显示的根域的内容
- javascript - 网站上的图像在桌面上正确显示,但在移动设备上不正确
- google-sheets - 在谷歌电子表格中填写条件后未更改的单元格
- javascript - 附加到画布对象的 IF 语句问题 - JS
- linux - 无论分隔符如何,通过 sed 替换字符串失败
- c++ - 为模板重载 +=?
- python - 无法提供静态文件