Copy codeThe Code is as follows:
Series :[{
Type: 'pie ',
Name: 'browser share ',
Data :[
['Firefox, 45.0],
['Ie', 26.8],
{
Name: 'chromi ',
Y: 12.8,
Sliced: true,
Selected: true
},
['Safari, 8.5],
['Opera, 6.2],
['Others, 0.7]
]
}]
Mainly refer to this section:
Copy codeThe Code is as follows:
{
Name: 'chromi ',
Y: 12.8,
Sliced: true,
Selected: true
}
Copy codeThe Code is as follows:
<! Doctype html>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<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": "\ u5317 \ u4eac", "y ": 48.2 },{ "name": "\ u5e7f \ u4e1c", "y": 18.2}];
// In fact, you only need to display the result in json format, 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
$ ('# Iner'). highcharts ({
Chart :{
PlotBackgroundColor: null,
PlotBorderWidth: null,
PlotShadow: false
},
Title :{
Text: 'browser market shares at a specific website, 100'
},
Tooltip :{
PointFormat: '{series. name }:< B> {point. percentage:. 1f }%</B>'
},
PlotOptions :{
Pie :{
AllowPointSelect: true,
Cursor: 'pointer ',
DataLabels :{
Enabled: true,
Color: '#000000 ',
ConnectorColor: '#000000 ',
Formatter: function (){
Return '<B>' + this. point. name + '</B>:' + this. percentage + '% ';
}
}
}
},
Series :[{
Type: 'pie ',
Name: 'browser share ',
Data: ds,
}]
});
});
</Script>
</Head>
<Body>
<Script src = "js/hc. js"> </script>
<Script src = "js/modules/exporting. js"> </script>
<Div id = "container" style = "min-width: 310px; height: 400px; margin: 0 auto"> </div>
<? Php
Area ();
/**
* Region Interface
* Name
* Y Data Value
*
*/
Function area ()
{
$ B = array (
Array ('name' => 'shanghai', 'y' => 28.2 ),
Array ('name' => 'beijing', 'y' => 48.2 ),
Array ('name' => 'guangdong ', 'y' => 18.2 ),
);
$ Data = json_encode ($ B );
Echo ($ data );
}
?>
</Body>
</Html>
Below is the json data output by php for js:
Copy codeThe Code is as follows:
<? Php
$ 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 + )/", $ strs [$ I], $ info );
/* $ NetInput [$ I] = formatsize ($ info [2] [0]);
$ NetOut [$ I] = formatsize ($ info [10] [0]);
*/
$ Tmo = round ($ info [2] [0]/1024/1024, 5 );
$ Tmo 2 = 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 + )/", $ 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 codeThe Code is as follows:
{"2": {"name": "lo", "data": [0, 0]}, "3": {"name": "eth0", "data ": [0.40377, 0.00353]}
Js call:
Copy codeThe Code is as follows:
Series :[
<Span style = "white-space: pre"> </span> ds [2], ds [3]
<Span style = "white-space: pre"> </span>]