Highchats and PHP combine to generate dynamic statistics graphs

Source: Internet
Author: User
Tags array count json net return




Series: [{
            type: ' Pie ',
            name: ' Browser share ',
            data: [
                ' Firefox ',   45.0],
                [' IE ',       26.8],
                {
                    name: ' Chrome ',
                    y:12.8,
                    sliced:true,
                    selected:true
                },
                [' Safari ',    8.5],
                [' Opera ',     6.2],
                [' Others ',   0.7]
            ]
        }]

Mainly look at this paragraph:

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


	
		
 
  
 
		<title>Fusioncharts</title>

		<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" ></ script> <script type= "Text/javascript" > $ (function () {var ds = [{"Name": "\u4e0a\u6d77", "Y": 28.2},{"name": "\u
5317\u4eac "," Y ": 48.2},{" name ":" \u5e7f\u4e1c "," Y ": 18.2}];
    	
    	In fact, just follow the example in the JSON display way to show the line, 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,}]};
    

		}); </script>
	<script src= "Js/hc.js" ></script> <script src= "Js/modules/exporting.js" ></script>
 -->' Shanghai ', ' y ' =>28.2 ', Array (' name ' => ' Beijing ', ' y ' =>48.2), Array (' name ' => ' Guangdong ', ' y ' =>18.2),);
	$data = Json_encode ($b);
Echo ($data); }?>


Here is the PHP output JSON data for JS use:

 -->
Output:
{"2": {"name": "Lo", "Data": [0,0]}, "3": {"name": "Eth0", "Data": [0.40377,0.00353]}


JS call:
Series: [
						ds[2], ds[3]
					]



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.