Highcharts无法用逗号读取数据

时间:2015-02-02 01:52:34

标签: jquery highcharts

我有一个问题就是把逗号放在我从数据库中提取的金额上。

我添加了'commaSeparateNumber函数'并且我工作,但问题是Highcharts无法用逗号读取数字。我尝试过使用parsefloat,但对我没用。这是我的功能:

  function Filltbl(data) {

                        $.each(data, function () {
                            var html = "<tr><td>" + this.SampleNo + "</td><td>" + this.SC_Com + "</td><td>" + this.SC_AP + "</td><td>" + this.SC_Cer + "</td><td>" + this.SC_Pd + "</td></tr>";
                            $('#datatable').append(commaSeparateNumber(html));

                        });                   
                    }

这个是commaSeparateNumber函数:

  function commaSeparateNumber(val) {
                while (/(\d+)(\d{3})/.test(val.toString())) {
                    val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
                }
                return val;
            }

这是我从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:

series: [{
    data: ["3", "5", "1", "6"]
}]
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.3).

0 个答案:

没有答案