highcharts错误处理:Uncaught Highcharts error #14: www.highcharts.com/errors/14

内容纲要

今天在用highcharts做饼图的时候突然冒出这么个错误,然后是各种排除都未找到问题,索性直接点击这个链接进去看了一下,果然找到了答案,呵呵!!

以下是官方的原文:

Highcharts Error #14

String value sent to series.data, expected Number

This happens if you pass in a string as a data point, for example in a setup like this:

Highcharts expects the data values to be numbers. The most common reason for this is that data is parsed from CSV or from a XML source, and the implementer forgot to run parseFloat on the parsed value.

For performance reasons internal type casting is not performed, and only the first value is checked (since 2.

其实大概意思就是说data中的数字不能是字符串格式的,那这就好办了,直接转换一下就完事了.

我的项目中用的是tp,所以在模板中直接用如下方法就解决了:

如果你也遇到以上问题,可以根据自己程序的实际情况把字符串转换成整型就OK了.

发表评论

邮箱地址不会被公开。 必填项已用*标注

62 ÷ = 31