Exemplo n.º 1
0
 public function barGraph_2($data, $examinee_id, $color = 'green')
 {
     require_once '../app/classes/jpgraph/jpgraph_bar.php';
     // Create the graph. These two calls are always required
     $graph = new Graph(400, 334);
     $graph->SetScale('textlin');
     $graph->SetShadow(true, 5, 'white');
     // Adjust the margin a bit to make more room for titles
     $graph->SetMargin(40, 30, 20, 40);
     $graph->SetFrame(true, 'black', 1);
     // Create a bar pot
     $datay = array();
     $datalabel = array();
     foreach ($data as $value) {
         $datay[] = $value['score'];
         $datalabel[] = $value['chs_name'];
     }
     $bplot = new BarPlot($datay);
     // Adjust fill color
     $bplot->SetFillColor($color);
     $bplot->SetShadow("white");
     $graph->Add($bplot);
     // Setup labels
     $lbl = $datalabel;
     $graph->xaxis->SetTickLabels($lbl);
     $graph->xaxis->SetFont(FF_CHINESE, FS_BOLD, 12);
     // Send back the HTML page which will call this script again
     // to retrieve the image.
     //临时文件命名规范    $examinee_id_$date_rand(100,900)
     $date = date('H_i_s');
     $stamp = rand(100, 900);
     $fileName = './tmp/' . $examinee_id . '_' . $date . '_' . $stamp . '.jpeg';
     $graph->Stroke($fileName);
     return $fileName;
 }
 public function index()
 {
     // We want a bar graph, so use JpGraph's bar chart library
     require_once APPPATH . '/libraries/JpGraph/jpgraph_bar.php';
     // Example data (04/2015)
     $json = '[{"Hogwarts Academy":{"Yield":"19021 kWh","Yield specific":"127.01 kWh\\/kWp","Target yield":"16069.23 kWh","Current-target yield %":"<span style=\\"color: #3ab121\\">118.37 %<span>"}},{"cols": [{"id":"","label":"Time","pattern":"","type":"string"},{"id":"","label":"Hogwarts Academy (AC)","pattern":"","type":"number"},{"id":"","label":"Target values","pattern":"","type":"number"}], "rows": [{"c":[{"v":"01/04","f":null}, {"v":615.8,"f":"615,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"02/04","f":null}, {"v":712.5,"f":"712,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"03/04","f":null}, {"v":171,"f":"171,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"04/04","f":null}, {"v":382.3,"f":"382,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"05/04","f":null}, {"v":606.3,"f":"606,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"06/04","f":null}, {"v":774.5,"f":"774,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"07/04","f":null}, {"v":570.6,"f":"570,60 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"08/04","f":null}, {"v":726.8,"f":"726,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"09/04","f":null}, {"v":789.2,"f":"789,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"10/04","f":null}, {"v":592.9,"f":"592,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"11/04","f":null}, {"v":677.1,"f":"677,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"12/04","f":null}, {"v":244.5,"f":"244,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"13/04","f":null}, {"v":457.4,"f":"457,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"14/04","f":null}, {"v":340.8,"f":"340,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"15/04","f":null}, {"v":425.3,"f":"425,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"16/04","f":null}, {"v":828.8,"f":"828,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"17/04","f":null}, {"v":616.8,"f":"616,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"18/04","f":null}, {"v":660.3,"f":"660,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"19/04","f":null}, {"v":453.2,"f":"453,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"20/04","f":null}, {"v":691.9,"f":"691,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"21/04","f":null}, {"v":904.4,"f":"904,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"22/04","f":null}, {"v":879.1,"f":"879,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"23/04","f":null}, {"v":824.8,"f":"824,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"24/04","f":null}, {"v":777.9,"f":"777,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"25/04","f":null}, {"v":413.8,"f":"413,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"26/04","f":null}, {"v":834.8,"f":"834,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"27/04","f":null}, {"v":920.8,"f":"920,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"28/04","f":null}, {"v":751,"f":"751,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"29/04","f":null}, {"v":737.7,"f":"737,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"30/04","f":null}, {"v":638.7,"f":"638,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]}]}]';
     // Turn string into object
     $obj = json_decode($json);
     // Stores for graph data
     $xdata = array();
     $ydata = array();
     // Get coords data from object
     $obj_data = $obj[1]->rows;
     $counter = 1;
     // Add it to each of our storage arrays
     foreach ($obj_data as $data) {
         // only plot when there is a kW value
         if (isset($data->c[1]->v)) {
             $xdata[] = $data->c[0]->v;
             // date
             $ydata[] = $data->c[1]->v;
             // kw
         }
     }
     // Create the graph.
     // One minute timeout for the cached image
     // INLINE_NO means don't stream it back to the browser.
     $graph = new Graph(600, 350, 'auto');
     $graph->SetScale("textlin");
     $graph->img->SetMargin(60, 30, 20, 40);
     $graph->yaxis->SetTitleMargin(45);
     $graph->yaxis->scale->SetGrace(30);
     $graph->SetShadow();
     // Turn the tickmarks
     $graph->xaxis->SetTickSide(SIDE_DOWN);
     $graph->yaxis->SetTickSide(SIDE_LEFT);
     // Create a bar pot
     $bplot = new BarPlot($ydata);
     $bplot->SetFillColor("orange");
     // Use a shadow on the bar graphs (just use the default settings)
     $bplot->SetShadow();
     $bplot->value->SetFormat(" %2.1f kW", 70);
     $bplot->value->SetFont(FF_VERDANA, FS_NORMAL, 8);
     $bplot->value->SetColor("blue");
     $bplot->value->Show();
     $graph->Add($bplot);
     $graph->title->Set("Hogwarts Academy");
     $graph->xaxis->title->Set("Day");
     $graph->yaxis->title->Set("Yield in kilowatt hours");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     // Send back the HTML page which will call this script again
     // to retrieve the image.
     $graph->StrokeCSIM();
 }
 public function iterationSummaryAux($id)
 {
     JpGraph\JpGraph::load();
     JpGraph\JpGraph::module('bar');
     $datay = array(12, 26, 9, 17, 31);
     // Create the graph.
     // One minute timeout for the cached image
     // INLINE_NO means don't stream it back to the browser.
     $graph = new Graph(310, 250, 'auto');
     $graph->SetScale("textlin");
     $graph->img->SetMargin(60, 30, 20, 40);
     $graph->yaxis->SetTitleMargin(45);
     $graph->yaxis->scale->SetGrace(30);
     $graph->SetShadow();
     // Turn the tickmarks
     $graph->xaxis->SetTickSide(SIDE_DOWN);
     $graph->yaxis->SetTickSide(SIDE_LEFT);
     // Create a bar pot
     $bplot = new BarPlot($datay);
     // Create targets for the image maps. One for each column
     $targ = array("bar_clsmex1.php#1", "bar_clsmex1.php#2", "bar_clsmex1.php#3", "bar_clsmex1.php#4", "bar_clsmex1.php#5", "bar_clsmex1.php#6");
     $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
     $bplot->SetCSIMTargets($targ, $alts);
     $bplot->SetFillColor("orange");
     // Use a shadow on the bar graphs (just use the default settings)
     $bplot->SetShadow();
     $bplot->value->SetFormat(" \$ %2.1f", 70);
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
     $bplot->value->SetColor("blue");
     $bplot->value->Show();
     $graph->Add($bplot);
     $graph->title->Set("Image maps barex1");
     $graph->xaxis->title->Set("X-title");
     $graph->yaxis->title->Set("Y-title");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     // Send back the HTML page which will call this script again
     // to retrieve the image.
     $graph->StrokeCSIM();
 }
