1

我正在使用JpGraph来绘制一些数据。当我使用 SetScale 函数强制 y 轴范围时,输出视觉上会溢出图形区域。我想将输出裁剪到图形区域。

<?php

require_once ('include/jpgraph/jpgraph.php');
require_once ('include/jpgraph/jpgraph_line.php');

$datay1 = array(20,7,16,46,90,5,0,5,95);

// Setup the graph
$graph = new Graph(400,300);
$graph->title->Set('Graph Title');
$graph->title->font_size = 20;
$graph->SetScale("textlin",20,50);

//this version works but does not set the y-axis scale
//$graph->SetScale("textlin");

$p1 = new LinePlot($datay1);
$graph->Add($p1);

// Output line
$graph->Stroke();

?>

这是当前的输出:
在此处输入图像描述

这是所需的输出(由 Excel 呈现):
在此处输入图像描述

4

2 回答 2

0

我与 JpGraph 背后的公司取得了联系,他们能够提供帮助。缺少的选项是:

$graph->setClipping(true);

我希望这对可能有类似问题的其他人有所帮助。

于 2013-10-21T15:15:06.037 回答
0
$myMaxY = 50; //You need to set Y Max as you want

$length = count($datay1);

for($i = 0; $i < $lenght; $i++)
{
    if($datay1[$i] > $myMaxY)
       $datay1[$i] = $myMaxY;
} 

$graph->SetScale("textlin",20,$myMaxY); //Dont forget to change this
于 2013-09-12T13:33:33.657 回答