Exemplo n.º 1
0
 }
 $rsCSC = sql("SELECT COUNT(`cache_logs`.`type`) `count`, `log_types`.`&2` AS `type` FROM `cache_logs` INNER JOIN `log_types` ON (`cache_logs`.`type`=`log_types`.`id`) WHERE type=3 AND cache_logs.deleted=0 AND cache_logs.cache_id=&1 GROUP BY `cache_logs`.`type` ORDER BY `log_types`.`pl` ASC", $cache_id, $lang_db);
 if ($rsCSC !== false) {
     $xtitle = "";
     $ry = mysql_fetch_array($rsCSC);
     $y[] = $ry['count'];
     $x[] = $ry['type'];
 } else {
     $x[] = tr("comment");
 }
 mysql_free_result($rsCSF);
 mysql_free_result($rsCSNF);
 mysql_free_result($rsCSC);
 /// A new pie graph
 $graph = new PieGraph(400, 200, "auto");
 $graph->SetScale('textint');
 $logtype = tr("by_logtype");
 // Title setup
 $graph->title->Set($logtype);
 $graph->title->SetFont(FF_ARIAL, FS_NORMAL);
 //$graph ->legend->Pos( 0.25,0.8,"right" ,"bottom");
 // Setup the pie plot
 $p1 = new PiePlot($y);
 $p1->SetTheme("earth");
 $p1->value->SetFormat("%d");
 $p1->SetLabelType(PIE_VALUE_ABS);
 $p1->SetSliceColors(array('chartreuse3', 'chocolate2', 'wheat1'));
 // Adjust size and position of plot
 $p1->SetSize(0.35);
 $p1->SetCenter(0.25, 0.52);
 $f = tr("found");
