Jump to content

Recommended Posts

Currently I've managed to create this graph with help from a tutorial on phpfreaks.
[img src=\"http://www.coachloanprocessing.com/download/bar-graph.gif\" border=\"0\" alt=\"IPB Image\" /]


Here is the code:

<?php
include ("c:/jpgraph/src/jpgraph.php");
include ("c:/jpgraph/src/jpgraph_bar.php");

$db = mysql_connect("localhost", "root","password") or die(mysql_error());

mysql_select_db("bar_graph",$db) or die(mysql_error());

$sql = mysql_query("SELECT * FROM employees") or die(mysql_error());

while($row = mysql_fetch_array($sql))
{
$data[] = $row[1];
$leg[] = $row[0];
}

$graph = new Graph(600,150,"auto");
$graph->SetScale("textint");
$graph->SetShadow();
$graph->Set90AndMargin(50,40,0,20);
$graph->xaxis->SetTickLabels($leg);

$bplot = new BarPlot($data);
$bplot->SetFillColor("lightgreen"); // Fill color
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetColor("black","navy");

$graph->Add($bplot);
$graph->Stroke();
?>

And here is the mysql table:
CREATE TABLE `employees` (`Name` varchar(50) default NULL, `Marks` int(11) default NULL);


What I want to do is replace the top numbers with 00:00 - 23:59 military time. And I need to make it look like this below:

[img src=\"http://www.coachloanprocessing.com/download/bar-graph2.gif\" border=\"0\" alt=\"IPB Image\" /]



Basically it is a time schedule to let me know when an employee is working during the day.

And so far the first example is as far as I can go without pulling my hair out.
Does anyone have any ideas how to change the code to reflect this?

thanks!
Link to comment
https://forums.phpfreaks.com/topic/5693-adding-24hr-time-to-a-graph/
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.