Implementing Charts.js in Laravel 5.1 -


hi i've been wondering around net getting answers can't find one. i'm trying display chart using charts.js..

in route:

route::get('surveys/chart', 'aboutcontroller@projectchartdata'); 

in aboutcontroller: used json_encode() pass data view

public function projectchartdata()     {         $devlist = json_encode(db::table('surveys')             ->select(db::raw('monthname(updated_at) month'), db::raw("date_format(updated_at,'%y-%m') monthnum"),                 db::raw('count(*) projects'))             ->groupby('monthnum')             ->get());          return view('pages.chart',compact('devlist'));     } 

in view:

<canvas id="projects-graph" width="1000" height="400"></canvas> <script type="text/javascript">     $(function(){         $.getjson("surveys/chart", function (result) {             alert('');             var labels = [],data=[];             (var = 0; < result.length; i++) {                 labels.push(result[i].batch);                 data.push(result[i].created_at);             }              var buyerdata = {                 labels : labels,                 datasets : [                     {                         fillcolor : "rgba(240, 127, 110, 0.3)",                         strokecolor : "#f56954",                         pointcolor : "#a62121",                         pointstrokecolor : "#741f1f",                         data : data                     }                 ]             };             var buyers = document.getelementbyid('projects-graph').getcontext('2d');             new chart(buyers).line(buyerdata, {                 beziercurve : true             });          });      }); </script> 

the problem doesn't display graph. if return data not using json_encode gives me array() charts.js needs json.

i'm having difficulty implementing charts (morris,lavacharts,highcharts,charts.js) in laravel 5 since, not of proper turorial out of google. , if can give me nice package use. big thanks..

you pass data view , in view json_encode {!! json_encode($devlist) !!}


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -