var today = new Date();
var thisDD = today.getDate();
var thisMM = today.getMonth(); //January is 0! might need to +1
var thisYYYY = today.getFullYear();
var lastYYYY = today.getFullYear()-1;
var nextYYYY = today.getFullYear()+1;
google.charts.load("current", {packages:["timeline"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('water-supply-bank-calendar');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'string', id: 'Priority' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
/*subtract 1 for each month to display correctly*/
[ 'Month', 'JUN', new Date(lastYYYY, 5, 1), new Date(lastYYYY, 5, 30) ],
[ 'Month', 'JUL', new Date(lastYYYY, 6, 1), new Date(lastYYYY, 6, 31) ],
[ 'Month', 'AUG', new Date(lastYYYY, 7, 1), new Date(lastYYYY, 7, 31) ],
[ 'Month', 'SEP', new Date(lastYYYY, 8, 1), new Date(lastYYYY, 8, 30) ],
[ 'Month', 'OCT', new Date(lastYYYY, 9, 1), new Date(lastYYYY, 9, 31) ],
[ 'Month', 'NOV', new Date(lastYYYY, 10, 1), new Date(lastYYYY, 10, 30) ],
[ 'Month', 'DEC', new Date(lastYYYY, 11, 1), new Date(lastYYYY, 11, 31) ],
[ 'Month', 'JAN', new Date(thisYYYY, 0, 1), new Date(thisYYYY, 0, 31) ],
[ 'Month', 'FEB', new Date(thisYYYY, 1, 1), new Date(thisYYYY, 1, 28) ],
[ 'Month', 'MAR', new Date(thisYYYY, 2, 1), new Date(thisYYYY, 2, 31) ],
[ 'Month', 'APR', new Date(thisYYYY, 3, 1), new Date(thisYYYY, 3, 30) ],
[ 'Month', 'MAY', new Date(thisYYYY, 4, 1), new Date(thisYYYY, 4, 31) ],
[ 'Season', 'Summer', new Date(lastYYYY, 5, 1), new Date(lastYYYY, 8, 1) ],
[ 'Season', 'Fall', new Date(lastYYYY, 8, 1), new Date(lastYYYY, 11, 1) ],
[ 'Season', 'Winter', new Date(lastYYYY, 11, 1), new Date(thisYYYY, 2, 1) ],
[ 'Season', 'Spring', new Date(thisYYYY, 2, 1), new Date(thisYYYY, 4, 31) ],
[ 'Process Rental Proposals', 'Standard Priority', new Date(lastYYYY, 5, 1), new Date(lastYYYY, 10, 1) ],
[ 'Process Rental Proposals', 'High Priority', new Date(lastYYYY, 10, 1), new Date(thisYYYY, 2, 15) ],
[ 'Process Rental Proposals', 'Standard Priority', new Date(thisYYYY, 2, 15), new Date(thisYYYY, 4, 31) ],
[ 'Process Lease Proposals', 'Standard Priority', new Date(lastYYYY, 5, 1), new Date(lastYYYY, 8, 15) ],
[ 'Process Lease Proposals', 'High Priority', new Date(lastYYYY, 8, 15), new Date(lastYYYY, 10, 1) ],
[ 'Process Lease Proposals', 'Medium Priority', new Date(lastYYYY, 10, 1), new Date(thisYYYY, 2, 15) ],
[ 'Process Lease Proposals', 'Standard Priority', new Date(thisYYYY, 2, 15), new Date(thisYYYY, 4, 31) ],
[ 'Request Rental Fees', 'Standard Priority', new Date(lastYYYY, 9, 1), new Date(thisYYYY, 1, 28) ],
[ 'Cancel Unpaid Rentals', 'Standard Priority', new Date(thisYYYY, 0, 1), new Date(thisYYYY, 2, 31) ],
[ 'Issue Lessor Payments', 'High Priority', new Date(lastYYYY, 8, 15), new Date(lastYYYY, 10, 30) ],
[ 'Process Lease Releases', 'Standard Priority', new Date(lastYYYY, 5, 1), new Date(lastYYYY, 6, 15) ],
[ 'Process Lease Releases', 'High Priority', new Date(lastYYYY, 6, 15), new Date(lastYYYY, 9, 15) ],
[ 'Process Lease Releases', 'Standard Priority', new Date(lastYYYY, 9, 15), new Date(thisYYYY, 4, 31) ],
[ 'Expiration Reminders', 'Standard Priority', new Date(lastYYYY, 6, 1), new Date(lastYYYY, 7, 31) ],
[ 'Close Expired Leases', 'Standard Priority', new Date(lastYYYY, 11, 1), new Date(thisYYYY, 0, 31) ],
[ 'Close Expired Rentals', 'Standard Priority', new Date(lastYYYY, 11, 1), new Date(thisYYYY, 0, 31) ] ]);
var options = {
tooltip: {trigger: 'none'},
colors: ['white','white','white','white','white','white','white','white','white','white','white','white','lawngreen', 'chocolate','steelblue', '#e580ff', '#0f9d58','#db4437','#f4b400']};
/*hide the x-axis*/
google.visualization.events.addListener(chart, 'ready', function () {
var labels = container.getElementsByTagName('text');
Array.prototype.forEach.call(labels, function(label) {
if (label.getAttribute('text-anchor') === 'middle') {
label.setAttribute('fill', '#ffffff');} });
});
/*end hide*/
chart.draw(dataTable, options);
}