google.charts.load('current', {
callback: function () {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Room' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
[ '1', 'A', new Date(2011, 3, 30), new Date(2012, 2, 4) ],
[ '2', 'B', new Date(2012, 2, 4), new Date(2013, 3, 30) ],
[ '3', 'C', new Date(2013, 3, 30), new Date(2014, 2, 4) ],
[ '4', 'D', new Date(2014, 2, 4), new Date(2015, 2, 4) ],
[ '5', 'E', new Date(2015, 3, 30), new Date(2016, 2, 4) ],
[ '6', 'F', new Date(2016, 2, 4), new Date(2017, 2, 4) ],
[ '7', 'G', new Date(2017, 2, 4), new Date(2018, 2, 4) ],
[ '8', 'H', new Date(2018, 2, 4), new Date(2019, 2, 4) ],
[ '9', 'I', new Date(2019, 2, 4), new Date(2020, 2, 4) ],
[ '0', 'J', new Date(2020, 2, 4), new Date(2021, 2, 4) ]
]);
var rowHeight = 42;
var timelinePos;
google.visualization.events.addListener(chart, 'ready', function () {
$('#timeline').scrollTop(timelinePos);
});
function drawChart() {
timelinePos = $('#timeline').scrollTop();
chart.draw(dataTable, {
height: (dataTable.getNumberOfRows() * rowHeight) + rowHeight
});
}
$('#draw-chart').on('click', drawChart);
$(window).resize(drawChart);
drawChart();
},
packages: ['timeline']
});
#timeline {
overflow-x: scroll;
overflow-y: scroll;
white-space: nowrap;
border: 13px solid #bed5cd;
width: 100%;
margin: 0 auto;
position: relative;
background-color: deepskyblue;
height: 350px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="timeline"></div>
<button id="draw-chart">Draw Chart</button>