if ($value['var2'] != 0) { // si todos los valores están a 0, el piegraph da el siguiente error 'Illegal pie plot. Sum of all data is zero for pie plot' $temp_activado = true; } } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_pie.php"; require_once "{$jpgraph}/jpgraph_pie3d.php"; // Setup the graph. $graph = new PieGraph(400, 150, "auto"); $graph->SetAntiAliasing(); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); if (isset($temp_activado)) { // Create the bar plots $piePlot3d = new PiePlot3D($data['value']); $piePlot3d->SetSliceColors(array(COLORPIE1, COLORPIE2, COLORPIE3, COLORPIE4, COLORPIE5, COLORPIE6, COLORPIE7, COLORPIE8)); //$piePlot3d->SetAngle(30); $piePlot3d->SetHeight(12); $piePlot3d->SetSize(0.5); $piePlot3d->SetCenter(0.26, 0.4); // Labels //$piePlot3d->SetLabels($data['title'],1); $piePlot3d->SetLegends($data['title']); $graph->Add($piePlot3d); $graph->legend->SetPos(0.01, 0.6, 'right', 'bottom'); }
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(); $graph->SetColor($color); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($marginbottom - 35); $graph->yaxis->SetTitleMargin(50);
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; }
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(); }
$format = "$%.2f"; $title = "Potential $"; break; default: $sliceCol = "riot_tracker_red1"; $data = array($rep_month_count,$all_month_count); $legends = array('my assigned leads','other leads'); $format = "%d"; $title = "leads assigned to me"; } $graph = new PieGraph($size['w'],$size['h']); $graph->SetShadow(); $graph->SetColor('#333333'); // style the legend $graph->legend->SetColor('#dfdfdf'); $graph->legend->SetFillColor('#333333'); $graph->legend->SetFont(FF_UNIVERS,FS_LIGHT,8); $graph->legend->SetMarkAbsHSize(16); //style the title $graph->title->SetColor('#4d4d4d'); $graph->title->Set($title); $graph->title->SetFont(FF_UNIVERS,FS_BOLD,24); $p1 = new PiePlot3D($data); $graph->Add($p1);
list($cc,$cctotal) = $ps->db->fetch_row(0); $data[] = $cctotal; $labels[] = '?'; /**/ // if we have no country data show a 100% unknown slice if (!count($data)) { $data[] = 1; $labels[] = 'unknown'; } } //$graph = new PieGraph(375, 285, $imgfilename, CACHE_TIMEOUT); $graph = new PieGraph(imgdef($q['width'], 600), imgdef($q['height'], 300), $imgfilename, CACHE_TIMEOUT); if (imgdef($q['antialias'], 0)) { $graph->SetAntiAliasing(); } $graph->SetColor(imgdef($q['frame']['margin'], '#d7d7d7')); $graph->title->Set(imgdef($q['frame']['title']['_content'], 'Breakdown of Countries')); $graph->title->SetFont(constant(imgdef($q['frame']['title']['font'], 'FF_FONT1')), FS_BOLD); //$graph->subtitle->Set("(Excludes unknown)"); //$graph->subtitle->SetFont(FF_FONT0,FS_NORMAL); $p1 = new PiePlot($data); $p1->ExplodeSlice(0); // make the largest slice explode out from the rest #$p1->ExplodeAll(); //$p1->SetStartAngle(45); if (imgdef($q['slices']['border'], 0) == 0) { $p1->ShowBorder(false, false); } $p1->SetGuideLines(); $p1->SetCenter(0.35); $p1->SetTheme(imgdef($q['slices']['theme'], 'earth'));
if ($risk7 > 0) { $data[] = $risk7; $legend[] = "Info - {$risk7}"; $totalvulns += $risk7; $colors[] = "#F0E68C"; } //$data = array($risk1,$risk2,$risk3,$risk6,$risk7); //$legend=array("Serious - $risk1","High - $risk2","Medium - $risk3","Low - $risk6","Info - $risk7"); //$totalvulns=$risk1+$risk2+$risk3+$risk6+$risk7; if ($totalvulns > 0) { $graph = new PieGraph(450, 200, "auto"); $graph->SetAntiAliasing(); //$graph->SetShadow(); $graph->title->Set("Vulnerabilities Found - {$totalvulns}"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->SetColor('#fbfbfb'); if (intval($w) == 1) { $graph->SetMarginColor('#FAFAFA'); $graph->legend->SetShadow('#fafafa', 0); //$graph->legend->SetFillColor('#fafafa'); $graph->legend->SetFrameWeight(0); } else { if (intval($w) == 2) { $graph->SetMarginColor('#FFFFFF'); $graph->legend->SetShadow('#FFFFFF', 0); $graph->legend->SetFillColor('#FFFFFF'); $graph->legend->SetFrameWeight(0); } } $p1 = new PiePlot3D($data); $graph->SetFrame(false, '#ffffff');
if (!isset($_GET['map_id'])) { die('No map id given'); } require_once 'core/jpgraph/jpgraph_pie.php'; // Get data $wins = $db->GetRow("SELECT mapstat_alien_wins,\n mapstat_human_wins,\n mapstat_ties + mapstat_draws AS ties\n FROM map_stats WHERE mapstat_id = ?", array($_GET['map_id'])); if ($wins['mapstat_alien_wins'] + $wins['mapstat_human_wins'] + $wins['ties'] > 0) { $data = array($wins['mapstat_alien_wins'], $wins['mapstat_human_wins'], $wins['ties']); } else { $data = array(0, 0, 1); } // Build graph $g = new PieGraph(200, 120); $g->SetMargin(30, 30, 10, 25); $g->SetMarginColor('#22262a'); $g->SetColor('#22262a'); $g->SetFrame(true, array(0, 0, 0), 0); $g->SetBox(false); // Build plot $p1 = new PiePlot($data); $p1->SetCenter(40, 60); $p1->SetSliceColors(array('#CC0000', '#0055FF', '#888888')); $p1->value->show(false); $legends = array('Aliens (%d%%)', 'Humans (%d%%)', 'Tied (%d%%)'); $p1->SetLegends($legends); $g->legend->SetShadow(false); $g->legend->SetAbsPos(10, 60, 'right', 'center'); // Stroke $g->Add($p1); $g->Stroke(); break;