Google Chart Pie Chart - coffee consumption sample

Attempt to anser this question: https://stackoverflow.com/q/67644426/12511801

by MauricioSO2021

HTML

<script src="https://www.google.com/jsapi"></script>
<div id="myPieChart"/>

JavaScript

google.charts.load('current', {
  packages: ['corechart']
});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  // Define the chart to be drawn.
  /*var data = google.visualization.arrayToDataTable({
      label: 'Item',
      type: 'string'
    }, {
      label: 'Quantity Sold',
      type: 'number'
    },
    ['Espresso', 0],
    ['Cappuccino', 2],
    ['Black Coffee', 0],
    ['Cafe Latte', 0],
    ['Mocha', 0],
    ['Iced Americano', 0],
    ['Iced Caramel Macchiato', 0],
    ['Cold Brew', 0]
  );*/

  // OK
  /*var data = google.visualization.arrayToDataTable([
  [{label: 'Country', type: 'string'},
   {label: 'Population', type: 'number'},
   {label: 'Area', type: 'number'},
   {type: 'string', role: 'annotation'}],
  ['CN', 1324, 9640821, 'Annotated'],
  ['IN', 1133, 3287263, 'Annotated'],
  ['US', 304, 9629091, 'Annotated'],
  ['ID', 232, 1904569, 'Annotated'],
  ['BR', 187, 8514877, 'Annotated']
]);*/


	// Modificando...
  var data = google.visualization.arrayToDataTable([
    [{label: 'Item', type: 'string'}, 
     {label: 'Quantity Sold', type: 'number'}],
    ['Espresso', 0],
    ['Cappuccino', 2],
    ['Black Coffee', 0],
    ['Cafe Latte', 0],
    ['Mocha', 0],
    ['Iced Americano', 0],
    ['Iced Caramel Macchiato', 0],
    ['Cold Brew', 0]
  ]);

  /*var data = google.visualization.arrayToDataTable([
    [{
        label: 'Country',
        type: 'string'
      },
      {
        label: 'Population',
        type: 'number'
      },
      {
        label: 'Area',
        type: 'number'
      },
      {
        type: 'string',
        role: 'annotation'
      }
    ],
    ['CN', 1324, 9640821, 'Annotated'],
    ['IN', 1133, 3287263, 'Annotated'],
    ['US', 304, 9629091, 'Annotated'],
    ['ID', 232, 1904569, 'Annotated'],
    ['BR', 187, 8514877, 'Annotated']
  ]);*/

  // Create the data table.
  /*var data = new google.visualization.DataTable();
  data.addColumn('string', 'Topping');
  data.addColumn('number', 'Slices');
 ...