请选择 进入手机版 | 继续访问电脑版
绿茶科技社区

PHP生成折线图和饼图等

2019-11-22 01:41
1563
pchart类库下载(地址:http://pchart.sourceforge.net/documentation.php) , 下载过后其中也有相应的例子,供选择
生成折线图
  1. include("pChart/pData.class");  

  2. include("pChart/pChart.class");  

  3. // Dataset definition

  4. $DataSet = new pData;

  5. $DataSet->AddPoint(array(100,320,200,10,43),"Serie1");

  6. $DataSet->AddPoint(array(20190726,20190727,20190728,20190729,20190730),"Serie3");

  7. $DataSet->AddSerie("Serie1");

  8. $DataSet->SetAbsciseLabelSerie("Serie3");

  9. // Initialise the graph   

  10. $Test = new pChart(700,230);

  11. $Test->setFontProperties("Fonts/tahoma.ttf",8);

  12. $Test->setGraphArea(85,30,650,200);

  13. $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);

  14. $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);

  15. $Test->drawGraphArea(255,255,255,TRUE);

  16. $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);

  17. $Test->drawGrid(4,TRUE,230,230,230,50);

  18. $Test->setFontProperties("Fonts/tahoma.ttf",6);

  19. $Test->drawTreshold(0,143,55,72,TRUE,TRUE);

  20. $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());

  21. $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);

  22. //生成图表

  23. $imageFile = "1.png";

  24. $Test->Render($imageFile);

  25. echo '<img src="'.$imageFile.'">';
复制代码


分享到 :
0 人收藏

3 个回复

倒序浏览
Dragon龙  高级会员 | 2019-11-22 01:52:53
好帖必须得顶起
施杨  金牌会员 | 2019-12-8 12:25:10
路过 帮顶 嘿嘿
EtherDream  高级会员 | 2019-12-15 10:22:00
鄙视楼下的顶帖没我快,哈哈
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

举报|Archiver|手机版|小黑屋|Lvchakeji Inc.  

Powered by Discuz! X3.3 © 2001-2016 Comsenz Inc.

返回顶部