Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn how to implement the flash PIE analysis graph code instance in the area of simulation traffic statistics.
Today we will share with you a pie distribution chart of the flash animation effect. Users who have used traffic statistics know that the regional distribution chart in the traffic statistics is awesome. When you move the cursor to a certain area, the area will be automatically separated. As shown in the following figure:
The data table and plug-in used in this paper: http://www.jb100.net/html/content-28-373-1.html
Download the required data from the above address, import the data table to the database, and put the charts file in the public folder.
Let's talk about the Code directly. PHP code:
Public function fenbu (){
$ This-> checkuser ('stats _ dq ');
$ End_date = strtotime (date ('Y-m-d', time ()));
$ Start_date = $ end_date-31536000;
$ Area_xml =" ";
$ SQL = "SELECT COUNT (*) AS access_count, area FROM ja_stats ".
"WHERE access_time> = '$ start_date' AND access_time <". ($ end_date + 86400 ).
"Group by area order by access_count desc limit 20 ";
$ Res = M ('stats')-> query ($ SQL );
$ Key = 0;
Foreach ($ res as $ val ){
$ Area = empty ($ val ['region'])? 'Unknow': $ val ['region'];
$ Area_xml. =" Chart_color ($ key). "'/> ";
$ Key ++;
}
$ Area_xml. =' ';
$ From_xml =" ";
$ SQL = "SELECT COUNT (*) AS access_count, source_url FROM ja_stats ".
"WHERE access_time> = '$ start_date' AND access_time <=". ($ end_date + 86400 ).
"Group by source_url order by access_count desc limit 20 ";
$ Res = M ('stats')-> query ($ SQL );
$ Key = 0;
Foreach ($ res as $ val ){
$ From = empty ($ val ['source _ url'])? 'Enter the url directly ': $ val ['source _ url'];
$ From_xml. =" Chart_color ($ key). "'/> ";
$ Key ++;
}
$ From_xml. =' ';
$ This-> assign ('from _ data', $ from_xml );
$ This-> assign ('area _ data', $ area_xml );
$ This-> display ();
}
Public function chart_color ($ n ){
/* Randomly display the color code */
$ Arr = array ('33ff66', 'ff6600 ', '3399ff', '000000', 'cc3399', 'ffcc33', '6699cc', 'cc3366 ', '33ff66', 'ff6600 ', '3399ff ');
If ($ n> 8 ){
$ N = $ n % 8;
}
Return $ arr [$ n];
}
HTML code:
Regional distribution
The data table and plug-in used in this paper: http://www.jb100.net/html/content-28-373-1.html
I hope this article will help you, and I hope you will continue to follow me!
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB