0

我用 JPGraph 制作了一个图表,但我有一个小问题。

没有显示错误,但图片是“损坏的图片”。

这是我的代码:

$graph = new Graph(1000,300);
$graph->img->SetMargin(40,30,50,40);    
$graph->SetScale("textlin");
$graph->title->Set("Graph");

$graph->ygrid->Show();
$graph->ygrid->SetColor('blue@0.7');
$graph->ygrid->SetLineStyle('dashed');

$graph->xgrid->Show();
$graph->xgrid->SetColor('red@0.7');
$graph->xgrid->SetLineStyle('dashed');

$graph->title->SetFont(FF_ARIAL,FS_BOLD,11);

$bigCourbe = array();
$i = 0;
foreach($bigData as $data)
{
    var_dump($data);

    $courbe = new LinePlot($data);
    $courbe->value->Show();

    $courbe->value->SetFont(FF_ARIAL,FS_NORMAL,9);
    $courbe->value->SetFormat('%d');

    $courbe->mark->SetType(MARK_FILLEDCIRCLE);
    $courbe->mark->SetFillColor("green");
    $courbe->mark->SetWidth(2);

    $courbe->SetWeight(10);         

    echo $function[$i];
    $courbe->SetLegend($function[$i++]);

    $bigCourbe[] = $courbe;
}

$graph->xaxis->title->Set("Heures");
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

foreach ($bigCourbe as $elem) {
        $graph->Add($elem);
}

//$graph->Stroke();

所以,结果似乎不错:

array (size=24)
0 => string '0.000' (length=5)
1 => string '0.000' (length=5)
2 => string '0.000' (length=5)
3 => string '0.000' (length=5)
4 => string '0.000' (length=5)
5 => string '0.000' (length=5)
....
Index HC <- it's the $function[$i] var

array (size=24)
0 => string '0.200' (length=5)
1 => string '0.200' (length=5)
2 => string '0.100' (length=5)
3 => string '0.200' (length=5)
4 => string '0.200' (length=5)
5 => string '0.200' (length=5)
....
Index HP

array (size=24)
0 => string '0.000' (length=5)
1 => string '0.000' (length=5)
2 => string '0.000' (length=5)
3 => string '0.000' (length=5)
4 => string '0.000' (length=5)
5 => string '0.000' (length=5)
Index HPTE

array (size=24)
0 => string '0.200' (length=5)
1 => string '0.200' (length=5)
2 => string '0.100' (length=5)
3 => string '0.200' (length=5)
4 => string '0.200' (length=5)
5 => string '0.200' (length=5)
....
Total Heure

我没有看到问题...

如果我删除调试,并取消注释 $graph->Stroke(); 线。我有这个 :

在此处输入图像描述

你能帮助我吗 ?

先感谢您。

4

3 回答 3

1

就我而言(php 7.1.0),它是已弃用的消息

就放

ini_set('display_errors', 0);

在脚本的顶部,然后重试。

或者

注释掉$graph->Stroke();,看看你有什么错误(或警告)

于 2017-01-04T17:26:34.560 回答
0

你如何显示图表?你有 HTML 页面吗?请显示 HTML 代码。我有一个类似的问题,我没有错误消息,但得到损坏的图像图标。

jpGraph 不能包含 PHP 文件

我推荐的一件事是添加行

//save to file
$fileName = "/tmp/imagefile.png";
$graph->img->Stream($fileName);

如果文件中的图像正确,则可以排除图形生成代码。

于 2013-05-16T01:46:56.983 回答
0

我知道这是一个老问题,但我只是遇到了同样的问题,并通过删除<?php.

这是在下面的链接中建议的 - 检查 1.b。

解决方案来源

于 2014-08-01T20:32:20.947 回答