function generate_image()
{
    global $percent, $legend;
    // Create the graph. These two calls are always required
    $graph = new Graph(550, 250);
    $graph->SetScale("textlin");
    $graph->yaxis->scale->SetGrace(20);
    $graph->xaxis->SetLabelmargin(5);
    $graph->xaxis->SetTickLabels($legend);
    $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
    // Add a drop shadow
    $graph->SetShadow();
    // Adjust the margin a bit to make more room for titles
    $graph->img->SetMargin(50, 30, 20, 40);
    // Create a bar pot
    $bplot = new BarPlot($percent);
    // Adjust fill color
    $bplot->SetFillColor('#9999CC');
    $bplot->SetShadow();
    $bplot->value->Show();
    $bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10);
    $bplot->value->SetAngle(45);
    $bplot->value->SetFormat('%0.0f');
    // Width
    $bplot->SetWidth(0.6);
    $graph->Add($bplot);
    // Setup the titles
    $graph->title->Set("PHP documentation");
    $graph->xaxis->title->Set("Language");
    $graph->yaxis->title->Set("Files up to date (%)");
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    // Display the graph
    $graph->Stroke('../www/images/revcheck/info_revcheck_php_all_lang.png');
}
Exemplo n.º 5
0
$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->SetFillGradient($color, $color2, GRAD_MIDVER);
$bplot->SetFillColor("#DF7E0D@0.5");
$bplot->SetShadow("#DF7E0D@0.7", 5, 5);
// Set color for the frame of each bar
$bplot->SetColor("#DF7E0D@1");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
Exemplo n.º 6
0
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(2);
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetAbsWidth(6);
$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
?>


Exemplo n.º 7
0
$graph->SetScale("textint");
$graph->SetShadow();
$graph->SetFrame(false);
// No border around the graph
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
$graph->yaxis->scale->SetGrace(100);
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT2);
// Setup graph title ands fonts
$graph->title->Set("Example of integer Y-scale");
$graph->title->SetFont(FF_FONT2, FS_BOLD);
$graph->xaxis->title->Set("Year 2002");
$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetWidth(0.5);
$bplot->SetShadow();
// Setup the values that are displayed on top of each bar
$bplot->value->Show();
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL, FS_BOLD);
$bplot->value->SetAngle(45);
// Black color for positive values and darkred for negative values
$bplot->value->SetColor("black", "darkred");
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
Exemplo n.º 8
0
$datay1 = array(35, 160, 0, 0, 0, 0);
$datay2 = array(35, 190, 190, 190, 190, 190);
$datay3 = array(20, 70, 70, 140, 230, 260);
$graph = new Graph(450, 200, 'auto');
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 40, 40);
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set('Group bar plot');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
$bplot1->SetFillColor("orange");
$bplot2->SetFillColor("brown");
$bplot3->SetFillColor("darkgreen");
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

Exemplo n.º 9
0
$color = "navy";
$color2 = "navy";
//$color2 = "lightsteelblue";
// Setup graph
$graph = new Graph($width, 250, "auto");
$graph->SetScale("textlin");
$graph->SetMarginColor($background);
$graph->img->SetMargin(40, 30, 20, 40);
//$graph->SetShadow();
//Setup Frame
$graph->SetFrame(true, "#ffffff");
// Setup graph title
$graph->title->Set($title);
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
//$bplot->SetFillGradient($color, $color2, GRAD_MIDVER);
//$bplot->SetColor($color);
// color@transparencia
$bplot->SetFillColor(array(COLOR1 . "@0.5"));
//
$bplot->SetShadow(array(COLOR1 . "@0.7"), 5, 5);
$bplot->SetColor(array(COLOR1 . "@1"));
//
$graph->Add($bplot);
$graph->xaxis->SetTickLabels($labelx);
//$graph->xaxis->SetLabelAngle(40); // only with TTF fonts
$graph->title->Set($title);
$graph->xaxis->title->Set($titley);
$graph->yaxis->title->Set($titlex);
$graph->Stroke();
Exemplo n.º 10
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);
}
Exemplo n.º 11
0
 }
 $pdf->Ln(3);
 $graph = new Graph(500, 250, 'auto');
 $graph->img->SetAntiAliasing(false);
 $graph->SetScale("textlin");
 $graph->img->SetMargin(30, 15, 15, 30);
 if (count($mediciones) === 1) {
     $graph->xaxis->SetTickLabels(array('1'));
 } else {
     $graph->xaxis->SetTickLabels(array('1', '2', '3'));
 }
 if (count($mediciones) === 1) {
     $datay1 = array($datay1[0]);
 }
 $bplot1 = new BarPlot($datay1);
 $bplot1->SetShadow();
 // Setup color for gradient fill style
 $bplot1->SetFillGradient("dodgerblue4", "lightsteelblue", GRAD_HOR);
 // Set color for the frame of each bar
 $bplot1->SetColor("black");
 $graph->Add($bplot1);
 if (count($mediciones) === 1) {
     $datay2 = array($datay2[0]);
 }
 $p1 = new LinePlot($datay2);
 $graph->Add($p1);
 $p1->mark->SetType(MARK_DIAMOND);
 $p1->mark->SetWidth(8);
 $p1->mark->SetFillColor('navy');
 $p1->SetBarCenter();
 $p1->SetColor('navy');
Exemplo n.º 12
0
$graph3->yaxis->SetColor('black');
$graph3->yaxis->title->Set('time(us)');
$graph3->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph3->ygrid->SetColor('black');
$graph3->yaxis->SetTitleMargin(45);
$graph3->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph3->title->Set("Pthread kill latency -Mesuring Standard Deviation(us)");
// TITRE: marge et apparence
$graph3->title->SetFont(FF_FONT1, FS_BOLD, 11);
// Couleurs et transparence par histogramme
$bplot3 = new BarPlot($data4);
$bplot3->SetFillColor('red');
$bplot3->value->SetFormat('%01.3f');
$bplot3->value->Show();
$bplot3->SetShadow('black');
$bplot3->value->SetColor("black", "darkred");
$bplot3->SetShadow('black');
$bplot3->SetWidth(0.3);
$graph3->Add($bplot3);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(10, 10, 10, 10);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetBackgroundImage('../fond.png');
$mgraph->AddMix($graph, 0, 0, 85);
$mgraph->AddMix($graph1, 0, 270, 85);
$mgraph->AddMix($graph2, 0, 540, 85);
$mgraph->AddMix($graph3, 0, 810, 85);
 public static function show()
 {
     $level_id = wbRequest::getVarClean('level_id', 'int', 0);
     $tahun = wbRequest::getVarClean('tahun', 'str', '');
     //timestamp
     $t = wbRequest::getVarClean('t', 'str', '');
     if (empty($level_id) or empty($tahun)) {
         exit;
     }
     try {
         $ws_client = self::getNusoap();
         $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 'dashboard_pendidikan', 'method' => 'show', 'type' => '')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit);
         $ws_data = self::getResultData($ws_client, $params);
         $data['items'] = $ws_data['data'];
         $data['total'] = $ws_data['total'];
         $data['message'] = $ws_data['message'];
         $data['success'] = $ws_data['success'];
     } catch (Exception $e) {
         $data['message'] = $e->getMessage();
     }
     $items = $data['items']['items'];
     $itemLevel = $data['items']['itemLevel'];
     //$items = $tSchoolType->getAllByLevelID($level_id, $tahun);
     //$itemLevel = $tSchoolLevel->get($level_id);
     $print = wbRequest::getVarClean('print', 'int', 0);
     if (!empty($print)) {
         wbUtil::startExcel('pendidikan_dashboard.xls');
     }
     echo '<div class="body-wrap">';
     echo '<div style="float:left;margin:5 5 0 5;">';
     echo '<div><h3>JUMLAH SISWA ' . strtoupper($itemLevel['description']) . ' <br/>BERDASARKAN JENISNYA - TAHUN ' . $tahun . '</h3></div>';
     if (!empty($print)) {
         echo '<table border="1" width ="100%">';
     } else {
         echo '<table border="0" class="table-data" width ="100%">';
     }
     echo '<tr>
             <th width="15">No</th>
             <th width="150">Jenis ' . $itemLevel['description'] . '</th>
             <th width="100">Jumlah Masuk </th>
             <th width="100">Jumlah Lulus </th>
             <th width="100">Jumlah Aktif </th>
           </tr>';
     $i = 1;
     $datay = array();
     $dataCode = array();
     foreach ($items as $item) {
         $datay[] = $item['jml_masuk'];
         $dataCode[] = $item['code'];
         echo '<tr>';
         echo '<td>' . $i++ . '</td>';
         echo '<td>' . $item['code'] . '</td>';
         echo '<td align="right">' . wbUtil::numberFormat($item['jml_masuk'], 0) . '</td>';
         echo '<td align="right">' . wbUtil::numberFormat($item['jml_lulus'], 0) . '</td>';
         echo '<td align="right">' . wbUtil::numberFormat($item['jml_aktif'], 0) . '</td>';
         echo '</tr>';
     }
     echo '</table>';
     wbCore::loadJPGraph();
     // Create the graph and setup the basic parameters
     $graph = new Graph(550, 300, 'auto');
     $graph->img->SetMargin(40, 30, 40, 40);
     $graph->SetScale("textint");
     $graph->SetFrame(true, 'white', 1);
     $graph->SetColor('#C9C9C9');
     $graph->SetMarginColor('#D0DEF0');
     // Add some grace to the top so that the scale doesn't
     // end exactly at the max value.
     //$graph->yaxis->scale->SetGrace(20);
     // Setup X-axis labels
     $graph->xaxis->SetTickLabels($dataCode);
     $graph->xaxis->SetFont(FF_FONT1);
     $graph->xaxis->SetColor('#400000', 'black');
     // Stup "hidden" y-axis by given it the same color
     // as the background
     $graph->yaxis->SetColor('lightblue', '#004080');
     $graph->ygrid->SetColor('white');
     // Setup graph title ands fonts
     $graph->title->Set('GRAFIK SISWA ' . strtoupper($itemLevel['description']) . ' - TAHUN ' . $tahun);
     // Create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetFillColor('#6C6CFF');
     $bplot->SetColor('darkblue');
     $bplot->SetWidth(0.5);
     $bplot->SetShadow('darkgray');
     // Setup the values that are displayed on top of each bar
     $bplot->value->Show();
     // Must use TTF fonts if we want text at an arbitrary angle
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
     $bplot->value->SetFormat('%d');
     // Black color for positive values and darkred for negative values
     $bplot->value->SetColor("black", "darkred");
     $graph->Add($bplot);
     // Finally stroke the graph
     $graph->Stroke('var/dashboard/dashboard_pendidikan.png');
     echo '</div>';
     echo '</div>';
     echo '<div style="float:right;margin:15 5 0 5;"> <img src="' . wbServer::getBaseURL() . 'var/dashboard/dashboard_pendidikan.png?' . $t . '" alt="' . $t . '" /> </div>';
     exit;
 }
