javascript - converting data from db to chartjs areachart dynamic data -


i have question populating dynamic data chartjs area chart, manage query database clinics these query result :

select tbl_clinics.clinic_name, coalesce(count(tbl_check_up.check_up_id),0) total_checked_up tbl_clinics left outer join tbl_queue on tbl_clinics.clinic_id = tbl_queue.clinic_id left outer join tbl_check_up on tbl_queue.queue_id = tbl_check_up.queue_id tbl_clinics.user_id = 102 group tbl_clinics.clinic_name 

enter image description here now, here ajax function query , response of json data object :

function getpieclinic() {     $.ajax({        url: siteurl+"patients_report/piedataclinic",        type: "get",        datatype: "json",         success:function(response) {             alert(response)         }     }); } 

now question how convert or put chartjs areachart data like. area chartjs format code below:

// context jquery - using jquery's .get() method.     var piechartcanvas = $("#piechart").get(0).getcontext("2d");     var piechart = new chart(piechartcanvas);     var piedata = [       {         value: 700,         color: "#f56954",         highlight: "#f56954",         label: "chrome"       },       {         value: 500,         color: "#00a65a",         highlight: "#00a65a",         label: "ie"       },       {         value: 400,         color: "#f39c12",         highlight: "#f39c12",         label: "firefox"       },       {         value: 600,         color: "#00c0ef",         highlight: "#00c0ef",         label: "safari"       },       {         value: 300,         color: "#3c8dbc",         highlight: "#3c8dbc",         label: "opera"       },       {         value: 100,         color: "#d2d6de",         highlight: "#d2d6de",         label: "navigator"       }     ];     var pieoptions = {       //boolean - whether should show stroke on each segment       segmentshowstroke: true,       //string - colour of each segment stroke       segmentstrokecolor: "#fff",       //number - width of each segment stroke       segmentstrokewidth: 2,       //number - percentage of chart cut out of middle       percentageinnercutout: 50, // 0 pie charts       //number - amount of animation steps       animationsteps: 100,       //string - animation easing effect       animationeasing: "easeoutbounce",       //boolean - whether animate rotation of doughnut       animaterotate: true,       //boolean - whether animate scaling doughnut centre       animatescale: false,       //boolean - whether make chart responsive window resizing       responsive: true,       // boolean - whether maintain starting aspect ratio or not when responsive, if set false, take entire container       maintainaspectratio: true,       //string - legend template       legendtemplate: "<ul class=\"<%=name.tolowercase()%>-legend\"><% (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillcolor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"     };     //create pie or douhnut chart     // can switch between pie , douhnut using method below.     piechart.doughnut(piedata, pieoptions); 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -