php報表類別庫jpgraph長條圖產生實例

WBOY
發布: 2016-07-25 08:55:31
原創
921 人瀏覽過
  1. /**
  2. * JpGraph类生成柱状图
  3. * by bbs.it-home.org
  4. */
  5. $datay=array(); //纵坐标数据
  6. $datax=array(); //横坐标数据
  7. foreach ($usernums as $key => $value){
  8. $datay[] = $value;
  9. $datax[] = $userids[$key];
  10. }
  11. require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php');
  12. require_once (‘jpgraph-3.0.7/jpgraph/jpgraph_bar.php');
  13. // Create the graph. These two calls are always required
  14. $graph = new Graph(800,600); //图像高宽
  15. $graph->SetScale(“textlin”);
  16. $graph->xaxis->SetTickLabels($datax);
  17. $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
  18. $graph->xaxis->SetLabelAngle(30);
  19. $graph->yaxis->scale->SetGrace(20);
  20. $graph->xaxis->scale->SetGrace(20);
  21. // Add a drop shadow
  22. $graph->SetShadow();
  23. // Adjust the margin a bit to make more room for titles
  24. $graph->img->SetMargin(40,30,20,40);
  25. // Create a bar pot
  26. $bplot = new BarPlot($datay);
  27. // Adjust fill color
  28. $bplot->SetFillColor(‘orange');
  29. $bplot->value->Show();
  30. $bplot->value->SetFont(FF_ARIAL,FS_BOLD,10);
  31. $bplot->value->SetAngle(45);
  32. $bplot->value->SetFormat(‘%d');
  33. $graph->Add($bplot);
  34. // Setup the titles
  35. $graph->title->Set(iconv(“UTF-8″, “gb2312″,”用户消费报表图”));
  36. $graph->xaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户姓名”));
  37. $graph->yaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户订单数量”));
  38. $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
  39. $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
  40. $graph->title->SetFont(FF_SIMSUN,FS_BOLD);
  41. // Display the graph
  42. $graph->Stroke();
  43. ?>
复制代码

效果如下图: php報表類別庫jpgraph長條圖產生實例



來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!