Search code examples
phpjpgraph

JpGraph small demo is not working


I'm going to use JpGraph in my web-project. To do this, I downloaded the library into my project folder and created the following test code:

        <?php
        include ( "jpgraph-3.5.0b1/src/jpgraph.php");
        include ("jpgraph-3.5.0b1/src/jpgraph_gantt.php");

        // A new graph with automatic size
        $graph = new GanttGraph (0,0, "auto");

        //  A new activity on row '0'
        $activity = new GanttBar (0,"Project", "2001-12-21", "2002-02-20");
        $graph->Add( $activity);

        // Display the Gantt chart
        $graph->Stroke();
        ?> 

The error message is:

The image “http://localhost:10088/test/check.php” cannot be displayed, 
because it contains errors.

What's wrong with my code? In fact, it was just copied from here. The only thing I changed was the path to the JpGraph library. So, do I need to import this library in some special way into my project (so far, I've just copied the JpGraph's folder into the project's folder)? I'm using Zend Studio.


Solution

  • This can be caused by extra whitespace on the page. Make sure you don't have any spaces or line breaks before your opening <?php tag.