In-depth explanation of PHP statistical charts _ PHP Tutorial

Source: Internet
Author: User
In-depth explanation of PHP statistical charts. You can use GoogleChartAPI to create various statistical charts. Currently, linear charts, column charts, pie charts, scatter plots, and graphs are supported. The GoogleChartsAPICode page is correct.

The Google Chart API can generate various statistical charts. Currently, linear charts, column charts, pie charts, scatter charts, and graphs are supported. The Google Charts API Code page provides detailed instructions on the use of this API, but it is still a little tedious. Today, I found that someone has developed a PHP statistical chart class in this area. There are also three examples. I will pick an example and explain how to use it in combination with my own project:

  1. <? Php
  2. Include ('googchart. class. php ');
  3. // Import the Google Chart API class
  4. $ Chart = new GoogChart ();
  5. // Instantiate a GoogChart object
  6. $ Servers = get_max_servers ();
  7. // Obtain the ranking of the 17fav.com favorites service
  8. $ Data = array (); // initialize data
  9. Foreach ($ servers as $ server ){
  10. $ Data ["$ server->Server_name "] = $ server->
    Server _number/100;
  11. // Except 100, it is found during the test.
    Chart API not supported>= A value of 100.
  12. }
  13. $ Color = array (
  14. '# FF6600 ′,
  15. '# Ffb380 ′,
  16. '# FFD9BF ',
  17. '# DFBEA7 ′,
  18. '# Bf8660 ′,
  19. '# Aa6639 ′,
  20. ); // Set the image color
  21. $ Chart->SetChartAttrs (array (
  22. 'Type' =>'Pie', // pie chart
  23. 'Title' =>'Favorites & Sharing ', // image name
  24. 'Data' =>$ Data, // image data
  25. 'Size' =>Array (468,300), // Image size
  26. 'Color' =>$ Color // image color
  27. ));
  28. Echo $ chart; // output image
  29. ?>

The above is the specific implementation method of the PHP statistical chart class.


Google Chart API can generate various statistical charts. Currently, linear charts, column charts, pie charts, scatter charts, and graphs are supported. Google Charts API Code page has this...

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.