Exemplo n.º 14
0
$bplot6 = new BarPlot($t_arr6);
$bplot7 = new BarPlot($t_arr7);
$bplot1->SetFillColor('indianred2');
$bplot2->SetFillColor('maroon1');
$bplot3->SetFillColor('gold1');
$bplot4->SetFillColor('lightyellow');
$bplot5->SetFillColor('cornflowerblue');
$bplot6->SetFillColor('darkseagreen2');
$bplot7->SetFillColor('white');
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$bplot4->SetShadow();
$bplot5->SetShadow();
$bplot6->SetShadow();
$bplot7->SetShadow();
/*	$bplot1->SetLegend( 'New' );
	$bplot2->SetLegend( 'Feedback' );
	$bplot3->SetLegend( 'Acked' );
	$bplot4->SetLegend( 'Fixed' );
	$bplot5->SetLegend( 'Assigned' );
	$bplot6->SetLegend( 'Resolved' );
	$bplot7->SetLegend( 'Closed' );*/
/*	$bplot1->value->Show();
	$bplot2->value->Show();
	$bplot3->value->Show();
	$bplot4->value->Show();
	$bplot5->value->Show();
	$bplot6->value->Show();
	$bplot7->value->Show();*/
$bplot1->value->SetFont(FF_FONT0);
Exemplo n.º 15
0
 public static function show()
 {
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     $jenis_jalan = wbRequest::getVarClean('jenis_jalan', 'int', 0);
     if (empty($jenis_jalan)) {
         exit;
     }
     try {
         $ws_client = self::getNusoap();
         $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 'dashboard_jalan', 'method' => 'show', 'type' => '')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit);
         $ws_data = self::getResultData($ws_client, $params);
         $data['items'] = $ws_data['data'];
         $data['total'] = $ws_data['total'];
         $data['message'] = $ws_data['message'];
         $data['success'] = $ws_data['success'];
     } catch (Exception $e) {
         $data['message'] = $e->getMessage();
     }
     $items = $data['items'];
     echo '<div class="body-wrap">';
     echo '<div style="float:left;margin:5 5 0 5;">';
     echo '<div><h3>DATA JALAN</h3></div>';
     echo '<table class="table-data">';
     echo '<tr>
             <th width="30">No</th>
             <th width="200">Jenis Jalan</th>
             <th width="100">Panjang(Km)</th>
           </tr>';
     $i = 1;
     $datay = array();
     $dataCode = array();
     foreach ($items as $item) {
         $datay[] = $item['panjang'];
         $dataCode[] = $item['param_name'];
         echo '<tr>';
         echo '<td>' . $i++ . '</td>';
         echo '<td>' . $item['param_name'] . '</td>';
         echo '<td align="right">' . wbUtil::numberFormat($item['panjang'], 0) . '</td>';
         echo '</tr>';
     }
     echo '</table>';
     wbCore::loadJPGraph();
     // Create the graph and setup the basic parameters
     $graph = new Graph(550, 300, 'auto');
     $graph->img->SetMargin(40, 30, 40, 40);
     $graph->SetScale("textint");
     $graph->SetFrame(true, 'white', 1);
     $graph->SetColor('#C9C9C9');
     $graph->SetMarginColor('#D0DEF0');
     // Add some grace to the top so that the scale doesn't
     // end exactly at the max value.
     //$graph->yaxis->scale->SetGrace(20);
     // Setup X-axis labels
     $graph->xaxis->SetTickLabels($dataCode);
     $graph->xaxis->SetFont(FF_FONT1);
     $graph->xaxis->SetColor('#400000', 'black');
     // Stup "hidden" y-axis by given it the same color
     // as the background
     $graph->yaxis->SetColor('lightblue', '#004080');
     $graph->ygrid->SetColor('white');
     // Setup graph title ands fonts
     $graph->title->Set('DATA JALAN');
     // Create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetFillColor('#6C6CFF');
     $bplot->SetColor('darkblue');
     $bplot->SetWidth(0.5);
     $bplot->SetShadow('darkgray');
     // Setup the values that are displayed on top of each bar
     $bplot->value->Show();
     // Must use TTF fonts if we want text at an arbitrary angle
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
     $bplot->value->SetFormat('%d');
     // Black color for positive values and darkred for negative values
     $bplot->value->SetColor("black", "darkred");
     $graph->Add($bplot);
     // Finally stroke the graph
     $graph->Stroke('var/dashboard/dashboard_jalan.png');
     echo '</div>';
     echo '</div>';
     echo '<div style="float:right;margin:15 5 0 5;"> <img src="var/dashboard/dashboard_jalan.png?' . $t . '" alt="' . $t . '" /> </div>';
     exit;
 }
    $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();
