Skip to content

Commit 27e220c

Browse files
Merge remote-tracking branch 'github/feat-bar-overlap' into feat-bar-overlap
2 parents eeb3ce6 + 7b1ce67 commit 27e220c

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

docs/usage/shapes/chart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ $barChart->setGapWidthPercent(250);
334334
#### Overlap
335335

336336
You can define the bar overlap within bars or columns clusters. It is defined in percent.
337-
The default value is 100% for stacked and 0% for grouped bar charts. The value must be defined between -100 and 100.
337+
The default value is `100%` for stacked and `0%` for grouped bar charts. The value must be defined between -100 and 100.
338338

339339
When defining the bar grouping type, the default overlap values will be set. Any changes to the overlap must be made after setting the bar grouping type through `setBarGrouping`.
340340

src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,25 @@ public function setGapWidthPercent($gapWidthPercent)
143143
/**
144144
* @return int
145145
*/
146-
public function getOverlapWidthPercent()
146+
public function getOverlapWidthPercent(): int
147147
{
148148
return $this->overlapWidthPercent;
149149
}
150150

151151
/**
152152
* @param int $overlapWidthPercent
153153
*
154-
* @return $this
154+
* @return self
155155
*/
156-
public function setOverlapWidthPercent($overlapWidthPercent)
156+
public function setOverlapWidthPercent(int $value): self
157157
{
158-
if ($overlapWidthPercent < -100) {
159-
$overlapWidthPercent = -100;
158+
if ($value < -100) {
159+
$value = -100;
160160
}
161-
if ($overlapWidthPercent > 100) {
162-
$overlapWidthPercent = 100;
161+
if ($value > 100) {
162+
$value = 100;
163163
}
164-
$this->overlapWidthPercent = $overlapWidthPercent;
164+
$this->overlapWidthPercent = $value;
165165

166166
return $this;
167167
}

tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function testOverlapWidthPercent(): void
108108
$value = mt_rand(-100, 100);
109109
$object = new Bar();
110110
$this->assertEquals(0, $object->getOverlapWidthPercent());
111-
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setOverlapWidthPercent($value));
111+
$this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent($value));
112112
$this->assertEquals($value, $object->getOverlapWidthPercent());
113-
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setOverlapWidthPercent(101));
113+
$this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(101));
114114
$this->assertEquals(100, $object->getOverlapWidthPercent());
115-
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setOverlapWidthPercent(-101));
115+
$this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(-101));
116116
$this->assertEquals(-100, $object->getOverlapWidthPercent());
117117
}
118118

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ public function testTypeBar(): void
582582
$oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
583583
$oBar = new Bar();
584584
$oBar->setGapWidthPercent($valueGapWidthPercent);
585-
$valueOverlapWidthPercent = -10;
586-
$oBar->setOverlapWidthPercent($valueOverlapWidthPercent);
585+
$oBar->setOverlapWidthPercent(-10);
587586
$oSeries = new Series('Downloads', $this->seriesData);
588587
$oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
589588
$oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
@@ -606,7 +605,7 @@ public function testTypeBar(): void
606605
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:gapWidth';
607606
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueGapWidthPercent);
608607
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:overlap';
609-
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueOverlapWidthPercent);
608+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $oBar->getOverlapWidthPercent());
610609

611610
$this->assertIsSchemaECMA376Valid();
612611
}

0 commit comments

Comments
 (0)