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
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);

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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??

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.