php - Error using chartJs on laravel project -


i trying use chartjs draw bar chart on laravel project have been getting error - "failed create chart: can't acquire context given item". have tried debugging , think looks okay.

this js file

$(document).ready(function () {     $.ajax({         url: "{{url('properties','totaltaxpaidbylga')}}",         method: "get",         success: function(data) {             console.log(data);             var player = [];             var score = [];              for(var in data) {                 player.push("player " + data[i].playerid);                 score.push(data[i].score);             }              var chartdata = {                 labels: player,                 datasets : [                     {                         label: 'player score',                         backgroundcolor: 'rgba(200, 200, 200, 0.75)',                         bordercolor: 'rgba(200, 200, 200, 0.75)',                         hoverbackgroundcolor: 'rgba(200, 200, 200, 1)',                         hoverbordercolor: 'rgba(200, 200, 200, 1)',                         data: score                     }                 ]             };              var ctx = $("#mycanvas");              var bargraph = new chart(ctx, {                 type: 'bar',                 data: chartdata             });          },         error: function(data) {             console.log(data);         }     }); }); 

this blade file

 <div id="chart-container">         <canvas id="mycanvas"> </canvas>         <p>hi</p>     </div> 

this controller

 public function totaltaxpaidbylga(){         $query = db::select("select sum(a.settlement_amount) totaltaxpaid, d.local_name  settlements a, assessments b,         property_details c, locals d         a.assessment_ref = b.assessment_ref  ,                 b.property_id = c.id ,                 c.lga_id = d.local_id         group d.local_id");         foreach ($query $row) {             $data[] = $row;         }          print json_encode($data);      } 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -