I’m using the google visualization charts api but I believe this is some kind of javascript mistake I am making. I populate this array with numbers:
visibleRows = [];
And make it a comma delimted string:
visibleRows.join(',');
console.logging visibleRows after this gives:
0,1,3
But when I feed visibleRows into the function the very next line:
pieViewHits.setRows([visibleRows]);
I get the error: Invalid row index 0,1,3 Should be in the range [0-3] BUT if I replace all the above code with just:
pieViewHits.setRows([0,1,3]);
It works perfectly! Any ideas?
[0,1,3]is an array containing three numbersvisibleRows.join(',');returns a comma delimited string. You aren’t assigning it anywhere, so it doesn’t do anything.[visibleRows]is an array containing a second array that contains three numbers in turn. It will be flattened to a comma delimited string if used in a string context.The function expects an array containing three numbers, not an array containing another array or an array containing a comma delimited string.
Just pass the array without wrapping it in another array or
joining it.