Skip to content

Commit bb1251b

Browse files
committed
Word2007 Writer: LineChart supports LabelPosition for Series
1 parent 9c1e92e commit bb1251b

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

docs/changes/1.2.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Word2007 Reader: Fixed cast of color by [@Progi1984](https://github.com/Progi1984) fixing [#826](https://github.com/PHPOffice/PHPPresentation/pull/826) in [#840](https://github.com/PHPOffice/PHPPresentation/pull/840)
1717
- Word2007 Reader: Fixed panose with 20 characters by [@Progi1984](https://github.com/Progi1984) fixing [#798](https://github.com/PHPOffice/PHPPresentation/pull/798) in [#842](https://github.com/PHPOffice/PHPPresentation/pull/842)
1818
- `Gd::setImageResource()` : Fixed when imagecreatetruecolor returns false by [@jaapdh](https://github.com/jaapdh) in [#843](https://github.com/PHPOffice/PHPPresentation/pull/843)
19+
- Word2007 Writer: LineChart supports LabelPosition for Series by [@pal-software](https://github.com/jaapdh) fixing [#606](https://github.com/PHPOffice/PHPPresentation/pull/606) in [#8434](https://github.com/PHPOffice/PHPPresentation/pull/844)
1920

2021
## Miscellaneous
2122

samples/Sample_05_Chart_Line.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
$series = new Series('Downloads', $seriesData);
6363
$series->setShowSeriesName(true);
6464
$series->setShowValue(true);
65+
$series->setLabelPosition(Series::LABEL_BOTTOM);
6566
$lineChart->addSeries($series);
6667

6768
// Create a shape (chart)

src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php

+3
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,9 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
17961796

17971797
$objWriter->endElement();
17981798

1799+
// c:dLblPos
1800+
$this->writeElementWithValAttribute($objWriter, 'c:dLblPos', $series->getLabelPosition());
1801+
17991802
// c:showVal
18001803
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');
18011804

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

+29
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,35 @@ public function testTypeLineMarkerFill(): void
12431243
$this->assertIsSchemaECMA376Valid();
12441244
}
12451245

1246+
public function testTypeLineSeriesLabelPosition(): void
1247+
{
1248+
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLblPos';
1249+
1250+
$oSlide = $this->oPresentation->getActiveSlide();
1251+
$oShape = $oSlide->createChartShape();
1252+
$oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
1253+
$oLine = new Line();
1254+
$oSeries = new Series('Downloads', $this->seriesData);
1255+
$oLine->addSeries($oSeries);
1256+
$oShape->getPlotArea()->setType($oLine);
1257+
1258+
$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
1259+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
1260+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'val', Series::LABEL_CENTER);
1261+
1262+
$this->assertIsSchemaECMA376Valid();
1263+
1264+
$oSeries->setLabelPosition(Series::LABEL_BOTTOM);
1265+
$oLine->setSeries([$oSeries]);
1266+
$this->resetPresentationFile();
1267+
1268+
$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
1269+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
1270+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'val', Series::LABEL_BOTTOM);
1271+
1272+
$this->assertIsSchemaECMA376Valid();
1273+
}
1274+
12461275
public function testTypeLineSeriesOutline(): void
12471276
{
12481277
$expectedWidth = mt_rand(1, 100);

0 commit comments

Comments
 (0)