简体   繁体   English

SPServices出现Highcharts错误#14

[英]Highcharts Error #14 with SPServices

I'm new to both highcharts and jQuery and I'm experiencing problems displaying the data from a Sharepoint list using SPServices. 我对highcharts和jQuery都是新手,并且在使用SPServices从Sharepoint列表显示数据时遇到问题。 I have two columns; 我有两栏; one with a Date value, and another with numeric values. 一个带有日期值,另一个带有数字值。 I'm using tutorial this as my guideline for the code. 我使用教程这个作为我指引的代码。

I'm getting the error ' Uncaught Highcharts error #14: www.highcharts.com/errors/14 ', which I understand is because Highcharts is expecting the Date value to be a number. 我收到错误“ 未捕获的Highcharts错误#14:www.highcharts.com/errors/14 ”,这是因为Highcharts期望Date值是一个数字。 I read here that I should use parseFloat() or parseInt() which has not worked. 在这里读到我应该使用parseFloat()或parseInt(),但它们没有起作用。

I then tried to generate a line chart using a 'Number' type column instead of the date column and I'm receiving the same error which confuses me further. 然后,我尝试使用“数字”类型列而不是日期列来生成折线图,并且收到相同的错误,这进一步使我感到困惑。 Thanks for any help. 谢谢你的帮助。

Code: 码:

<script>
$(document).ready(function () {

    var valuesArray = [];
    $().SPServices({
        operation: "GetListItems",
        async: false,
        CAMLQuery: "<Query><OrderBy><FieldRef Name='Week'/></OrderBy></Query>",
        listName: "{GUIDVALUEREMOVED}",
        CAMLViewFields: "<ViewFields><FieldRef Name='Week'/><FieldRef Name='Total'/></ViewFields>",
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function () {  
                var week = ($(this).attr('ows_Week'));             
                var total = ($(this).attr('ows_Total'));
                valuesArray.push([parseFloat(week), total]);      
            });
        }
    });
    chart = new Highcharts.Chart({

        chart: {
            renderTo: 'CHANGEME',
            type: 'line'
        },
        title: {
            text: 'FS Total by Week'
        },
        yAxis: {
            title: {
                text: 'values'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        subtitle: {
            text: 'Change me 2'
        },

        tooltip: {
            formatter: function() {
                return '<b>'+ this.y;}
        },
        credits: {
            enabled: false
        },
        plotOptions: {
            column: {
                allowPointSelect: true,
                pointPadding: 0.2,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: 'transparent',
                    formatter: function() {
                        return '<b>'+ this.y;
                    }
                }
            }
        },
        series: [{
            type:'line',
            name: 'Total',
            data: valuesArray
        }]
    });
});
</script>
<div id="CHANGEME">
</div>

Here: valuesArray.push([parseFloat(week), total]); 此处: valuesArray.push([parseFloat(week), total]); you are parsing only x-value, do the same with y-value: valuesArray.push([parseFloat(week), parseFloat(total)]); 您只解析x值,对y值执行相同操作: valuesArray.push([parseFloat(week), parseFloat(total)]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM