Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Donut chart in PHP

    var employees = $("#employees").val();
    //var fairs     = $("#fairs").val();

    $.ajax({

        url     : 'php_script/chart_values.php',
        method  : 'POST',
        data    : {employees:employees},

        success : function(data){
            $("#page_content").fadeIn();
            $("#bar_chart_div").fadeOut();
            var obj = JSON.parse(data);

            var a = obj[0]; // labele data "Won","Contracted","Intersted"
            var b = obj[1]; // label values "100","90","70"
            var labeldata=[];
            for( i=0; i<a.length;i++){ 

                labeldata.push({label:a[i],y:parseInt(b[i]),legendText:a[i]});
            }

            debugger;
           console.log(JSON.stringify(labeldata));

            var chart = new CanvasJS.Chart("chartContainer", {
                title: { 

                    fontSize:15
                }, 
                axisY: { 
                    title: "Products in %" 
                }, 
                legend :{ 
                    verticalAlign: "center", 
                    horizontalAlign: "right" 
                },
                data: [{
                type: "pie", 
                showInLegend: true, 
                toolTipContent: "{label} <br/> {y} ", 
                indexLabel: "{y} %", 
                dataPoints: labeldata



        }] 
}); 
chart.render();



        }

    });

});
Comment

PREVIOUS NEXT
Code Example
Php :: Stopping On First Validation Failure 
Php :: config in php 
Php :: wp php blog info background image 
Php :: laravel-websockets 403 forbidden error 
Php :: import csv to laravel 
Php :: laravel collection load 
Php :: how to remove words in contain integer php 
Php :: remove public from url laravel 7 
Php :: Drupal 9 check if UUD is valid 
Php :: app/Controllers/Home.php 
Php :: wordpress microformats vs. schema.org 
Php :: Allow mass assignment in Laravel 
Php :: dot after each character php 
Php :: prevent undefined offset php 
Php :: "A non well formed numeric value encountered 
Php :: php sort array 
Php :: php calculate age as float 
Php :: session flash data (old input) 
Php :: laravel components scripts 
Php :: larvel still laod the local file location on production 
Php :: Drupal 9 select node data with query conditions using entity type manager 
Php :: onde fica o php ini ubuntu 
Php :: undefined variable require_once 
Php :: how to set db table type in laravel 
Php :: dir_instalación_Zend_Studiopluginscom.zend.php.debug.debugger.win32.x86_10.6.0.v20140121-1240 esourcesphp.ini 
Php :: how to get last 10 digit from number in php 
Php :: datetime confict function php 
Php :: How to get only content-length with CURL PHP? 
Php :: Get page title, excerpt or content by Name of the Page 
Php :: Lavavel nova toggle 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =