PHPlot 5.3.1使用GD扩展来生成 PNG/GIF/JPEG图表

  PHPLOT 是一个用来创建图表的PHP图形类,需要 PHP5 的支持。PHPLot使用PHP的GD扩展来生成 PNG/GIF/JPEG 格式图片。

  

\

 

  该版本主要改进了多线图的支持,包括很多bug修复和文档更新。

  1. 生成上面图形的代码如下:  
  2.  
  3. # PHPlot Demo  
  4. # 2008-01-09 ljb  
  5. # For more information see http://sourceforge.net/projects/phplot/  
  6.  
  7. # Load the PHPlot class library:  
  8. require_once 'phplot.php';  
  9.  
  10. # Define the data array: Label, the 3 data sets.  
  11. # Year,  Features, Bugs, Happy Users:  
  12. $data = array(  
  13.   array('2001',  60,  35,  20),  
  14.   array('2002',  65,  30,  30),  
  15.   array('2003',  70,  25,  40),  
  16.   array('2004',  72,  20,  60),  
  17.   array('2005',  75,  15,  70),  
  18.   array('2006',  77,  10,  80),  
  19.   array('2007',  80,   5,  90),  
  20. );  
  21.  
  22. # Create a PHPlot object which will make a 600x400 pixel image:  
  23. $p = new PHPlot(600, 400);  
  24.  
  25. # Use TrueType fonts:  
  26. $p->SetDefaultTTFont('./arial.ttf');  
  27.  
  28. # Set the main plot title:  
  29. $p->SetTitle('PHPlot Customer Satisfaction (estimated)');  
  30.  
  31. # Select the data array representation and store the data:  
  32. $p->SetDataType('text-data');  
  33. $p->SetDataValues($data);  
  34.  
  35. # Select the plot type - bar chart:  
  36. $p->SetPlotType('bars');  
  37.  
  38. # Define the data range. PHPlot can do this automatically, but not as well.  
  39. $p->SetPlotAreaWorld(0, 0, 7, 100);  
  40.  
  41. # Select an overall image background color and another color under the plot:  
  42. $p->SetBackgroundColor('#ffffcc');  
  43. $p->SetDrawPlotAreaBackground(True);  
  44. $p->SetPlotBgColor('#ffffff');  
  45.  
  46. # Draw lines on all 4 sides of the plot:  
  47. $p->SetPlotBorderType('full');  
  48.  
  49. # Set a 3 line legend, and position it in the upper left corner:  
  50. $p->SetLegend(array('Features''Bugs''Happy Users'));  
  51. $p->SetLegendWorld(0.1, 95);  
  52.  
  53. # Turn data labels on, and all ticks and tick labels off:  
  54. $p->SetXDataLabelPos('plotdown');  
  55. $p->SetXTickPos('none');  
  56. $p->SetXTickLabelPos('none');  
  57. $p->SetYTickPos('none');  
  58. $p->SetYTickLabelPos('none');  
  59.  
  60. # Generate and output the graph now:  
  61. $p->DrawGraph();  
  62.  

怎么样,不错吧。。 喜欢的朋友可以到  http://phplot.sourceforge.net/ 官方站下载