Ejemplo n.º 1
2
 function xls_write_graph($graphfile = null)
 {
     //init all
     $CI =& get_instance();
     //load
     $CI->load->helper('misc');
     $graph = new PHPGraphLib(495, 280, $graphfile);
     $data1 = array('alpha' => intval(rand(20) + 1), 'beta' => intval(rand(15) + 1), 'cappa' => intval(rand(10) + 1), 'delta' => intval(rand(20) + 1), 'echo' => intval(rand(10) + 1));
     $data2 = array('alpha' => intval(rand(8) + 1), 'beta' => intval(rand(20) + 1), 'cappa' => intval(rand(20) + 1), 'delta' => intval(rand(20) + 1), 'echo' => intval(rand(50) + 1));
     $data3 = array('alpha' => intval(rand(25) + 1), 'beta' => intval(rand(8) + 1), 'cappa' => intval(rand(10) + 1), 'delta' => intval(rand(50) + 1), 'echo' => intval(rand(50) + 1));
     $data4 = array('alpha' => intval(rand(7) + 1), 'beta' => intval(rand(50) + 1), 'cappa' => intval(rand(5) + 1), 'delta' => intval(rand(50) + 1), 'echo' => intval(rand(50) + 1));
     $data = array(rand(20, 30), rand(40, 50), 20, 44, 41, 18, rand(40, 50), 19, rand(40, 50));
     $data2 = array(15, rand(20, 30), rand(20, 30), 11, rand(40, 60), 21, rand(40, 60), 34, rand(20, 30));
     $data3 = array(rand(40, 50), rand(20, 30), 34, 23, rand(45, 60), 32, 43, 41);
     $graph->addData($data, $data2, $data3);
     $graph->setTitle('CPU Cycles x1000');
     $graph->setTitleLocation('left');
     $graph->setLegend(true);
     $graph->setLegendTitle('Module-1', 'Module-2', 'Module-3');
     $xcolor1 = sprintf("%02X%02X%02X", rand(20, 255), rand(20, 250), rand(20, 250));
     $xcolor2 = sprintf("%02X%02X%02X", rand(20, 250), rand(20, 255), rand(20, 250));
     $graph->setGradient("#{$xcolor1}", "#{$xcolor2}");
     $graph->createGraph();
     //give the format
     return 1;
 }
 public function getGraphData()
 {
     $company = Input::get('company');
     $interval = Input::get('interval');
     $precision = Input::get('prc');
     $company_symbol = isset($company) && !empty($company) ? $company : 'goog';
     $interval = isset($interval) && !empty($interval) ? $interval : 'd';
     $precision = isset($precision) && !empty($precision) && is_numeric($precision) ? $precision : 1;
     $stock_market = new StockMarket($company_symbol, $interval, $precision);
     //<---class declared here and passed the datas
     /* // <--utilizing the function for finding the Company name from Symbol
     			//<-- to check the given company symbol is correct or not */
     $company_name = $stock_market->find_company_name_from_symbol();
     if ($company_name) {
         //<-- if company name given is not false go further
         $stock_records = $stock_market->get_the_market_data();
         //<--function to collect Historical data for given company symbol
         if ($stock_records) {
             //<----if it retuns a record then proceed
             $range_from = $stock_market->get_graph_range_start();
             //<--this function helps to calculate historical Graph area minmum range
             $range_to = $stock_market->get_graph_range_ends();
             //<--this function helps to calculate historical Graph area maximum range
             $lower_range_coords = $stock_market->get_lower_price_data();
             //<--this function helps to return the lower price data for graph
             $higher_range_coords = $stock_market->get_higher_price_data();
             //<--this function helps  to return the higher price data for graph
             $graph = new PHPGraphLib(470, 270);
             $graph->addData($lower_range_coords);
             $graph->addData($higher_range_coords);
             $graph->setRange($range_from, $range_to);
             $graph->setTitle($company_name . '  Graph');
             $graph->setBars(false);
             $graph->setLine(true);
             $graph->setDataPoints(true);
             $graph->setDataPointColor('maroon');
             $graph->setDataPointColor('red');
             $graph->setDataValues(true);
             $graph->setDataValueColor('blue');
             $graph->setGoalLine(0.25);
             $graph->setGoalLineColor('red');
             $graph->createGraph();
             //<--this draw the graph
             $contents = View::make('graph')->with('graph', $graph);
             // Create a response and modify a header value
             $response = Response::make($contents, 200);
             $response->header('Content-Type', 'image/png');
             return $response;
         }
         //<-- stock data checks ends
     }
     //<--company name check ends
 }
