Heim  >  Artikel  >  Backend-Entwicklung  >  深入解读PHP统计图表类_PHP教程

深入解读PHP统计图表类_PHP教程

WBOY
WBOYOriginal
2016-07-15 13:35:111527Durchsuche

用我们通过对

Google Chart API 可以制出各种统计图表,当前支持线形图、柱形图、饼形图、散点图、曲线图。Google Charts API Code 页面有对这个 API 使用的详细说明,但是还略显繁琐。今天发现有人开发了一个这个方面的PHP统计图表类,并且还包括三个例子,我就挑选一个例子结合自己的一个项目给大家讲解下如何使用:

  1.  ?php   
  2. include( ’GoogChart.class.php’ ); 
  3. // 导入 Google Chart API 类   
  4. $chart = new GoogChart(); 
  5. //实例化一个 GoogChart 对象   
  6. $servers = get_max_servers(); 
  7. //获取 17fav.com 收藏服务排名   
  8. $data = array(); // 初始化数据   
  9. foreach ($servers as $server){   
  10. $data["$server->server_name"] = $server->
    server_number/100; 
  11. // 这里除 100是因为测试的时候发现 
    Chart API 不支持 
    >=100 的数值。   
  12. }   
  13. $color = array(   
  14. ’#FF6600′,   
  15. ’#FFB380′,   
  16. ’#FFD9BF’,   
  17. ’#DFBEA7′,   
  18. ’#BF8660′,   
  19. ’#AA6639′,   
  20. ); //设置图像的颜色   
  21. $chart->setChartAttrs( array(   
  22. ’type’ => ’pie’, // 饼形图   
  23. ’title’ => ’收藏 & 分享’, // 图像名称   
  24. ’data’ => $data, // 图像数据   
  25. ’size’ => array(468, 300), // 图像大小   
  26. ’color’ => $color // 图像颜色   
  27. ));   
  28. echo $chart; // 输出图像   
  29. ?>  

以上就是PHP统计图表类的具体实现方法。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445920.htmlTechArticle用我们通过对 Google Chart API 可以制出各种统计图表,当前支持线形图、柱形图、饼形图、散点图、曲线图。Google Charts API Code 页面有对这个...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn