【问题标题】:JpGraph : no error but broken pictureJpGraph:没有错误但图片损坏
【发布时间】:2013-04-17 02:39:44
【问题描述】:

我用 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();线。我有那个:

你能帮帮我吗?

提前谢谢你。

【问题讨论】:

  • 确保所有字体都可用..
  • 所有字体都可用。不是这样的:(
  • 如果将 PHP 设置为打印所有错误会怎样?
  • PHP 已经打印出所有错误 :(

标签: php jpgraph


【解决方案1】:

在我的情况下(php 7.1.0)它是已弃用的消息

随便放

ini_set('display_errors', 0);

在脚本顶部,然后重试。

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

【讨论】:

    【解决方案2】:

    我知道这是一个老问题,但我只是遇到了同样的问题,并通过删除 &lt;?php 之前的所有内容来修复它。

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

    Solution Source

    【讨论】:

      【解决方案3】:

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

      jpGraph can't include PHP file

      我推荐的一件事是添加行

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-19
        • 1970-01-01
        • 1970-01-01
        • 2019-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-11
        相关资源
        最近更新 更多