Example #1
0
/**
 * Show Horizontal Bar graph
 */
function ShowHBar(&$legend, &$value)
{
    $height = 50 + count($value) * 18;
    $width = 500;
    // Set the basic parameters of the graph
    $graph = new Graph($width, $height, 'auto');
    $graph->SetScale("textlin");
    $top = 30;
    $bottom = 20;
    $left = 100;
    $right = 50;
    $graph->Set90AndMargin($left, $right, $top, $bottom);
    $graph->xaxis->SetTickLabels($legend);
    $graph->SetFrame(false);
    // Label align for X-axis
    $graph->xaxis->SetLabelAlign('right', 'center', 'right');
    // Label align for Y-axis
    $graph->yaxis->SetLabelAlign('center', 'bottom');
    // Create a bar pot
    $bplot = new BarPlot($value);
    $bplot->SetFillColor("orange");
    $bplot->SetWidth(0.5);
    // We want to display the value of each bar at the top
    $graph->yaxis->scale->SetGrace(10);
    $graph->yaxis->SetLabelAlign('center', 'bottom');
    $graph->yaxis->SetLabelFormat('%d');
    $bplot->value->Show();
    $bplot->value->SetFormat('%.d votes');
    // Setup color for gradient fill style
    $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_MIDVER);
    $graph->Add($bplot);
    $graph->Stroke();
}
function makeGraph($x_data, $y_data, $num_results, $title = "Statistics", $graph_type = "bar", $graph_scale = "textint")
{
    // default graph info
    $width = 600;
    $height = 500;
    $top = 60;
    $bottom = 30;
    $left = 80;
    $right = 30;
    if ($graph_type != 'csv' && $num_results == 0) {
        header('Content-type: image/png');
        readfile($GLOBALS['BASE_DIR'] . '/images/no-calls.png');
        exit;
    }
    // Set the basic parameters of the graph
    switch ($graph_type) {
        case "line":
            //do line graph here
            break;
            // not really a graph, returns comma seperated values
        // not really a graph, returns comma seperated values
        case "csv":
            header("content-type: text/csv");
            header('Content-Disposition: attachment; filename="statistics.csv"');
            $columns = implode(',', $x_data);
            $rows = implode(',', $y_data);
            echo $columns . "\n" . $rows;
            break;
        case "bar":
        default:
            // bar is default
            $graph = new Graph($width, 90 + 10 * $num_results, 'auto');
            $graph->SetScale($graph_scale);
            // Nice shadow
            $graph->SetShadow();
            $graph->Set90AndMargin($left, $right, $top, $bottom);
            // Setup labels
            $graph->xaxis->SetTickLabels($x_data);
            // Label align for X-axis
            $graph->xaxis->SetLabelAlign('right', 'center', 'right');
            // Label align for Y-axis
            $graph->yaxis->SetLabelAlign('center', 'bottom');
            // Create a bar pot
            $bplot = new BarPlot($y_data);
            $bplot->SetFillColor("#708090");
            $bplot->SetWidth(0.5);
            $bplot->SetYMin(0);
            //$bplot->SetYMin(1990);
            $graph->title->Set($title);
            $graph->Add($bplot);
            $graph->Stroke();
    }
}
Example #3
0
 public function executeBarGraph()
 {
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     // Change this defines to where Your fonts are stored
     DEFINE("TTF_DIR", "/usr/share/fonts/truetype/freefont/");
     // Change this define to a font file that You know that You have
     DEFINE("TTF_SANS", "FreeSans.ttf");
     $util = new util();
     $dataDVDrip = $util->getTotalFormat('DVDrip', 'movies');
     $dataHDrip = $util->getTotalFormat('HDrip', 'movies');
     $data720p = $util->getTotalFormat('720p', 'movies');
     $data1080p = $util->getTotalFormat('1080p', 'movies');
     $datay = array($dataDVDrip, $dataHDrip, $data720p, $data1080p);
     $graph = new Graph(199, 145);
     $graph->SetScale('textlin');
     $graph->SetColor('black');
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $top = 25;
     $bottom = 20;
     $left = 50;
     $right = 20;
     $graph->Set90AndMargin($left, $right, $top, $bottom);
     // Setup labels
     $lbl = array("DVDrip", "HDrip", "720p", "1080p");
     $graph->xaxis->SetTickLabels($lbl);
     $graph->xaxis->SetColor('white');
     $graph->xaxis->SetLabelAlign('right', 'center', 'right');
     $graph->yaxis->SetLabelAlign('center', 'bottom');
     $graph->yaxis->SetColor('white');
     // Create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetWidth(0.5);
     $bplot->SetFillGradient(array(250, 2, 2), array(109, 2, 2), GRAD_VERT);
     $graph->Add($bplot);
     $graph->Stroke();
     return sfView::NONE;
 }
