Home  >  Article  >  Backend Development  >  Generate dynamic statistical charts with php+highchats_PHP tutorial

Generate dynamic statistical charts with php+highchats_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:29:29919browse

Copy code The code is as follows:

series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
                                                                                                                           : 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others' , 0.7]
                                                                             
Watch this paragraph mainly:


Copy code

The code is as follows:

{ name: 'Chrome', y: 12.8, sliced: true,
selected: true
}






Copy code
The code is as follows:


                                                                                                              utf-8">
                                                              1.8.2/jquery.min.js">
                                                           name":"u4e0au6d77","y":28.2},{"name":"u5317u4eac","y":48.2},{"name":"u5e7fu4e1c","y":18.2}];
//In fact, just display it according to the json display method in the example, such as chrome. 
            // Radialize the colors 
            Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) { 
                return { 
                    radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 }, 
                    stops: [ 
                        [0, color], 
                        [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken 
                    ] 
                }; 
            }); 
            // Build the chart 
            $('#container').highcharts({ 
                chart: { 
                    plotBackgroundColor: null, 
                    plotBorderWidth: null, 
                    plotShadow: false 
                }, 
                title: { 
                    text: 'Browser market shares at a specific website, 2010' 
                }, 
                tooltip: { 
                    pointFormat: '{series.name}: {point.percentage:.1f}%
                }, 
                plotOptions: { 
                    pie: { 
                        allowPointSelect: true, 
                        cursor: 'pointer', 
                        dataLabels: { 
                            enabled: true, 
                            color: '#000000', 
                            connectorColor: '#000000', 
                            formatter: function() { 
                                return ''+ this.point.name +': '+ this.percentage +' %'; 
                            } 
                        } 
                    } 
                }, 
                series: [{ 
                    type: 'pie', 
                    name: 'Browser share', 
                    data: ds, 
                }] 
            }); 
        }); 
             
         
         
     
     
   

area();
/**
* Region interface
* name name
* y data value
* *
*/
function area()
{
$b = array(
'name'=>'Shanghai', 'y'=>28.2),
                                 array('name'=> '=>'Guangdong', 'y'=>18.2),
       );                                               ?>
                                                               
The following is the json data output by php for use by js:




Copy code
The code is as follows:

$strs = @file("/proc/net /dev");
for ($i = 2; $i < count($strs); $i++ ) { preg_match_all( "/([^s]+):[s] {0,}(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)/", $strs[$i], $info ); /* $NetInput[$i] = formatsize($info[2][0]); $NetOut[$i] = formatsize($info[ 10][0]);
*/
$tmo = round($info[2][0]/1024/1024, 5);
$tmo2 = round($tmo / 1024, 5 );
$NetInput[$i] = $tmo2;
$tmp = round($info[10][0]/1024/1024, 5);
$tmp2 = round($tmp / 1024, 5);
$NetOut[$i] = $tmp2;

}

$arr = array();
if (false !== ($strs = @file("/proc/net/dev"))) :
for ($i = 2; $i < count($strs); $i++ ) :
preg_match_all( "/([^ s]+):[s]{0,}(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+ )s+(d+)/", $strs[$i], $info );
$arr[$i]["name"] = $info[1][0];
$arr[$ i]["data"][0] = $NetInput[$i];
$arr[$i]["data"][1] = $NetOut[$i];

endfor ;
endif;
echo(json_encode($arr));
?>



Output:




Copy code
The code is as follows:

{"2":{"name":"lo","data": [0,0]},"3":{"name":"eth0","data":[0.40377,0.00353]}}

js call:

Copy code
The code is as follows:

series: [

http://www.bkjia.com/PHPjc/774999.html
www.bkjia.com

true

http: //www.bkjia.com/PHPjc/774999.html
TechArticleCopy the code The code is as follows: series: [{ type: 'pie', name: 'Browser share', data: [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safa...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn