Jpgraph创建柱状图展示年度收支情况

来源:互联网 发布:java数据导出到excel 编辑:程序博客网 时间:2024/05/18 02:13

一 代码

<?phprequire_once 'src/jpgraph.php';     //导入Jpgraph类库require_once 'src/jpgraph_bar.php';     //导入Jpgraph类库的柱状图功能$data = array(80, 73, 89, 85, 92, 75 ,85 ,65, 84, 79, 85, 98);     //设置统计数据$graph = new Graph(600, 300);     //设置画布大小$graph->SetScale('textlin');     //设置坐标刻度类型$graph->SetShadow();    //设置画布阴影$graph->img->SetMargin(40, 20, 20, 40);    //设置统计图边距$barplot = new BarPlot($data);    //实例化BarPlat对象$barplot->SetFillColor('blue');    //设置柱形图前景色$barplot->value->Show();$graph->Add($barplot);$graph->title->Set('吉林省***科技有限公司年度收支');     //设置统计图标题$graph->xaxis->title->Set('月份');     //设置X轴名称$graph->yaxis->title->Set('总金额(万元)');     //设置y轴名称$graph->title->SetFont(FF_SIMSUN, FS_BOLD);     //设置标题字体$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);    //设置X轴字体$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);    //设置Y轴字体$graph->Stroke();     //输出图像

 

二 运行结果

 
  • 大小: 11.1 KB
  • 查看图片附件