unset($graph);
?>

Exemplo n.º 17
0
// Adjust the margin slightly so that we use the
// entire area (since we don't use a frame)
$graph->SetMargin(30, 1, 20, 5);
// Box around plotarea
$graph->SetBox();
// No frame around the image
$graph->SetFrame(false);
// Setup the tab title
$graph->tabtitle->Set('  ' . $t . '  ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 12);
// Setup the X and Y grid
$graph->ygrid->SetFill(true, '#FEFEFE@0.5', '#EEEEEE@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Setup $x as labels on the X-axis
$graph->xaxis->SetTickLabels($x);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->xaxis->SetLabelAngle(60);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->yaxis->SetLabelFormat('%d %%');
// Create a bar pot
$bplot = new BarPlot($y);
$bplot->SetWidth(0.6);
$bplot->SetFillColor($c);
$bplot->SetWeight(1);
$bplot->SetShadow('gray@0.25', 2, 2);
$graph->Add($bplot);
$graph->Stroke();
Exemplo n.º 18
0
$graph9->yaxis->title->Set('time(micro-sec)');
$graph9->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph9->ygrid->SetColor('black');
$graph9->yaxis->SetTitleMargin(45);
$graph9->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph9->title->Set("Mesuring latency Sh process (micro-sec)");
// TITRE: marge et apparence
$graph9->title->SetFont(FF_FONT1, FS_BOLD, 11);
// Couleurs et transparence par histogramme
$bplot9 = new BarPlot($data10);
$bplot9->SetFillColor('lightgray');
$bplot9->value->Show();
$bplot9->value->SetFormat('%01.3f');
$bplot9->value->SetColor("black", "darkred");
$bplot9->SetShadow('black');
$bplot9->SetWidth(0.3);
$graph9->Add($bplot9);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(10, 10, 10, 10);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetBackgroundImage('../fond.png');
$mgraph->AddMix($graph, 0, 0, 85);
$mgraph->AddMix($graph1, 0, 270, 85);
$mgraph->AddMix($graph2, 0, 540, 85);
$mgraph->AddMix($graph3, 0, 810, 85);
$mgraph->AddMix($graph4, 0, 1080, 85);
$mgraph->AddMix($graph5, 0, 1350, 85);
Exemplo n.º 19
0
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

Exemplo n.º 20
0
$bplot3 = new BarPlot($medium_count_arr);
$bplot4 = new BarPlot($low_count_arr);
$bplot5 = new BarPlot($none_count_arr);
$bplot6 = new BarPlot($duplicate_count_arr);
$bplot1->SetFillColor("slateblue");
$bplot2->SetFillColor("maroon");
$bplot3->SetFillColor("lightgoldenrodyellow");
$bplot4->SetFillColor("paleturquoise");
$bplot5->SetFillColor("palegreen3");
$bplot6->SetFillColor("sienna2");
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$bplot4->SetShadow();
$bplot5->SetShadow();
$bplot6->SetShadow();
$bplot1->SetLegend('Critical');
$bplot2->SetLegend('High');
$bplot3->SetLegend('Medium');
$bplot4->SetLegend('Low');
$bplot5->SetLegend('None');
$bplot6->SetLegend('Duplicate');
$bplot1->value->Show();
$bplot2->value->Show();
$bplot3->value->Show();
$bplot4->value->Show();
$bplot5->value->Show();
$bplot6->value->Show();
$bplot1->value->SetFont(FF_FONT1);
$bplot2->value->SetFont(FF_FONT1);
$bplot3->value->SetFont(FF_FONT1);
Exemplo n.º 21
0
$graph->xaxis->SetColor('darkblue', 'black');
// Setup "hidden" y-axis by given it the same color
// as the background (this could also be done by setting the weight
// to zero)
$graph->yaxis->SetColor('lightblue', 'darkblue');
$graph->ygrid->SetColor('white');
// Setup graph title ands fonts
$graph->title->Set('Using grace = 50%');
$graph->title->SetFont(FF_FONT2, FS_BOLD);
$graph->xaxis->SetTitle('Year 2002', 'center');
$graph->xaxis->SetTitleMargin(10);
$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
$graph->yaxis->scale->SetGrace(50);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('darkblue');
$bplot->SetWidth(0.5);
$bplot->SetShadow('darkgray');
// Setup the values that are displayed on top of each bar
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
$bplot->value->SetFormat('$%d');
$bplot->value->SetColor('darkred');
$bplot->value->SetAngle(45);
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
}
$datax[] = $_REQUEST["actual"];
$datay[] = "Prima Actual";
$datax[] = $_REQUEST["provart"];
$datay[] = "Prima Provincia ART";
$graph = new Graph(400, 256, "auto");
$graph->SetScale("textlin", $min, $max);
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 20, 40);
$graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->xaxis->SetLabelAlign("center", "bottom");
$graph->xaxis->SetLabelAngle(0);
$graph->xaxis->SetLabelMargin(16);
$graph->xaxis->SetTickLabels($datay);
$graph->yaxis->SetLabelMargin(1);
if ($leyenda) {
    $txt = new Text(" (En miles)");
    $txt->SetColor("red");
    $graph->AddText($txt);
}
$bplot = new BarPlot($datax);
//$bplot->SetColor("gray");
//$bplot->SetFillColor("orange");
$bplot->SetFillGradient("#00a4e4", "#00a4e4", GRAD_VER);
$bplot->SetShadow("black", 8, 4);
$bplot->SetValuePos("bottom");
$bplot->SetWidth(0.3);
$graph->Add($bplot);
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->Stroke(GRAFICO_CARTA_COTIZACION . $_REQUEST["archivo"]);
//$graph->Stroke();
Exemplo n.º 23
0
$graph7->yaxis->title->Set('pourcentage(%)');
$graph7->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph7->ygrid->SetColor('black');
$graph7->yaxis->SetTitleMargin(45);
$graph7->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph7->title->Set("Benchmarking simulated cpu of x in the presence of simulated Memload -Mesuring Deadline met-");
// TITRE: marge et apparence
$graph7->title->SetFont(FF_FONT1, FS_BOLD, 11);
// Couleurs et transparence par histogramme
$bplot7 = new BarPlot($data8);
$bplot7->SetFillColor('green');
$bplot7->value->Show();
$bplot7->value->SetFormat('%01.3f');
$bplot7->value->SetColor("black", "darkred");
$bplot7->SetShadow('black');
$bplot7->SetWidth(0.3);
$graph7->Add($bplot7);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(10, 10, 10, 10);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetBackgroundImage('../fond.png');
$mgraph->AddMix($graph, 0, 0, 85);
$mgraph->AddMix($graph2, 0, 270, 85);
$mgraph->AddMix($graph3, 0, 540, 85);
$mgraph->AddMix($graph4, 0, 810, 85);
$mgraph->AddMix($graph5, 0, 1080, 85);
$mgraph->AddMix($graph6, 0, 1350, 85);
Exemplo n.º 24
0
$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->SetFillGradient("$color", $color2, GRAD_MIDVER);
$bplot->SetFillColor($color . "@0.5");
$bplot->SetShadow($color . "@0.7", 5, 5);
// Set color for the frame of each bar
$bplot->SetColor($color . "@1");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
$geoloc->close();
?>