Exemplo n.º 2
0
 function generate_graph_image()
 {
     // Create the graph.
     // Set up Font Mapping Arrays
     $fontfamilies = array("Font 0" => FF_FONT0, "Font 1" => FF_FONT1, "Font 2" => FF_FONT2, "Font0" => FF_FONT0, "Font1" => FF_FONT1, "Font2" => FF_FONT2, "Arial" => FF_ARIAL, "Verdana" => FF_VERDANA, "Courier" => FF_COURIER, "Comic" => FF_COMIC, "Times" => FF_TIMES, "Georgia" => FF_GEORGIA, "Trebuchet" => FF_TREBUCHE, "advent_light" => advent_light, "Bedizen" => Bedizen, "Mukti_Narrow" => Mukti_Narrow, "calibri" => calibri, "Forgotte" => Forgotte, "GeosansLight" => GeosansLight, "MankSans" => MankSans, "pf_arma_five" => pf_arma_five, "Silkscreen" => Silkscreen, "verdana" => verdana, "Vera" => FF_VERA);
     $fontstyles = array("Normal" => FS_NORMAL, "Bold" => FS_BOLD, "Italic" => FS_ITALIC, "Bold+Italic" => FS_BOLDITALIC);
     $this->apply_defaults();
     if (!function_exists("imagecreatefromstring")) {
         handle_error("Graph Option Not Available. Requires GD2");
         return;
     }
     if ($this->plot[0]["type"] == "PIE" || $this->plot[0]["type"] == "PIE3D") {
         $graph = new PieGraph($this->width_actual, $this->height_actual, "auto");
         $graph->SetScale("textlin");
         $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual);
         $graph->SetMarginColor($this->margincolor_actual);
         $graph->img->SetAntiAliasing();
         $graph->SetColor($this->graphcolor_actual);
         $graph->SetShadow();
         $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45);
         $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25);
     } else {
         $graph = new Graph($this->width_actual, $this->height_actual, "auto");
         $graph->SetScale("textlin");
         $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual);
         $graph->SetMarginColor($this->margincolor_actual);
         $graph->img->SetAntiAliasing();
         $graph->SetColor($this->graphcolor_actual);
         $graph->SetShadow();
         $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45);
         $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25);
     }
     $lplot = array();
     $lplotct = 0;
     foreach ($this->plot as $k => $v) {
         switch ($v["type"]) {
             case "PIE":
                 $lplot[$lplotct] = new PiePlot($v["data"]);
                 $lplot[$lplotct]->SetColor($v["linecolor"]);
                 foreach ($xlabels as $k => $v) {
                     $xlabels[$k] = $v . "\n %.1f%%";
                 }
                 $lplot[$lplotct]->SetLabels($xlabels, 1.0);
                 $graph->Add($lplot[$lplotct]);
                 break;
             case "PIE3D":
                 $lplot[$lplotct] = new PiePlot3D($v["data"]);
                 $lplot[$lplotct]->SetColor($v["linecolor"]);
                 foreach ($xlabels as $k => $v) {
                     $xlabels[$k] = $v . "\n %.1f%%";
                 }
                 $lplot[$lplotct]->SetLabels($xlabels, 1.0);
                 $graph->Add($lplot[$lplotct]);
                 break;
             case "STACKEDBAR":
             case "BAR":
                 $lplot[$lplotct] = new BarPlot($v["data"]);
                 $lplot[$lplotct]->SetColor($v["linecolor"]);
                 $lplot[$lplotct]->SetWidth(0.8);
                 //$lplot[$lplotct]->SetWeight(5);
                 if ($v["fillcolor"]) {
                     $lplot[$lplotct]->SetFillColor($v["fillcolor"]);
                 }
                 if ($v["legend"]) {
                     $lplot[$lplotct]->SetLegend($v["legend"]);
                 }
                 $graph->Add($lplot[$lplotct]);
                 break;
             case "LINE":
             default:
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $lplot[$lplotct] = new LinePlot($v["data"]);
                 $lplot[$lplotct]->SetColor($v["linecolor"]);
                 //$lplot[$lplotct]->SetWeight(5);
                 if ($v["fillcolor"]) {
                     $lplot[$lplotct]->SetFillColor($v["fillcolor"]);
                 }
                 if ($v["legend"]) {
                     $lplot[$lplotct]->SetLegend($v["legend"]);
                 }
                 $graph->Add($lplot[$lplotct]);
                 break;
         }
         $lplotct++;
     }
     $graph->title->Set($this->title_actual);
     $graph->xaxis->title->Set($this->xtitle_actual);
     $graph->yaxis->title->Set($this->ytitle_actual);
     $graph->xgrid->SetColor($this->xgridcolor_actual);
     $graph->ygrid->SetColor($this->ygridcolor_actual);
     switch ($this->xgriddisplay_actual) {
         case "all":
             $graph->xgrid->Show(true, true);
             break;
         case "major":
             $graph->xgrid->Show(true, false);
             break;
         case "minor":
             $graph->xgrid->Show(false, true);
             break;
         case "none":
         default:
             $graph->xgrid->Show(false, false);
             break;
     }
     switch ($this->ygriddisplay_actual) {
         case "all":
             $graph->ygrid->Show(true, true);
             break;
         case "major":
             $graph->ygrid->Show(true, false);
             break;
         case "minor":
             $graph->ygrid->Show(false, true);
             break;
         case "none":
         default:
             $graph->ygrid->Show(false, false);
             break;
     }
     $graph->title->SetFont($fontfamilies[$this->titlefont_actual], $fontstyles[$this->titlefontstyle_actual], $this->titlefontsize_actual);
     $graph->title->SetColor($this->titlecolor_actual);
     $graph->xaxis->SetFont($fontfamilies[$this->xaxisfont_actual], $fontstyles[$this->xaxisfontstyle_actual], $this->xaxisfontsize_actual);
     $graph->xaxis->SetColor($this->xaxiscolor_actual, $this->xaxisfontcolor_actual);
     $graph->yaxis->SetFont($fontfamilies[$this->yaxisfont_actual], $fontstyles[$this->yaxisfontstyle_actual], $this->yaxisfontsize_actual);
     $graph->yaxis->SetColor($this->yaxiscolor_actual, $this->yaxisfontcolor_actual);
     $graph->xaxis->title->SetFont($fontfamilies[$this->xtitlefont_actual], $fontstyles[$this->xtitlefontstyle_actual], $this->xtitlefontsize_actual);
     $graph->xaxis->title->SetColor($this->xtitlecolor_actual);
     $graph->yaxis->title->SetFont($fontfamilies[$this->ytitlefont_actual], $fontstyles[$this->ytitlefontstyle_actual], $this->ytitlefontsize_actual);
     $graph->yaxis->title->SetColor($this->ytitlecolor_actual);
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->SetLabelMargin(5);
     $graph->yaxis->SetLabelMargin(5);
     $graph->xaxis->SetTickLabels($this->xlabels);
     $graph->xaxis->SetTextLabelInterval($this->xticklabelinterval_actual);
     $graph->yaxis->SetTextLabelInterval($this->yticklabelinterval_actual);
     $graph->xaxis->SetTextTickInterval($this->xtickinterval_actual);
     $graph->yaxis->SetTextTickInterval($this->ytickinterval_actual);
     $graph->SetFrame(true, 'darkblue', 2);
     $graph->SetFrameBevel(2, true, 'black');
     if ($this->gridpos_actual == "front") {
         $graph->SetGridDepth(DEPTH_FRONT);
     }
     // Display the graph
     $handle = $graph->Stroke(_IMG_HANDLER);
     return $handle;
 }
