when copy paste console log data to data.Addrows() it shows working else not . please help me to solve the problem

767 views
Skip to first unread message

Ahmed Mohamed

unread,
Jul 20, 2019, 6:40:54 AM7/20/19
to Google Visualization API

    $(document).ready(function() {
    
  
    var optcounts1 = <?php echo json_encode($optcountss); ?>;
    var options1 = <?php echo json_encode($optionss); ?>;
    

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

    
          function drawChart() {
      var j = <?php echo $i ?>;
   
    for(var x=1; x<=j;x++) {
    var p = x-1;
            // Create the data table.
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Topping');
            data.addColumn('number', 'Slices');
    
    
    console.log(options1[p]);
   
    
    var m = 'chart_div'+x;
   
    data.addRows(options1[p]);
   
   
            var options = {'title':'mi',
                           'width':400,
                           'height':300};
    
         
            var chart = new google.visualization.PieChart(document.getElementById(m));
            chart.draw(data, options);
   
          }
      
    }
    
    });
    
    

Ahmed Mohamed

unread,
Jul 20, 2019, 6:43:23 AM7/20/19
to Google Visualization API
And this my error:
Uncaught (in promise) Error: Argument given to addRows must be either a number or an array
    at gvjs_R.gvjs_.eq (jsapi_compiled_default_module.js:142)
    at drawChart (resultreprt.php?frmid=1:1137) 
Reply all
Reply to author
Forward
0 new messages