Highcharts 对数组的要求

    function Reflush(phaid,proid) {

        $.post('GetProjectSummer.ashx', { proid: proid, phaid: phaid }, function (data) {

            var serverData = $.parseJSON(data);

            //清空DIV

            document.getElementById('con').innerHTML = "";

            for (var i = 0; i < serverData.length; i++) {

                $('<div id="container' + i + '" style="width: 45%; height: 400px; margin: 0 auto; float:left"></div>').appendTo('#con');

                var arr1 = serverData[i].CreateTime.split(',');

                var arr2 = serverData[i].Used.split(',');

                var arr3 = new Array(arr2.length);

                //直接用arr2无法识别,将字符串数组转换成数字数组

                for (var j = 0; j < arr2.length; j++) {                    

                    arr3[j] = parseInt(arr2[j].replace("]", "").replace("[", ""));

                }            

                //自动绑定DIV

                $('#container'+i).highcharts({

                    title: {

                        text: serverData[i].ProName

                    },

                    subtitle: {

                        text: serverData[i].PhaName

                    },

                    xAxis: {

                        categories: arr1,

                        title: {

                            text: '日期'

                        }

                    },

                    yAxis: {

                        title: {

                            text: serverData[i].Name + '使用量'

                        },

                        plotLines: [{

                            value: 0,

                            width: 1,

                            color: '#808080'

                        }]

                    },

                    tooltip: {

                        valueSuffix:''

                    },



                    plotOptions: {

                        spline: {

                            marker: {

                                enabled: true

                            }

                        }

                    },



                    series: [{

                        name:serverData[i].Name,

                        data: arr3

                    }] 

                });

            }

        });

    }

 

你可能感兴趣的:(Highcharts)