我正在尝试使用php图库在我的localhost上显示一个简单的图形。我的代码是:
include('phpgraphlib.php');
$graph = new PHPGraphLib(650,200);
$data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
"5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
"10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
"14" => .0028, "15" => .0025);
$graph->addData($data);
$graph->setTitle('PPM Per Container');
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('maroon');
$graph->setGoalLine(.0025);
$graph->setGoalLineColor('red');
$graph->createGraph();
但不幸的是,我的屏幕上没有显示图表。我已经检查了我对phpinfo的GD支持,它给了我以下结果
GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.10
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 8
PNG Support enabled
libPNG Version 1.2.50
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
我的Php版本是5.4.19,
我在这里做错了什么?请帮帮我
提前致谢
答案 0 :(得分:1)
您的$ data数组似乎是数字。我建议像这样创建数组而不是创建一个关联数组:
$data = array(.0032, .0028, .0021, .0033, .0034, .0031, .0036, .0027,
.0024, .0021, .0026, .0024, .0036, .0028, .0025);
我在本地计算机上运行PHP 7.1,由于某种原因,PHPGraphLib不会渲染图形,因为我对$ data数组使用了一个关联数组。 PHP 5.4.45将使用关联数组渲染图形。它可能与每个版本如何识别或内部处理关联数组有关。
答案 1 :(得分:0)
同样的事情发生在我身上..但是使用PHP 5.5它完美地工作..我只是不明白什么是PHP 5.4的问题..