Merge remote-tracking branch 'FrankMeyer/develop' into develop
This commit is contained in:
commit
a8d1775eb1
|
|
@ -23,11 +23,16 @@ $categories = array('A', 'B', 'C', 'D', 'E');
|
|||
$series1 = array(1, 3, 2, 5, 4);
|
||||
$series2 = array(3, 1, 7, 2, 6);
|
||||
$series3 = array(8, 3, 2, 5, 4);
|
||||
$showGridLines = false;
|
||||
$showAxisLabels = false;
|
||||
|
||||
foreach ($chartTypes as $chartType) {
|
||||
$section->addTitle(ucfirst($chartType), 2);
|
||||
$chart = $section->addChart($chartType, $categories, $series1);
|
||||
$chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2));
|
||||
$chart->getStyle()->setShowGridX($showGridLines);
|
||||
$chart->getStyle()->setShowGridY($showGridLines);
|
||||
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
|
||||
if (in_array($chartType, $twoSeries)) {
|
||||
$chart->addSeries($categories, $series2);
|
||||
}
|
||||
|
|
@ -44,7 +49,8 @@ $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous
|
|||
|
||||
$chartTypes = array('pie', 'bar', 'column', 'line', 'area');
|
||||
$multiSeries = array('bar', 'column', 'line', 'area');
|
||||
$style = array('width' => Converter::cmToEmu(5), 'height' => Converter::cmToEmu(4), '3d' => true);
|
||||
$style = array('width' => Converter::cmToEmu(5), 'height' => Converter::cmToEmu(4), '3d' => true,
|
||||
'showAxisLabels' => $showAxisLabels, 'showGridX' => $showGridLines, 'showGridY' => $showGridLines);
|
||||
foreach ($chartTypes as $chartType) {
|
||||
$section->addTitle(ucfirst($chartType), 2);
|
||||
$chart = $section->addChart($chartType, $categories, $series1, $style);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,27 @@ class Chart extends AbstractStyle
|
|||
*/
|
||||
private $is3d = false;
|
||||
|
||||
/**
|
||||
* Show labels for axis
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showAxisLabels = false;
|
||||
|
||||
/**
|
||||
* Show Gridlines for Y-Axis
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $gridY = false;
|
||||
|
||||
/**
|
||||
* Show Gridlines for X-Axis
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $gridX = false;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
|
|
@ -123,4 +144,73 @@ class Chart extends AbstractStyle
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show labels for axis
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function showAxisLabels()
|
||||
{
|
||||
return $this->showAxisLabels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show Gridlines for Y-Axis
|
||||
*
|
||||
* @param bool $value
|
||||
* @return self
|
||||
*/
|
||||
public function setShowAxisLabels($value = true)
|
||||
{
|
||||
$this->showAxisLabels = $this->setBoolVal($value, $this->showAxisLabels);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Gridlines for Y-Axis
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function showGridY()
|
||||
{
|
||||
return $this->gridY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show Gridlines for Y-Axis
|
||||
*
|
||||
* @param bool $value
|
||||
* @return self
|
||||
*/
|
||||
public function setShowGridY($value = true)
|
||||
{
|
||||
$this->gridY = $this->setBoolVal($value, $this->gridY);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Gridlines for X-Axis
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function showGridX()
|
||||
{
|
||||
return $this->gridX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show Gridlines for X-Axis
|
||||
*
|
||||
* @param bool $value
|
||||
* @return self
|
||||
*/
|
||||
public function setShowGridX($value = true)
|
||||
{
|
||||
$this->gridX = $this->setBoolVal($value, $this->gridX);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@ class Chart extends AbstractPart
|
|||
*/
|
||||
private function writeAxis(XMLWriter $xmlWriter, $type)
|
||||
{
|
||||
$style = $this->element->getStyle();
|
||||
$types = array(
|
||||
'cat' => array('c:catAx', 1, 'b', 2),
|
||||
'val' => array('c:valAx', 2, 'l', 1),
|
||||
|
|
@ -272,10 +273,14 @@ class Chart extends AbstractPart
|
|||
$xmlWriter->writeElementBlock('c:delete', 'val', 0);
|
||||
$xmlWriter->writeElementBlock('c:majorTickMark', 'val', 'none');
|
||||
$xmlWriter->writeElementBlock('c:minorTickMark', 'val', 'none');
|
||||
$xmlWriter->writeElementBlock('c:tickLblPos', 'val', 'none'); // nextTo
|
||||
if ($style->showAxisLabels()) {
|
||||
$xmlWriter->writeElementBlock('c:tickLblPos', 'val', 'nextTo');
|
||||
} else {
|
||||
$xmlWriter->writeElementBlock('c:tickLblPos', 'val', 'none');
|
||||
}
|
||||
$xmlWriter->writeElementBlock('c:crosses', 'val', 'autoZero');
|
||||
}
|
||||
if (isset($this->options['radar'])) {
|
||||
if (isset($this->options['radar']) || ($type == "cat" && $style->showGridX()) || ($type == "val" && $style->showGridY())) {
|
||||
$xmlWriter->writeElement('c:majorGridlines');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue