title->SetFont(FF_SIMSUN,FS_BOLD,14);但是加上后就报错图像因其本身有错无法显示如果去掉这句,或者将中文改成英文就没有问题查了网上说要加一句ob_clean();清除之前的输出"/> title->SetFont(FF_SIMSUN,FS_BOLD,14);但是加上后就报错图像因其本身有错无法显示如果去掉这句,或者将中文改成英文就没有问题查了网上说要加一句ob_clean();清除之前的输出">
Home > Backend Development > PHP Tutorial > jpgraph中出错" 图像因其本身有错无法显示"

jpgraph中出错" 图像因其本身有错无法显示"

WBOY
Release: 2016-06-13 11:55:09
Original
1082 people have browsed it

jpgraph中报错" 图像因其本身有错无法显示"
因为中文乱码的问题,我加了一行设置中文字体的语句$graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);
但是加上后就报错图像因其本身有错无法显示
如果去掉这句,或者将中文改成英文就没有问题
查了网上说要加一句ob_clean();清除之前的输出,但是不知道加在哪里?求前辈指点。

下面是代码

<br /><?php <br />require_once ('jpgraph/jpgraph.php');<br />require_once ('jpgraph/jpgraph_bar.php');<br /><br />$datay1=array(13,8,19,7,17,6);<br />$datay2=array(4,5,2,7,5,25);<br /><br />// Create the graph.<br />$graph = new Graph(350,250);<br />$graph->SetScale('textlin');<br />$graph->SetMarginColor('silver');<br /><br />// Setup title<br />$graph->title->Set('支持布什的人数统计(万)');<br />$graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);<br /><br />// Create the first bar<br />$bplot = new BarPlot($datay1);<br />$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);<br />$bplot->SetColor('darkred');<br /><br />// Create the second bar<br />$bplot2 = new BarPlot($datay2);<br />$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);<br />$bplot2->SetColor('darkgreen');<br /><br />// And join them in an accumulated bar<br />$accbplot = new AccBarPlot(array($bplot,$bplot2));<br />$graph->Add($accbplot);<br /><br />ob_clean();<br />$graph->Stroke();<br /><br />?><br /><br />
Copy after login

------解决方案--------------------
将中文改成英文就没有问题
显然你的中文字库设置有误
------解决方案--------------------
1.字体是否存在,名字是否相同->FF_SIMSUN 是个常量,所以要检视其具体值和你的系统是否相符
2.编码

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template