I am trying to create a stacked bar chart using Google Charts. The data I have is kind of jumpy, for example: Let's say I have a data set like this:
- 2001, A, 500
- 2001, B, 200
- 2001, C, 100
- 2002, B, 900
- 2002, C, 400
- 2003, A, 600
- 2003, C, 900
The columns are the year and the letter. In Google Charts, you would create this chart like this:
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'A');
data.addColumn('number', 'B');
data.addColumn('number', 'C');
data.addRows([
['2001', 500, 200, 100],
['2002', undefined, 900, 400],
['2003', 600, undefined, 900],
]);
However, because the data is jumpy and it's not possible to know what comes next, creating a chart like this becomes a headache. Is it possible to create one row at a time like so:
data.addRow['2001', 'A', 500]; data.addRow['2001', 'B', 200], etc? So for example, undefined columns that don't exist won't show up like 2002: A. Is it possible to do something like this?