dimanche 19 avril 2020

Uncaught (in promise) Error: Row 1 has 42 columns, but must have 2

I'm using google bar charts for my project and I create an ajax function to load charts with data. But when I use jquery each function to create data bars in google charts its getting error called Uncaught (in promise) Error: Row 1 has 42 columns, but must have 2. Can Anyone show me the error in my code

This is my chart code

//chart 2
google.charts.load('current', {
  'packages': ['bar']
});
google.charts.setOnLoadCallback(drawChart1);

function drawChart1() {
  var dataa1 = google.visualization.arrayToDataTable([
    ['DS Division', 'No of Youths'],
    $.each(data.locations, function(index, value3) {
      ['' + value3.DSD_Name + '', value3.total]

    }),

  ]);

  var options1 = {
    chart: {

    },
    bars: 'horizontal', // Required for Material Bar Charts.

    legend: {
      position: 'none'
    },
  };

  var chart1 = new google.charts.Bar(document.getElementById('barchart_material'));

  chart1.draw(dataa1, google.charts.Bar.convertOptions(options1));
}

This is my response data from the controller

return response() => json(array(
  'male' => $male,
  'female' => $female,
  'locations' => $locations,
  'salary1' => $salary1,
  'salary2' => $salary2,
  'salary3' => $salary3,
  'salary4' => $salary4,
  'salary5' => $salary5,
  'salary6' => $salary6,
  'employers' => $employers
));

Please help me to slove this

Thank You



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire