Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide Axis #1447

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]

- Conditionals - Extend Support for (NOT)CONTAINSBLANKS [#1278](https://github.com/PHPOffice/PhpSpreadsheet/pull/1278)
### Added

- Allow chart axis to be fully hidden [#1446](https://github.com/PHPOffice/PhpSpreadsheet/issues/1446)

### Fixed

Expand Down
27 changes: 27 additions & 0 deletions src/PhpSpreadsheet/Chart/Axis.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Axis extends Properties
* @var array of mixed
*/
private $axisOptions = [
'hide' => 0,
'minimum' => null,
'maximum' => null,
'major_unit' => null,
Expand Down Expand Up @@ -193,6 +194,32 @@ public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value
($minor_unit !== null) ? $this->axisOptions['minor_unit'] = (string) $minor_unit : null;
}

/**
* Set Axis Visibility to TRUE.
*/
public function showAxis()
{
$this->axisOptions['hide'] = 0;
}

/**
* Set Axis Visibility to FALSE.
*/
public function hideAxis()
{
$this->axisOptions['hide'] = 1;
}

/**
* Get Axis Visibility.
*
* @return int
*/
public function getAxisVisibilty()
{
return $this->axisOptions['hide'];
}

/**
* Get Axis Options Property.
*
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Writer/Xlsx/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMulti
$objWriter->endElement();

$objWriter->startElement('c:delete');
$objWriter->writeAttribute('val', 0);
$objWriter->writeAttribute('val', $yAxis->getAxisVisibilty());
$objWriter->endElement();

$objWriter->startElement('c:axPos');
Expand Down Expand Up @@ -552,7 +552,7 @@ private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2,
$objWriter->endElement();

$objWriter->startElement('c:delete');
$objWriter->writeAttribute('val', 0);
$objWriter->writeAttribute('val', $xAxis->getAxisVisibilty());
$objWriter->endElement();

$objWriter->startElement('c:axPos');
Expand Down