I am using Google’s Annotated Time Line tool to plot data which spans over two years, for example 2010 and 2011.
The timeline on x-axis only shows entries on 2011. It skips all the values of 2010.
Take following data table for example:
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Mac Client');
data.addColumn('number', 'Win Client');
data.addColumn('number', 'Total');
data.addRows(7)
data.setValue(0, 0, new Date(2010, 12, 16, 11, 0, 0, 0));
data.setValue(0, 1, 0);
data.setValue(0, 2, 1);
data.setValue(0, 3, 1);
data.setValue(1, 0, new Date(2010, 12, 24, 16, 0, 0, 0));
data.setValue(1, 1, 0);
data.setValue(1, 2, 5);
data.setValue(1, 3, 5);
data.setValue(2, 0, new Date(2010, 12, 16, 12, 0, 0, 0));
data.setValue(2, 1, 0);
data.setValue(2, 2, 19);
data.setValue(2, 3, 19);
data.setValue(3, 0, new Date(2011, 3, 30, 2, 0, 0, 0));
data.setValue(3, 1, 0);
data.setValue(3, 2, 17);
data.setValue(3, 3, 17);
data.setValue(4, 0, new Date(2011, 4, 11, 13, 0, 0, 0));
data.setValue(4, 1, 0);
data.setValue(4, 2, 37);
data.setValue(4, 3, 37);
data.setValue(5, 0, new Date(2011, 10, 2, 0, 0, 0, 0));
data.setValue(5, 1, 1);
data.setValue(5, 2, 21);
data.setValue(5, 3, 22);
data.setValue(6, 0, new Date(2011, 4, 19, 2, 0, 0, 0));
data.setValue(6, 1, 0);
data.setValue(6, 2, 6);
data.setValue(6, 3, 6);
The resulting graph starts from 2011, instead of 2010. Google code playground
How can I make it to include data points for 2010 too?
The graph ends at November 02, 2011, although my last data point in October 2, 2011. How can I make the x-axis of graph end at October 30.
The JavaScript Date object’s ‘month’ value is indexed at 0 (i.e.: 0=January, 1=February), so right now, everything is a month off.
Change
to
across the board and you should get what you want!