Week 9 - Activity 2 Solutions

This is the barchart that is a solution to the Week 9 Google Chart Activity

by Brian von Konsky

HTML

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
  <div id="chart_div"><div>

JavaScript

google.load('visualization', '1', {packages: ['corechart', 'bar']});
google.setOnLoadCallback(drawAxisTickColors);

function drawAxisTickColors() {
      var data = google.visualization.arrayToDataTable([
        ['Financials', 'January', 'February', 'March', 'April', 'May'],
        ['Sales',    5000, 5700, 4890, 4010, 3500],
        ['Expenses', 1959, 1964, 1977, 2159, 3699],
      ]);

      var options = {
        title: 'Corporate Cash Flow',
        chartArea: {width: '50%'},
        hAxis: {
          title: 'AUD$',
          minValue: 0,
          textStyle: {
            bold: true,
            fontSize: 12,
            color: '#4d4d4d'
          },
          titleTextStyle: {
            bold: true,
            fontSize: 18,
            color: '#4d4d4d'
          }
        },
        vAxis: {
          title: 'Financial Position',
          textStyle: {
            fontSize: 14,
            bold: true,
            color: '#848484'
          },
          titleTextStyle: {
            fontSize: 14,
            bold: true,
            color: '#848484'
          }
        }
      };
      var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }