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); }
$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->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);