标签:
<?php
require_once 'jpgraph/src/jpgraph.php'; //导入Jpgraph类库
require_once 'jpgraph/src/jpgraph_bar.php'; //导入Jpgraph类库的柱状图功能
$data = array(80, 73, 89, 43, 56, 76, 89, 96, 93, 30, 98, 78); //设置统计数据
$xdata = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$graph = new Graph(600, 300); //设置画布大小
$graph->SetScale('textlin'); //设置坐标刻度类型
$graph->SetShadow(); //设置画布阴影
$graph->img->SetMargin(40, 30, 20, 40); //设置统计图边距
$barplot = new BarPlot($data); //实例化BarPlot对象
$barplot->SetFillColor('blue'); //设置柱状图前景色
$barplot->value->Show(); //显示
$graph->Add($barplot);
$graph->title->Set(iconv('utf-8', 'GB2312//IGNORE','***科技有限公司年度收支'));//设置标题iconv防止中文乱码
$graph->xaxis->title->Set(iconv('utf-8', 'GB2312//IGNORE','月份')); //设置X轴名称
$graph->xaxis->SetTickLabels($xdata);//设置x轴标注
$graph->yaxis->title->Set(iconv('utf-8', 'GB2312//IGNORE','总金额(万元)')); //设置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(); //输出图像标签:
原文地址:http://blog.csdn.net/qq_28602957/article/details/52116854