Harry Lime
Harry Lime

Reputation: 2217

PHP graphing CSV file

I'm new to web pages and dynamic content:

I have a server running php and I'm able to read in and display CSV text data - how may I graph this? I was using http://phpmygraph.abisvmm.nl/ but I'm unsure how to parse my CSV data into columns.

In addition, how do I create date-time objects in PHP (is this possible?)

A code example:

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

//Include phpMyGraph5.0.php
include_once('phpMyGraph5.0.php');

//Set config directives
$cfg['title'] = 'Flow data site#3, John Radcliff Hospital';
$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->parseVerticalLineGraph($data, $cfg); 
    ?>

This image shows an example of data I can generate on a webpage and the graph I would like to see - this is not a screen shot, only a 'wish list' of what I would like to generate:

enter image description here

Upvotes: 1

Views: 7129

Answers (1)

Valkyrie00
Valkyrie00

Reputation: 51

if I can recommend, I would adapt your data and would use Google Charts

https://developers.google.com/chart/

Upvotes: 1

Related Questions