Php+highchats generating a dynamic chart _php instance

Source: Internet
Author: User
Copy CodeThe 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
},
[' Safari ', 8.5],
[' Opera ', 6.2],
[' Others ', 0.7]
]
}]

Mainly look at this paragraph:

Copy the Code code as follows:
{
Name: ' Chrome ',
y:12.8,
Sliced:true,
Selected:true
}

Copy the Code code as follows:




Fusioncharts







Area ();
/**
* Regional 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);
}
?>


The following is the PHP output JSON data for JS use:

Copy CodeThe 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);
$tmo 2 = round ($TMO/1024, 5);
$NetInput [$i] = $tmo 2;
$tmp = Round ($info [10][0]/1024/1024, 5);
$tmp 2 = round ($tmp/1024, 5);
$NetOut [$i] = $tmp 2;

}

$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 the Code code as follows:
{"2": {"name": "Lo", "Data": [0,0]}, "3": {"name": "Eth0", "Data": [0.40377,0.00353]}}

JS Call:

Copy the Code code as follows:
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.