I am attempting to create a line chart using Google Charts ( ), but I am struggling with formatting the array for the chart.
The required array format is as follows :
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
Here is my attempt at formatting it differently :
var data = google.visualization.arrayToDataTable([['Year', 'Marque1', 'Marque2', 'Marque3', 'Marque4']]);
var i=1;
msg.forEach(function(entry) {
data.addRows([
['2004', i-1, 0, i, 6],
['2004', i, 0, i, 6],
['2004', i+1, 0, i, 6]
]);
i++;
});
These values are dummy data placeholders until I can successfully create the array.
Upon running this code, I receive the following error in the browser console :
Uncaught Error: Type mismatch. Value 0 does not match type string in column index 1
When I replace the values with strings, Google displays an error message instead of the chart :
Data column(s) for axis #0 cannot be of type string