Example #4
0
// creamos dos grupos y añadimos sus valores
$data = array();
foreach ($var as $value) {
    $data['title'][] = $value['var1'];
    $data['value'][] = $value['var2'];
}
//
require_once 'ossim_conf.inc';
$conf = $GLOBALS["CONF"];
$jpgraph = $conf->get_conf("jpgraph_path");
require_once "{$jpgraph}/jpgraph.php";
require_once "{$jpgraph}/jpgraph_bar.php";
// Setup the graph.
$graph = new Graph(600, 250, "auto");
$graph->SetScale("textlin");
$graph->Set90AndMargin(270, 10, 20, 0);
$graph->SetMarginColor("#fafafa");
$graph->xaxis->SetTickLabels($data['title']);
$graph->SetColor("#fafafa");
$graph->SetFrame(true, '#fafafa', 0);
// Create the bar plots
$b1plot = new BarPlot($data['value']);
// color@transparencia
$b1plot->SetFillColor(array(COLOR1 . "@0.5", COLOR2 . "@0.5", COLOR3 . "@0.5", COLOR4 . "@0.5", COLOR5 . "@0.5", COLOR6 . "@0.5", COLOR7 . "@0.5", COLOR8 . "@0.5", COLOR9 . "@0.5", COLOR10 . "@0.5", COLOR11 . "@0.5", COLOR12 . "@0.5"));
//
$b1plot->SetShadow(array(COLOR1 . "@0.7", COLOR2 . "@0.7", COLOR3 . "@0.7", COLOR4 . "@0.7", COLOR5 . "@0.7", COLOR6 . "@0.7", COLOR7 . "@0.7", COLOR8 . "@0.7", COLOR9 . "@0.7", COLOR10 . "@0.7", COLOR11 . "@0.7", COLOR12 . "@0.7"), 5, 5);
$b1plot->SetColor(array(COLOR1 . "@1", COLOR2 . "@1", COLOR3 . "@1", COLOR4 . "@1", COLOR5 . "@1", COLOR6 . "@1", COLOR7 . "@1", COLOR8 . "@1", COLOR9 . "@1", COLOR10 . "@1", COLOR11 . "@1", COLOR12 . "@1"));
//
$graph->Add($b1plot);
// Finally send the graph to the browser
$graph->Stroke();
Example #5
0
}
$sqltool = new SQLTool();
$res = $sqltool->dbQuery("select depart_name,depart_id,(select count(req_num) from t_req,t_user where t_req.req_author=t_user.user_name and t_user.depart_id=t_depart.depart_id {$sql}) num from t_depart order by num desc");
for ($i = 0; $i < count($res); $i++) {
    $datay[$i] = $res[$i][2];
    $datax[$i] = $res[$i][0];
}
// Size of graph
$width = 870;
$height = count($res) * 40 + 20;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale('textlin');
$graph->setcolor('white');
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(100, 20, 30, 10);
// Setup title
$graph->title->Set($title);
$graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(10);
// We don't want to display Y-axis
$graph->yaxis->Hide();
Example #6
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(17, 22, 33, 48, 24, 20);
// Create the graph. These two calls are always required
$graph = new Graph(220, 300, 'auto');
$graph->SetScale("textlin");
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->Set90AndMargin(50, 40, 40, 40);
$graph->img->SetAngle(90);
// set major and minor tick positions manually
$graph->SetBox(false);
//$graph->ygrid->SetColor('gray');
$graph->ygrid->Show(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D', 'E', 'F'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// For background to be gradient, setfill is needed first.
$graph->SetBackgroundGradient('#00CED1', '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
// Create the bar plots
$b1plot = new BarPlot($datay);
// ...and add it to the graPH
$graph->Add($b1plot);
$b1plot->SetWeight(0);
$b1plot->SetFillGradient("#808000", "#90EE90", GRAD_HOR);
$b1plot->SetWidth(17);
// Display the graph
Example #7
0
 function GerarGraficoBarraHorizontal()
 {
     require_once "../biblioteca/jpgraph/jpgraph.php";
     require_once "../biblioteca/jpgraph/jpgraph_bar.php";
     $graph = new Graph($this->largura, $this->altura, "png");
     $graph->SetScale("textlin");
     $graph->Set90AndMargin(600, 40, 40, 40);
     $graph->xaxis->SetPos('min');
     $graph->SetShadow($this->cor_sombra);
     $graph->title->Set($this->titulo);
     $graph->subtitle->Set($this->subtitulo);
     $graph->xaxis->SetTickLabels($this->dados_eixoX);
     $graph->xaxis->SetLabelMargin(15);
     $graph->xaxis->SetLabelAlign('right', 'center');
     $graph->xaxis->SetLabelFormat($this->label_formato);
     $graph->yaxis->SetPos('max');
     $graph->yaxis->SetLabelAlign('center', 'top');
     $graph->yaxis->SetLabelSide(SIDE_RIGHT);
     $graph->yaxis->SetTickSide(SIDE_LEFT);
     $graph->yaxis->SetTitleSide(SIDE_RIGHT);
     $graph->yaxis->SetTitleMargin(50);
     $graph->yaxis->SetTitle("");
     $graph->yaxis->title->Align('left');
     $graph->yaxis->title->SetAngle(0);
     $bplot = new BarPlot($this->dados_eixoY);
     $bplot->SetFillColor($this->cor_barra);
     $bplot->SetShadow($this->cor_sombra);
     $bplot->value->Show();
     $bplot->value->SetAlign('left', 'center');
     $bplot->value->SetColor("black", "darkred");
     $bplot->value->SetFormat($this->formato);
     // Add the bar to the graph
     $graph->Add($bplot);
     $graph->Stroke("imagens/graficos/" . $this->nome);
 }
Example #8
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(2, 3, 5, 8, 12, 6, 3);
$datax = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul");
$width = 400;
$height = 500;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale("textlin");
$top = 80;
$bottom = 30;
$left = 50;
$right = 30;
$graph->Set90AndMargin($left, $right, $top, $bottom);
// Nice shadow
$graph->SetShadow();
// Setup title
$graph->title->Set("Horizontal bar graph ex 2");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->subtitle->Set("(Axis at top)");
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 12);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(5);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
    function top($VAR)
    {
        global $smarty, $C_translate, $C_auth;
        # Get the period type, default to month
        if (empty($VAR['period'])) {
            $p = 'm';
        } else {
            $p = $VAR['period'];
        }
        # Load the jpgraph class
        include PATH_GRAPH . "jpgraph.php";
        include PATH_GRAPH . "jpgraph_bar.php";
        # check the validation for this function
        if (!$C_auth->auth_method_by_name($this->module, 'search')) {
            $error = $C_translate->translate('module_non_auth', '', '');
            include PATH_GRAPH . "jpgraph_canvas.php";
            $graph = new CanvasGraph(460, 55, "auto");
            $t1 = new Text($error);
            $t1->Pos(0.2, 0.5);
            $t1->SetOrientation("h");
            $t1->SetBox("white", "black", 'gray');
            $t1->SetFont(FF_FONT1, FS_NORMAL);
            $t1->SetColor("black");
            $graph->AddText($t1);
            $graph->Stroke();
            exit;
        }
        # Get the period start & end
        switch ($p) {
            # By Weeks:
            case 'w':
                $interval = "1";
                $width = ".9";
                $title = 'Top Accounts for Last Last Week';
                $dow = date('w');
                $start_str = mktime(0, 0, 0, date('m'), date('d') - $dow, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
                # By Months:
            # By Months:
            case 'm':
                $interval = "3";
                $width = ".6";
                $title = 'Top Accounts for Last Last Month';
                $start_str = mktime(0, 0, 0, date('m'), 1, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
                # By Years:
            # By Years:
            case 'y':
                $interval = "1";
                $width = ".8";
                $title = 'Top Accounts for Last Last Year';
                $start_str = mktime(0, 0, 0, 1, 1, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
        }
        ##############################@@@@@@@@
        # Get accounts & sales for this period
        ##############################@@@@@@@@
        $db =& DB();
        $sql = 'SELECT account_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE
				   date_orig    >=  ' . $db->qstr($start_str) . ' AND  date_orig    <=  ' . $db->qstr($end_str) . ' AND
				   site_id      =  ' . $db->qstr(DEFAULT_SITE);
        $result = $db->Execute($sql);
        if (@$result->RecordCount() == 0) {
            $file = fopen(PATH_THEMES . 'default_admin/images/invisible.gif', 'r');
            fpassthru($file);
            exit;
        }
        while (!$result->EOF) {
            $amt = $result->fields['total_amt'];
            $acct = $result->fields['account_id'];
            if (!isset($arr[$acct])) {
                $arr[$acct] = 0;
            }
            $arr[$acct] += $amt;
            $result->MoveNext();
        }
        $i = 0;
        while (list($key, $var) = each(@$arr)) {
            # Get the user name
            $sql = 'SELECT first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE
						   id           =  ' . $db->qstr($key) . ' AND
						   site_id      =  ' . $db->qstr(DEFAULT_SITE);
            $rs = $db->Execute($sql);
            $_lbl[] = strtoupper(substr($rs->fields['first_name'], 0, 1)) . ". " . $rs->fields['last_name'];
            $_datay[] = $var;
            $i++;
        }
        ### Sort the arrays
        array_multisort($_datay, SORT_DESC, SORT_NUMERIC, $_lbl);
        ### Limit the results to 10 or less
        for ($i = 0; $i < count($_lbl); $i++) {
            $lbl[$i] = $_lbl[$i];
            $datay[$i] = $_datay[$i];
            if ($i >= 9) {
                $i = count($_lbl);
            }
        }
        $i = count($lbl);
        # Get the Currency
        $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE
					id           =  ' . $db->qstr(DEFAULT_CURRENCY) . ' AND
					site_id      =  ' . $db->qstr(DEFAULT_SITE);
        $rs = $db->Execute($sql);
        $currency_iso = $rs->fields['symbol'];
        // Size of graph
        $width = 265;
        $height = 75 + $i * 15;
        // Set the basic parameters of the graph
        $graph = new Graph($width, $height, 'auto');
        $graph->SetScale("textlin");
        $graph->yaxis->scale->SetGrace(50);
        $graph->SetMarginColor('#F9F9F9');
        $graph->SetFrame(true, '#CCCCCC', 1);
        $graph->SetColor('#FFFFFF');
        $top = 45;
        $bottom = 10;
        $left = 95;
        $right = 15;
        $graph->Set90AndMargin($left, $right, $top, $bottom);
        // Label align for X-axis
        $graph->xaxis->SetLabelAlign('right', 'center', 'right');
        // Label align for Y-axis
        $graph->yaxis->SetLabelAlign('center', 'bottom');
        $graph->xaxis->SetTickLabels($lbl);
        // Titles
        $graph->title->SetFont(FF_FONT1, FS_BOLD, 9.5);
        $title = $C_translate->translate('graph_top', 'account_admin', '');
        $graph->title->Set($title);
        // Create a bar pot
        $bplot = new BarPlot($datay);
        $bplot->SetFillColor("#506DC7");
        $bplot->SetWidth(0.2);
        // Show the values
        $bplot->value->Show();
        $bplot->value->SetFont(FF_FONT1, FS_NORMAL, 8);
        $bplot->value->SetAlign('center', 'center');
        $bplot->value->SetColor("black", "darkred");
        $bplot->value->SetFormat($currency_iso . '%.2f');
        $graph->Add($bplot);
        $graph->Stroke();
        return;
    }
Example #10
0
// Set up the title for the graph
/*
$graph->title->Set("$title");
$graph->title->SetFont(FF_FONT1, FS_BOLD, 18);
$graph->title->SetColor("$titlecolor");
*/
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_FONT1, FS_NORMAL, 11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
if ($gorientation == "v") {
    $graph->img->SetAngle(90);
    $graph->Set90AndMargin(120, 40, 40, 40);
} else {
    $graph->xaxis->SetLabelAngle(90);
}
//Setup Frame
$graph->SetFrame(true, "#fafafa");
//$graph->SetFrame(false);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillColor($color . "@0.3");
//$bplot->SetShadow($color."@0.7",5,5);
// Set color for the frame of each bar
$bplot->SetColor($color . "@1");
$graph->Add($bplot);
Example #11
0
 private function barHPlot($question, $datax, $datay, $width, $height)
 {
     include_once BASE . "jpgraph.php";
     include_once BASE . "jpgraph_bar.php";
     $tFontSize = 11;
     $xFontSize = 6 + $height / $this->amountOfVariants / 30;
     $maxX = 0;
     foreach ($datax as $x) {
         if (($t = strlen($x)) > $maxX) {
             $maxX = $t;
         }
     }
     for ($i = 0; $i < $this->amountOfVariants; $i++) {
         $x =& $datax[$i];
         if (($t = strlen($x)) >= MAXCHARSPERLINE) {
             $index = strrpos(substr($x, 0, MAXCHARSPERLINE - 1), ' ');
             if ($index === false) {
                 $index = MAXCHARSPERLINE - 3;
             }
             $x[$index] = "\n";
             if ($t > $index + MAXCHARSPERLINE) {
                 $x = substr($x, 0, $index + MAXCHARSPERLINE - 3) . "...";
             }
         }
     }
     unset($x);
     // Set the basic parame graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin", 0, 100);
     //if (amountOfVariants>5) $xFontSize--;
     $lm = 0;
     foreach ($datax as $x) {
         $linia = strtok($x, "\n");
         while ($linia != '') {
             $t = new Text($linia);
             $t->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
             $lineWidth = $t->GetWidth($graph->img);
             if ($lineWidth > $lm) {
                 $lm = $lineWidth;
             }
             //echo $linia.$lineWidth."<BR>";
             $linia = strtok("\n");
         }
     }
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin($lm + 10, 20, 40, 30);
     // Set white margin color
     $graph->SetMarginColor('gray@0.95');
     // Setup title
     $graph->title->Set($question);
     $graph->title->SetMargin(10);
     $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize);
     $tWidth = $graph->title->GetWidth($graph->img);
     //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2);
     if ($tWidth > $width) {
         $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' ');
         //echo $index;
         if ($index === false) {
             $index = $len / 2 - 3;
         }
         $question[$index] = "\n";
         $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize -= 2);
         $graph->title->Set($question);
     }
     //$graph->subtitle->Set("(Non optimized)");
     // Setup X-axis
     $graph->xaxis->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetColor('black');
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     //$graph->yaxis->scale->SetGrace(5);
     $graph->yaxis->SetPos('max');
     $graph->yaxis->SetLabelAlign('center', 'top');
     $graph->yaxis->SetLabelSide('SIDE_RIGHT');
     $graph->yaxis->SetLabelFormat('%2d%%');
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetWidth(0.4);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_VERDANA, FS_BOLD, $xFontSize - 1);
     //$bplot->SetShadow("black@0.1",2,2);
     $bplot->value->SetAlign('right', 'center');
     $bplot->value->SetColor("yellow");
     $bplot->value->SetFormat('%d%%');
     $bplot->value->HideZero();
     $bplot->SetValuePos('max');
     //$graph->SetMarginColor('green');
     // Box around plotarea
     $graph->SetBox();
     $graph->SetFrame();
     $graph->SetShadow();
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
     $graph->ygrid->SetLineStyle('dashed');
     $graph->ygrid->SetColor('gray');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle('dashed');
     $graph->xgrid->SetColor('gray');
     $fcol = '#440000';
     $tcol = '#FF9090';
     $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
     // Set line weigth to 0 so that there are no border
     // around each bar
     $bplot->SetWeight(0);
     $graph->Add($bplot);
     // .. and stroke the graph
     return $graph->Stroke("images/raporty/{$this->id_pytanie}H.png");
 }
