liupengcheng201的专栏

一、Jpgraph安装配置

下载Jpgraph安装包

二、Jpgraph说明

1、包含所需要的类库文件require_once();

2

3、创建

4、将数据添加到图形上$graph->Add();

5、显示图片$graph->Stroke();

中文字体乱码问题

Gpgraph默认显示汉字时是把汉字编码认为,如果文件的编码方式是gb2312

如果是

转换编码方式可以使用iconv("UTF-8","gb2312",$x);

一些常用的方法:

$graph->title->Set(‘设置图表的标题’);

$graph->tabtitle->Set(‘设置图片头部文字’);$graph->xaxis->title->Set("设置X轴的标题");$graph->yaxis->title->Set("设置Y轴的标题");

$graph->SetScale(‘textlin’);//设置刻度值类型

$graph->img->SetMargin(50,40,40,55);//边框间距(左右上下)

$graph->title->SetFont(FF_SIMSUN,FS_BOLD,12);//标题字体

$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD,10);

$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD,10);

$graph->xaxis->SetFont(FF_SIMSUN,FS_BOLD,12);//坐标柱上的字体

$graph->yaxis->SetFont(FF_SIMSUN,FS_BOLD,12);

$graph->title->SetColor(‘red’);///标题颜色

$graph->xaxis->title->SetColor(‘red’);

$graph->yaxis->title->SetColor(‘red’);

$graph->xaxis->title->SetMargin(20);//距离坐标轴的距离$graph->yaxis->title->SetMargin(20);//

$linepot->SetColor(‘red’);//折线的颜色(折线图)

$linepot->SetWeight(2);//折线的宽度

$linepot->value->SetFormat(‘%0.1f’);//值的格式化

$linepot->value->show(true);//显示值

$graph->SetBackGroundImage();设置背景

$graph->SetMarginColor(‘lightblue’);//设置图形颜色

$graph->SetShadow();//

$graph->Set3DPerspecttive();//

$p1->SetTheme(‘water’);//设置样式

$p1->SetCenter(0.5,0.55);//设置图形位置

$graph->legend->Pos(0.1,0.9);//设置注释文字的位置

$graph->legend->SetFont(FF_SIMSUN,FS_BOLD,12);//设置注释文字的字体

给出一个能事例

gradline.php

<?php // content="text/plain; charset=utf-8"require_once ('jpgraph/jpgraph.php');require_once ('jpgraph/jpgraph_line.php');$graph = new Graph($nLenth,$nWeith);$graph->SetMargin(80,60,60,60);$graph->SetScale("intlin");$graph->SetBox();$graph->SetMarginColor('darkgreen@0.8');//设置标题$graph->title->Set(iconv("UTF-8","GB2312//IGNORE",$title));$graph->title->SetFont(FF_SIMSUN,FS_BOLD);// Setup a background gradient image$graph->SetBackgroundGradient('darkred','yellow',GRAD_HOR,BGRAD_PLOT);$graph->xaxis->SetTickLabels($datax);$graph->yscale->SetAutoMin(0);$graph->xaxis->title->Set(iconv("UTF-8","GB2312//IGNORE",$xtitle)); $graph->yaxis->title->Set(iconv("UTF-8","GB2312//IGNORE",$ytitle));///标题颜色$graph->title->SetColor('red');$graph->xaxis->title->SetColor('red');$graph->yaxis->title->SetColor('red');// Create the line$p1 = new LinePlot($datay);$p1->SetFillGradient('white','darkgreen');$graph->Add($p1);// Output line$graph->Stroke();?>onlineGraph.php

<?php$datax = json_decode($_GET['datax']);$datay = json_decode($_GET['datay']);$nLenth = 1300;$nWeith = 400;$title = "在线玩家统计";$xtitle = "time";$ytitle = "count";include_once "gradline.php";

,喜欢真实的人,要做真实的人,所以从来不会想要刻意模仿任何人。

liupengcheng201的专栏

相关文章:

你感兴趣的文章:

标签云: