|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include ("jpgraph/jpgraph.php");
|
|
|
|
|
include ("jpgraph/jpgraph_pie.php");
|
|
|
|
|
include ("jpgraph/jpgraph_pie3d.php");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Se os dados estiverem zerados
|
|
|
|
|
* manda um valor padrao como inativo
|
|
|
|
|
*/
|
|
|
|
|
if (array_sum($_SESSION["SSdadosAgtGraphPie"])) {
|
|
|
|
|
$dados = $_SESSION["SSdadosAgtGraphPie"];
|
|
|
|
|
$legenda = $_SESSION["SSlegendAgtGraphPie"];
|
|
|
|
|
$aColor = $_SESSION["SScolorAgtGraphPie"];
|
|
|
|
|
$legendaFont = $_SESSION["SSLegendaFontGraph"];
|
|
|
|
|
$legendaFontStyle = $_SESSION["SSLegendaFontStyle"];
|
|
|
|
|
$legendaFontSize = $_SESSION["SSLegendaFontSize"];
|
|
|
|
|
$legendaPosTop = $_SESSION["SSLegendaPosTop"];
|
|
|
|
|
$legendaPosLeft = $_SESSION["SSLegendaPosLeft"];
|
|
|
|
|
$legendaSetColumns = isset($_SESSION["SSLegendaSetColumns"]) ? $_SESSION["SSLegendaSetColumns"] : 0;
|
|
|
|
|
$graphHorAlign = $_SESSION["SSGraphHorAlign"] ? $_SESSION["SSGraphHorAlign"] : 0;
|
|
|
|
|
$graphVertAlign = $_SESSION["SSGraphVertAlin"] ? $_SESSION["SSGraphVertAlin"] : 0;
|
|
|
|
|
$plotSize = $_SESSION["SSPlotSize"] ? $_SESSION["SSPlotSize"] : 0;
|
|
|
|
|
} else {
|
|
|
|
|
$dados = array('1');
|
|
|
|
|
$legenda = array("Inativo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$grafW = empty($_SESSION["SSdadoGraphWidth"]) ? 350 : $_SESSION["SSdadoGraphWidth"];
|
|
|
|
|
$grafH = empty($_SESSION["SSdadoGraphHeigth"]) ? 200 : $_SESSION["SSdadoGraphHeigth"];
|
|
|
|
|
|
|
|
|
|
// criar novo gr<EFBFBD>fico de 350x200 pixels com tipo de
|
|
|
|
|
// imagem autom<EFBFBD>tico
|
|
|
|
|
$grafico = new PieGraph($grafW, $grafH, "auto");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adicionar sombra
|
|
|
|
|
$grafico->SetShadow();
|
|
|
|
|
|
|
|
|
|
// t<EFBFBD>tulo do gr<EFBFBD>fico
|
|
|
|
|
$_SESSION["SSnomeGraphPie"] = ''; //Limpando titulo para n<EFBFBD>o sobrescrever as legendas.
|
|
|
|
|
$grafico->title->Set($_SESSION["SSnomeGraphPie"]);
|
|
|
|
|
$grafico->title->SetFont(FF_FONT0, FS_BOLD);
|
|
|
|
|
|
|
|
|
|
if ($legendaSetColumns)
|
|
|
|
|
$grafico->legend->SetColumns($legendaSetColumns);
|
|
|
|
|
//if($legendaPosTop !== false){ $grafico->legend->Pos($legendaPosLeft, $legendaPosTop); }
|
|
|
|
|
$grafico->legend->SetAbsPos($legendaPosLeft, $legendaPosTop, 'left', 'top');
|
|
|
|
|
//$grafico->legend->Pos(0.5,0.0.5,'left','bottom');
|
|
|
|
|
//$grafico->legend->SetLayout(LEGEND_VERT);
|
|
|
|
|
|
|
|
|
|
if ($legendaFont) {
|
|
|
|
|
$grafico->legend->SetFont($legendaFont, $legendaFontStyle, $legendaFontSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// definir valores ao gr<EFBFBD>fico
|
|
|
|
|
$p1 = new PiePlot3D($dados);
|
|
|
|
|
if ($plotSize)
|
|
|
|
|
$p1->SetSize($plotSize);
|
|
|
|
|
// destacar o valor correspondente ao elemento (1), sendo
|
|
|
|
|
// que o primeiro elemento do array corresponde a (0),
|
|
|
|
|
// ent<EFBFBD>o esse <EFBFBD> o cara cujo valor equivale a 26
|
|
|
|
|
//$p1->ExplodeSlice(1);
|
|
|
|
|
//$p1->ShowBorder(true, true);
|
|
|
|
|
// centralizar a 45% da largura
|
|
|
|
|
$p1->SetCenter($graphHorAlign ? $graphHorAlign : 0.45, $graphVertAlign ? $graphVertAlign : 0.5);
|
|
|
|
|
|
|
|
|
|
// definir legendas
|
|
|
|
|
$p1->SetLegends($legenda);
|
|
|
|
|
|
|
|
|
|
if (isset($aColor))
|
|
|
|
|
$p1->SetSliceColors($aColor);
|
|
|
|
|
|
|
|
|
|
// adicionar valores ao gr<EFBFBD>fico
|
|
|
|
|
$grafico->Add($p1);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Gerar o gr<EFBFBD>fico
|
|
|
|
|
* Exemplo salvar em disco
|
|
|
|
|
* if(!isset($_SESSION["SSidGraf"]))$_SESSION["SSidGraf"] = 1; else $_SESSION["SSidGraf"]++;
|
|
|
|
|
* $idGraf = $_SESSION["SSidGraf"];
|
|
|
|
|
* $grafico->Stroke("grafAgente_$idGraf.jpg");
|
|
|
|
|
*/
|
|
|
|
|
$grafico->Stroke();
|
|
|
|
|
unset($_SESSION["SScolorAgtGraphPie"]);
|
|
|
|
|
unset($_SESSION["SSdadosAgtGraphPie"]);
|
|
|
|
|
unset($_SESSION["SSlegendAgtGraphPie"]);
|
|
|
|
|
unset($_SESSION["SScolorAgtGraphPie"]);
|
|
|
|
|
unset($_SESSION["SSLegendaFontGraph"]);
|
|
|
|
|
unset($_SESSION["SSLegendaFontStyle"]);
|
|
|
|
|
unset($_SESSION["SSLegendaFontSize"]);
|
|
|
|
|
unset($_SESSION["SSLegendaPosTop"]);
|
|
|
|
|
unset($_SESSION["SSLegendaPosLeft"]);
|
|
|
|
|
unset($_SESSION["SSPlotSize"]);
|
|
|
|
|
unset($_SESSION["SSGraphHorAlign"]);
|
|
|
|
|
unset($_SESSION["SSGraphVertAlign"]);
|
|
|
|
|
?>
|