Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Ionic/Angular中的Google图表为PieChart动态创建数据表_Angular_Ionic Framework_Charts_Google Visualization - Fatal编程技术网

使用Ionic/Angular中的Google图表为PieChart动态创建数据表

使用Ionic/Angular中的Google图表为PieChart动态创建数据表,angular,ionic-framework,charts,google-visualization,Angular,Ionic Framework,Charts,Google Visualization,我试图用饼图将一些数据以离子/角度可视化。这是大学的一个项目。 在我的app.module.ts中,我正在导入 从“ng2谷歌图表”导入{Ng2GoogleChartsModule} 在我的statistics.page.ts中,我有以下方法: createChart() { if (this.stats.length > 0) { this.hasStats = true; } this.pieChartData = { chartType: 'PieChart', dataTa

我试图用饼图将一些数据以离子/角度可视化。这是大学的一个项目。 在我的app.module.ts中,我正在导入
从“ng2谷歌图表”导入{Ng2GoogleChartsModule}
在我的statistics.page.ts中,我有以下方法:

createChart() {
if (this.stats.length > 0) { this.hasStats = true; }
this.pieChartData = {
  chartType: 'PieChart',
  dataTable: this.stats,
  options: {
    title: 'Ausgaben',
    width: 400,
    height: 300
  }
};
}

统计数据定义为:

stats: [string, number] [] = []; 
并填充了我想要显示的数据。 编译应用程序时,出现以下错误:

ERROR Error: Uncaught (in promise): Error: Unknown header type: 102

我对Angular/Ionic相当陌生,我找到的所有解决方案都是针对嵌入HTML代码中的Javascript。但我必须使用角模。我就是无法让它工作。

您需要为
stats

ng2谷歌图表使用以下方法创建数据表

此方法要求数据数组中的第一个数组元素为列标题。
[string,string]

例如,有效的数据数组可能包含

[
  ['Column 1', 'Column 2'],
  ['First Row', 15000000],
  ['Second Row', 20000000]
]
arrayToDataTable
方法确实有-->
firstRowIsData

将此设置为
true
也可以解决此问题


然而,要做到这一点,需要修改ng2谷歌图表代码

谢谢,这很有帮助。但是我的stats数组是[string,number]类型的,我怎样才能将[string,string]类型的前导元素添加到此数组中?找到了一个解决方案,我只是将其更改为[any,any]类型。解决了,谢谢!