Exemplo n.º 25
0
 private function _renderPlotBar($groupID, $dimensions = '2d')
 {
     $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
     //	Rotate for bar rather than column chart
     if ($groupID == 0 && $rotation == 'bar') {
         $this->_graph->Set90AndMargin();
     }
     $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
     $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
     if ($labelCount > 0) {
         $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
         $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation);
         //	Rotate for bar rather than column chart
         if ($rotation == 'bar') {
             $datasetLabels = array_reverse($datasetLabels);
             $this->_graph->yaxis->SetPos('max');
             $this->_graph->yaxis->SetLabelAlign('center', 'top');
             $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
         }
         $this->_graph->xaxis->SetTickLabels($datasetLabels);
     }
     $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
     $seriesPlots = array();
     if ($grouping == 'percentStacked') {
         $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
     }
     //	Loop through each data series in turn
     for ($j = 0; $j < $seriesCount; ++$j) {
         $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
         if ($grouping == 'percentStacked') {
             $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
         }
         //	Fill in any missing values in the $dataValues array
         $testCurrentIndex = 0;
         foreach ($dataValues as $k => $dataValue) {
             while ($k != $testCurrentIndex) {
                 $dataValues[$testCurrentIndex] = null;
                 ++$testCurrentIndex;
             }
             ++$testCurrentIndex;
         }
         //	Reverse the $dataValues order for bar rather than column chart
         if ($rotation == 'bar') {
             $dataValues = array_reverse($dataValues);
         }
         $seriesPlot = new BarPlot($dataValues);
         $seriesPlot->SetColor('black');
         $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
         if ($dimensions == '3d') {
             $seriesPlot->SetShadow();
         }
         if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
             $dataLabel = '';
         } else {
             $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
         }
         $seriesPlot->SetLegend($dataLabel);
         $seriesPlots[] = $seriesPlot;
     }
     //	Reverse the plot order for bar rather than column chart
     if ($rotation == 'bar' && !($grouping == 'percentStacked')) {
         $seriesPlots = array_reverse($seriesPlots);
     }
     if ($grouping == 'clustered') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } elseif ($grouping == 'standard') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } else {
         $groupPlot = new AccBarPlot($seriesPlots);
         if ($dimensions == '3d') {
             $groupPlot->SetShadow();
         }
     }
     $this->_graph->Add($groupPlot);
 }