Exemplo n.º 3
0
 function PIE_graph($module, $method, $type, $start, $extra_fields)
 {
     global $C_translate, $C_auth;
     include_once PATH_CORE . 'validate.inc.php';
     $dt = new CORE_validate();
     include PATH_GRAPH . "jpgraph.php";
     ####################################################################
     ### Check if 'search' is authorized for this account
     ####################################################################
     # check the validation for this function
     if ($C_auth->auth_method_by_name($module, 'search')) {
         # validate this file exists, and include it.
         if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) {
             include_once PATH_MODULES . '/' . $module . '/' . $module . '.inc.php';
         } else {
             ### Not exist!
             $error = $C_translate->translate('module_non_existant', '', '');
         }
     } else {
         ### Not auth
         $error = $C_translate->translate('module_non_auth', '', '');
     }
     if (isset($error)) {
         include PATH_GRAPH . "jpgraph_canvas.php";
         // Create the graph.
         $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;
     }
     # initialize the module, if it has not already been initialized
     $eval = '$' . $module . ' = new ' . $module . '; ';
     $eval .= '$this_Obj  = $' . $module . ';';
     eval($eval);
     # run the function
     $array = call_user_func(array($module, $method), $start_str, $end_str, $constraint_array, $default_array, $extra_fields);
     include PATH_GRAPH . "jpgraph_pie.php";
     include PATH_GRAPH . "jpgraph_pie3d.php";
     $data = $array['data'];
     $legends = $array['legends'];
     // Create the Pie Graph.
     $graph = new PieGraph(500, 250, "auto");
     $graph->SetScale("textlin");
     $graph->SetMarginColor('#F9F9F9');
     $graph->SetFrame(true, '#FFFFFF', 0);
     $graph->SetColor('#F9F9F9');
     // Create pie plot
     $p1 = new PiePlot3d($data);
     $p1->SetTheme("water");
     $p1->SetCenter(0.4);
     $p1->SetAngle(30);
     $p1->value->SetFont(FF_FONT1, FS_NORMAL, 8);
     $p1->SetLegends($legends);
     // Explode the larges slice:
     $largest = 0;
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i] > $largest) {
             $largest = $data[$i];
             $explode = $i;
         }
     }
     if ($explode) {
         $p1->ExplodeSlice($explode);
     }
     $graph->Add($p1);
     $graph->Stroke();
 }
