/** * Create a JpGraph accumulated barPlot chart * * @param Array $bplot Array of JpGraph barPlot objects * @param Chart $graph The output graph that will contains accumulated barPlots * * @return Void */ private function displayAccumulatedGraph($bplot, $graph) { $abplot = new AccBarPlot($bplot); $abplot->SetAbsWidth(10); $graph->Add($abplot); $graph->Stroke(); }
$b1plot = new BarPlot($data1y); $b1plot->SetFillColor("orange"); $targ=array("bar_clsmex2.php#1","bar_clsmex2.php#2","bar_clsmex2.php#3", "bar_clsmex2.php#4","bar_clsmex2.php#5","bar_clsmex2.php#6"); $alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); $b1plot->SetCSIMTargets($targ,$alts); $b2plot = new BarPlot($data2y); $b2plot->SetFillColor("blue"); $targ=array("bar_clsmex2.php#7","bar_clsmex2.php#8","bar_clsmex2.php#9", "bar_clsmex2.php#10","bar_clsmex2.php#11","bar_clsmex2.php#12"); $alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); $b2plot->SetCSIMTargets($targ,$alts); // Create the accumulated bar plot $abplot = new AccBarPlot(array($b1plot,$b2plot)); $abplot->SetShadow(); // We want to display the value of each bar at the top $abplot->value->Show(); $abplot->value->SetFont(FF_FONT1,FS_NORMAL); $abplot->value->SetAlign('left','center'); $abplot->value->SetColor("black","darkred"); $abplot->value->SetFormat('%.1f mkr'); // ...and add it to the graph $graph->Add($abplot); // Send back the HTML page which will call this script again // to retrieve the image. $graph->StrokeCSIM();
$graph->xaxis->SetPosAbsDelta(15); $graph->yaxis->SetPosAbsDelta(-15); $graph->xaxis->SetLabelAngle(50); // Legend $graph->legend->SetMarkAbsSize(5); $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 7); $graph->legend->Pos(0.02, 0.02, "right", "top"); // Create the bar pot $colors = array("#aa5500", "#55aa00", "#0055aa", "#aa0055", "#5500aa", "#00aa55", "#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff"); $listPlots = array(); foreach ($opbysalle as $key => $value) { $bplot = new BarPlot($value["sejour"]); $from = $colors[$key]; $to = "#EEEEEE"; $bplot->SetFillGradient($from, $to, GRAD_LEFT_REFLECTION); $bplot->SetColor("white"); $bplot->setLegend($value["nom"]); $bplot->value->SetFormat("%01.0f"); $bplot->value->SetColor($colors[$key]); $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); //$bplot->value->show(); $listPlots[] = $bplot; } $gbplot = new AccBarPlot($listPlots); $gbplot->SetWidth(0.6); $gbplot->value->SetFormat("%01.0f"); $gbplot->value->show(); // Set color for the frame of each bar $graph->Add($gbplot); // Finally send the graph to the browser $graph->Stroke();
//$graph->title->Set($title); //$graph->title->SetFont(FF_FONT1, FS_BOLD); $bar_array = array(); $i = 0; foreach ($final_values as $title => $values) { $i %= count($color_list); $datay = explode(",", $values); $bplot = new BarPlot($datay); $bplot->SetWidth(0.7); $bplot->SetFillColor($color_list[$i] . "@0.5"); $bplot->SetColor($color_list[$i] . "@1"); $bplot->SetLegend($title); $bar_array[] = $bplot; $i++; } // Create the grouped bar plot $gbplot = new AccBarPlot($bar_array); $gbplot->SetShadow($color . "@0.9", 6, 5); $gbplot->SetWidth(0.6); $graph->Add($gbplot); $graph->xaxis->SetTickLabels($labelx); $graph->xaxis->title->Set($titley); $graph->yaxis->title->Set($titlex); // Adjust the legend position $graph->legend->SetColumns(3); $graph->legend->SetPos(0.5, 0.95, 'center', 'bottom'); $graph->legend->SetShadow('#fafafa', 0); $graph->legend->SetFrameWeight(0); $graph->legend->SetFillColor('#fafafa'); $graph->Stroke(); unset($graph);
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); }
<?php // content="text/plain; charset=utf-8" require_once '../jpgraph.php'; require_once '../jpgraph_bar.php'; $datay1 = array(13, 8, 19, 7, 17, 6); $datay2 = array(4, 5, 2, 7, 5, 25); // Create the graph. $graph = new Graph(350, 250); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); // Setup title $graph->title->Set('Acc bar with gradient'); // Create the first bar $bplot = new BarPlot($datay1); $bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT); $bplot->SetColor('darkred'); // Create the second bar $bplot2 = new BarPlot($datay2); $bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT); $bplot2->SetColor('darkgreen'); // And join them in an accumulated bar $accbplot = new AccBarPlot(array($bplot, $bplot2)); $accbplot->SetColor('red'); $accbplot->SetWeight(1); $graph->Add($accbplot); $graph->Stroke();
private function createBarGraph($xdata, $data1, $ytitle) { // Create the graph. $graph = new Graph($this->width, $this->height, "auto"); $graph->SetScale("textlin"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->SetFrame(false); if ($this->shadow) { $graph->SetShadow(); } // Create the bar plot $arrPos = array(); $arrNeg = array(); foreach ($data1 as &$value) { if ($value >= 0) { array_push($arrPos, $value); array_push($arrNeg, 0); } else { array_push($arrPos, 0); array_push($arrNeg, $value); } } $bplotPos = new BarPlot($arrPos); // First group positive $bplotPos->SetFillColor('#ababab'); // color for positive '#ababab' Kulturplanner #8aa571 $bplotNeg = new BarPlot($arrNeg); // second group negative $bplotNeg->SetFillColor("#cc00cc"); //color for negative prologiq "#cc00cc" $gbplot = new AccBarPlot(array($bplotPos, $bplotNeg)); $gbplot->value->Show(); $gbplot->value->SetFormat('%d'); $gbplot->value->SetColor("black"); $gbplot->SetValuePos('center'); //$gbplot->SetLegend(Prado::localize($this->legend)); // ... and add it to the graph $graph->Add($gbplot); $graph->xaxis->title->Set($this->title); $graph->xaxis->SetTickLabels($xdata); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->Set($ytitle); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetLabelMargin(5); $graph->yaxis->scale->SetGrace(10); $graph->yaxis->HideZeroLabel(); $graph->ygrid->SetFill(true, '#f2f2f2@0.6', '#cacaca@0.6'); return $graph; }
$graph = new Graph(310, 200); $graph->SetScale("textlin"); $graph->img->SetMargin(40, 30, 20, 40); $graph->SetShadow(); // Create the bar plots $b1plot = new BarPlot($data1y); $b1plot->SetFillColor("orange"); $targ = array("bar_clsmex2.php#1", "bar_clsmex2.php#2", "bar_clsmex2.php#3", "bar_clsmex2.php#4", "bar_clsmex2.php#5", "bar_clsmex2.php#6"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $b1plot->SetCSIMTargets($targ, $alts); $b2plot = new BarPlot($data2y); $b2plot->SetFillColor("blue"); $targ = array("bar_clsmex2.php#7", "bar_clsmex2.php#8", "bar_clsmex2.php#9", "bar_clsmex2.php#10", "bar_clsmex2.php#11", "bar_clsmex2.php#12"); $alts = array("val=%v", "val=%v", "val=%v", "val=%v", "val=%v", "val=%v"); $b2plot->SetCSIMTargets($targ, $alts); // Create the grouped bar plot $abplot = new AccBarPlot(array($b1plot, $b2plot)); $abplot->SetShadow(); $abplot->ShowValue(); // ...and add it to the graPH $graph->Add($abplot); $graph->title->Set("Image map barex2"); $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); // Display the graph $graph->Stroke(GenImgName()); echo $graph->GetHTMLImageMap("myimagemap"); echo "<img src=\"" . GenImgName() . "\" ISMAP USEMAP=\"#myimagemap\" border=0>";
public function RenderGraph(&$form, &$robj) { $data = new DataObjX2Yp($this->code); $form->views[$this->view]->RenderSpecial('get-data', $form, $data); if (!empty($this->styles['chart-options']['xlabelangle'])) { $robj->xaxis->SetLabelAngle($this->styles['chart-options']['xlabelangle']); if ($this->styles['chart-options']['xlabelangle'] < 0) { $robj->xaxis->SetLabelAlign('left'); } } if (!empty($this->styles['chart-options']['xlabelfont'])) { $robj->xaxis->SetFont($this->styles['chart-options']['xlabelfont']); } else { $robj->xaxis->SetFont(FF_DEJAVU); } $robj->xaxis->SetTickLabels($data->xdata); $i = 0; foreach ($data->yzdata as $ykey => $ycol) { $accplots[] = new BarPlot($ycol); if (is_array($this->styles['accumplot-options']['color'])) { end($accplots)->SetFillColor($this->styles['accumplot-options']['color'][$i++]); } if (!empty($obj_leg->legend[$ykey])) { end($accplots)->SetLegend($obj_leg->legend[$ykey]); } else { end($accplots)->SetLegend(_("(none)")); } } $plot = new AccBarPlot($accplots); if (!empty($this->styles['plot-options']['setfillcolor'])) { $plot->SetFillColor($this->styles['plot-options']['setfillcolor']); } if (!empty($this->styles['plot-options']['setcolor'])) { $plot->SetColor($this->styles['plot-options']['setcolor']); } $robj->Add($plot); }
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; $datay1 = array(13, 8, 19, 7, 17, 6); $datay2 = array(4, 5, 2, 7, 5, 25); // Create the graph. $graph = new Graph(350, 250); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); // Setup title $graph->title->Set('Acc bar with gradient'); // Create the first bar $bplot = new BarPlot($datay1); $bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT); $bplot->SetColor('darkred'); $bplot->SetWeight(0); // Create the second bar $bplot2 = new BarPlot($datay2); $bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT); $bplot2->SetColor('darkgreen'); $bplot2->SetWeight(0); // And join them in an accumulated bar $accbplot = new AccBarPlot(array($bplot, $bplot2)); $accbplot->SetColor('darkgray'); $accbplot->SetWeight(1); $graph->Add($accbplot); $graph->Stroke();
$data_b = array($total ? $b * 100.0 / $total : 100); $data_c = array($total ? $c * 100.0 / $total : 0); // Build graph $graph = new Graph(400, 30); $graph->SetScale('textlin', 0, 100); $graph->Set90AndMargin(1, 1, 1, 1); $graph->SetMarginColor('#22262a'); $graph->SetColor('#22262a'); $graph->SetFrame(true, '#FFFFFF', 0); $bpa = new BarPlot($data_a); $bpa->SetFillColor('#CC0000'); $bpt = new BarPlot($data_b); if ($total == 0) { $bpt->SetFillColor('#222222'); } else { $bpt->SetFillColor('#888888'); } $bph = new BarPlot($data_c); $bph->SetFillColor('#0055FF'); $accplot = new AccBarPlot(array($bpa, $bpt, $bph)); $accplot->SetWidth(16); $graph->xaxis->Hide(); $graph->yaxis->HideLine(); $graph->yaxis->HideTicks(); $graph->yaxis->SetMajTickPositions(array(25, 50, 75)); $graph->ygrid->SetColor('#555555'); // Stroke $graph->Add($accplot); $graph->Stroke(); break; }
/** * Execute the action * * @return mixed * @access public * @since 2/28/08 */ public function execute() { // New graph with a drop shadow $graph = new Graph(800, 600, 'auto'); $graph->SetShadow(); // Use a "text" X-scale $graph->SetScale("textlin"); // Specify X-labels //$databarx = array('tXi','','','xxx','','','iXii','','','OOO','','','tOO'); $graph->xaxis->SetFont(FF_VERA, FS_NORMAL); $graph->xaxis->SetTickLabels($this->getLabels()); $graph->xaxis->SetLabelAngle(45); $days = $this->getNumDays(); // Between 3 and 20 weeks, use weekly intervals if ($days > 21 && $days < 140) { $graph->xaxis->SetTextLabelInterval(7); } else { if ($days >= 140) { $graph->xaxis->SetTextLabelInterval(round($days / 20)); } } $graph->SetMargin(40, 20, 40, 80); // Set title and subtitle $title = _("Segue Usage for the past %1 %2"); $title = str_replace('%1', $this->getIntervalSize(), $title); if ($this->getIntervalSize() == 1) { $unit = $this->getIntervalUnit(); } else { $unit = $this->getIntervalUnit() . 's'; } $title = str_replace('%2', ucfirst(strtolower($unit)), $title); $graph->title->Set($title); // Use built in font $graph->title->SetFont(FF_VERA, FS_BOLD); $graph->legend->SetFont(FF_VERA, FS_NORMAL); // Create the bar plot $b1 = new BarPlot($this->getEdits()); $b1->SetLegend(_("Edits")); $b1->SetFillColor('#7778F3'); $b2 = new BarPlot($this->getFiles()); $b2->SetLegend(_("Files")); $b2->SetFillColor('#FFCB3F'); $b3 = new BarPlot($this->getComments()); $b3->SetLegend(_("Discussion Posts")); $b3->SetFillColor('#89DF6D'); $accbar = new AccBarPlot(array($b1, $b2, $b3)); $accbar->SetWidth(1); //$b1->SetShadow(); $graph->Add($accbar); $line = new LinePlot($this->getErrors()); $line->SetLegend(_("Errors")); $line->SetColor('#FF0000'); $line->SetWeight(1); $line->SetBarCenter(true); $graph->Add($line); $line = new LinePlot($this->getLogins()); $line->SetLegend(_("Logins")); $line->SetColor('#615FFF'); $line->SetWeight(1); $line->SetBarCenter(true); $graph->Add($line); $line = new LinePlot($this->getUsers()); $line->SetLegend(_("Distinct Users")); $line->SetColor('#0300FF'); $line->SetWeight(3); $line->SetBarCenter(true); // For months and less, display value for the number of users if ($days < 32) { $line->value->Show(); $line->value->HideZero(); $line->value->SetFormat("%d"); } $graph->Add($line); // Finally output the image $graph->Stroke(); exit; }