Ejemplo n.º 3
0
function make_graph_multi_line($title, $data_min, $data_avg, $data_max, $is_bar_graph)
{
    include 'phpgraphlib.php';
    $graph = new PHPGraphLib(780, 300);
    if ($is_bar_graph == 'true') {
        $graph->setBars(true);
        $graph->setLine(false);
    } else {
        $graph->setBars(false);
        $graph->setLine(true);
    }
    $graph->setDataPoints(true);
    $graph->setDataPointSize(4);
    $graph->setDataPointColor('purple');
    $graph->setLegend(true);
    if (!isset($data_min)) {
        $graph->addData($data_avg);
        $graph->addData($data_max);
        if ($is_bar_graph == 'true') {
            $graph->setBarColor('purple', 'red');
        } else {
            $graph->setLineColor('purple', 'red');
        }
        $graph->setLegendTitle('avg', 'max');
    } else {
        $graph->addData($data_min);
        $graph->addData($data_avg);
        $graph->addData($data_max);
        if ($is_bar_graph == 'true') {
            $graph->setBarColor('blue', 'purple', 'red');
        } else {
            $graph->setLineColor('blue', 'purple', 'red');
        }
        $graph->setLegendTitle('min', 'avg', 'max');
    }
    $graph->setTitle($title);
    $graph->setTitleColor("88,89,91");
    $graph->setXValuesVertical(true);
    $graph->createGraph();
}
Ejemplo n.º 4
0
function create_graph($graph_type = '')
{
    $graph = new PHPGraphLib(1400, 600);
    $model = new TwextraModel();
    //$data = array("Alex"=>99, "Mary"=>98, "Joan"=>70, "Ed"=>90);
    if ($graph_type == 'daily_stats') {
        $data = $model->get_stats_daily();
        $graph->setTitle("Daily Unique Traffic");
    } else {
        if ($graph_type == 'message_history') {
            //this graph is currently not plotted!
            $screen_name = 'rajen4126';
            $message_from = 0;
            $next = 20;
            $order = 'created';
            $asc_desc = 'desc';
            $length = 20;
            $data = $model->get_message_history($screen_name, $message_from, $next, $order, $asc_desc, $length);
            foreach ($data as $entry) {
                $data[$entry[message_id]] = $entry[view_count];
            }
            $graph->setTitle("Message History");
        } else {
            if ($graph_type == 'monthly_stats') {
                $data = $model->get_monthly_uniques();
                $graph->setTitle("Monthly Unique Traffic");
            } else {
                if ($graph_type == 'messages_stats') {
                    $data = $model->get_messages_stats();
                    $graph->setTitle("Daily Messages Created");
                } else {
                    $data = array();
                }
            }
        }
    }
    $graph->addData($data);
    $graph->setTextColor("blue");
    //additions for a line graph..........
    $graph->setBars(false);
    $graph->setLine(true);
    //$graph->setDataPoints(true);
    $graph->setDataPointColor('maroon');
    $graph->setDataValues(true);
    $graph->setDataValueColor('maroon');
    $graph->setGoalLine(0.0025);
    $graph->setGoalLineColor('red');
    //........
    return $graph->createGraph();
}
Ejemplo n.º 5
0
 public function gbarra_getImagen($titulo = " ", $width = "500", $height = "350")
 {
     $config = XTConfig::singleton();
     $data = $this->barra_data;
     $nombreimagen = uniqid() . "barraimagen.png";
     $file = $config->get("XTSITE_PATH_ABSOLUTE") . "tmp/pie/" . $nombreimagen;
     $file_url = $config->get("XTSITE_PATH") . "tmp/pie/" . $nombreimagen;
     $graph = new PHPGraphLib($width, $height, $file);
     $graph->addData($data);
     //$graph->setBarColor('255,255,204');
     $graph->setGradient('255,255,204', '254,254,154');
     if ($titulo != "") {
         $graph->setTitle($titulo);
     }
     $graph->setLineColor('maroon');
     $graph->setDataPointColor('maroon');
     $graph->setXValuesHorizontal(true);
     $graph->setLine(true);
     $graph->setDataPoints(true);
     $graph->setDataValues(true);
     $graph->createGraph();
     print "<img src=\"{$file_url}\">";
 }
