首先是here is a fiddle。我想動態更改變量data
的參數。如果你看看Firebug控制檯,你可以看看數據數組對象。我擡頭看了很多,但我無法弄清楚data
。更改數組對象的元素
總之我想用return_data
元素重新生成數據數組對象。 return_data
對象的元素是動態的。在fiddle它有3個元素,但它可能不同於3.我如何動態地改變它?
在此先感謝。
var return_data = [{"name":"mrzurafa","count":315,"pop":5,"impact":7.37},{"name":"mutcato","count":20,"pop":5,"impact":56},{"name":"s0lukciyerli","count":3488,"pop":5,"impact":25.65}];
var data = google.visualization.arrayToDataTable([
['name','impact','pop','temp','count'],
['beyinsiz',80.66,1.67,2,33739900],
['mutcato',79.84,1.36,4,81902307],
['s0lukciyerli',78.6,1.84,8,5523095],
['herbkubilenadam',81.55,2.96,10,748560000],
['mrzurafa',88.09,2.05,40,307007000]
]);
所以,你想要將return_data中的JSON轉換爲單獨的數組以便在數據中使用? –
@MatthewRiches也許這不是必要的。我只想用數據元素替換return_data元素,考慮到return_data的長度是可變的。 – Tahtakafa
我想你可以很容易地使用循環將一個數組轉換爲另一個數組。你嘗試過嗎? –