Example #1
0
function graficar_defectos($eje_y, $x_label, $pareto, $titulo_eje_x, $titulo_eje_y, $title, $name)
{
    include "../jpgraph/src/jpgraph.php";
    include "../jpgraph/src/jpgraph_line.php";
    include "../jpgraph/src/jpgraph_bar.php";
    $graph = new Graph(820, 350);
    $graph->SetScale("textlin");
    $graph->SetMarginColor("#FFFFFF");
    $graph->img->SetMargin(80, 80, 60, 140);
    $graph->yaxis->SetTitleMargin(40);
    $graph->SetBackgroundImage("../imagenes/fondo.jpg", BGIMG_FILLFRAME);
    $graph->xaxis->SetLabelAngle(90);
    $graph->xaxis->SetTickLabels($x_label);
    $graph->legend->Pos(0.03, 0.3);
    $graph->title->SetColor("#000000");
    $graph->title->Set($title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    //$graph->yaxis->title->Set($titulo_eje_y);
    //$graph->xaxis->title->Set($titulo_eje_x);
    $graph->setcolor("#EEEEEE");
    $graph->setshadow("true", 3, "#aaaaaa");
    // Crear la gráfica de barras
    $bplot1 = new BarPlot($eje_y);
    $bplot1->SetWidth(0.3);
    $bplot1->SetYMin(0.02);
    $bplot1->SetFillColor("orange@0.2");
    $bplot1->SetShadow('darkgray');
    $bplot1->value->SetFormat("%0.1f");
    $bplot1->value->SetColor("darkred");
    $bplot1->value->Show();
    // Crear la gráfica de líneas
    $lplot = new LinePlot($pareto);
    $lplot->mark->SetType(MARK_FILLEDCIRCLE);
    $lplot->mark->SetFillColor("red");
    $lplot->mark->SetWidth(3);
    $lplot->SetColor("blue");
    $lplot->SetBarCenter();
    $graph->Add($bplot1);
    $graph->Add($lplot);
    $graph->Stroke("charts/" . $name);
}
Example #2
0
} else {
    $sql = " and (req_time >'{$start_date}' and req_time<'{$end_date}')";
}
$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);