Ejemplo n.º 6
0
<?php

include '../phpgraphlib.php';
$graph = new PHPGraphLib(500, 280);
$data = array(23, 45, 20, 44, 41, 18, 49, 19, 42);
$data2 = array(15, 23, 23, 11, 54, 21, 56, 34, 23);
$data3 = array(43, 23, 34, 23, 53, 32, 43, 41);
$graph->addData($data, $data2, $data3);
$graph->setTitle('CPU Cycles x1000');
$graph->setTitleLocation('left');
$graph->setLegend(true);
$graph->setLegendTitle('Module-1', 'Module-2', 'Module-3');
$graph->setGradient('green', 'olive');
$graph->createGraph();
Ejemplo n.º 7
0
<?php

require_once dirname(__FILE__) . '\\..\\util.php';
require_abs('images/graphs/phpgraphlib.php');
require_abs('images/graphs/phpgraphlib_pie.php');
require_controller('statisticsGraphicsController');
use Qnet\Controller\StatisticsGraphicsController;
$sid = $_GET['sid'];
$ctrl = new StatisticsGraphicsController();
$ctrl->computeStatistic($sid);
if (!$ctrl->isDrawable()) {
    echo 'Cannot draw this statistic.';
} else {
    $big = $_GET['size'] == 'big';
    $graph = new PHPGraphLib($big ? 800 : 400, $big ? 400 : 200);
    $graph->addData($ctrl->getData(0), $ctrl->getData(1), $ctrl->getData(2), $ctrl->getData(3), $ctrl->getData(4));
    if ($ctrl->hasZ()) {
        $graph->setLegend(true);
        $graph->setLegendTitle($ctrl->getLegend(0), $ctrl->getLegend(1), $ctrl->getLegend(2), $ctrl->getLegend(3), $ctrl->getLegend(4));
    }
    $graph->setXValuesHorizontal(true);
    $graph->createGraph();
}
Ejemplo n.º 8
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();
Ejemplo n.º 9
0
$all = array(array());
$sql = "SELECT LB, remote_ID, name, amount, transdate FROM firsttable";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        if ($row['remote_ID'] == $_SESSION['handle']) {
            if ($row['name'] == $_SESSION["graphval"]) {
                if ($row['LB'] == 'L') {
                    if (array_key_exists($row['transdate'], $lenddata)) {
                        $lenddata[$row['transdate']] = $lenddata[$row['transdate']] + $row['amount'];
                    } else {
                        $lenddata[$row['transdate']] = $row['amount'];
                    }
                } else {
                    if (array_key_exists($row['transdate'], $borrowdata)) {
                        $borrowdata[$row['transdate']] = $borrowdata[$row['transdate']] + $row['amount'];
                    } else {
                        $borrowdata[$row['transdate']] = $row['amount'];
                    }
                }
            }
        }
    }
}
$graph->addData($lenddata, $borrowdata);
$graph->setXValuesHorizontal(TRUE);
$graph->setTextColor('blue');
$graph->setBarColor('green', 'red');
$graph->setLegend(TRUE);
$graph->setLegendTitle('Lended', 'Borrowed');
$graph->createGraph();
Ejemplo n.º 10
0
<?php

