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

Add chart's secondary y axis. #1073

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

### Added

- Added chart's secondary y axis - [Issue #1072](https://github.com/PHPOffice/PhpSpreadsheet/issues/1072)

### Fixed

- COUPNUM should not return zero when settlement is in the last period - [Issue #1020](https://github.com/PHPOffice/PhpSpreadsheet/issues/1020) and [PR #1021](https://github.com/PHPOffice/PhpSpreadsheet/pull/1021)
Expand Down
38 changes: 37 additions & 1 deletion src/PhpSpreadsheet/Chart/DataSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class DataSeries
const STYLE_MARKER = 'marker';
const STYLE_FILLED = 'filled';

const VALUE_AXIS_POSITION_LEFT = 'l';
const VALUE_AXIS_POSITION_RIGHT = 'r';

/**
* Series Plot Type.
*
Expand Down Expand Up @@ -103,6 +106,11 @@ class DataSeries
*/
private $plotValues = [];

/**
* @var string
*/
private $valueAxisPosition;

/**
* Create a new DataSeries.
*
Expand All @@ -116,7 +124,7 @@ class DataSeries
* @param bool $smoothLine
* @param null|string $plotStyle
*/
public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null)
public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null, $valueAxisPosition = null)
{
$this->plotType = $plotType;
$this->plotGrouping = $plotGrouping;
Expand All @@ -140,6 +148,10 @@ public function __construct($plotType = null, $plotGrouping = null, array $plotO
$plotDirection = self::DIRECTION_COL;
}
$this->plotDirection = $plotDirection;

if ($valueAxisPosition === null) {
$this->valueAxisPosition = self::VALUE_AXIS_POSITION_LEFT;
}
}

/**
Expand Down Expand Up @@ -355,6 +367,16 @@ public function getSmoothLine()
return $this->smoothLine;
}

/**
* Get Value Axis Position.
*
* @return string
*/
public function getValueAxisPosition()
{
return $this->valueAxisPosition;
}

/**
* Set Smooth Line.
*
Expand All @@ -369,6 +391,20 @@ public function setSmoothLine($smoothLine)
return $this;
}

/**
* Set Value Axis Position.
*
* @param string $valueAxisPosition
*
* @return string
*/
public function setValueAxisPosition($valueAxisPosition)
{
$this->valueAxisPosition = $valueAxisPosition;

return $this;
}

public function refresh(Worksheet $worksheet)
{
foreach ($this->plotValues as $plotValues) {
Expand Down
Loading