score:1

Accepted answer

please remind that jquery.getjson() is executed asynchronously. therefore you should create the chart only once the data is available and processed to a format suitable for your chart. this can be done if you place code responsible for chart creation inside the jquery.getjson() success handler (callback function) as follows.

$.getjson("https://spreadsheets.google.com/feeds/list/1gnakunnqvfxjuzmspnbpu9eufb4sooqlgl2ofc3lfas/od6/public/values?alt=json", data => {
  var labels = [];
  var numbers = [];
  data.feed.entry.foreach(e => {
    labels.push(e['gsx$names']['$t']);
    numbers.push(number(e['gsx$numbers']['$t']));
  });
  new chart(document.getelementbyid('mychart'), {
    type: 'radar',
    data: {
      labels: labels,
      datasets: [{
        label: 'current level',
        data: numbers,
        backgroundcolor: 'rgba(253, 48, 76, 0.2)',
        bordercolor: 'rgb(253, 48, 76)',
        pointbackgroundcolor: 'rgb(253, 48, 76)'
      }]
    },
    options: {
      tooltips: {
        callbacks: {
          title: (tooltipitem, data) => data.labels[tooltipitem[0].index]
        }
      }
    }
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.3/chart.min.js"></script>
<canvas id="mychart"></canvas>


Related Query

More Query from same tag