require '../functions.php';
require 'phpgraphlib.php';
date_default_timezone_set('America/New_York');
// Use date to generate the current day.
// Omitting the specific time passed makes strtotime() return today's first second.
$Today = strtotime(date("d F Y"));
$Day = 86400;
// Seconds
$LastWeek = $Today - $Day * 30;
$Query = mysql_query("Select `Time` from `Wiki Searches` where `Time` > {$LastWeek}");
while (list($Time) = mysql_fetch_array($Query)) {
    $When = date('d M', $Time);
    $Data[$When]++;
}
$Graph = new PHPGraphLib(800, 400);
$Graph->addData($Data);
$Graph->setTitle("Searches This Month");
$Graph->setTextColor("blue");
$Graph->createGraph();
Ejemplo n.º 11
0
<?php

if ($_REQUEST['mode'] == 'graph' || $_REQUEST['mode'] == 'graph_line') {
    include '../lib/phpgraphlib.php';
    $graph = new PHPGraphLib(1120, 600);
    $graph->addData(unserialize($_REQUEST['graph_data']));
    if ($_REQUEST['mode'] == 'graph_line') {
        $graph->setBars(false);
        $graph->setLine(true);
        $graph->setLineColor();
    } else {
        $graph->setGradient();
    }
    $graph->setLegend(true);
    $graph->setLegendTitle(unserialize($_REQUEST['titles']));
    $graph->createGraph();
} elseif ($_REQUEST['mode'] == 'graph_pie') {
    include '../lib/phpgraphlib.php';
    include '../lib/phpgraphlib_pie.php';
    $graph = new PHPGraphLibPie(1120, 600);
    $graph->addData(unserialize($_REQUEST['graph_data']));
    $graph->setLabelTextColor("50,50,50");
    $graph->createGraph();
}
Ejemplo n.º 12
0
            break;
        case 'memuse':
            $graph = new PHPGraphLib(800, 450, "./result-" . date("Ymd") . "/memory-usage.png");
            $graph->addData($rsm['memuse']);
            $graph->setTitle("Memory Usage (KB)");
            break;
        case 'files':
            $graph = new PHPGraphLib(800, 450, "./result-" . date("Ymd") . "/number-of-files.png");
            $graph->addData($rsm['files']);
            $graph->setTitle("Number of files been included or required");
            break;
        case 'funcal':
            $graph = new PHPGraphLib(800, 450, "./result-" . date("Ymd") . "/number-of-function-calls.png");
            $graph->addData($rsm['funcal']);
            $graph->setTitle("Number fo function calls");
            break;
        case 'time':
            $graph = new PHPGraphLib(800, 450, "./result-" . date("Ymd") . "/response-time.png");
            $graph->addData($rsm['time']);
            $graph->setTitle("Response Time (Millisecond)");
            break;
        default:
            continue;
    }
    $graph->setTitleLocation('left');
    $graph->setBarColor('255,102,51');
    $graph->setDataValues(true);
    $graph->setXValuesHorizontal(true);
    $graph->setupXAxis(20, '');
    $graph->createGraph();
}
Ejemplo n.º 13
0
                 $recent[$value['interface']] = round($value['bytes']);
                 $total_new = round($total + $value['bytes']);
             }
         }
         // process last 6 hour traffic array
         foreach ($traffic_old as $key_old => $value_old) {
             if ($value_old['interface'] !== 'lo') {
                 $value_old['bytes'] = $value_old['bytes'] / 1024 / 1024;
                 $old[$value_old['interface']] = round($value_old['bytes']);
                 $total_old = round($total_old + $value_old['bytes']);
             }
         }
         // get total from both data sets
         $total = $total_new + $total_old;
         // push the image and assign attributes
         $graph->addData($old, $recent);
         $graph->setTitle("MBytes Total: " . $total);
         $graph->setTitleLocation("left");
         $graph->setLegendTitle("Last 60 Minutes", "Last 6 Hours");
         $graph->setBars(true);
         $graph->setLegend(true);
         $graph->setDataPoints(true);
         $graph->setDataPointColor("red");
         $graph->setDataValueColor("gray");
         $graph->setGoalLineColor("red");
         $graph->createGraph();
     }
 } else {
     // page view restricted by access level
     $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['level']);
 }
