Graphical data with Flash (2)

Source: Internet
Author: User
How can we bake cookies )?? After successfully installing ShockwaveFlash support in php (as the mainstream development language), you can use php (as the mainstream development language) to create Shockwave files. The best way to learn is to directly jump to the program, so let's look at the program below. The first package SyntaxHighligh lets us bake cookies (pie charts)
?? After successfully installing Shockwave Flash support in php (as the mainstream development language), you can use php (as the mainstream development language) to create Shockwave files. The best way to learn is to directly jump to the program, so let's look at the program below. The first file includes sample code for how to use the class, and shows how to embed a Flash file into an HTML document.


// Include class needed for flash graph
Include ("class. pie. flash. php (as the mainstream development language )");

MySQL (the best combination with PHP) _ connect ("localhost", "root ","");

$ Query = "select distinct city_name, COUNT (city_id)
FROM city
Group by city_name ;";

$ Result = MySQL (the best combination with PHP) _ db_query ("hermes", $ query );

While ($ row = MySQL (the best combination with PHP) _ fetch_array ($ result )){
$ City_counts [] = $ row ["COUNT (city_id)"];
$ City_names [] = $ row ["city_name"];
}

MySQL (the best combination with PHP) _ free_result ($ result );

// Instantiate new object
$ Graph = new flash_pie ($ city_counts, "city.swf ");

// Set graph title (shocould not exceed about 25 characters)
$ Graph-> pie_title ("City Results", 30 );

// Set graph legend
$ Graph-> pie_legend ($ city_names );

// Show graph
$ Graph-> show ();

// Free resources
$ Graph-> close ();

?>










Type = "application/x-shockwave-flash" width = 600 height = 300>







Class flash_pie {

// Class variables

// Setup some global colors
Var $ r_arr = array (0.1, 1, 0, 1, 0, 1, 0.388235294, 0.4, 0.388235294, 0.929411765 );
Var $ g_arr = array (1, 0, 0, 1, 1, 0, 0.8, 0.4, 0.8, 0.439215686 );
Var $ B _arr = array (0.25, 0, 1, 0, 1, 1, 1, 0.4, 1, 0.043137255 );

Var $ percents;

Function flash_pie ($ values, $ this_file) {// begin constructor
// To write out code directly to browser, set content header and use "php (as the mainstream development language): // stdout"
// Swf_openfile ("php (as the mainstream development language): // stdout", 700,250, 30, 1, 1 );
// Header ("Content-type: application/x-shockwave-flash ");

Swf_openfile ($ this_file, 1000,450, 30, 1, 1, 1 );

// Set up viewport for flash movie
Swf_ortho2 (-400,300,-90,250 );

// Choose the font we will use for pie graph
Swf_definefont (10, "Mod ");

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.