Exemplo n.º 4
0
    $plottype = derive_request_item("plottype" . $v, "LINE");
    $plotlcolor = derive_request_item("plotlinecolor" . $v, "black");
    $plotfcolor = derive_request_item("plotfillcolor" . $v, "");
    $plotlegend = derive_request_item("plotlegend" . $v, "");
    if (array_key_exists("{$vval}", $_REQUEST)) {
        $vals = explode(",", $_REQUEST["{$vval}"]);
        $plot[$v] = array("type" => $plottype, "fillcolor" => $plotfcolor, "linecolor" => $plotlcolor, "legend" => $plotlegend, "data" => $vals);
    } else {
        break;
    }
    $v++;
}
// Create the correct type of graph.
if ($plot[0]["type"] == "PIE" || $plot[0]["type"] == "PIE3D") {
    $graph = new PieGraph($width, $height, "auto");
    $graph->SetScale("textlin");
    $graph->img->SetMargin($marginleft, $marginright, $margintop, $marginbottom);
    $graph->SetMarginColor($margincolor);
    $graph->img->SetAntiAliasing();
    $graph->SetColor($color);
    $graph->SetShadow();
    $graph->xaxis->SetTitleMargin($marginbottom - 35);
    $graph->yaxis->SetTitleMargin(50);
    $graph->yaxis->SetTitleMargin($marginleft - 15);
    $graph->title->Set($title);
} else {
    $graph = new Graph($width, $height, "auto");
    $graph->SetScale("textlin");
    $graph->img->SetMargin($marginleft, $marginright, $margintop, $marginbottom);
    $graph->SetMarginColor($margincolor);
    $graph->img->SetAntiAliasing();
Exemplo n.º 5
0
 public function create_graph($width = 600, $height = 200, $data, $title, $xaxis, $yaxis, $type = "bar")
 {
     require_once 'jpgraph/jpgraph.php';
     require_once 'jpgraph/jpgraph_line.php';
     require_once 'jpgraph/jpgraph_bar.php';
     require_once 'jpgraph/jpgraph_pie.php';
     // Create a graph instance
     if ($type == "bar" || $type == "line") {
         $graph = new Graph($width, $height);
     } else {
         if ($type == "pie") {
             $graph = new PieGraph($width, $height);
         }
     }
     // Specify what scale we want to use,
     // int = integer scale for the X-axis
     // int = integer scale for the Y-axis
     $graph->SetScale('intint');
     $graph->SetMarginColor("lightblue:1.1");
     $graph->SetShadow();
     $graph->SetMargin(60, 20, 10, 40);
     // Box around plotarea
     $graph->SetBox();
     // No frame around the image
     $graph->SetFrame(false);
     // Setup a title for the graph
     $graph->title->Set($title);
     $graph->title->SetMargin(8);
     $graph->title->SetColor("darkred");
     // 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');
     // Setup titles and X-axis labels, if it's array, first row is title
     if (is_array($xaxis)) {
         $graph->xaxis->title->Set($xaxis[0]);
         $xaxis = array_slice($xaxis, 1, count($xaxis) - 1);
         $graph->xaxis->SetTickLabels($xaxis);
     } else {
         $graph->xaxis->title->Set($xaxis);
     }
     // no array, just show name
     // Setup Y-axis title
     $graph->yaxis->title->SetMargin(10);
     $graph->yaxis->title->Set($yaxis);
     if ($type == "bar") {
         $plot = new BarPlot($data);
         $plot->SetWidth(0.6);
         $fcol = '#440000';
         $tcol = '#FF9090';
         $plot->SetFillGradient("navy:0.9", "navy:1.85", GRAD_LEFT_REFLECTION);
         //$plot->SetColor("black");
         // Set line weigth to 0 so that there are no border
         // around each bar
         $plot->SetWeight(0);
         // Add the plot to the graph
         $graph->Add($plot);
     } else {
         if ($type == "line") {
             $plot = new LinePlot($data);
             $plot->SetFillColor('skyblue@0.5');
             $plot->SetColor('navy@0.7');
             $plot->mark->SetType(MARK_SQUARE);
             $plot->mark->SetColor('blue@0.5');
             $plot->mark->SetFillColor('lightblue');
             $plot->mark->SetSize(5);
             // Add the plot to the graph
             $graph->Add($plot);
         } else {
             if ($type == "pie") {
                 $plot = new PiePlot($data);
                 $plot->SetCenter(0.5, 0.55);
                 $plot->SetSize(0.2);
                 // Enable and set policy for guide-lines
                 $plot->SetGuideLines();
                 $plot->SetGuideLinesAdjust(1.4);
                 // Setup the labels
                 $plot->SetLabelType(PIE_VALUE_PER);
                 $plot->value->Show();
                 //$plot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
                 $plot->value->SetFormat('%2.1f%%');
                 $plot->ExplodeSlice(1);
                 $plot->SetGuideLines(true);
                 $graph->SetMarginColor("white");
                 $plot->SetLegends($xaxis);
                 // Add the plot to the graph
                 $graph->Add($plot);
             } else {
                 die($type . " is not known graph type");
             }
         }
     }
     // Display the graph
     $fn = strtolower($title);
     $fn = str_replace(" ", "", $fn);
     $filename_relative = "site/web_app/images/dynamic/{$fn}.jpg";
     $filename_full = __DIR__ . "/" . $filename_relative;
     $graph->Stroke($filename_full);
     $imglink = "<img src='{$filename_relative}' title='{$title}' />\n";
     return $imglink;
 }