Ejemplo n.º 14
0
 public function addData($data, $data2 = '', $data3 = '', $data4 = '', $data5 = '')
 {
     parent::addData($data, $data2, $data3, $data4, $data5);
     $key_max = array();
     //loop through each row, adding values to keyed arrays to find combined max
     foreach ($this->data_array as $data_set_num => $data_set) {
         foreach ($data_set as $key => $item) {
             $key_max[$key] = isset($key_max[$key]) ? $key_max[$key] + $item : $item;
             if ($key_max[$key] < $this->data_min) {
                 $this->data_min = $key_max[$key];
             }
             if ($key_max[$key] > $this->data_max) {
                 $this->data_max = $key_max[$key];
             }
         }
     }
 }
Ejemplo n.º 15
0
<?php

include "phpgraphlib.php";
$graph = new PHPGraphLib(1300, 420);
$link = mysql_connect('localhost', 'root', 'root') or die('Could not connect: ' . mysql_error());
mysql_select_db('nixlogger') or die('Could not select database');
$dataArray = array();
//get data from database
$sql = "(SELECT * FROM log_table ORDER BY date_time DESC  LIMIT 0,360) ORDER BY date_time ASC";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
    while ($row = mysql_fetch_assoc($result)) {
        $date_time = $row["date_time"];
        $mem_used = $row["mem_used"];
        $cpu_load = $row["cpu_load"];
        //add to data areray
        $dataArray[$date_time] = $mem_used;
        $data2[$date_time] = $cpu_load;
    }
}
//configure graph
$graph->addData($dataArray, $data2);
$graph->setTitle("system memory usage ");
$graph->setBarColor('blue', 'green');
$graph->setBarOutlineColor("black");
$graph->createGraph();
Ejemplo n.º 16
0
     if (ObjectValidation::validateDate($data) == false) {
         ImageText::createTextImage($chartWidth, $chartHeight, "Blogas datos formatas");
         exit(0);
     }
     $graph->setTitle($data);
     $dbQuery = "SELECT * FROM PadaliniuParaiskuKiekis WHERE Nuo = '" . $data . "'";
     $dbResult = db::select($dbQuery);
     if (empty($dbResult["data"])) {
         ImageText::createTextImage($chartWidth, $chartHeight, "Neturima duomenų apie pasirinktą mėnesį");
         exit(0);
     }
     $chartData = array();
     foreach ($dbResult["data"] as $i) {
         $chartData[$i["Kodas"]] = $i["Paraiskos"];
     }
     $graph->addData($chartData);
     drawAnalysisGraph($graph);
     break;
 case "is_paraiskos":
     if (!isset($_GET["menuo"])) {
         ImageText::createTextImage($chartWidth, $chartHeight, "Bloga nuoroda");
         exit(0);
     }
     $data = $_GET["menuo"] . "-01";
     if (ObjectValidation::validateDate($data) == false) {
         ImageText::createTextImage($chartWidth, $chartHeight, "Blogas datos formatas");
         exit(0);
     }
     $graph->setTitle($data);
     $dbQuery = "SELECT * FROM IsParaiskuKiekis WHERE Nuo = '" . $data . "'";
     $dbResult = db::select($dbQuery);
Ejemplo n.º 17
0
<?php