Exemplo n.º 26
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;
}
Exemplo n.º 27
0
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.03, 0.5, "right", "center");
// Display every 6:th tickmark
$graph->xaxis->SetTextTickInterval(6);
// Label every 2:nd tick mark
$graph->xaxis->SetTextLabelInterval(2);
// Setup the labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetFillColor("orange");
$b1->SetAbsWidth(8);
// Drop shadow on bars adjust the default values a little bit
$b1->SetShadow("steelblue", 2, 2);
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->AddY2($b1);
// Finally output the  image
$graph->Stroke();
?>


Exemplo n.º 28
0
    $y1[$m] = $row["nbre_log"];
}
mysql_close($db);
//------------------------------------------------------------------------------ Génération du graph.
$graph = new Graph(800, 280);
$graph->SetMargin(60, 40, 40, 60);
$graph->SetBox(false);
$graph->SetMarginColor('white');
$graph->SetColor('white');
$graph->SetScale("textlin");
$graph->xaxis->SetTickLabels($x);
$graph->xaxis->title->SetColor("gray5");
$graph->xaxis->SetColor("gray5", "gray5");
$graph->yaxis->title->SetColor("gray5");
$graph->yaxis->SetColor("gray5", "gray5");
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.05, 0.97, "left", "bottom");
$b1plot = new BarPlot($y1);
$b1plot->SetFillColor("red@0.4");
$b1plot->SetShadow();
$b1plot->value->SetColor("gray5");
$b1plot->value->SetFormat('%d');
$b1plot->value->Show();
$b1plot->value->SetColor("black");
$b1plot->SetLegend("Connections");
$graph->Add($b1plot);
$graph->title->Set("Année " . $a);
$graph->title->SetColor("gray7");
$graph->xaxis->title->Set("Mois");
//$graph->yaxis->title->Set("Connections");
$graph->Stroke();
Exemplo n.º 29
0
$graph4->yaxis->title->Set('time(nano-sec)');
$graph4->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph4->ygrid->SetColor('black');
$graph4->yaxis->SetTitleMargin(45);
$graph4->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph4->title->Set("Mesuring latency Mod operation (nano-sec)");
// TITRE: marge et apparence
$graph4->title->SetFont(FF_FONT1, FS_BOLD, 11);
// Couleurs et transparence par histogramme
$bplot4 = new BarPlot($data5);
$bplot4->value->Show();
$bplot4->SetFillColor('blue');
$bplot4->value->SetFormat('%01.3f');
$bplot4->value->SetColor("black", "darkred");
$bplot4->SetShadow('black');
$bplot4->SetWidth(0.3);
$graph4->Add($bplot4);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(10, 10, 10, 10);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetBackgroundImage('../fond.png');
$mgraph->AddMix($graph, 0, 0, 85);
$mgraph->AddMix($graph1, 0, 270, 85);
$mgraph->AddMix($graph2, 0, 540, 85);
$mgraph->AddMix($graph3, 0, 810, 85);
$mgraph->AddMix($graph4, 0, 1080, 85);
$mgraph->Stroke();
Exemplo n.º 30
0
$graph->SetShadow();
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 15);
$graph->title->Set("Cash flow ");
$graph->subtitle->Set("Use of static line, 3D and solid band");
// Turn off Y-grid (it's on by default)
$graph->ygrid->Show(false);
// Add 10% grace ("space") at top of Y-scale.
$graph->yscale->SetGrace(10);
$graph->yscale->SetAutoMin(-20);
// Turn the tick mark out from the plot area
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetShadow("darkblue");
// Show the actual value for each bar on top/bottom
$bplot->value->Show(true);
$bplot->value->SetFormat("%02d kr");
// Position the X-axis at the bottom of the plotare
$graph->xaxis->SetPos("min");
// .. and add the plot to the graph
$graph->Add($bplot);
// Add upper and lower band and use no frames
$band[0] = new PlotBand(HORIZONTAL, BAND_3DPLANE, "min", 0, "blue");
$band[0]->ShowFrame(false);
$band[0]->SetDensity(20);
$band[1] = new PlotBand(HORIZONTAL, BAND_SOLID, 0, "max", "steelblue");
$band[1]->ShowFrame(false);
$graph->Add($band);
$graph->Add(new PlotLine(HORIZONTAL, 0, "black", 2));