<script>

$(document).ready(function(){


  $.ajax({
    url: "zdash/chart1.php",
    method: "GET",
    dataType: "json",
    success: function(data) {     
      
      var cname = [];
      var ans = [];
      

      for(var i in data) {
         cname.push( data[i].cname);
         ans.push(data[i].ans);
        
                         }
      
      var ctx = document.getElementById('mycanvas1');
      var mycanvas = new Chart(ctx, {
        type: 'bar',
        data: {
                labels:cname,
                datasets : [ {
                                label: 'Sales  ',
                                backgroundColor:  'rgba(75, 192, 192, 1)',                              
                                borderColor: 'rgba(75, 200, 200, 1)',
                                hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
                                hoverBorderColor: 'rgba(200, 200, 200, 1)',
                                data: ans,
                                fill: false
                              } ]
              }
      });
    }
  });

    });
</script>