PHP 画图——使用jpgraph画图
假设是在window下首先须要改动文件的路径
改动jpgraph_ttf.inc.php文件
$jpgraph_font_dir = dirname(__FILE__).'\\fonts\\';//改动字体的路径从原来的/fonts/ 改为 \\fonts\\
假设没改动在windows下会报以下的错误
解决中文问题:
假设你的文件编码为utf-8,改动方法例如以下
方法一:
找到
elseif( $aFF === FF_SIMSUN) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
改动为
elseif( $aFF === FF_SIMSUN) {
// Do Chinese conversion
/*
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
*/
return $aTxt;
}
方法二:在程序中改动
$title="流量图";
$title = iconv("UTF-8", "gb2312", $title);
$graph->title->Set($title);
注:
jpgraph默认显示汉字时是把汉字编码觉得gb2312,转化为utf-8以后再显示。
这种话,假设你的文件编码是gb2312,SetFont方法的第一个參数为FF_SIMSUN就可以。
假设你是utf-8编码你还须要先把汉字编码转化为gb2312。这样你的汉字才干够正常显示。
代码例如以下:
<?php /** * 使用jpgraph生成3D饼图 * */ include 'src/jpgraph.php'; include 'src/jpgraph_pie.php'; include 'src/jpgraph_pie3d.php';//引用3D饼图pieplot3D对象所在的类文件
$result = array(5,8,11,1,1,1); $vote_content = array("张三","丽丽","lili","张三","丽丽","lili"); $title = '标题';
$graph = new PieGraph(500,245);//创建图像 $graph->SetShadow();//创建图像阴影 $graph->tabtitle->SetFont(FF_SIMSUN,FS_BOLD,14);//设置标题字体 $graph->tabtitle->Set($title);//输出标题 $graph->title->SetColor("darkblue");//定义标题颜色
$p1 = new PiePlot3D($result);//创建图像 //$p1->SetTheme("water");//控制图像的颜色 //$p1->SetCenter(0.4);//设置图像位置 //$p1->SetSize(0.4);//设置图像的大小 //$p1->SetHeight(20);//设置饼图的高度 //$p1->SetAngle(45);//设置图像的倾斜角度 //$p1->Explode(array(5,40,10,30,20));//控制饼图的切割 //$p1->value->SetFont(FF_SIMSUN,FS_BOLD,20);//设置字体 /* 凝视文字 */ $p1->SetLegends($vote_content); $graph->legend->SetFont(FF_SIMSUN,FS_BOLD);//设置凝视文字字体 $graph->legend->Pos(0.05,0.3,"right","center");//控制凝视文字的位置 $graph->legend->SetShadow();//边界 $graph->legend->SetLayout(LEGEND_VERT);//设置图例样式和位置
$graph->Add($p1);//加入数据 $graph->Stroke();//生成图像
- PHP使用jpgraph画图,以柱状图为例
- 【php】使用jpgraph完成投票系统的普通用户部分
- php使用Jpgraph绘制简单X-Y坐标图的方法
- 使用jpgraph画图
- PHP绘图入门以及JPGraph库的使用
- JpGraph php柱状图使用介绍
- php使用Jpgraph绘制3D饼状图的方法
- php使用Jpgraph绘制饼状图的方法
- php使用Jpgraph创建折线图效果示例
- php使用Jpgraph创建柱状图展示年度收支表效果示例
- PHP 中 GD库(以及Jpgraph库) 的配置和使用。(满屏荒唐言,一把辛酸泪)
- PHP画图之GD库的使用——介绍、安装(一)
- php JpGraph使用和中文乱码
- php中jpgraph类库的使用介绍
- php JpGraph使用和中文乱码
- php使用Jpgraph绘制饼状图的方法
- php使用Jpgraph绘制复杂X-Y坐标图的方法
- php使用Jpgraph创建3D饼形图效果示例
- PHP图标类库 - JpGraph使用详解
- PHP 绘图——使用jpgraph绘图