VegaChart Radar Chart

An example of a Google VegaChart Radar Chart.

by siegesan

HTML

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
       <div id="chart-area"></div>

JavaScript

google.charts.load('49', {'packages': ['vegachart']}).then(loadCharts);

      const lasagna = [
        ["Protein",0.1308,"Lasagna, cheese, frozen, prepared"],
        ["Carbohydrates",0.05032727272727273,"Lasagna, cheese, frozen, prepared"],
        ["Vitamin C",0.228,"Lasagna, cheese, frozen, prepared"],
        ["Calcium",0.08538461538461538,"Lasagna, cheese, frozen, prepared"],
        ["Zinc",0.11375,"Lasagna, cheese, frozen, prepared"],
        ["Sodium",0.18933333333333333,"Lasagna, cheese, frozen, prepared"]
      ];

      const pork = [
        ["Protein",0.2638,"Pulled pork in barbecue sauce"],
        ["Carbohydrates",0.06814545454545454,"Pulled pork in barbecue sauce"],
        ["Vitamin C",0.002666666666666667,"Pulled pork in barbecue sauce"],
        ["Calcium",0.033846153846153845,"Pulled pork in barbecue sauce"],
        ["Zinc",0.23125,"Pulled pork in barbecue sauce"],
        ["Sodium",0.444,"Pulled pork in barbecue sauce"]
      ];

      const melon = [
        ["Protein",0.0168,"Melons, cantaloupe, raw"],
        ["Carbohydrates",0.029672727272727274,"Melons, cantaloupe, raw"],
        ["Vitamin C",0.4893333333333334,"Melons, cantaloupe, raw"],
        ["Calcium",0.006923076923076923,"Melons, cantaloupe, raw"],
        ["Zinc",0.0225,"Melons, cantaloupe, raw"],
        ["Sodium",0.010666666666666666,"Melons, cantaloupe, raw"]
      ];

      function loadCharts() {
        addChart(lasagna[0][2], lasagna, "#B82E2E");
        addChart(pork[0][2], pork, "#6633CC");
        addChart(melon[0][2], melon, "#109618");
      };

      function addChart(title, data, color) {
        const dataTable = new google.visualization.DataTable();
        dataTable.addColumn({type: 'string', 'id': 'key'});
        dataTable.addColumn({type: 'number', 'id': 'value'});
        dataTable.addColumn({type: 'string', 'id': 'category'});
        dataTable.addRows(data);

        const options = {
          'vega': {
            "$schema":...