jpgraph does´t work. There is no lineplot. But a dark window with a small square.

131 views
Skip to first unread message

Werner Werni335

unread,
Jun 27, 2019, 7:35:10 AM6/27/19
to JpGraph
I wanted to creat a grph within jpgraph but instead the graph it shows a dark window with a little square in it. The logfile tells me that there is an error in the file jpgraph.php in line 4025. Must be an cache error.
Has anybody had the same problem? Is ther a solution?

Thank you for your help.

SEMPERVIVUM1412

unread,
Jun 27, 2019, 7:37:52 AM6/27/19
to JpGraph
Shurely there is a solution but in order to find and fix the error one has to view your code. Please post it.

David Martin

unread,
Jun 27, 2019, 7:38:27 AM6/27/19
to JpGraph
Please post enough of your code and data to allow us to try and replicate your problem. Without being able to see the failure and the code that causes the failure all we can do is take wild guesses.

Werner Werni335

unread,
Jun 27, 2019, 7:40:11 AM6/27/19
to JpGraph
<?php
require '/usr/share/jpgraph/jpgraph.php';
require '/usr/share/jpgraph/jpgraph_line.php';
require '/usr/share/jpgraph/jpgraph_bar.php';

$ydata = array(11,3,8,7,5,1,9,13,5,7,15);
$xdata = array(1,2,3,4,5,6,7,8,9,10,11);
#
#
#$graph->clearTheme();
$graph = new Graph(350,250);
$graph->SetScale('intlin');
#
$graph->img->SetMargin(40,20,20,40);
$graph->title->Set("Werner");
$graph->xaxis->title->Set("id");
$graph->yaxis->title->Set("hallo");
$graph->yaxis->SetColor("blue");
#
$lineplot=new LinePlot($xdata,$ydata);
$lineplot->SetStepStyle();
$lineplot->SetColor( "blue" );
$lineplot->SetWeight(0);
#
$graph->Add($lineplot);
#
$graph->xaxis->SetPos("min");
#
$graph->Stroke();
###### Plot Ende
#
#
#
$erg->free();
$db->close();
#
?>

Werner Werni335

unread,
Jun 27, 2019, 7:40:47 AM6/27/19
to JpGraph
Sorry. Of course you are right. Thank you for your help!

Werner Werni335

unread,
Jun 27, 2019, 7:45:09 AM6/27/19
to JpGraph
I forgot to tell that it is running on a Raspberry pi 3 ModelB+

SEMPERVIVUM1412

unread,
Jun 27, 2019, 7:59:08 AM6/27/19
to JpGraph
After having adjusted the paths this code works fine for me. Which version of jpgraph are you using? The manual says:
Please note that it is not possible to run the "3.x.y" series on PHP7.0. If you need to run on PHP7.0 then you must use the 4.x version of the library.

Werner Werni335

unread,
Jun 27, 2019, 8:01:00 AM6/27/19
to JpGraph
Thank you a lot! How can I get the version i am running?

SEMPERVIVUM1412

unread,
Jun 27, 2019, 8:02:59 AM6/27/19
to JpGraph
Obviously in gpgrap.php this is indicating the version:
// Version info
define('JPG_VERSION','4.2.6');


David Martin

unread,
Jun 27, 2019, 8:03:23 AM6/27/19
to JpGraph
Near the top of jpgraph.php you will see the define that shows the version.

define('JPG_VERSION','4.2.0');

David Martin

unread,
Jun 27, 2019, 8:03:59 AM6/27/19
to JpGraph
Your code works just fine with version 4.2.0 of JPGraph.

Worked.png


Werner Werni335

unread,
Jun 27, 2019, 8:07:07 AM6/27/19
to JpGraph
If I punsh in define('......  then I always get a syntax error

Werner Werni335

unread,
Jun 27, 2019, 8:07:59 AM6/27/19
to JpGraph
How can I install this jpgraph version?

David Martin

unread,
Jun 27, 2019, 8:08:45 AM6/27/19
to JpGraph
I'm not at all sure what you mean but that is something you should not touch. It's part of the package and tells you what the version is.

David Martin

unread,
Jun 27, 2019, 8:15:54 AM6/27/19
to JpGraph
Download a copy from https://jpgraph.net/download/

Werner Werni335

unread,
Jun 27, 2019, 8:18:15 AM6/27/19
to JpGraph
I am running php7 version. And jpgraph4.2.7

David Martin

unread,
Jun 27, 2019, 8:24:21 AM6/27/19
to JpGraph
As am I and your code works just fine. PHP 7.3.6 and JPGraph 4.2.7.

SEMPERVIVUM1412

unread,
Jun 27, 2019, 8:33:58 AM6/27/19
to JpGraph
The system requirements say:
The PHP installation must have the low level graphic primitive library "GD"
I recommend to check this. 

Werner Werni335

unread,
Jun 27, 2019, 8:51:09 AM6/27/19
to JpGraph
how can I do that? It seems that there is nothing simular:

Werner Werni335

unread,
Jun 27, 2019, 8:51:56 AM6/27/19
to JpGraph
it has a gd.ini file

SEMPERVIVUM1412

unread,
Jun 27, 2019, 8:53:12 AM6/27/19
to JpGraph

Werner Werni335

unread,
Jun 27, 2019, 9:12:13 AM6/27/19
to JpGraph
OK. Thank you. It seems that the GD is working.

SEMPERVIVUM1412

unread,
Jun 27, 2019, 9:17:02 AM6/27/19
to JpGraph
Then I'm helpless. Is the code you posted complete or did you simplify something?

Werner Werni335

unread,
Jun 27, 2019, 9:18:39 AM6/27/19
to JpGraph
Thank you anyway. I am at least a bit closer to a solution.

Thankx!! 

David Martin

unread,
Jun 27, 2019, 9:50:44 AM6/27/19
to JpGraph
In your code you have 

$erg->free();
$db
->close();

near the end of the file. Since those weren't defined in what you posted take them out or comment them out and see if works. As a couple of us have said, the code you posted, without those 2 lines of course, is working just fine.

If you are doing DB queries to get the data make sure that the results from the queries are actually what you think they are using 

var_dump($variable_name);

Werner Werni335

unread,
Jun 27, 2019, 10:14:45 AM6/27/19
to JpGraph
Thank you. I still have the problem. It is that I can not install the jpgraph-4.2.7.tar.gz on the rasoberry. I don´t know how i can install this package?

Werner Werni335

unread,
Jun 27, 2019, 10:15:40 AM6/27/19
to JpGraph
It says "use GD version that comes with PHP and not the standalone version"  How?
Reply all
Reply to author
Forward
0 new messages