// 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(); ?>
function getBarPlot($data, $color) { $b = new BarPlot($data); //parameters hard coded for the moment $b->SetAbsWidth(10); $b->value->Show(true); $b->value->SetColor($this->graph->getMainColor()); $b->value->SetFormat("%d"); $b->value->HideZero(); $b->value->SetMargin(4); $b->value->SetFont($this->graph->getFont(), FS_NORMAL, 7); $b->SetWidth(0.4); $b->SetColor($color . ':0.7'); $b->SetFillColor($color); // end hard coded parameter return $b; }
$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(); ?>
if ($i % 10 == 0) { $databarx[] = $i; $databary[] = $datay[$i] / 2; } } // New graph with a background image and drop shadow $graph = new Graph(450, 300); $graph->img->SetMargin(40, 180, 40, 40); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME); //$graph->img->SetAntiAliasing(); $graph->SetScale("intlin"); $graph->SetShadow(); $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("(\"center\" aligned bars)"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line $p1 = new LinePlot($datay, $datax); $p1->SetWeight(1); $p1->SetColor("red"); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); $b1 = new BarPlot($databary, $databarx); $b1->SetAbsWidth(10); $b1->SetAlign("center"); $b1->SetShadow(); $graph->Add($b1); $graph->Stroke();
// Setup graph $graph = new Graph($width, 250, "auto"); $graph->SetFrame(false); $graph->SetScale('textlin', $options['graph_y_min'], $options['graph_y_max'], $options['graph_x_min'], $options['graph_x_max']); $graph->yaxis->scale->SetGrace($options['graph_y_top'], $options['graph_y_bot']); $graph->xaxis->scale->SetGrace($options['graph_x_top'], $options['graph_x_bot']); $graph->SetMarginColor($background); $graph->img->SetMargin(40, 30, 20, 40); //$graph->SetShadow(); // Setup graph title $graph->title->Set($data['title']); $graph->title->SetFont(FF_FONT1, FS_BOLD); $plot = new BarPlot($data['values']); $plot->SetWidth(0.6); // set bars width in percentage $plot->SetAbsWidth(20); // set bars width in pixels $color = $options['graph_color']; // One plain color if ($options['graph_gradient'] == 0) { $plot->SetFillColor($color); // Gradient color } elseif ($options['graph_gradient'] != 0) { // Made the color $degree darker // Given color "#FF1E1E", we split the color into groups // (red, gree, blue): "FF", "1E" and "1E" and convert them to decimal. // Then sum to each group $degree and transform the result back to hex. $degree = -75; $color2 = ''; for ($x = 1; $x < 6; $x += 2) { $dec = hexdec($color[$x] . $color[$x + 1]);
$lineplot5->SetColor("black"); $lineplot5->SetWeight(3); // Create the linear plot $lineplot6 = new LinePlot($Atmpf, $times); $lineplot6->SetLegend("Air Temperature"); $lineplot6->SetColor("red"); $lineplot6->SetWeight(3); // Create the linear plot $lineplot7 = new LinePlot($Adwpf, $times); $lineplot7->SetLegend("Dew Point"); $lineplot7->SetColor("green"); $lineplot7->SetWeight(3); $bp1 = new BarPlot($pcpn, $times); $bp1->SetLegend("Precip"); $bp1->SetFillColor("black"); $bp1->SetAbsWidth(1.0); // Create the linear plot $fz = new LinePlot($freezing, $times); $fz->SetColor("blue"); // Title Box $tx1 = new Text($cities[$station]['name'] . " \nMeteogram "); $tx1->SetPos(0.01, 0.01, 'left', 'top'); $tx1->SetFont(FF_FONT1, FS_BOLD, 16); $tx2 = new Text("Time series showing temperatures\n from the pavement sensors and \n the sub-surface sensor "); $tx2->SetPos(0.01, 0.11, 'left', 'top'); $tx2->SetFont(FF_FONT1, FS_NORMAL, 10); include "{$rootpath}/include/mlib.php"; $mySOb = array(); if ($mode == "hist") { $ptext = "Historical Plot for dates:\n"; $tx3 = new Text($ptext . $plotTitle);
function GerarGraficoBarra() { require_once "../biblioteca/jpgraph/jpgraph.php"; require_once "../biblioteca/jpgraph/jpgraph_bar.php"; $grafico = new graph($this->largura, $this->altura, "png"); /* Margem das partes principais do gráfico (dados), o que está * fora da margem fica separado para as labels, títulos, etc * Este valor ficará como padrão para todos os gráficos */ $grafico->img->SetMargin(40, 30, 20, 40); $grafico->SetScale("textlin"); $grafico->SetShadow(); //Define Titulo e Subtitulo $grafico->title->Set($this->titulo); $grafico->subtitle->Set($this->subtitulo); // pedir para mostrar os grides no fundo do gráfico, // o ygrid é marcado como true por padrão $grafico->ygrid->Show(true); $grafico->xgrid->Show(true); $gBarras = new BarPlot($this->dados_eixoY); $gBarras->SetFillColor($this->cor_barra); $gBarras->SetShadow($this->cor_sombra); $gBarras->SetAbsWidth($this->largura_barra); $gBarras->value->Show(); $gBarras->value->SetFormat('%d'); $gBarras->SetValuePos('center'); $gBarras->value->SetFont(FF_FONT1, FS_BOLD); // título dos vértices $grafico->yaxis->title->Set($this->label_eixoY); $grafico->xaxis->title->Set($this->label_eixoX); // título das barras $grafico->xaxis->SetTickLabels($this->dados_eixoX); $grafico->Add($gBarras); $grafico->Stroke("imagens/graficos/" . $this->nome); }
function getChart($exec_arr, $auto_arr, $user_arr, $testplan_name) { $data1y = $exec_arr; $data2y = $auto_arr; // Create the graph. These two calls are always required $graph = new Graph(1500, 300, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->yaxis->SetTickPositions(array(20, 40, 60, 80, 100), array(10, 30, 50, 70, 90)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels($user_arr); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new BarPlot($data1y); $b2plot = new BarPlot($data2y); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot)); $gbplot->SetWidth(0.3); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("red"); $b1plot->SetAbsWidth(10); $b1plot->SetLegend("Executed"); $b2plot->SetColor("white"); $b2plot->SetFillColor("green"); $b2plot->SetAbsWidth(10); $b2plot->SetLegend("Automated"); $graph->title->Set("Execution Status of {$testplan_name}"); $graph->yaxis->title->Set("value in %"); // Display the graph //$graph->Stroke(); $graph->img->SetImgFormat('jpeg'); $fileName = "execution.jpeg"; $graph->Stroke($fileName); return $fileName; }