Example #12
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_line.php';
// some data
$data_weight = array(120, 130, 123, 100, 150, 160, 170, 200, 220, 240);
$data_fat = array(22, 20, 12, 16, 15, 24, 37, 39, 40, 44);
// Create the graph.
$graph = new Graph(250, 400);
// $graph->SetAngle(90);
// Setup some basic graph parameters
$graph->SetScale("textlin");
$graph->SetY2Scale('lin', 0, 100);
// $graph->img->SetMargin(50,70,30,40);
$graph->Set90AndMargin(40, 40, 60, 40);
$graph->yaxis->SetTitleMargin(30);
$graph->SetMarginColor('#EEEEEE');
// $title = iconv("UTF-8", "gb2312", $title);
// Setup titles and fonts
$graph->title->Set("Health Monitor");
$graph->xaxis->title->Set("T");
$graph->yaxis->title->Set("W");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%2d.0');
// Create a bar pot
Example #13
0
 public function generateLog($winner = false)
 {
     $gameid = strtotime('now');
     $template = file_get_contents('data/log.html');
     $fp = fopen(sprintf('logs/log_%d.html', $gameid), 'a');
     $htplayers = array();
     foreach ($this->players as $pl) {
         $htplayers[] = sprintf('<li>%s</li>', htmlspecialchars(parent::playerName($pl)));
     }
     $players = implode("\n", $htplayers);
     if ($winner) {
         $data = sprintf("After %d hands played, the player <strong>%s</strong> won the total pot of <strong>\$%0.2f</strong>", $this->game, parent::playerName($winner), $winner->money);
     } else {
         $htplayers = array();
         foreach ($this->players as $pl) {
             $htplayers[] = sprintf('<li>%s ($%0.2f)</li>', htmlspecialchars(parent::playerName($pl)), $pl->money);
         }
         $htplayers = implode("\n", $htplayers);
         $data = sprintf("After %d hands no winner was determined a summary of each individual player's money follows:<ol>%s</ol>", $this->game, $htplayers);
     }
     $template = str_replace("{players}", $players, $template);
     $template = str_replace("{gameid}", $gameid, $template);
     $template = str_replace("{winner}", $data, $template);
     $template = str_replace("{version}", parent::$version, $template);
     $template = str_replace("{date}", date('d-m-Y h:i', $gameid), $template);
     $template = str_replace("{startmoney}", sprintf('%0.2f', $this->playermoney), $template);
     $template = str_replace("{bigblind}", sprintf('%0.2f', $this->bigblind), $template);
     $template = str_replace("{smallblind}", sprintf('%0.2f', $this->smallblind), $template);
     $template = str_replace("{maxgames}", $this->totalgames, $template);
     $template = str_replace("{winner}", $data, $template, $template);
     fputs($fp, $template);
     fclose($fp);
     require_once 'data/jpgraph.php';
     require_once 'data/jpgraph_line.php';
     $width = 900;
     $height = 300;
     $graph = new Graph($width, $height);
     $graph->img->SetMargin(40, 40, 40, 40);
     $graph->SetShadow();
     $graph->setScale('intlin');
     $graph->title->Set('Amount of money per player, per hand');
     $graph->xaxis->title->Set('Hand');
     $graph->yaxis->title->Set('Money');
     foreach ($this->moneylog as $id => $data) {
         $p = $this->players[$id];
         $lineplot = new LinePlot($data);
         $lineplot->setweight($id);
         $lineplot->SetLegend(parent::playerName($p));
         $graph->add($lineplot);
     }
     $graph->stroke(sprintf('logs/playermoney_%d.jpg', $gameid));
     // Pie graph, showing checks, folds, bets, wins, calls and raises
     require_once "data/jpgraph_pie.php";
     // Create the Pie Graph.
     $height = ceil(count($this->players) / 2) * 440;
     $graph = new PieGraph($width, $height);
     $graph->SetShadow();
     // Set A title for the plot
     $graph->title->Set("Moves per user");
     // Create plots
     $size = 0.2;
     $x = array(0.25, 0.75);
     $y = 220;
     $i = 1;
     $legend = array("Check", "Call", "Bet", "Raise", "Fold");
     foreach ($this->players as $id => $player) {
         $plot = new PiePlot(array($player->checks, $player->calls, $player->bets, $player->raises, $player->folds));
         if ($player->id == 1) {
             $plot->SetLegends($legend);
         }
         $plot->SetLabelType(PIE_VALUE_ADJPERCENTAGE);
         $plot->SetSize($size);
         $plot->SetCenter($x[$i - 1], $y);
         if ($i == 2) {
             $i = 0;
             $y += 420;
         }
         $i++;
         $plot->title->Set(parent::playerName($player));
         $graph->add($plot);
     }
     $graph->stroke(sprintf('logs/playermoves_%d.jpg', $gameid));
     // Bargraph containing each player's wins
     $height = 70 * count($this->players);
     require_once "data/jpgraph_bar.php";
     $graph = new Graph($width, $height);
     $graph->SetScale('textlin');
     $graph->SetShadow();
     $lbl = array();
     $data = array();
     foreach ($this->players as $pl) {
         $lbl[] = parent::PlayerName($pl);
         $data[] = $pl->wins;
     }
     $top = 60;
     $bottom = 30;
     $left = 80;
     $right = 30;
     $graph->Set90AndMargin($left, $right, $top, $bottom);
     $graph->xaxis->SetTickLabels($lbl);
     $graph->xaxis->SetLabelAlign('right', 'center', 'right');
     $graph->yaxis->SetLabelAlign('center', 'bottom');
     $graph->title->Set('Amount of hands won by individual players');
     $bplot = new BarPlot($data);
     $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_HOR);
     $bplot->SetWidth(0.5);
     $bplot->SetYMin(0);
     $graph->Add($bplot);
     $graph->Stroke(sprintf('logs/playerwins_%d.jpg', $gameid));
     $this->newgame = false;
     // Remove the clients from the server
     $this->broadcast("[SERVER] Thank you for playing Texas Hold`em (LIMIT)\n[SERVER] If you want to play another game, just reconnect to the server!");
     $this->return = true;
     foreach ($this->players as $player) {
         $this->disconnect($player);
     }
     $this->return = true;
     $this->restore();
 }
