Timeline Example

An example of a Google Timeline.

by Daniel Buttery

HTML

<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['timeline']}]}"></script>
       <div id="timeline" style="width: 900px; height: 180px;"></div>

JavaScript

google.setOnLoadCallback(drawChart);

      function drawChart() {
        var container = document.getElementById('timeline');
        var chart = new google.visualization.Timeline(container);
        var dataTable = new google.visualization.DataTable();

        dataTable.addColumn({ type: 'string', id: 'President' });
        dataTable.addColumn({ type: 'date', id: 'Start' });
        dataTable.addColumn({ type: 'date', id: 'End' });
        dataTable.addRows([
          [ 'Washington', new Date(30), new Date(40) ], // << change 999 to 1000 to make it work
          [ 'Adams',      new Date(3),  new Date(1000) ],
          [ 'Jefferson',  new Date(500),  new Date(600) ]]);

        chart.draw(dataTable);
      }