JPGraph错误,情节有非法规模

时间:2015-08-28 07:14:47

标签: php jpgraph

我正在尝试使用JPGragph制作图表,但我一直收到错误说:

JpGraph Error A plot has an illegal scale. This could for example be that you are trying to use text auto scaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only '-' or 'x')

$ydata = round($ydata[0]); // An attempt to convert float to int
$ydata = (int)$ydata; // That didn't bring any solution(thought it couldn't handle float)

$pt = new LinePlot($ydata); // Here is where the error is thrown
$bar2->Add($pt);
$pt->SetColor("blue");
$pt->SetWeight(10);

我尝试用整数替换$ ydata,但这只会引发致命的错误。

没有圆形和类型转换,这是$ ydata的var_dump:

array(1) { [0]=> float(8.1102970953135) }

2 个答案:

答案 0 :(得分:1)

当图表仅包含一个数据点时,我在使用PHP 7.2时遇到了同样的问题。 原因似乎是JPGraph试图将单个数据点同时放在图的左右边缘。

使用$plot->SetCenter();为我解决了这个问题,对于BoxPlots来说看起来更好。

答案 1 :(得分:0)

使用PHP 7?我得到了同样的错误,发现了这个:

http://jpgraph.net/doc/faq.php#F4-13

他们说你的PHP安装是错误的"。

帮助我的是为数据数组添加第二个值 - 只有一个值不起作用。