Jump to content

phpMyGraph - Configuration/Usage Issues


Recommended Posts

I just downloaded phpMyGraph version 5.  Not really much documentation on this other than how to create graphs.  For installation, I installed the phpMyGraph.5.0.php in my /var/www and copy/pasted one of the examples from the website to make an example graph.  All I get is weird text taking up the whole page.  Both the phpMyGraph.5.0.php and examplegraph.php are located in /var/www.  Anyone know if this is correct?  Any answer on how to actually get a graph to display rather than a page full of random characters???

 

Their "user forum" had one answer for this and it doesn't work. see here: http://phpclasses.elib.com/discuss/package/4636/thread/1/

 

Anyone who has ever used this can probably solve my problem.  Any help appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/206877-phpmygraph-configurationusage-issues/
Share on other sites

Are you using the output in a seperate file?

Or are you trying to put the output between the rest of your code?

 

Use it like

<img src="graph.php">

 

and then in graph.php put something like

<?php
header("Content-type: image/png");

//Include phpMyGraph5.0.php
    include_once('phpMyGraph5.0.php');
    
    //Set config directives
    $cfg['title'] = 'Example graph';
    $cfg['width'] = 500;
    $cfg['height'] = 250;
    
    //Set data
    $data = array(
        'Jan' => 12,
        'Feb' => 25,
        'Mar' => 0,
        'Apr' => 7,
        'May' => 80,
        'Jun' => 67,
        'Jul' => 45,
        'Aug' => 66,
        'Sep' => 23,
        'Oct' => 23,
        'Nov' => 78,
        'Dec' => 23
    );
    
    //Create phpMyGraph instance
    $graph = new phpMyGraph();

    //Parse
    $graph->parseHorizontalSimpleColumnGraph($data, $cfg);

?>

Initially, I just had the "graph.php" file and was trying to display that with my browser: (http://www.somewebsiteblahblah.com/graph.php).  After reading your post, I created a basic blank html and between the <body> and </body> I put the <img src="graph.php">.  I saved this as graph.html.  When I tried to display the graph.html in my browser: (http://www.somewebsiteblahblah.com/graph.html), all I get is a "broken image" icon in the top left corner.

 

Should I post my "graph.html" and "graph.php" files here for someone to look at?

 

At this point I have no clue why it doesn't work.  I am not very good yet with php, but am learning.

My 'graph.php" looks exactly like yours:

 

<?php
header("Content-type: image/png");

//Include phpMyGraph5.0.php
    include_once('phpMyGraph5.0.php');
    
    //Set config directives
    $cfg['title'] = 'Example graph';
    $cfg['width'] = 500;
    $cfg['height'] = 250;
    
    //Set data
    $data = array(
        'Jan' => 12,
        'Feb' => 25,
        'Mar' => 0,
        'Apr' => 7,
        'May' => 80,
        'Jun' => 67,
        'Jul' => 45,
        'Aug' => 66,
        'Sep' => 23,
        'Oct' => 23,
        'Nov' => 78,
        'Dec' => 23
    );
    
    //Create phpMyGraph instance
    $graph = new phpMyGraph();

    //Parse
    $graph->parseHorizontalSimpleColumnGraph($data, $cfg);

?>

 

And my "graph.html" looks like:

 

<html>
<head>
<title>GRAPH</title>
</head>

<body>
<img src="graph.php">
</body>

</html>

 

Any ideas??

 

All 3 files (phpMyGraph5.0.php, graph.php, graph.html) are located in /var/www.  Is this the correct place for them to be??

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.