【原创】jpgraph中文乱码问题的解决
2014-03-17 14:44
375 查看
php jpgraph库非常强大,可以在后台生成图片
后台生成在需要导出图表型报告的时候非常有用,当然,前端的可视化还是要用highcharts/echarts/anycharts等类库
比较麻烦的是中文乱码问题,有3个地方乱码:
legend
setStickLabels
title
先说明下我的环境和版本:
Ubuntu12.04
PHP 5.3.10-1
Jpgraph 3.5.0b1
文件fileencoding=utf-8
记得下载一份 simsun.ttc 放到 /usr/share/fonts/truetype
原创文章,转载请注明:http://www.cnblogs.com/phpgcs/
上面的解决方法,我是参考了:
http://blog.csdn.net/yiping1980/article/details/6023144
然后后面的2个我认为就是找到title/stickLabels源码的地方,将 FF_DEFAULT 改为 FF_SIMSUN 即可
后来证明果然是这样,而且方便的是 这2个家伙都在 jpgraph.php 文件中
直接
就搞定了
还有个地方也有FF_DEFAULT,
修改 jpgraph_ttf.inc.php, $aFF === FF_SIMSUN 则直接返回 $aTx
原创文章,转载请注明:http://www.cnblogs.com/phpgcs/
后台生成在需要导出图表型报告的时候非常有用,当然,前端的可视化还是要用highcharts/echarts/anycharts等类库
比较麻烦的是中文乱码问题,有3个地方乱码:
legend
setStickLabels
title
先说明下我的环境和版本:
Ubuntu12.04
PHP 5.3.10-1
Jpgraph 3.5.0b1
文件fileencoding=utf-8
Legend 乱码
//jpgraph_legend.inc.php 3 class Legend { 2 public $txtcol=array(); 1 //public $font_family=FF_DEFAULT,$font_style=FS_NORMAL,$font_size=8; // old. 12 0 public $font_family=FF_SIMSUN,$font_style=FS_NORMAL,$font_size=8; // old. 12
记得下载一份 simsun.ttc 放到 /usr/share/fonts/truetype
//jpgraph_ttf.inc.php 9 elseif( $aFF === FF_SIMSUN ) { 8 // Do Chinese conversion 7 /* 6 if( $this->g2312 == null ) { 5 include_once 'jpgraph_gb2312.php' ; 4 $this->g2312 = new GB2312toUTF8(); 3 } 2 return $this->g2312->gb2utf8($aTxt); 1 */ 0 return $aTxt; 1 }
原创文章,转载请注明:http://www.cnblogs.com/phpgcs/
上面的解决方法,我是参考了:
http://blog.csdn.net/yiping1980/article/details/6023144
然后后面的2个我认为就是找到title/stickLabels源码的地方,将 FF_DEFAULT 改为 FF_SIMSUN 即可
后来证明果然是这样,而且方便的是 这2个家伙都在 jpgraph.php 文件中
直接
:%s/FF_DEFAULT/FF_SIMSUN/g
就搞定了
title 乱码
2 $this->title = new Text(); 1 $this->title->ParagraphAlign('center'); 0 //$this->title->SetFont(FF_DEFAULT,FS_NORMAL); //FF_FONT2, FS_BOLD 1 $this->title->SetFont(FF_SIMSUN,FS_NORMAL); //FF_FONT2, FS_BOLD
stickLables 乱码
5 class AxisPrototype { 4 public $scale=null; 3 public $img=null; 2 public $hide=false,$hide_labels=false; 1 public $title=null; 0 public $font_family=FF_DEFAULT,$font_style=FS_NORMAL,$font_size=8,$label_angle=0;
还有个地方也有FF_DEFAULT,
5 class DisplayValue { 4 public $margin=5; 3 public $show=false; 2 public $valign='',$halign='center'; 1 public $format='%.1f',$negformat=''; 0 private $ff=FF_DEFAULT,$fs=FS_NORMAL,$fsize=8;
总结:
找到相关的源码(FF_DEFAULT)修改 jpgraph_ttf.inc.php, $aFF === FF_SIMSUN 则直接返回 $aTx
原创文章,转载请注明:http://www.cnblogs.com/phpgcs/
相关文章推荐
- 解决jpgraph中文乱码问题
- GAE下的SiteMesh3--解决静态html中文乱码问题(原创)
- php jpgraph的中文乱码问题及解决方法
- 如何解决JpGraph中文乱码的问题
- JPgraph中文乱码问题解决 版本(jpgraph-3.0.7)
- jpgraph 折线图--解决中文乱码的问题(标题和图例)
- JpGraph中文乱码问题解决
- 解决Windows下JpGraph中文乱码问题
- (原创)Linux下MySQL 5.5/5.6的修改字符集编码为UTF8(彻底解决中文乱码问题)
- JPgraph中文乱码问题解决
- (原创)Linux下MySQL 5.5/5.6的修改字符集编码为UTF8(彻底解决中文乱码问题)
- 原创:如何解决 传中文参数 显示乱码问题
- php JpGraph 使用完美解决中文乱码问题
- 【原创】[C#]解决 vs2003 升级 vs2005 中文乱码问题
- java 和 C++ Socket通信(java作为服务端server,C++作为客户端client,解决中文乱码问题GBK和UTF8)
- DbVisualizer解决中文乱码问题
- 解决拷贝中文注释到KEIL4.6中呈现乱码的问题
- 解决Spring MVC @ResponseBody返回中文字符串乱码问题
- Code:Blocks 中文乱码问题原因分析和解决方法!
- 在控制器中添加过滤器,解决中文由jsp到action进而到数据库传输过程中出现的乱码问题(Struts)