koen_hendriks

Visualization Google

Sep 10th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization',
  2.        'version':'1','packages':['timeline']}]}"></script>
  3. <script type="text/javascript">google.setOnLoadCallback(drawChart);
  4.  
  5. function drawChart() {
  6.  
  7.     var container = document.getElementById('example1');
  8.     var chart = new google.visualization.Timeline(container);
  9.  
  10.     var dataTable = new google.visualization.DataTable();
  11.     dataTable.addColumn({
  12.         type: 'string',
  13.         id: 'Title'
  14.     });
  15.     dataTable.addColumn({
  16.         type: 'string',
  17.         id: 'Status'
  18.     });
  19.     dataTable.addColumn({
  20.         type: 'date',
  21.         id: 'Start'
  22.     });
  23.     dataTable.addColumn({
  24.         type: 'date',
  25.         id: 'End'
  26.     });
  27.     dataTable.addRows([
  28.         ["1", "Planning", new Date(2013, 5, 20), new Date(2013, 6, 21)],
  29.         ["2", "Design", new Date(2013, 6, 25), new Date(2013, 7, 25)],
  30.         ["3", "Development", new Date(2013, 7, 25), new Date(2013, 10, 11)],
  31.         ["4", "Implementation", new Date(2013, 10, 15), new Date(2013, 11, 14)],
  32.         ["5", "Testing", new Date(2013, 11, 18), new Date(2013, 12, 10)],
  33.         ["6", "Delivering", new Date(2013, 12, 1), new Date(2013, 12, 21)]
  34.     ]);
  35.  
  36.     var formatter = new google.visualization.DateFormat({
  37.         formatType: 'medium'
  38.     });
  39.    
  40.     formatter.format(dataTable, 2);
  41.     formatter.format(dataTable, 3);
  42.  
  43.     var options = {
  44.         timeline: {
  45.             showRowLabels: false,
  46.             barLabelStyle: {
  47.                 fontSize: 10
  48.             },
  49.             groupByRowLabel: false,
  50.             colorByRowLabel: false
  51.         },
  52.         avoidOverlappingGridLines: false,
  53.         colors: ['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58', '#A7A7A7']
  54.     };
  55.  
  56.     chart.draw(dataTable, options);
  57. }
  58. </script>
  59. <div id="example1" style="width: 900px; height: 300px;"></div>
Add Comment
Please, Sign In to add comment