function drawChart() {
  fetch('/cuisine-data').then(response => response.json())
    .then((cuisineVotes) => {

    let data = new google.visualization.DataTable();
    data.addColumn('string', 'Cuisine');
    data.addColumn('number', 'Votes');

    document.getElementById("cuisine-select").innerHTML = '';

    let selectElement = document.createElement("option");
    const selectText = document.createTextNode("Select Here");
    selectElement.appendChild(selectText);
    selectElement.setAttribute("value", "");
    selectElement.disabled = true;
    document.getElementById("cuisine-select").appendChild(selectElement);

    document.getElementById("cuisine-select").value = "";

    cuisineVotes.forEach(({ cuisineId, cuisineName, votes }) => {
      let element = document.createElement("option");
      const text = document.createTextNode(cuisineName);
      element.appendChild(text);
      element.setAttribute("value", cuisineId);
      document.getElementById("cuisine-select").appendChild(element);

      if (votes > 0) {
        data.addRow([cuisineName, votes]);
      }
    })

    const options = {
      pieHole: 0.4,
      pieSliceTextStyle: {
        color: '#f5f6fa'
      },
      backgroundColor: '#a6ded2',
      legend: 'none'
    };

    const chart = new google.visualization.PieChart(document.getElementById('chart-container'));
    chart.draw(data, options);
  })
}
/** Creates the pie chart and adds it to the page. */
Creates the pie chart and adds it to the page.
Creates the pie chart and adds it to the page .
function drawChart() {
  fetch('/cuisine-data').then(response => response.json())
    .then((cuisineVotes) => {
    let data = new google.visualization.DataTable();
    data.addColumn('string', 'Cuisine');
    data.addColumn('number', 'Votes');
    document.getElementById("cuisine-select").innerHTML = '';
    let selectElement = document.createElement("option");
    const selectText = document.createTextNode("Select Here");
    selectElement.appendChild(selectText);
    selectElement.setAttribute("value", "");
    selectElement.disabled = true;
    document.getElementById("cuisine-select").appendChild(selectElement);
    document.getElementById("cuisine-select").value = "";
    cuisineVotes.forEach(({ cuisineId, cuisineName, votes }) => {
      let element = document.createElement("option");
      const text = document.createTextNode(cuisineName);
      element.appendChild(text);
      element.setAttribute("value", cuisineId);
      document.getElementById("cuisine-select").appendChild(element);
      if (votes > 0) {
        data.addRow([cuisineName, votes]);
      }
    })
    const options = {
      pieHole: 0.4,
      pieSliceTextStyle: {
        color: '#f5f6fa'
      },
      backgroundColor: '#a6ded2',
      legend: 'none'
    };
    const chart = new google.visualization.PieChart(document.getElementById('chart-container'));
    chart.draw(data, options);
  })
}
function drawChart ( ) { fetch ( '/cuisine-data' ) . then ( response => response . json ( ) ) . then ( ( cuisineVotes ) => { let data = new google . visualization . DataTable ( ) ; data . addColumn ( 'string' , 'Cuisine' ) ; data . addColumn ( 'number' , 'Votes' ) ; document . getElementById ( "cuisine-select" ) . innerHTML = '' ; let selectElement = document . createElement ( "option" ) ; const selectText = document . createTextNode ( "Select Here" ) ; selectElement . appendChild ( selectText ) ; selectElement . setAttribute ( "value" , "" ) ; selectElement . disabled = true ; document . getElementById ( "cuisine-select" ) . appendChild ( selectElement ) ; document . getElementById ( "cuisine-select" ) . value = "" ; cuisineVotes . forEach ( ( { cuisineId , cuisineName , votes } ) => { let element = document . createElement ( "option" ) ; const text = document . createTextNode ( cuisineName ) ; element . appendChild ( text ) ; element . setAttribute ( "value" , cuisineId ) ; document . getElementById ( "cuisine-select" ) . appendChild ( element ) ; if ( votes > 0 ) { data . addRow ( [ cuisineName , votes ] ) ; } } ) const options = { pieHole : 0.4 , pieSliceTextStyle : { color : '#f5f6fa' } , backgroundColor : '#a6ded2' , legend : 'none' } ; const chart = new google . visualization . PieChart ( document . getElementById ( 'chart-container' ) ) ; chart . draw ( data , options ) ; } ) }
Creates the pie chart and adds it to the page.
Creates the pie chart and adds it to the page .