PHPlot 介绍
PHPLOT 是一个用来创建图表的PHP图形类,需要 PHP5 的支持。PHPLot使用PHP的GD扩展来生成 PNG/GIF/JPEG 格式图片。
`# PHPlot Demo
2008-01-09 ljb
For more @R_143_4045@ion see http://sourceforge.net/projects/phplot/
Load the PHPlot class library:
Define the data array: Label, the 3 data sets.
Year, Features, Bugs, Happy Users:
$data = array(
array(‘2001’, 60, 35, 20),
array(‘2002’, 65, 30, 30),
array(‘2003’, 70, 25, 40),
array(‘2004’, 72, 20, 60),
array(‘2005’, 75, 15, 70),
array(‘2006’, 77, 10, 80),
array(‘2007’, 80, 5, 90),
);
Create a PHPlot object which will make a 600x400 pixel image:
$p = new PHPlot(600, 400);
Use TrueType fonts:
$p->SetDefaultTTFont(‘./arial.ttf’);
Set the main plot title:
$p->SetTitle(‘PHPlot Customer Satisfaction (estimated)’);
Select the data array representation and store the data:
$p->SetDataType(‘text-data’);
$p->SetDataValues($data);
Select the plot type - bar chart:
$p->SetPlottype(‘bars’);
Define the data range. PHPlot can do this automatically, but not as well.
$p->SetPlotAreaWorld(0, 0, 7, 100);
Select an overall image background color and another color under the plot:
$p->SetBackgroundColor(‘#ffffcc’);
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor(‘#ffffff’);
Draw lines on all 4 sides of the plot:
$p->SetPlotBorderType(‘full’);
Set a 3 line legend, and position it in the upper left corner:
$p->SetLegend(array(‘Features’, ‘Bugs’, ‘Happy Users’));
$p->SetLegendWorld(0.1, 95);
Turn data labels on, and all ticks and tick labels off:
$p->SetXDataLabelPos(‘plotdown’);
$p->SetXTickPos(‘none’);
$p->SetXTickLabelPos(‘none’);
$p->SetYTickPos(‘none’);
$p->SetYTickLabelPos(‘none’);
Generate and output the graph Now:
$p->DrawGraph();`
PHPlot 官网
http://phplot.sourceforge.net/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。