Using javascript array variables as single variable for displaying google chart

by user8467658   Last Updated August 16, 2017 09:03 AM

Here is a part of my javascript code included inside google chart program:- . .

var arr1 = <?php echo json_encode($phparray1) ?>;
var arr2  = <?php echo json_encode($phparray2)?>;

function drawChart() {
var data = google.visualization.arrayToTableData([
['col1', 'col2'],
[arr1[0], arr2[0]],
[arr1[1], arr2[1]],
[arr1[2], arr2[2]]
]);

. . .continued.... .

How can I use a loop instead of defining​ each and every element inside the array separately (say, arr1[0] arr2[0] etc...)? Let me know the code.



Related Questions


Webservice which allows chat with math formulas

Updated August 26, 2017 03:03 AM