score:1

Accepted answer

since your csv data has no header, you should use d3.text to load the data, followed by d3.csvparserows to parse it to a json array (see https://stackoverflow.com/a/13870360/2358409). to extract the data values from the json array, you can use array.map.

data: d3.csvparserows(types).map(v => v[1])

please take a look at your amended code and see how it works.

d3.text("https://raw.githubusercontent.com/uminder/testdata/main/so/csv/donut.csv").then(makechart);
function makechart(types) {
  new chart('doughnut-chart', {
    type: 'doughnut',
    data: {
      labels: ['cancelled', 'success', 'failed'],
      datasets: [{
        label: 'population (millions)',
        backgroundcolor: ['#3e95cd', '#3cba9f', '#8e5ea2'],
        data: d3.csvparserows(types).map(v => v[1])
      }]
    },
    options: {
      title: {
        display: true,
        text: 'weekly  status'
      }
    }
  });
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.2.0/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.4/chart.min.js"></script>
<canvas id="doughnut-chart" height="90"></canvas>


Related Query

More Query from same tag