Implement the flash PIE analysis graph code instance for area distribution of traffic statistics

Source: Internet
Author: User
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

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.