title->SetFont(FF_SIMSUN,FS_BOLD,14);但是加上后就报错图像因其本身有错无法显示如果去掉这句">
当前位置:Gxlcms > PHP教程 > jpgraph中出错"图像因其本身有错无法显示"

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

时间:2021-07-01 10:21:17 帮助过:7人阅读

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

下面是代码

require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');

$datay1=array(13,8,19,7,17,6);
$datay2=array(4,5,2,7,5,25);

// Create the graph.
$graph = new Graph(350,250);
$graph->SetScale('textlin');
$graph->SetMarginColor('silver');

// Setup title
$graph->title->Set('支持布什的人数统计(万)');
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);

// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);
$bplot->SetColor('darkred');

// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);
$bplot2->SetColor('darkgreen');

// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot,$bplot2));
$graph->Add($accbplot);

ob_clean();
$graph->Stroke();

?>


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

人气教程排行