php报表类库jpgraph柱状图生成实例

WBOY
Libérer: 2016-07-25 08:55:31
original
892 Les gens l'ont consulté
  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. ?>
复制代码

效果如下图: JpGraph生成柱状图



source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!