Example #14
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_line.php';
// 数据
$data_follow = array(140, 110, 77, 104, 29, 161, 13, 195);
// 构造对象
$graph = new Graph(320, 440);
//屏幕分辨率
// 基本参数
$graph->SetScale("textlin");
//线性标尺
$graph->SetY2Scale('lin', 0, 100);
//对数
$graph->Set90AndMargin(50, 0, 65, 0);
//旋转90度
$graph->yaxis->SetTitleMargin(25);
// 标题与字体
$graph->title->Set("Scene Analysis");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->Set("Sce");
$graph->yaxis->title->Set("Num");
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%2d');
// 生成柱状图
$bplot = new BarPlot($data_follow);
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
Example #15
0
     $graph->Stroke();
     break;
 case 'balance_bar':
     require_once 'core/jpgraph/jpgraph_bar.php';
     // Get data
     $a = isset($_GET['a']) ? $_GET['a'] : 0;
     $b = isset($_GET['b']) ? $_GET['b'] : 0;
     $c = isset($_GET['c']) ? $_GET['c'] : 0;
     $total = $a + $b + $c;
     $data_a = array($total ? $a * 100.0 / $total : 0);
     $data_b = array($total ? $b * 100.0 / $total : 100);
     $data_c = array($total ? $c * 100.0 / $total : 0);
     // Build graph
     $graph = new Graph(400, 30);
     $graph->SetScale('textlin', 0, 100);
     $graph->Set90AndMargin(1, 1, 1, 1);
     $graph->SetMarginColor('#22262a');
     $graph->SetColor('#22262a');
     $graph->SetFrame(true, '#FFFFFF', 0);
     $bpa = new BarPlot($data_a);
     $bpa->SetFillColor('#CC0000');
     $bpt = new BarPlot($data_b);
     if ($total == 0) {
         $bpt->SetFillColor('#222222');
     } else {
         $bpt->SetFillColor('#888888');
     }
     $bph = new BarPlot($data_c);
     $bph->SetFillColor('#0055FF');
     $accplot = new AccBarPlot(array($bpa, $bpt, $bph));
     $accplot->SetWidth(16);
