您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

pChart 图表中文显示有关问题

2024/3/11 22:57:01发布18次查看
pchart 图表中文显示问题
项目需要,图表显示数据,个人能力有限,
/* cat:bar chart */
header(content-type:text/html; charset=utf-8);
/* pchart library inclusions */
include(class/pdata.class.php);
include(class/pdraw.class.php);
include(class/pimage.class.php);
/* create and populate the pdata object */
$mydata = new pdata();
$mydata->addpoints(array(150,220,300,250,420,200,300,200,100),test);
$mydata->setaxisname(0,hits);
$mydata->addpoints(array(1月,2月,3月,4月,5月,6月,7月,8月,9月),months);
$mydata->setseriedescription(months,month);
$mydata->setabscissa(months);
/* create the pchart object */
$mypicture = new pimage(700,230,$mydata);
/* turn of antialiasing */
$mypicture->antialias = false;
/* add a border to the picture */
$mypicture->drawgradientarea(0,0,700,230,direction_vertical,array(startr=>240,startg=>240,startb=>240,endr=>180,endg=>180,endb=>180,alpha=>100));
$mypicture->drawgradientarea(0,0,700,230,direction_horizontal,array(startr=>240,startg=>240,startb=>240,endr=>180,endg=>180,endb=>180,alpha=>20));
$mypicture->drawrectangle(0,0,699,229,array(r=>0,g=>0,b=>0));
/* set the default font */
$mypicture->setfontproperties(array(fontname=>fonts/pf_arma_five.ttf,fontsize=>6));
/* define the chart area */
$mypicture->setgrapharea(60,40,650,200);
/* draw the scale */
$scalesettings = array(gridr=>200,gridg=>200,gridb=>200,drawsubticks=>true,cyclebackground=>true);
$mypicture->drawscale($scalesettings);
/* write the chart legend */
$mypicture->drawlegend(580,12,array(style=>legend_noborder,mode=>legend_horizontal));
/* turn on shadow computing */
$mypicture->setshadow(true,array(x=>1,y=>1,r=>0,g=>0,b=>0,alpha=>10));
/* draw the chart */
$mypicture->setshadow(true,array(x=>1,y=>1,r=>0,g=>0,b=>0,alpha=>10));
$settings = array(surrounding=>-30,innersurrounding=>30);
$mypicture->drawbarchart($settings);
ob_clean(); //关键代码,防止出现'图像因其本身有错无法显示'的问题。
header(content-type: image/png);
/* render the picture (choose the best way) */
$mypicture->autooutput(examples/pictures/example.drawbarchart.simple.png);

怎么把 $mydata->addpoints(array(150,220,300,250,420,200,300,200,100),test);的字符串test显示为中文,怎么把 $mydata->setaxisname(0,hits);显示中文,比如 $mydata->setaxisname(0,套);。。
------解决方案--------------------
直接中文写上去不行吗?
------解决方案--------------------
注释掉 header(content-type:text/html; charset=utf-8);
------解决方案--------------------
是最新版的吗?
待会下一个看看
------解决方案--------------------
1、header 是不要的,因为你是以图片方式输出
2、你选用的字体是西文字体,没有汉字当然不能显示,你需要选一款中文字体
3、如果你的程序不是utf-8的,那么所有要输出的汉字都必须转成utf-8的
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product