//mysqli_select_db($link,'gfb11176') or die('Could not select database');
//mysql_select_db("mydatabase") or die("MySQL Error: " . mysql_error());
$dataArray = array();
// Get the values from the COReadings table for the currently logged in user.
$sql = "SELECT COValue, AddedOn FROM COReadings \n\t\tJOIN COUsers ON COUsers.id = COReadings.UserID\n\t\tWHERE COUsers.Email = '{$email}'";
$result = mysqli_query($link, $sql) or die('Query failed: ' . mysql_error());
if ($result) {
    while ($row = mysqli_fetch_assoc($result)) {
        $dateAdded = $row["AddedOn"];
        $count = $row["COValue"];
        // Add to data array
        $dataArray[$dateAdded] = $count;
    }
}
// Configure graph
$graph->addData($dataArray);
$graph->setTitle("Carbon Monoxide Readings");
$graph->setTitleColor('navy');
$graph->setGradient("lime", "green");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataValues(true);
$graph->setDataValueColor('navy');
$graph->setDataPointColor('navy');
$graph->setXValuesHorizontal(true);
//$graph->setBackgroundColor("black");
$graph->setYAxisTextColor('black');
$graph->setXAxisTextColor('black');
$graph->setLineColor('navy');
$graph->createGraph();
Example #2
0
<?php

include '../phpgraphlib.php';
$graph = new PHPGraphLib(495, 280);
$data = array('alpha' => 23, 'beta' => 45, 'cappa' => 20, 'delta' => 32, 'echo' => 14);
$data2 = array('alpha' => 15, 'beta' => 23, 'cappa' => 23, 'delta' => 12, 'echo' => 17);
$data3 = array('alpha' => 43, 'beta' => 23, 'cappa' => 34, 'delta' => 16, 'echo' => 20);
$data4 = array('alpha' => 23, 'beta' => 34, 'cappa' => 23, 'delta' => 9, 'echo' => 8);
$graph->addData($data, $data2, $data3, $data4);
$graph->setupYAxis("15");
$graph->setGradient('teal', '#0000FF');
$graph->setXValuesHorizontal(true);
$graph->setXAxisTextColor('navy');
$graph->setLegend(true);
$graph->setLegendTitle('M1', 'M2', 'M3', 'M4');
$graph->createGraph();