Example #16
0
function print_graph($g, $pgwidth)
{
    $splines = false;
    $bandw = false;
    $percent = false;
    $show_percent = false;
    $stacked = false;
    $h = false;
    $show_values = false;
    $hide_grid = false;
    $hide_y_axis = false;
    if (isset($g['attr']['TYPE']) && $g['attr']['TYPE']) {
        $type = strtolower($g['attr']['TYPE']);
    }
    if (!in_array($type, array('bar', 'horiz_bar', 'line', 'radar', 'pie', 'pie3d', 'xy', 'scatter'))) {
        $type = 'bar';
    }
    // Default=bar
    if (isset($g['attr']['STACKED']) && $g['attr']['STACKED']) {
        $stacked = true;
    }
    // stacked for bar or horiz_bar
    if (isset($g['attr']['SPLINES']) && $g['attr']['SPLINES'] && $type == 'xy') {
        $splines = true;
    }
    // splines for XY line graphs
    if (isset($g['attr']['BANDW']) && $g['attr']['BANDW']) {
        $bandw = true;
    }
    // black and white
    if (isset($g['attr']['LEGEND-OVERLAP']) && $g['attr']['LEGEND-OVERLAP']) {
        $overlap = true;
    }
    // avoid overlap of Legends over graph (line, bar, horiz_bar only)
    if (isset($g['attr']['PERCENT']) && $g['attr']['PERCENT'] && $type != 'xy' && $type != 'scatter') {
        $percent = true;
    }
    // Show data series as percent of total in series
    if (isset($g['attr']['SHOW-VALUES']) && $g['attr']['SHOW-VALUES']) {
        $show_values = true;
    }
    // Show the individual data values
    if (isset($g['attr']['HIDE-GRID']) && $g['attr']['HIDE-GRID']) {
        $hide_grid = true;
    }
    // Hide the y-axis gridlines
    if (isset($g['attr']['HIDE-Y-AXIS']) && $g['attr']['HIDE-Y-AXIS']) {
        $hide_y_axis = true;
    }
    // Hide the y-axis
    // Antialias: If true - better quality curves, but graph line will only be 1px even in PDF 300dpi
    // default=true for most except line and radar
    if (isset($g['attr']['ANTIALIAS']) && ($g['attr']['ANTIALIAS'] == '' || $g['attr']['ANTIALIAS'] == 0)) {
        $antialias = false;
    } else {
        if (isset($g['attr']['ANTIALIAS']) && $g['attr']['ANTIALIAS'] > 0) {
            $antialias = true;
        } else {
            if ($type == 'line' || $type == 'radar') {
                $antialias = false;
            } else {
                $antialias = true;
            }
        }
    }
    if ($g['attr']['DPI']) {
        $dpi = intval($g['attr']['DPI']);
    }
    if (!$dpi || $dpi < 50 || $dpi > 2400) {
        $dpi = 150;
    }
    // Default dpi 150
    $k = 0.2645 / 25.4 * $dpi;
    // mPDF 4.5.009
    global $JpgUseSVGFormat;
    if (isset($JpgUseSVGFormat) && $JpgUseSVGFormat) {
        $img_type = 'svg';
        $k = 1;
        // Overrides as Vector scale does not need DPI
    } else {
        $img_type = 'png';
    }
    if (isset($g['attr']['TITLE']) && $g['attr']['TITLE']) {
        $title = $g['attr']['TITLE'];
    }
    if (isset($g['attr']['LABEL-X']) && $g['attr']['LABEL-X']) {
        $xlabel = $g['attr']['LABEL-X'];
    }
    // NOT IMPLEMENTED??????
    if (isset($g['attr']['LABEL-Y']) && $g['attr']['LABEL-Y']) {
        $ylabel = $g['attr']['LABEL-Y'];
    }
    if (isset($g['attr']['AXIS-X']) && $g['attr']['AXIS-X']) {
        $xaxis = strtolower($g['attr']['AXIS-X']);
    }
    if (!in_array($xaxis, array('text', 'lin', 'linear', 'log'))) {
        $xaxis = 'text';
    }
    // Default=text
    if ($xaxis == 'linear') {
        $xaxis = 'lin';
    }
    if (isset($g['attr']['AXIS-Y']) && $g['attr']['AXIS-Y']) {
        $yaxis = strtolower($g['attr']['AXIS-Y']);
    }
    if (!in_array($yaxis, array('lin', 'linear', 'log', 'percent'))) {
        $yaxis = 'lin';
    }
    // Default=lin
    if ($yaxis == 'percent') {
        $show_percent = true;
        $yaxis = 'lin';
    }
    // Show percent sign on scales
    if ($yaxis == 'linear') {
        $yaxis = 'lin';
    }
    if ($splines) {
        $xaxis = 'lin';
    }
    $axes = $xaxis . $yaxis;
    // e.g.textlin, textlog, loglog, loglin, linlog (XY)
    // mPDF 4.0
    if (isset($g['attr']['cWIDTH']) && $g['attr']['cWIDTH']) {
        $w = $g['attr']['cWIDTH'] / 0.2645;
    }
    // pixels
    if (isset($g['attr']['cHEIGHT']) && $g['attr']['cHEIGHT']) {
        $h = $g['attr']['cHEIGHT'] / 0.2645;
    }
    if (isset($g['attr']['SERIES']) && strtolower($g['attr']['SERIES']) == 'rows') {
        $dataseries = 'rows';
    } else {
        $dataseries = 'cols';
    }
    // Defaults - define data
    $rowbegin = 2;
    $colbegin = 2;
    if ($type == 'scatter' || $type == 'xy') {
        if ($dataseries == 'rows') {
            $rowbegin = 1;
        } else {
            $colbegin = 1;
        }
    }
    $rowend = 0;
    $colend = 0;
    if (isset($g['attr']['DATA-ROW-BEGIN']) && ($g['attr']['DATA-ROW-BEGIN'] === '0' || $g['attr']['DATA-ROW-BEGIN'] > 0)) {
        $rowbegin = $g['attr']['DATA-ROW-BEGIN'];
    }
    if (isset($g['attr']['DATA-COL-BEGIN']) && ($g['attr']['DATA-COL-BEGIN'] === '0' || $g['attr']['DATA-COL-BEGIN'] > 0)) {
        $colbegin = $g['attr']['DATA-COL-BEGIN'];
    }
    if (isset($g['attr']['DATA-ROW-END']) && ($g['attr']['DATA-ROW-END'] === '0' || $g['attr']['DATA-ROW-END'] != 0)) {
        $rowend = $g['attr']['DATA-ROW-END'];
    }
    if (isset($g['attr']['DATA-COL-END']) && ($g['attr']['DATA-COL-END'] === '0' || $g['attr']['DATA-COL-END'] != 0)) {
        $colend = $g['attr']['DATA-COL-END'];
    }
    $nr = count($g['data']);
    $nc = 0;
    foreach ($g['data'] as $r) {
        $cc = 0;
        foreach ($r as $c) {
            $cc++;
        }
        $nc = max($nc, $cc);
    }
    if ($colend == 0) {
        $colend = $nc;
    } else {
        if ($colend < 0) {
            $colend = $nc + $colend;
        }
    }
    if ($rowend == 0) {
        $rowend = $nr;
    } else {
        if ($rowend < 0) {
            $rowend = $nr + $rowend;
        }
    }
    if ($colend < $colbegin) {
        $colend = $colbegin;
    }
    if ($rowend < $rowbegin) {
        $rowend = $rowbegin;
    }
    //	if ($type == 'xy' || $type=='scatter') { $colstart=0; }
    // Get Data + Totals
    $data = array();
    $totals = array();
    for ($r = $rowbegin - 1; $r < $rowend; $r++) {
        for ($c = $colbegin - 1; $c < $colend; $c++) {
            if (isset($g['data'][$r][$c])) {
                $g['data'][$r][$c] = floatval($g['data'][$r][$c]);
            } else {
                $g['data'][$r][$c] = 0;
            }
            if ($dataseries == 'rows') {
                $data[$r + 1 - $rowbegin][$c + 1 - $colbegin] = $g['data'][$r][$c];
                $totals[$r + 1 - $rowbegin] += $g['data'][$r][$c];
            } else {
                $data[$c + 1 - $colbegin][$r + 1 - $rowbegin] = $g['data'][$r][$c];
                if (isset($totals[$c + 1 - $colbegin])) {
                    $totals[$c + 1 - $colbegin] += $g['data'][$r][$c];
                } else {
                    $totals[$c + 1 - $colbegin] = $g['data'][$r][$c];
                }
            }
        }
    }
    // PERCENT
    if ($percent && $type != 'pie' && $type != 'pie3d') {
        for ($r = 0; $r < count($data); $r++) {
            for ($c = 0; $c < count($data[$r]); $c++) {
                $data[$r][$c] = $data[$r][$c] / $totals[$r] * 100;
            }
        }
    }
    // Get Legends and labels
    $legends = array();
    $labels = array();
    $longestlegend = 0;
    $longestlabel = 0;
    if ($dataseries == 'cols') {
        if ($colbegin > 1) {
            for ($r = $rowbegin - 1; $r < $rowend; $r++) {
                $legends[$r + 1 - $rowbegin] = $g['data'][$r][0];
                $longestlegend = max($longestlegend, strlen($g['data'][$r][0]));
            }
        }
        if ($rowbegin > 1) {
            for ($c = $colbegin - 1; $c < $colend; $c++) {
                $labels[$c + 1 - $colbegin] = $g['data'][0][$c];
                $longestlabel = max($longestlabel, strlen($g['data'][0][$c]));
            }
        }
    } else {
        if ($dataseries == 'rows') {
            if ($colbegin > 1) {
                for ($r = $rowbegin - 1; $r < $rowend; $r++) {
                    $labels[$r + 1 - $rowbegin] = $g['data'][$r][0];
                    $longestlabel = max($longestlabel, strlen($g['data'][$r][0]));
                }
            }
            if ($rowbegin > 1) {
                for ($c = $colbegin - 1; $c < $colend; $c++) {
                    $legends[$c + 1 - $colbegin] = $g['data'][0][$c];
                    $longestlegend = max($longestlegend, strlen($g['data'][0][$c]));
                }
            }
        }
    }
    // Default sizes
    $defsize = array();
    $defsize['pie'] = array('w' => 600, 'h' => 300);
    $defsize['pie3d'] = array('w' => 600, 'h' => 300);
    $defsize['radar'] = array('w' => 600, 'h' => 300);
    $defsize['line'] = array('w' => 600, 'h' => 400);
    $defsize['xy'] = array('w' => 600, 'h' => 400);
    $defsize['scatter'] = array('w' => 600, 'h' => 400);
    $defsize['bar'] = array('w' => 600, 'h' => 400);
    $defsize['horiz_bar'] = array('w' => 600, 'h' => 500);
    // Use default ratios
    if ($w && !$h) {
        $h = $w * $defsize[$type]['h'] / $defsize[$type]['w'];
    }
    if ($h && !$w) {
        $w = $h * $defsize[$type]['w'] / $defsize[$type]['h'];
    }
    if (!$h && !$w) {
        $w = $defsize[$type]['w'];
        $h = $defsize[$type]['h'];
    }
    if (count($data) > 0 && $type) {
        $figure_file = "graph_cache/" . rand(11111, 999999999) . "." . $img_type;
        if ($bandw) {
            $colours = array('snow1', 'black', 'snow4', 'snow3', 'snow2', 'cadetblue4', 'cadetblue3', 'cadetblue1', 'bisque4', 'bisque2', 'beige');
        } else {
            $colours = array('cyan', 'darkorchid4', 'cadetblue3', 'khaki1', 'darkolivegreen2', 'cadetblue4', 'coral', 'cyan4', 'rosybrown3', 'wheat1');
        }
        $fills = array('navy', 'orange', 'red', 'yellow', 'purple', 'navy', 'orange', 'red', 'yellow', 'purple');
        $patterns = array(PATTERN_DIAG1, PATTERN_CROSS1, PATTERN_STRIPE1, PATTERN_DIAG3, PATTERN_CROSS2, PATTERN_DIAG2, PATTERN_DIAG4, PATTERN_CROSS3, PATTERN_CROSS4, PATTERN_STRIPE1);
        $markers = array(MARK_DIAMOND, MARK_SQUARE, MARK_CIRCLE, MARK_UTRIANGLE, MARK_DTRIANGLE, MARK_FILLEDCIRCLE, MARK_CROSS, MARK_STAR, MARK_X);
        // LEGENDS
        if ($type == 'pie' || $type == 'pie3d') {
            $graph = new PieGraph($w * $k, $h * $k);
        } else {
            if ($type == 'radar') {
                $graph = new RadarGraph($w * $k, $h * $k);
            } else {
                $graph = new Graph($w * $k, $h * $k);
            }
        }
        // mPDF 4.5.009
        //	$graph->img->SetImgFormat($img_type) ;
        //	if (strtoupper($img_type)=='JPEG') { $graph->img->SetQuality(90); }
        if ($antialias) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetShadow(true, 2 * $k);
        $graph->SetMarginColor("white");
        // TITLE
        $graph->title->Set($title);
        $graph->title->SetMargin(10 * $k);
        $graph->title->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
        $graph->title->SetColor("black");
        $graph->legend->SetLineSpacing(3 * $k);
        $graph->legend->SetMarkAbsSize(6 * $k);
        $graph->legend->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
        // Set GRAPH IMAGE MARGINS
        if ($type == 'pie' || $type == 'pie3d') {
            $psize = 0.3;
            $pposxabs = $w / 2;
            $pposy = 0.55;
            if ($longestlegend) {
                // if legend showing
                $pposxabs -= ($longestlegend * 5 + 20) / 2;
            }
            $pposx = $pposxabs / $w;
            $graph->legend->Pos(0.02, 0.5, 'right', 'center');
        } else {
            if ($type == 'radar') {
                $psize = 0.5;
                $pposxabs = $w / 2;
                $pposy = 0.55;
                if ($longestlabel) {
                    // if legend showing
                    $pposxabs -= ($longestlabel * 5 + 20) / 2;
                }
                $pposx = $pposxabs / $w;
                $graph->legend->Pos(0.02, 0.5, 'right', 'center');
            } else {
                if ($type == 'xy' || $type == 'scatter') {
                    $pml = 50;
                    $pmr = 20;
                    $pmt = 60;
                    $pmb = 50;
                    $xaxislblmargin = $pmb - 30;
                    $yaxislblmargin = $pml - 15;
                    $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                } else {
                    if ($type == 'line' || $type == 'bar') {
                        $pml = 50;
                        $pmr = 20;
                        $pmt = 60;
                        $pmb = 50;
                        $xlangle = 0;
                        $ll = $longestlegend * 5;
                        // 45 degrees 8pt fontsize
                        if ($ll > 5 || $ll > 3 && count($data) > 10) {
                            $pmb = max($pmb, $ll + 30);
                            $xlangle = 50;
                        }
                        $xaxislblmargin = $pmb - 30;
                        $yaxislblmargin = $pml - 15;
                        if ($longestlabel && !$overlap) {
                            // if legend showing
                            $pmr = $longestlabel * 5 + 40;
                        }
                        $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                    } else {
                        if ($type == 'horiz_bar') {
                            $pml = 50;
                            $pmr = 20;
                            $pmt = 50;
                            $pmb = 45;
                            $ll = $longestlegend * 6.5;
                            // 8pt fontsize
                            $pml = max($pml, $ll + 20);
                            $xaxislblmargin = $pml - 20;
                            $yaxislblmargin = $pmb - 15;
                            if ($longestlabel && !$overlap) {
                                // if legend showing
                                $pmr = $longestlabel * 5 + 40;
                            }
                            $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                        }
                    }
                }
            }
        }
        // DRAW THE GRAPHS
        if ($type == 'pie') {
            $p1 = new PiePlot($data[0]);
            $p1->SetSliceColors($colours);
            if ($show_values) {
                $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                if ($percent) {
                    $p1->SetLabelType(PIE_VALUE_PERADJ);
                } else {
                    $p1->SetLabelType(PIE_VALUE_ABS);
                }
                if ($percent || $show_percent) {
                    $p1->value->SetFormat("%d%%");
                } else {
                    $p1->value->SetFormat("%s");
                }
                // Enable and set policy for guide-lines. Make labels line up vertically
                $p1->SetGuideLines(true);
                $p1->SetGuideLinesAdjust(1.5);
            } else {
                $p1->value->Show(false);
            }
            $p1->SetLegends($legends);
            $p1->SetSize($psize);
            $p1->SetCenter($pposx, $pposy);
            if ($labels[0]) {
                $graph->subtitle->Set($labels[0]);
                $graph->subtitle->SetMargin(10 * $k);
                $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
                $graph->subtitle->SetColor("black");
            }
            $graph->Add($p1);
        } else {
            if ($type == 'pie3d') {
                $p1 = new PiePlot3d($data[0]);
                $p1->SetSliceColors($colours);
                if ($show_values) {
                    $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                    if ($percent) {
                        $p1->SetLabelType(PIE_VALUE_PERADJ);
                    } else {
                        $p1->SetLabelType(PIE_VALUE_ABS);
                    }
                    if ($percent || $show_percent) {
                        $p1->value->SetFormat("%d%%");
                    } else {
                        $p1->value->SetFormat("%s");
                    }
                } else {
                    $p1->value->Show(false);
                }
                $p1->SetLegends($legends);
                $p1->SetEdge();
                $p1->SetSize($psize);
                $p1->SetCenter($pposx, $pposy);
                if ($labels[0]) {
                    $graph->subtitle->Set($labels[0]);
                    $graph->subtitle->SetMargin(10 * $k);
                    $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
                    $graph->subtitle->SetColor("black");
                }
                $graph->Add($p1);
            } else {
                if ($type == 'radar') {
                    $graph->SetSize($psize);
                    $graph->SetPos($pposx, $pposy);
                    $graph->SetTitles($legends);
                    // labels each axis
                    $graph->axis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                    $graph->axis->title->SetMargin(5 * $k);
                    $graph->axis->SetWeight(1 * $k);
                    $graph->axis->HideLabels();
                    $graph->axis->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k);
                    $graph->HideTickMarks();
                    $group = array();
                    foreach ($data as $series => $dat) {
                        $rdata = array();
                        foreach ($data[$series] as $row) {
                            $rdata[] = $row;
                        }
                        if (count($rdata) < 3) {
                            die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points.");
                        }
                        // Create the radar plot
                        $bplot = new RadarPlot($rdata);
                        $bplot->mark->SetType($markers[$series]);
                        $bplot->mark->SetFillColor($colours[$series]);
                        $bplot->mark->SetWidth(3 * $k);
                        $bplot->SetColor($colours[$series]);
                        if ($series == 0) {
                            $bplot->SetFillColor('lightred');
                        } else {
                            $bplot->SetFill(false);
                        }
                        $bplot->SetLineWeight(1 * $k);
                        $bplot->SetLegend($labels[$series]);
                        if ($bandw) {
                            $bplot->SetShadow("gray5");
                        }
                        $graph->Add($bplot);
                    }
                } else {
                    if ($type == 'line') {
                        // Setup the graph.
                        $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                        // LRTB
                        $graph->SetScale($axes);
                        $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                        if ($ylabel) {
                            $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            $graph->yaxis->SetTitle($ylabel, 'middle');
                            $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                        }
                        $graph->yaxis->SetLabelMargin(4 * $k);
                        if ($percent || $show_percent) {
                            $graph->yaxis->SetLabelFormat('%d%%');
                        }
                        // Percent
                        // Show 0 label on Y-axis (default is not to show)
                        $graph->yscale->ticks->SupressZeroLabel(true);
                        if ($hide_y_axis) {
                            $graph->yaxis->Hide();
                        }
                        if ($hide_grid) {
                            $graph->ygrid->Show(false);
                        }
                        // Setup X-axis labels
                        $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                        $graph->xaxis->SetTickLabels($legends);
                        $graph->xaxis->SetLabelAngle($xlangle);
                        $graph->xaxis->SetLabelMargin(4 * $k);
                        // X-axis title
                        if ($xlabel) {
                            $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            $graph->xaxis->SetTitle($xlabel, 'middle');
                            $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                        }
                        foreach ($data as $series => $rdata) {
                            $bplot = new LinePlot($rdata);
                            $bplot->mark->SetType($markers[$series]);
                            $bplot->mark->SetFillColor($colours[$series]);
                            $bplot->mark->SetWidth(4 * $k);
                            if ($show_values) {
                                $bplot->value->Show();
                                // Not if scatter
                                $bplot->value->SetMargin(6 * $k);
                                $bplot->value->SetColor("darkred");
                                $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                if ($percent || $show_percent) {
                                    $bplot->value->SetFormat('%d%%');
                                } else {
                                    $bplot->value->SetFormat("%s");
                                }
                            }
                            // Set color for each line
                            $bplot->SetColor($colours[$series]);
                            $bplot->SetWeight(2 * $k);
                            $bplot->SetLegend($labels[$series]);
                            if ($bandw) {
                                $bplot->SetShadow("gray5");
                            }
                            // Indent the X-scale so the first and last point doesn't fall on the edges
                            $bplot->SetCenter();
                            $graph->Add($bplot);
                        }
                    } else {
                        if ($type == 'xy' || $type == 'scatter') {
                            // Setup the graph.
                            $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                            // LRTB
                            $graph->SetScale($axes);
                            // Setup font for axis
                            $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            // Y-axis title
                            if ($labels[1]) {
                                $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                $graph->yaxis->SetTitle($labels[1], 'middle');
                            }
                            $graph->yaxis->SetLabelMargin(4 * $k);
                            if ($percent || $show_percent) {
                                $graph->yaxis->SetLabelFormat('%d%%');
                            }
                            // Percent
                            // Show 0 label on Y-axis (default is not to show)
                            $graph->yscale->ticks->SupressZeroLabel(true);
                            // Just let the maximum be autoscaled
                            $graph->yaxis->scale->SetAutoMin(0);
                            if ($hide_y_axis) {
                                $graph->yaxis->Hide();
                            }
                            if ($hide_grid) {
                                $graph->ygrid->Show(false);
                            }
                            // Setup X-axis labels
                            $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            // mPDF 2.5 Corrects labelling of x-axis
                            //			$graph->xaxis->SetTickLabels($legends);
                            $graph->xaxis->SetLabelAngle(50);
                            $graph->xaxis->SetLabelMargin(4 * $k);
                            // X-axis title
                            if ($labels[0]) {
                                $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                $graph->xaxis->SetTitle($labels[0], 'middle');
                            }
                            // Create the bar plot
                            // SPLINES
                            if ($splines && $type == 'xy') {
                                $spline = new Spline($data[0], $data[1]);
                                list($newx, $newy) = $spline->Get(100);
                            } else {
                                $newx = $data[0];
                                $newy = $data[1];
                            }
                            if ($type == 'xy') {
                                // LINE PLOT
                                $bplot = new LinePlot($newy, $newx);
                                // Set color for each line
                                $bplot->SetColor($fills[0]);
                                $bplot->SetWeight(4 * $k);
                                if ($bandw) {
                                    $bplot->SetShadow("gray5");
                                }
                                $graph->Add($bplot);
                            }
                            // SCATTER PLOT
                            $cplot = new ScatterPlot($data[1], $data[0]);
                            $cplot->mark->SetType($markers[0]);
                            $cplot->mark->SetFillColor($fills[0]);
                            $cplot->mark->SetWidth(8 * $k);
                            if ($show_values) {
                                // mPDF 2.5
                                if ($type == 'xy') {
                                    $cplot->value->Show();
                                }
                                // Not if scatter
                                $cplot->value->SetMargin(8 * $k);
                                $cplot->value->SetColor("darkred");
                                $cplot->value->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k);
                                if ($percent || $show_percent) {
                                    $cplot->value->SetFormat('%d%%');
                                } else {
                                    $cplot->value->SetFormat("%s");
                                }
                            }
                            // Set color for each line
                            $cplot->SetColor($fills[0]);
                            $cplot->SetWeight(4 * $k);
                            if ($bandw) {
                                $cplot->SetShadow("gray5");
                            }
                            $graph->Add($cplot);
                        } else {
                            if ($type == 'bar') {
                                // Setup the graph.
                                $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                                // LRTB
                                $graph->SetScale($axes);
                                // Setup y-axis
                                $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                if ($hide_y_axis) {
                                    $graph->yaxis->Hide();
                                }
                                if ($hide_grid) {
                                    $graph->ygrid->Show(false);
                                }
                                $graph->yaxis->SetLabelMargin(4 * $k);
                                if ($ylabel) {
                                    $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->yaxis->SetTitle($ylabel, 'middle');
                                    $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                }
                                // Show 0 label on Y-axis (default is not to show)
                                $graph->yscale->ticks->SupressZeroLabel(false);
                                // Setup X-axis labels
                                $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->xaxis->SetTickLabels($legends);
                                $graph->xaxis->SetLabelAngle($xlangle);
                                $graph->xaxis->SetLabelMargin(4 * $k);
                                // X-axis title
                                if ($xlabel) {
                                    $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->xaxis->SetTitle($xlabel, 'middle');
                                    $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                }
                                $group = array();
                                foreach ($data as $series => $dat) {
                                    $rdata = array();
                                    foreach ($data[$series] as $row) {
                                        $rdata[] = $row;
                                    }
                                    // Create the bar plot
                                    $bplot = new BarPlot($rdata);
                                    $bplot->SetWidth(0.6);
                                    // for SINGLE??
                                    // Setup color for gradient fill style
                                    if ($bandw) {
                                        $bplot->SetPattern($patterns[$series]);
                                    } else {
                                        $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION);
                                    }
                                    // Set color for the frame of each bar
                                    $bplot->SetColor("darkgray");
                                    $bplot->SetLegend($labels[$series]);
                                    if ($bandw) {
                                        $bplot->SetShadow("gray5");
                                    }
                                    if ($show_values) {
                                        $bplot->value->Show();
                                        $bplot->value->SetMargin(6 * $k);
                                        $bplot->value->SetColor("darkred");
                                        $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        if ($percent || $show_percent) {
                                            $bplot->value->SetFormat('%d%%');
                                        } else {
                                            $bplot->value->SetFormat("%s");
                                        }
                                    }
                                    $group[] = $bplot;
                                }
                                if (count($data) == 1) {
                                    $graph->Add($group[0]);
                                } else {
                                    // Create the grouped bar plot
                                    if ($stacked) {
                                        $gbplot = new AccBarPlot($group);
                                    } else {
                                        $gbplot = new GroupBarPlot($group);
                                    }
                                    $graph->Add($gbplot);
                                }
                            } else {
                                if ($type == 'horiz_bar') {
                                    $graph->SetScale($axes);
                                    $graph->Set90AndMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                                    // LRTB
                                    // Setup y-axis
                                    $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->yaxis->SetLabelMargin(4 * $k);
                                    $graph->yaxis->SetPos('max');
                                    // Intersect at top of x-axis i.e. y axis is at bottom
                                    // First make the labels look right
                                    $graph->yaxis->SetLabelAlign('center', 'top');
                                    if ($percent || $show_percent) {
                                        $graph->yaxis->SetLabelFormat('%d%%');
                                    }
                                    $graph->yaxis->SetLabelSide(SIDE_RIGHT);
                                    $graph->yaxis->scale->SetGrace(10);
                                    // sets 10% headroom
                                    if ($hide_y_axis) {
                                        $graph->yaxis->Hide();
                                    }
                                    if ($hide_grid) {
                                        $graph->ygrid->Show(false);
                                    }
                                    // The fix the tick marks
                                    $graph->yaxis->SetTickSide(SIDE_LEFT);
                                    if ($ylabel) {
                                        $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        $graph->yaxis->SetTitle($ylabel, 'middle');
                                        $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                        // Finally setup the title
                                        $graph->yaxis->SetTitleSide(SIDE_RIGHT);
                                        // To align the title to the right use :
                                        $graph->yaxis->title->Align('right');
                                        $graph->yaxis->title->SetAngle(0);
                                    }
                                    // Show 0 label on Y-axis (default is not to show)
                                    $graph->yscale->ticks->SupressZeroLabel(false);
                                    // Setup X-axis labels
                                    $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->xaxis->title->SetAngle(90);
                                    $graph->xaxis->SetTickLabels($legends);
                                    $graph->xaxis->SetLabelMargin(4 * $k);
                                    // X-axis title
                                    if ($xlabel) {
                                        $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                        $graph->xaxis->SetTitle($xlabel, 'middle');
                                    }
                                    $group = array();
                                    foreach ($data as $series => $dat) {
                                        $rdata = array();
                                        foreach ($data[$series] as $row) {
                                            $rdata[] = $row;
                                        }
                                        // Create the bar pot
                                        $bplot = new BarPlot($rdata);
                                        $bplot->SetWidth(0.6);
                                        // for SINGLE??
                                        // Setup color for gradient fill style
                                        if ($bandw) {
                                            $bplot->SetPattern($patterns[$series]);
                                        } else {
                                            $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION);
                                        }
                                        // Set color for the frame of each bar
                                        $bplot->SetColor("darkgray");
                                        $bplot->SetLegend($labels[$series]);
                                        if ($bandw) {
                                            $bplot->SetShadow("gray5");
                                        }
                                        if ($show_values) {
                                            $bplot->value->Show();
                                            $bplot->value->SetMargin(6 * $k);
                                            $bplot->value->SetColor("darkred");
                                            $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                            if ($percent || $show_percent) {
                                                $bplot->value->SetFormat('%d%%');
                                            } else {
                                                $bplot->value->SetFormat("%s");
                                            }
                                        }
                                        $group[] = $bplot;
                                    }
                                    if (count($data) == 1) {
                                        $graph->Add($group[0]);
                                    } else {
                                        // Create the grouped bar plot
                                        if ($stacked) {
                                            $gbplot = new AccBarPlot($group);
                                        } else {
                                            $gbplot = new GroupBarPlot($group);
                                        }
                                        $graph->Add($gbplot);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($graph) {
            $graph->Stroke(_MPDF_PATH . $figure_file);
            $srcpath = str_replace("\\", "/", dirname(__FILE__)) . "/";
            $srcpath .= $figure_file;
            return array('file' => $srcpath, 'w' => $w, 'h' => $h);
        }
    }
    return false;
}
Example #17
0
$graph2->xgrid->Show();
$graph2->yaxis->SetLabelAngle(90);
$graph2->yaxis->SetColor('red');
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph2->yaxis->SetLabelMargin(0);
$graph2->yaxis->scale->SetAutoMin(0);
$line2 = new LinePlot($data_windspeed, $xdata);
$line2->SetStepStyle();
$line2->SetColor('red');
$graph2->Add($line2);
//------------------------------------------------------------------
// Setup the wind temp graph
//------------------------------------------------------------------
$graph3 = new Graph(WIND_WIDTH - 30, WIND_HEIGHT);
$graph3->SetScale('datlin');
$graph3->Set90AndMargin(5, 20, 70, 30);
$graph3->SetMarginColor(BKG_COLOR);
$graph3->SetFrame(true, 'white', 0);
$graph3->SetBox();
$graph3->title->Set('Temperature');
$graph3->title->SetColor('black');
$graph3->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph3->title->SetMargin(5);
$graph3->xaxis->HideLabels();
$graph3->xgrid->Show();
$graph3->yaxis->SetLabelAngle(90);
$graph3->yaxis->SetColor('black');
$graph3->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph3->yaxis->SetLabelMargin(0);
$graph3->yaxis->scale->SetAutoMin(-10);
$line3 = new LinePlot($data_windtemp, $xdata);
Example #18
0
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->scale->SetDateFormat('h:i');
$graph->xgrid->Show();
$graph->yaxis->SetLabelAngle(90);
$graph->yaxis->SetColor('blue');
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->SetLabelMargin(0);
$graph->yaxis->scale->SetAutoMin(0);
$line = new LinePlot($data_winddirection, $xdata);
$line->SetStepStyle();
$line->SetColor('blue');
$graph->Add($line);
// Setup the wind speed graph
$graph2 = new Graph(WIND_WIDTH - 30, WIND_HEIGHT);
$graph2->SetScale('datlin');
$graph2->Set90AndMargin(5, 20, 60, 30);
$graph2->SetMarginColor(BKG_COLOR);
$graph2->SetFrame(true, 'white', 0);
$graph2->SetBox();
$graph2->title->Set('Windspeed');
$graph2->title->SetColor('red');
$graph2->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph2->title->SetMargin(5);
$graph2->xaxis->HideLabels();
$graph2->xgrid->Show();
$graph2->yaxis->SetLabelAngle(90);
$graph2->yaxis->SetColor('red');
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph2->yaxis->SetLabelMargin(0);
$graph2->yaxis->scale->SetAutoMin(0);
$line2 = new LinePlot($data_windspeed, $xdata);
    $var[] = array('var1' => '', 'var2' => 0);
}
foreach ($var as $value) {
    $data['title'][] = $value['var1'];
    $data['value'][] = $value['var2'];
}
//
require_once 'ossim_conf.inc';
$conf = $GLOBALS["CONF"];
$jpgraph = $conf->get_conf("jpgraph_path");
require_once "{$jpgraph}/jpgraph.php";
require_once "{$jpgraph}/jpgraph_bar.php";
// Setup the graph.
$graph = new Graph(600, 250, "auto");
$graph->SetScale("textlin");
$graph->Set90AndMargin(150, 10, 20, 0);
$graph->SetMarginColor("#fafafa");
$graph->xaxis->SetTickLabels($data['title']);
$graph->SetColor("#fafafa");
$graph->SetFrame(true, '#fafafa', 0);
// Create the bar plots
$b1plot = new BarPlot($data['value']);
// color@transparencia
$b1plot->SetFillColor(array(COLOR1 . "@0.5", COLOR2 . "@0.5", COLOR3 . "@0.5", COLOR4 . "@0.5", COLOR5 . "@0.5", COLOR6 . "@0.5", COLOR7 . "@0.5", COLOR8 . "@0.5", COLOR9 . "@0.5", COLOR10 . "@0.5", COLOR11 . "@0.5", COLOR12 . "@0.5"));
//
$b1plot->SetShadow(array(COLOR1 . "@0.7", COLOR2 . "@0.7", COLOR3 . "@0.7", COLOR4 . "@0.7", COLOR5 . "@0.7", COLOR6 . "@0.7", COLOR7 . "@0.7", COLOR8 . "@0.7", COLOR9 . "@0.7", COLOR10 . "@0.7", COLOR11 . "@0.7", COLOR12 . "@0.7"), 5, 5);
$b1plot->SetColor(array(COLOR1 . "@1", COLOR2 . "@1", COLOR3 . "@1", COLOR4 . "@1", COLOR5 . "@1", COLOR6 . "@1", COLOR7 . "@1", COLOR8 . "@1", COLOR9 . "@1", COLOR10 . "@1", COLOR11 . "@1", COLOR12 . "@1"));
//
$graph->Add($b1plot);
// Finally send the graph to the browser
$graph->Stroke();
Example #20
0
$graph->title->SetFont(FF_PGOTHIC, FS_NORMAL, 20);
$graph->title->Set("\n《大手電力会社 電力使用率》");
$z = date("H") % 3;
if ($z == 2) {
    $omimai = " 熊本地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 1) {
    $omimai = "東日本大震災の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 0) {
    $omimai = "鳥取県中部地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
}
$omimai .= " 一日も早く、復興が出来ますように、お祈り申し上げます。\n";
$omimai .= "                           " . $data_time . "更新";
$graph->xaxis->title->Set($omimai);
$graph->xaxis->title->SetFont(FF_GOTHIC, FS_NORMAL, 10);
$graph->xaxis->title->SetMargin(-585);
$graph->Set90AndMargin(312, 89, 90, 90);
$graph->SetBackgroundGradient('white', 'green:1.5', GRAD_HOR, BGRAD_PLOT);
$txt = new Text($data_w);
$txt->SetPos(686, -16);
$data_XXX = $xml->pref[10]->time_x;
$url = "http://s-proj.com/utils/checkHoliday.php?kind=h&date=" . $data_XXX;
$holiday_status = file_get_contents($url);
if ($holiday_status == "holiday") {
    $txt->SetColor("#FF0000");
} else {
    $txt->SetColor("#000000");
}
if ($data_w == "土") {
    $txt->SetColor("#0000FF");
}
$txt->SetFont(FF_GOTHIC, FS_NORMAL, 10);
Example #21
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(2, 3, 5, 8, 12, 6, 3);
$datax = array("320x240", "640x480", "600x800", "1024x768", "1280x1024(16)", "1280x1024(32)", "1600x1200(32)");
// Size of graph
$width = 300;
$height = 400;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale("textlin");
// No frame around the image
$graph->SetFrame(false);
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(100, 20, 50, 30);
// Set white margin color
$graph->SetMarginColor('white');
// Use a box around the plot area
$graph->SetBox();
// Use a gradient to fill the plot area
$graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
// Setup title
$graph->title->Set("Graphic card performance");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 11);
$graph->subtitle->Set("(Non optimized)");
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 8);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
     $lplot->SetBarCenter();
     $lplot->mark->SetType(MARK_SQUARE);
     $lplot->mark->SetColor('blue@0.7');
     $lplot->mark->SetFillColor('lightblue');
     $lplot->mark->SetSize(6);
     $graph->Add($lplot);
 } else {
     if ($content['chart_type'] == CHART_BARS_HORIZONTAL) {
         // Include additional code filers for this chart!
         include_once $gl_root_path . "classes/jpgraph/jpgraph_bar.php";
         include_once $gl_root_path . "classes/jpgraph/jpgraph_line.php";
         // Create Basic Image, and set basic properties!
         $graph = new Graph($content['chart_width'], $content['chart_width'], 'auto');
         //					$graph->SetMargin(60,20,30,50);
         $graph->SetScale("textlin");
         $graph->Set90AndMargin(80, 30, 30, 50);
         // Adjust margin area
         $graph->SetMarginColor('white');
         $graph->SetBox();
         // Box around plotarea
         // Setup X-AXIS
         $graph->xaxis->SetTickLabels($XchartData);
         $graph->xaxis->SetLabelAngle(0);
         //					$graph->xaxis->SetLabelAlign('center','top');
         $graph->xaxis->SetPos('min');
         $graph->xaxis->SetLabelMargin(5);
         $graph->xaxis->SetLabelAlign('right', 'center');
         // Setup Y-AXIS
         $graph->yaxis->scale->SetGrace(20);
         // So the value is readable
         $graph->yaxis->SetLabelAlign('center', 'top');
Example #23
0
 /**
  * 横柱图
  * 
  */
 function createhorizoncolumnar($title, $subtitle, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
 {
     vendor("Jpgraph.jpgraph");
     vendor("Jpgraph.jpgraph_bar");
     $datay = $data;
     $datax = $legend;
     //编码转化
     foreach ($datax as $k => $v) {
         $datax[$k] = iconv('utf-8', 'gb2312', $v);
     }
     // Size of graph
     $count = count($datay);
     $addheight = 0;
     if ($count > 10) {
         $addheight = ($count - 10) * 20;
     }
     $height = $height + $addheight;
     // Set the basic parameters of the graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin");
     // No frame around the image
     $graph->SetFrame(false);
     $graph->SetFrame(false, '#ffffff', 0);
     //去掉周围的边框
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin(70, 10, 50, 30);
     // Set white margin color
     $graph->SetMarginColor('white');
     // Use a box around the plot area
     $graph->SetBox();
     // Use a gradient to fill the plot area
     $graph->SetBackgroundGradient('white', 'white', GRAD_HOR, BGRAD_PLOT);
     // Setup title
     $graph->title->Set(iconv('utf-8', 'gb2312', "{$title}"));
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
     $graph->subtitle->Set("(" . iconv('utf-8', 'gb2312', $subtitle) . ")");
     $graph->subtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Setup X-axis
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     // We don't want to display Y-axis
     $graph->yaxis->Hide();
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     //$bplot->SetShadow();
     //You can change the width of the bars if you like
     //$bplot->SetWidth(0.5);
     // Set gradient fill for bars
     $bplot->SetFillGradient('blue', '#0080C0', GRAD_HOR);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7);
     $bplot->value->SetAlign('left', 'center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%.0f');
     //$bplot->SetValuePos('max');
     // Add the bar to the graph
     $graph->Add($bplot);
     // Add some explanation text
     $txt = new Text('');
     $txt->SetPos(130, 399, 'center', 'bottom');
     $txt->SetFont(FF_COMIC, FS_NORMAL, 8);
     $graph->Add($txt);
     // .. and stroke the graph
     $graph->Stroke();
 }
Example #24
0
 public static function horizontalBarShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y)
 {
     // $graph = new Graph($width,$height);
     $graph = new Graph(LENHSIZE, 400, "auto");
     $graph->SetScale('textlin');
     $graph->yaxis->scale->SetGrace(20);
     $top = 60;
     $bottom = 30;
     $left = 80;
     $right = 30;
     $graph->Set90AndMargin($left, $right, $top, $bottom);
     // $graph->img->SetMargin(LEFT,RIGHT,UP,DOWN);
     // // Nice shadow
     $graph->SetShadow();
     // Setup labels
     // $lbl = array("Andrew\nTait","Thomas\nAnderssen","Kevin\nSpacey","Nick\nDavidsson",
     // "David\nLindquist","Jason\nTait","Lorin\nPersson");
     $graph->xaxis->SetTickLabels($data_x);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center', 'right');
     // Label align for Y-axis
     $graph->yaxis->SetLabelAlign('center', 'bottom');
     // $graph->yaxis->setFont(FF_SIMSUN);
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE);
     // Titles
     $graph->title->Set($graph_title);
     $graph->xaxis->SetFont(FF_SIMSUN);
     //设置X坐标轴的字体
     // Create a bar pot
     $bplot = new BarPlot($data_y);
     $graph->Add($bplot);
     // $bplot->SetFillColor(BAR_COLOR);
     $bplot->SetColor(BAR_COLOR);
     $bplot->SetFillColor(BAR_COLOR);
     $bplot->SetShadow(SHADOW);
     $bplot->SetWidth(0.5);
     // $bplot->SetYMin(1990);
     $bplot->SetWidth(25);
     $num = rand(0, RAND);
     $graph->InitializeFrameAndMargin();
     // echo var_dump($num);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     // echo var_dump($name);
     $graph->Stroke($name);
     return $name;
 }