Using our Google Chart API to create various statistical charts, we currently support line charts, column charts, pie charts, scatter charts, Graph. The Google Charts API Code page has detailed instructions for using this API, but it is still a bit cumbersome. Today I found that someone has developed a PHP statistical chart class in this area, and it also includes three examples. I will choose an example and combine it with one of my own projects to explain how to use it:
- < ?php include( 'GoogChart.class.php' ) ;
- // Import Google Chart API class
- $
- chart = new GoogChart(); //Instantiate a GoogChart object
- $
- servers = get_max_servers(); //Get 17fav.com collection service ranking
- $
- data = array(); // Initialization data foreach ($servers as $server) {
- $data["$server-
- >server_name"] = $server->
server_number/100; // The reason for excluding 100 here is that during testing, it was found that the Chart API does not support the value of
-
>=100. }
- $
- color = array( '#FF6600′,
- '#FFB380′,
- '#FFD9BF',
- '#DFBEA7′,
- '#BF8660′ ,
- '#AA6639′,
- ); //Set the color of the image
- $chart-
-
>setChartAttrs( array( 'type' =
-
> 'pie', // Pie chart 'title' =
-
> 'Collect & Share', // Image name 'data ' =
-
> $data, // Image data 'size' =
-
> array(468, 300), // Image size 'color' =
-
> $color // Image color )) ;
- echo $chart; // Output image
?>-
The above is the specific implementation method of the PHP statistical chart class.
http://www.bkjia.com/PHPjc/445920.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445920.htmlTechArticleWe can use the Google Chart API to create various statistical charts. Currently, we support line charts, column charts, Pie charts, scatter plots, line graphs. The Google Charts API Code page has this...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn