Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial jpgraph中报错" 图像因其本身有错无法显示"

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

Jun 23, 2016 pm 01:58 PM

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

下面是代码

<?php 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();?>
Copy after login


回复讨论(解决方案)

将中文改成英文就没有问题
显然你的中文字库设置有误

将中文改成英文就没有问题
显然你的中文字库设置有误



请问代码应该怎么修改呢,请指点,谢谢。

视频教程里的代码也是这么写的,怎么就没问题呢。FF_SIMSUN字体是支持中文的。

1.字体是否存在,名字是否相同->FF_SIMSUN 是个常量,所以要检视其具体值和你的系统是否相符
2.编码

我也遇到你说的问题了,请问你找到方法了吗?求指导啊

$title="支持布什的统计情况(万)";
$title = iconv("UTF-8", "gb2312", $title);

$graph->title->Set($title);



已经解决了!

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

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

6 Extra Skills Every PHP Developer Should Have 6 Extra Skills Every PHP Developer Should Have Feb 28, 2025 am 10:52 AM

6 Extra Skills Every PHP Developer Should Have

Understand Arrays in PHP Understand Arrays in PHP Feb 28, 2025 am 10:53 AM

Understand Arrays in PHP

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

See all articles