private function PHPExcel_Chart_Renderer_jpgraph::_renderPlotBar in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php \PHPExcel_Chart_Renderer_jpgraph::_renderPlotBar()
2 calls to PHPExcel_Chart_Renderer_jpgraph::_renderPlotBar()
- PHPExcel_Chart_Renderer_jpgraph::_renderBarChart in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Chart/ Renderer/ jpgraph.php - PHPExcel_Chart_Renderer_jpgraph::_renderCombinationChart in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Chart/ Renderer/ jpgraph.php
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Chart/ Renderer/ jpgraph.php, line 329
Class
- PHPExcel_Chart_Renderer_jpgraph
- PHPExcel_Chart_Renderer_jpgraph
Code
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);
}