function drawChart() {
  fetch('/vote-data').then(response => response.json())
  .then((animalVotes) => {
    const data = new google.visualization.DataTable();
    data.addColumn('string', 'Animal');
    data.addColumn('number', 'Votes');
    console.log(animalVotes);
    Object.keys(animalVotes).forEach((animal) => {
      data.addRow([animal, animalVotes[animal]]);
    });

    const options = {
      'title': 'Favorite Pets/Animals',
      'width':600,
      'height':500
    };

    const chart = new google.visualization.ColumnChart(
        document.getElementById('chart-container'));
    chart.draw(data, options);
  });
}
/** Creates a chart and adds it to the page. */
Creates a chart and adds it to the page.
Creates a chart and adds it to the page .
function drawChart() {
  fetch('/vote-data').then(response => response.json())
  .then((animalVotes) => {
    const data = new google.visualization.DataTable();
    data.addColumn('string', 'Animal');
    data.addColumn('number', 'Votes');
    console.log(animalVotes);
    Object.keys(animalVotes).forEach((animal) => {
      data.addRow([animal, animalVotes[animal]]);
    });
    const options = {
      'title': 'Favorite Pets/Animals',
      'width':600,
      'height':500
    };
    const chart = new google.visualization.ColumnChart(
        document.getElementById('chart-container'));
    chart.draw(data, options);
  });
}
function drawChart ( ) { fetch ( '/vote-data' ) . then ( response => response . json ( ) ) . then ( ( animalVotes ) => { const data = new google . visualization . DataTable ( ) ; data . addColumn ( 'string' , 'Animal' ) ; data . addColumn ( 'number' , 'Votes' ) ; console . log ( animalVotes ) ; Object . keys ( animalVotes ) . forEach ( ( animal ) => { data . addRow ( [ animal , animalVotes [ animal ] ] ) ; } ) ; const options = { 'title' : 'Favorite Pets/Animals' , 'width' : 600 , 'height' : 500 } ; const chart = new google . visualization . ColumnChart ( document . getElementById ( 'chart-container' ) ) ; chart . draw ( data , options ) ; } ) ; }
Creates a chart and adds it to the page.
Creates a chart and adds it to the page .