session_start();
require_once "../Includes.php";
//print("<img src=\"../Utilities/Charts.php?chart=padaliniu_paraiskos&menuo=2008-01-01\">");
$graph = new PHPGraphLib(650, 200);
$data1 = array(0);
$data2 = array(8, 15, 4, 12);
$data3 = array(1, 2, 3, 4);
$graph->addData($data2);
$graph->setTitle('PPM Per Container');
$graph->setBars(false);
$graph->setLine(true);
$graph->setLineColor('#FF0000', 'green', 'red');
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('maroon');
$graph->setLegend(true);
$graph->setLegendTitle("PA1", "PA2", "PA3");
$graph->createGraph();
p(ErrorMessages::getErrors());
Ejemplo n.º 18
0
                 $total_leases = $total_leases + $total;
                 // trim last octet off subnet broadcast addr
                 preg_match('/([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\.[0-9]{1,3}/', $value['subnet'], $match);
                 $sql = "SELECT `ip` FROM `conf_leases` WHERE `ip` LIKE \"" . $match[1] . ".%\"";
                 // execute query and place results (if any) in array per-subnet
                 if (($value = $db->dbQuery($val->ValidateSQL($sql, $dbconn), $dbconn)) !== -1) {
                     $all[$name] = $total;
                     $data[$name] = count($db->dbArrayResults($value));
                 }
             }
         }
         // generate our graphs but check for gd lib extensions first
         if (function_exists('imagedestroy')) {
             $graph = new PHPGraphLib(450, 200);
             // push the image and assign attributes
             $graph->addData($data, $all);
             $graph->setTitle("Total Leases: " . $total_leases);
             $graph->setTitleLocation("left");
             $graph->setLegendTitle("Available", "In Use");
             $graph->setBars(true);
             $graph->setLegend(true);
             $graph->setDataPoints(true);
             $graph->setDataPointColor("red");
             $graph->setDataValueColor("gray");
             $graph->createGraph();
         }
     } else {
         // page view restricted by access level
         $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['level']);
     }
 } else {
Ejemplo n.º 19
0
//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();
Ejemplo n.º 20
0
<?php

include '../phpgraphlib.php';
$set1 = array(1917 => 4011, 1918 => 4886, 1919 => 5411, 1920 => 5831, 1921 => 5865, 1922 => 5704, 1923 => 5337, 1924 => 5144, 1925 => 5018, 1926 => 4971, 1927 => 4630, 1928 => 4411, 1929 => 4287, 1930 => 4116, 1931 => 3940, 1932 => 3764, 1933 => 3592, 1934 => 3447, 1935 => 3280, 1936 => 3215, 1937 => 3366, 1938 => 3569, 1939 => 3598, 1940 => 4436, 1941 => 5939, 1942 => 7397, 1943 => 8855, 1944 => 9835, 1945 => 9998, 1946 => 10631, 1947 => 11340, 1948 => 11549, 1949 => 11642);
$set2 = array(1910 => 2059, 1911 => 2135, 1912 => 2209, 1913 => 2332, 1914 => 2437, 1915 => 2786, 1916 => 3747, 1917 => 5011, 1918 => 5886, 1919 => 6411, 1920 => 6831, 1921 => 6865, 1922 => 6704, 1923 => 6337, 1924 => 6144, 1925 => 6018, 1926 => 5971, 1927 => 5630, 1928 => 5411, 1929 => 5287, 1930 => 5116, 1931 => 4940, 1932 => 4764, 1933 => 4592, 1934 => 4447, 1935 => 4280, 1936 => 4215, 1937 => 4366, 1938 => 4569, 1939 => 4598, 1940 => 5436, 1941 => 5939, 1942 => 8397, 1943 => 9855, 1944 => 10835);
$graph = new PHPGraphLib(600, 400);
$graph->addData($set1, $set2);
$graph->setTitleLocation('left');
$graph->setTitle("Two sets with different start points");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(false);
$graph->setLineColor('blue', 'red');
$graph->setDataValues(false);
$graph->setXValuesInterval(5);
$graph->setDataValueColor('blue', 'red');
$graph->setLegend(true);
$graph->setLegendTitle("set1", "set2");
$graph->createGraph();
Ejemplo n.º 21
0
<?php

include '../phpgraphlib.php';
$graph = new PHPGraphLib(350, 280);
$data = array("Roger" => 145, "Ralph" => 102, "Rhonda" => 123, "Ronaldo" => 137, "Rosario" => 149, "Robin" => 99, "Robert" => 88, "Rustof" => 111);
$graph->setBackgroundColor("black");
$graph->addData($data);
$graph->setBarColor('255, 255, 204');
$graph->setTitle('IQ Scores');
$graph->setTitleColor('yellow');
$graph->setupYAxis(12, 'yellow');
$graph->setupXAxis(20, 'yellow');
$graph->setGrid(false);
$graph->setGradient('silver', 'gray');
$graph->setBarOutlineColor('white');
$graph->setTextColor('white');
$graph->setDataPoints(true);
$graph->setDataPointColor('yellow');
$graph->setLine(true);
$graph->setLineColor('yellow');
$graph->createGraph();
Ejemplo n.º 22
0
 /**
  * Function to generate a file containing a graph of power (kW) against
  * solar radiation (W/m2) using data from the given tables.  A date range
  * can be specified to restrict the x-axis.
  * @param string $imageFilename Name of file to write graph to
  * @param string $powerTable Name of table to get power data from
  * @param string $solRadTable Name of table to get solar radiation data from
  * @param array $dateRange An optional array of two DateTime objects to limit
  *                         the range of data used
  */
 public function createGraphImage($imageFilename, $powerTable, $powerColumn, $solRadTable, &$dateRange = NULL)
 {
     global $verbose;
     if (!$this->graphsEnabled) {
         return;
     }
     // We inner join the tables on the datetime field.  This is expected to be called on
     // a solar radiation data table and a instananeous power data table so the two can
     // be easily compared.  They will need different y-axes.
     if ($verbose > 0) {
         print "Generating power graph in file {$imageFilename}\n";
     }
     $sql = "SELECT {$powerTable}.datetime, {$powerTable}.{$powerColumn}, sol_rad\n                FROM {$solRadTable} INNER JOIN {$powerTable}\n                ON {$powerTable}.datetime = {$solRadTable}.datetime";
     $whereClause = '';
     $whereClausePower = '';
     if ($dateRange != NULL) {
         $whereClause = " WHERE DATE({$solRadTable}.datetime) > '" . $dateRange[0]->format('Y-m-d') . "' &&\n                                   DATE({$solRadTable}.datetime) < '" . $dateRange[1]->format('Y-m-d') . "'";
         $whereClausePower = str_replace($solRadTable, $powerTable, $whereClause);
     }
     $sql .= $whereClause;
     $data = $this->fetchQuery($sql);
     $maxSolRad = $this->fetchQuery("SELECT MAX(sol_rad) FROM {$solRadTable}" . $whereClause, PDO::FETCH_NUM);
     $maxPower = $this->fetchQuery("SELECT MAX({$powerColumn}) FROM {$powerTable}" . $whereClausePower, PDO::FETCH_NUM);
     if ($maxPower[0][0] == 0) {
         // If there was never any power, divide by 1 rather than 0 when scaling!
         $maxPower[0][0] = 1;
     }
     $graph = new PHPGraphLib(10000, 1000, $imageFilename);
     $graph->setTitle($powerTable . ' against solar radiation (both scaled to % of maximum recorded value)');
     $graph->setBars(FALSE);
     $graph->setLine(TRUE);
     $graph->setLineColor('red', 'yellow');
     $graph->setLegend(TRUE);
     $graph->setLegendTitle('Power', 'Solar radiation');
     // Reassmble the data into the form needed for PHPGraphLib and scale values so they can be plotted on the same
     // y-axis (a limitation of PHPGraphLib...if we can go GPLv3, we can use PCharts2 which can do multiple y-axes,
     // or there's SVGGraph which is LGPL).
     foreach ($data as $entry) {
         $powerData[$entry['datetime']] = $entry[$powerColumn] / $maxPower[0][0] * 100;
         $solRadData[$entry['datetime']] = $entry['sol_rad'] / $maxSolRad[0][0] * 100;
     }
     // Free up memory (maybe!)
     $data = NULL;
     $graph->addData($powerData, $solRadData);
     $graph->createGraph();
 }