当前位置: 代码迷 >> PHP >> jpgraph图表使用引出类 就无法输出图表
  详细解决方案

jpgraph图表使用引出类 就无法输出图表

热度:203   发布时间:2016-04-28 19:10:14.0
jpgraph图表使用引入类 就无法输出图表
本帖最后由 h9zhou 于 2014-05-12 15:31:35 编辑
jpgraph图表使用问题,在显示图表的php文件一引入类  ,就无法输出图表,图表就变成一个叉,是jpgraph不支持吗

在问个问题 jpgraph 这东西要不要学,实际用的多吗?

<?php // content="text/plain; charset=utf-8"
require_once ('SqlHelper.class.php');//这是我写的类,用于操作数据库,但是一引入就出错
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');


$datay1=array(12,12,15);
$datay2=array(0,0,0);

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


// Setup title
$str="";
$id=$_REQUEST['id'];
if($id==1){
$str="支持布什的情况统计图";
}else if($id==2) {
$str="支持奥巴马的情况统计图";
}
$graph->title->Set($str);
$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);

$graph->Stroke();
?>

------解决方案--------------------
去掉所有相关文件的 BOM 头 和 <?php 之前的空格换行