function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'From');
data.addColumn('string', 'To');
data.addColumn('number', 'number of calls');
data.addRows([
[ 'calls', 'X', 5 ],
[ 'calls', 'A', 7 ],
[ 'calls', 'B', 6 ],
[ 'calls', 'C', 2 ],
[ 'calls', 'D', 9 ],
[ 'calls', 'E', 4 ]
]);
The above is just a portion of an HTML code that I would like to modify the data.addRows([]) by using the array values. It seems not practical to hardcode the rows, so I believe there is a simple workaround for this. For example I have a range values in google sheet, var values=Spreadsheet.getActive().getSheetByName('sheet1').getRange("A1:C6"). I tried to use data.addRows(values) but its not working. I am new to apps script coding and I don't know where to insert my code var values=Spreadsheet.getActive().getSheetByName('sheet1').getRange("A1:D5") to be usable in that HTML code above dataTable. Please help.
Try using:
var values=Spreadsheet.getActive().getSheetByName('sheet1').getRange("A1:D5").getValues();
data.addRows(values);