Home > php教程 > PHP源码 > body text

jpgraph 图表

PHP中文网
Release: 2016-05-25 16:58:47
Original
1033 people have browsed it

1. [代码][PHP]代码   

<?php
// header("Content-type: image/jpg");
error_reporting(E_ALL ^ E_NOTICE);
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
 $data2y=array(10,10,10,15,10,10);
$graph = new Graph(600,300,"auto");	//创建画布
$graph->SetScale(&#39;textlin&#39;,0,60);  // 设置y轴的值   这里是0到60
//$graph->SetScale("textlin");
// $graph->yaxis->scale->SetGrace(0,60);
//创建画布阴影
$graph->SetShadow();
$graph->img->SetMargin(40,30,30,40);//设置显示区左、右、上、下距边线的距离,单位为像素
$bplot = new BarPlot($data2y);//创建一个矩形的对象
$bplot->SetFillColor(&#39;red&#39;);	//设置柱形图的颜色
$bplot->value->Show();//设置显示数字	
$bplot->value->SetFormat(&#39;%d&#39;);//在柱形图中显示格式化的评选结果
$graph->Add($bplot);//将柱形图添加到图像中
$graph->SetMarginColor("lightblue");//设置画布背景色为淡蓝色
$graph->title->Set("评选结果");//创建标题
$vote_content=array(&#39;巴西&#39;,&#39;阿根廷&#39;,&#39;法国&#39;,&#39;瑞士&#39;,&#39;厄瓜多尔&#39;,&#39;德国&#39;);
$graph->xaxis->SetTickLabels($vote_content); //设置X坐标轴文字
$graph->title->SetFont(FF_SIMSUN);//设置字体
$graph->xaxis->SetFont(FF_SIMSUN); //设置字体
// $graph->Stroke();//输出矩形图表
 $graph->Stroke();
?>
Copy after login

                                                                        

2. [图片] test.php.png    

           

jpgraph 图表

                                           

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template