Echart..js插件渲染報錯 data.length<1?

問題函數

  getJSON提交 返回數據正常,在傳入參數進行序列化,渲染報表時報錯 option.data.length < 1.spa

分析 code

1.可能狀況一:blog

.字符串

可本身明明是getJSON()把渲染放在成功回調函數裏面了,因此顯然不是這個錯誤get

2.可能狀況二 :回調函數

  序列化數據沒有獲取到 爲空,因此提示option.data.length<1it

緣由:io

在序列化橫座標數據時,經過switch(type)根據不一樣類型 初始化橫座標 ,可是傳過來的type 0 爲 字符串型而switch(type)裏type爲數值型因此匹配 不到 初始化數據位空class

        types=type;    //types=parsesInt(type); switch (types) {
                case 0 :        // day

                    var strDate = date.getMonth() + 1 + "/" + date.getDate();
                    xAxis.push(strDate);
                    break;
                case 1 :        // week
                    var strDate = date.getMonth() + 1 + "/" + date.getDate();
                    xAxis.push(strDate);
                    break;
               case 3 :        // custom
                   var strDate = date.getMonth() + 1 + "/" + date.getDate();
                   xAxis.push(strDate);
                    break;
                default :
                    break;
            }

 

你媽坑我一下午,程序就是程序,走不通確定有問題,因此仍是要靜下來分析緣由,一步一步 調

parseInt(type)轉換爲數值型

相關文章
相關標籤/搜索