Google visualization 谷歌图表“;未捕获(承诺中)错误:列索引3无效。应为[0-3]范围内的整数。”;
在将此标记为重复之前,请注意其他人正在询问有关错误Google visualization 谷歌图表“;未捕获(承诺中)错误:列索引3无效。应为[0-3]范围内的整数。”;,google-visualization,Google Visualization,在将此标记为重复之前,请注意其他人正在询问有关错误无效列索引未定义或无效列索引5。应该是[0-4]范围内的整数。但不是。我的是“3应该是[0-3]范围内的整数”。此外,该表在没有formatter.format()行的情况下也可以工作(只是没有格式化) 有问题的标题如下所示: header[3] = { "html": "Total Amount", "source": "total_amount", "type": "number", "format": {
无效列索引未定义代码>或无效列索引5。应该是[0-4]范围内的整数。
但不是。我的是“3应该是[0-3]范围内的整数”。此外,该表在没有formatter.format()
行的情况下也可以工作(只是没有格式化)
有问题的标题如下所示:
header[3] = {
"html": "Total Amount",
"source": "total_amount",
"type": "number",
"format": {
"negativeColor": "#F05840", //orange
"negativeParens": true,
"pattern": "#,###",
"prefix": "$",
"suffix": "",
}
}
我不明白为什么会出错
请原谅我在这里的任何打字错误,我不得不手工编辑间距,并在粘贴代码时删除我公司的特定信息
编辑
WhiteHat是正确的,因为我的h
变量是一个字符串而不是一个整数,调用parseInt
确实消除了这个错误。然而,我没有在格式化程序上调用parseInt
,也没有在任何需要它的地方调用它,而是放弃了我的for(varh in data.headers)
调用,使用了bog标准for(varh=0;h
我对GoogleCharts NumberFormatter仍有疑问,但这是下一轮的研究和问题,不是这一轮。确保你传递了一个数字(3
),
而不是字符串('3'
),
通过使用-->parseInt
e、 g
formatter.format(googleData, parseInt(h)); // <-- here
formatter.format(googleData,parseInt(h))//
formatter.format(googleData, parseInt(h)); // <-- here