public function gpastel_getImagen($titulo = " ", $width = "500", $height = "350")
 {
     $config = XTConfig::singleton();
     $data = $this->pastel_data;
     $nombreimagen = uniqid() . "pieimagen.png";
     $file = $config->get("XTSITE_PATH_ABSOLUTE") . "tmp/pie/" . $nombreimagen;
     $file_url = $config->get("XTSITE_PATH") . "tmp/pie/" . $nombreimagen;
     $graph = new PHPGraphLibPie($width, $height, $file);
     $graph->addData($data);
     $graph->setTitle($titulo);
     $graph->setLabelTextColor('50,50,50');
     $graph->setLegendTextColor('50,50,50');
     $graph->createGraph();
     print "<img src=\"{$file_url}\">";
 }
Example #2
0
<?php

include '../phpgraphlib.php';
include '../phpgraphlib_pie.php';
$graph = new PHPGraphLibPie(400, 200);
$data = array("CBS" => 6.3, "NBC" => 4.5, "FOX" => 2.8, "ABC" => 2.7, "CW" => 1.4);
$graph->addData($data);
$graph->setTitle('8/29/07 Top 5 TV Networks Market Share');
$graph->setLabelTextColor('50, 50, 50');
$graph->setLegendTextColor('50, 50, 50');
$graph->createGraph();
Example #3
0
<?php

error_reporting(0);
include "phpgraphlib.php";
include "phpgraphlib_pie.php";
$showsmall = $_GET['showsmall'];
$datavalues = $_GET['datavalues'];
$header = unserialize(urldecode(stripslashes($_GET['header'])));
$data = unserialize(urldecode(stripslashes($_GET['mydata'])));
if ($showsmall) {
    $graph = new PHPGraphLibPie(300, 200);
} else {
    $graph = new PHPGraphLibPie(500, 300);
}
if ($datavalues) {
    $graph->setDataValues(true);
} else {
    $graph->setDataValues(false);
}
$graph->addData($data);
$graph->setTitle($header);
$graph->setLabelTextColor("blue");
$graph->createGraph();
<?php

session_start();
require_once "../../conf/pathconf.php";
require_once "phpgraphlib.php";
require_once "phpgraphlib_pie.php";
$data = $_SESSION["_pasteltmp_data"];
$titulo = $_SESSION["_pasteltmp_titulo"];
$width = $_SESSION["_pasteltmp_width"];
$height = $_SESSION["_pasteltmp_height"];
/*$_SESSION["_pasteltmp_data"] = null;
$_SESSION["_pasteltmp_titulo"] = null;
$_SESSION["_pasteltmp_width"] = null;
$_SESSION["_pasteltmp_height"] = null;*/
$graph = new PHPGraphLibPie($width, $height, XTSITE_PATH_ABSOLUTE . "tmp/pie/_" . $_SESSION["USERID"] . $_SESSION["TIPOID"] . "pieimagen.png");
$graph->addData($data);
$graph->setTitle($titulo);
$graph->setLabelTextColor('50,50,50');
$graph->setLegendTextColor('50,50,50');
$graph->createGraph();
                     }
                 }
                 // now build an unassigned list
                 $sql['hosts'] = "SELECT * FROM `conf_hosts` WHERE `subnet-name` IS NULL OR `subnet-name` = ''";
                 if (($value = $db->dbQuery($val->ValidateSQL($sql['hosts'], $dbconn), $dbconn)) !== -1) {
                     $hostdata['unassigned'] = $db->dbArrayResults($value);
                 }
                 // generate our graphs but check for gd lib extensions first
                 if (function_exists('imagedestroy')) {
                     $graph = new PHPGraphLibPie(450, 200);
                     foreach ($hostdata as $key => $value) {
                         $array[$key] = count($value);
                         $total = $total + count($value);
                     }
                     $graph->addData($array);
                     $graph->setTitle("Hosts to Subnet Assignments: Total static hosts #" . $total);
                     $graph->setLabelTextColor("50, 50, 50");
                     $graph->setLegendTextColor("50, 50, 50");
                     $graph->setLegendOutlineColor("black");
                     $graph->createGraph();
                 }
             }
         } else {
             // page view restricted by access level
             $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['level']);
         }
     } else {
         // general authentication error
         $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['auth_n']);
     }
 } else {
if (isset($_REQUEST['type'])) {
    if ($_REQUEST['type'] == "week") {
        //Last 7 days
        $range = "AND date > DATE_SUB(NOW(), INTERVAL 7 DAY)";
        $title = "Spending in last 7 days by percentage";
    } else {
        if ($_REQUEST['type'] == "month") {
            //Previous month
            $range = "AND YEAR(date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)\r\nAND MONTH(date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)";
            $title = "Spending in previous month by percentage";
        }
    }
}
//Null array so the array_push works
$data = array();
//Get database paramters
require_once "../scripts/connectvars.php";
//Attempt connection to database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Couldn't connect to server: " . mysqli_error());
//Create query to get required data
//Ignore categories where nothing has been spent
$query = "SELECT tbl_category.description AS 'Expense', SUM(tbl_item.amount) AS 'Total'\r\nFROM tbl_item\r\nJOIN (tbl_category) USING (category_id)\r\nWHERE tbl_item.user_id='{$_SESSION['user_id']}' " . $range . " GROUP BY tbl_category.description\r\nORDER BY tbl_category.description ASC;";
$result = mysqli_query($dbc, $query) or die("Couldn't get user data: ") . mysqli_error($dbc);
while ($row = mysqli_fetch_row($result)) {
    $data[$row[0]] = $row[1];
}
$graph->addData($data);
$graph->setTitle($title);
$graph->setLabelTextColor('50,50,50');
$graph->setLegendTextColor('50,50,50');
$graph->createGraph();
                     }
                 }
                 // now build an unassigned list
                 $sql['hosts'] = "SELECT * FROM `conf_hosts` WHERE `pxe-group` IS NULL OR `pxe-group` = ''";
                 if (($value = $db->dbQuery($val->ValidateSQL($sql['hosts'], $dbconn), $dbconn)) !== -1) {
                     $hostdata['unassigned'] = $db->dbArrayResults($value);
                 }
                 // generate our graphs
                 if (function_exists('imagedestroy')) {
                     $graph = new PHPGraphLibPie(450, 200);
                     foreach ($hostdata as $key => $value) {
                         $array[$key] = count($value);
                         $total = $total + count($value);
                     }
                     $graph->addData($array);
                     $graph->setTitle("Hosts to PXE Group Assignments: Total hosts to pxe groups #" . $total);
                     $graph->setLabelTextColor("50, 50, 50");
                     $graph->setLegendTextColor("50, 50, 50");
                     $graph->setLegendOutlineColor("black");
                     $graph->createGraph();
                 }
             }
         } else {
             // page view restricted by access level
             $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['level']);
         }
     } else {
         // general authentication error
         $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['auth_n']);
     }
 } else {
<?php

$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '******';
$link = mysql_connect($dbhost, $dbuser, $dbpass) or die('Could not connect: ' . mysql_error());
mysql_select_db('buttonnb') or die('Could not select database');
$data = array();
//get data from database
$sql = "SELECT return_value, currtime FROM balr2_tbl LIMIT 150";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
    while ($row = mysql_fetch_assoc($result)) {
        $return_value = $row["return_value"];
        $count = $row["currtime"];
        //add to data areray
        $data[$count] = $return_value;
    }
}
include 'phpgraphlib.php';
include 'phpgraphlib_pie.php';
$graph = new PHPGraphLibPie(400, 200);
$graph->addData($data);
$graph->setTitle('Analyze');
//$data = array("CBS" => 6.3, "NBC" => 4.5,"FOX" => 2.8, "ABC" => 2.7, "CW" => 1.4);
$graph->addData($data);
//$graph->setTitle('8/29/07 Top 5 TV Networks Market Share');
$graph->setLabelTextColor('50,50,50');
$graph->setLegendTextColor('50,50,50');
$graph->createGraph();