* * The data is an array of arrays that consist the following data: *o numeric value *o value legend *o red \ *o green > the RGB values for the color of the slice/legend *o blue / *
예제 #1
0
파일: pie.php 프로젝트: fjpqzm/ganglia-web
        $r = hexdec(substr($hex, 0, 2));
        $g = hexdec(substr($hex, 2, 2));
        $b = hexdec(substr($hex, 4, 2));
        return array($r, $g, $b);
    }
}
/* }}} */
$debug = 0;
// Parse CGI GET vars and generate chart.
//
// Format is ?name=value,color&name2=value,color...
// where name is set title, and color is in hex like (ffffff).
//
// Special names: title=[graph title], size=[WxH].
$vals = array();
$pie = new piechart();
foreach ($_GET as $key => $val) {
    if ($key == "title") {
        $heads[] = array($val, 4, "c");
    } elseif ($key == "size") {
        list($w, $h) = explode("x", $val);
    } else {
        list($value, $color) = explode(",", $val);
        list($r, $g, $b) = $pie->hex2rgb($color);
        $vals[] = array($value, $key, $r, $g, $b);
    }
}
if (!$w or !$h) {
    $w = 400;
    $h = 300;
}
예제 #2
0
    $dir[$key] = $row[1];
    $usage[$key] = $row[2];
    $limit[$key] = $row[3];
    $hard[$key] = $row[4];
    $used[$key] = $row[5];
}
array_multisort($used, SORT_NUMERIC, SORT_DESC, $filearray);
foreach ($filearray as $info) {
    list($red, $green, $blue) = $colors[$count];
    $vals[] = array((int) $info[5], $info[1], $red, $green, $blue);
    if ($count == 15) {
        break;
    }
    $count++;
}
$heads = array(array("Top 16 Biggest Directory's", 4, "c"), array("on pugsly /export/home", 4, "c"), array("", 4, "c"));
/*
print "<pre>";
print_r($colors);
print_r($vals);
print "</pre>";
*/
$pie = new piechart();
$pie->init(900, 700, $vals);
$pie->draw_heading($heads);
$pie->set_legend_percent();
$pie->display();
/*
* Local Variables:
* tab-width: 3
* End: */
예제 #3
0
<?php

error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
include "piechart.class.php";
$chart1 = new piechart(50, array('Used beds', 'Maximum beds'), array(50, 50), array('yellow', 'wheat'));
header('Content-type: image/jpeg');
$chart1->draw();
/*$chart1->out('test1.jpg',0);
$chart1->out('test2.jpg',100);
*/
?>

예제 #4
0
$count = 0;
if (count($users_id) > 0) {
    $users = @implode(",", $users_id);
    $sql1 = "select count(rater_userid) as count\n\t\t\n from {$other_raters},{$user_table} where {$other_raters}.cur_userid={$user_table}.user_id and\n\t\t \n  cur_userid<>rater_userid and \n\t\t  \n rating_over='y' and rater_userid in" . "(" . $users . ")" . " and (date_rating_requested-date_rating_over)<='{$one_week}'";
    $res1 = $db_object->get_single_column($sql1);
    $o_count += $res1[0];
    $sql2 = "select count(ref_userid) as count\n\nfrom {$tech_references},{$user_table} where {$tech_references}.user_to_rate={$user_table}.user_id and\n\nuser_to_rate<>ref_userid and \n\nrating_over='y' and ref_userid in " . "(" . $users . ")" . " and (date_rating_requested-date_rating_over)<='{$one_week}'";
    $res2 = $db_object->get_single_column($sql2);
    $o_count += $res2[0];
    $sql1 = "select count(rater_userid) as count\n\t\t\n from {$other_raters},{$user_table} where {$other_raters}.cur_userid={$user_table}.user_id and\n\t\t \n  cur_userid<>rater_userid and \n\t\t  \n  rater_userid in" . "(" . $users . ")";
    $res1 = $db_object->get_single_column($sql1);
    $ot_count += $res1[0];
    $sql2 = "select count(ref_userid) as count\n\nfrom {$tech_references},{$user_table} where {$tech_references}.user_to_rate={$user_table}.user_id and\n\nuser_to_rate<>ref_userid and \n\nref_userid in " . "(" . $users . ")";
    $res2 = $db_object->get_single_column($sql2);
    $ot_count += $res2[0];
    $pie = new piechart();
    $path = $common->path;
    $array = array($o_count, $ot_count);
    if ($ot_count != 0) {
        $heads = array(array("Rating Others", 3, "c"));
        $vals = $pie->return_Array($array);
        $image->init(150, 150, $vals);
        $image->draw_heading($heads);
        $image->set_legend_percent();
        $image->display($filename);
    }
} else {
    $heads = array(array("No employee", 3, "c"), array("under this admin", 3, "c"));
    $image = ImageCreate(150, 150);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
예제 #5
0
<?php

error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
require './roots.php';
/*
* We do not need the entire environment here so we just load the variable globalizer routine
*/
//require($root_path.'include/inc_vars_resolve.php');
define('PIE_CHART_BASE_COLOR', 'greenyellow');
// define the base color of the pie chart
define('PIE_CHART_RADIUS', 25);
// define the radius of the pie chart
if (!extension_loaded('gd')) {
    dl('php_gd.dll');
}
//pull out params from URL string
$qouta = 1;
$used = 0;
$uc = PIE_CHART_BASE_COLOR;
if (isset($_GET['qouta']) && isset($_GET['used']) && isset($_GET['uc'])) {
    $qouta = $_GET['qouta'];
    $used = $_GET['used'];
    $uc = $_GET['uc'];
}
/* Load the pie chart generator */
require $root_path . 'classes/pie_chart/piechart.class.php';
$chart = new piechart(PIE_CHART_RADIUS, array('', ''), array($qouta, $used), array(PIE_CHART_BASE_COLOR, $uc));
header('Content-type: image/png');
$chart->draw();