簡體   English   中英

JavaScript數組還是Google Charts view.setColumns?

[英]Javascript array or Google Charts view.setColumns?

我不知道對不起標題這個話題。 任何了解我的問題的人都可以編輯我的問題標題。

腳本:

// I get checkboxes values with using this function
var myValues = $(".filter:checked").map(function () {
    return this.value;
}).get();

alert("[0," + myValues + "]");
var view = new google.visualization.DataView(new google.visualization.DataTable(evalledData, 0.5));
view.setColumns([0, myValues]); // I pass the checked values.

當我編寫上面的代碼時,出現此錯誤: "type" must be specified

如果我寫了view.setColumns([0, 1,2,3,4]); 有用。

警報輸出: [0,1,2,3,4]因此兩種用法之間沒有區別。

為什么我得到這個錯誤。

謝謝。

我解決了

// This function returns string array. 
var myValues = $(".filter:checked").map(function () {
    return this.value;
}).get();

// I converted it an Int array.
$.each(myValues, function (index, value) {
    arrayAll.push(parseInt(value, 10));
    //alert(index + ': ' + value);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM