Skip to content

Word2007 Writer: LineChart supports LabelPosition for Series #844

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

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
1 change: 1 addition & 0 deletions docs/changes/1.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- 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)
- 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)
- `Gd::setImageResource()` : Fixed when imagecreatetruecolor returns false by [@jaapdh](https://github.com/jaapdh) in [#843](https://github.com/PHPOffice/PHPPresentation/pull/843)
- 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)

## Miscellaneous

Expand Down
1 change: 1 addition & 0 deletions samples/Sample_05_Chart_Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$series = new Series('Downloads', $seriesData);
$series->setShowSeriesName(true);
$series->setShowValue(true);
$series->setLabelPosition(Series::LABEL_BOTTOM);
$lineChart->addSeries($series);

// Create a shape (chart)
Expand Down
3 changes: 3 additions & 0 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,9 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl

$objWriter->endElement();

// c:dLblPos
$this->writeElementWithValAttribute($objWriter, 'c:dLblPos', $series->getLabelPosition());

// c:showVal
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,35 @@ public function testTypeLineMarkerFill(): void
$this->assertIsSchemaECMA376Valid();
}

public function testTypeLineSeriesLabelPosition(): void
{
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLblPos';

$oSlide = $this->oPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
$oLine = new Line();
$oSeries = new Series('Downloads', $this->seriesData);
$oLine->addSeries($oSeries);
$oShape->getPlotArea()->setType($oLine);

$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'val', Series::LABEL_CENTER);

$this->assertIsSchemaECMA376Valid();

$oSeries->setLabelPosition(Series::LABEL_BOTTOM);
$oLine->setSeries([$oSeries]);
$this->resetPresentationFile();

$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'val', Series::LABEL_BOTTOM);

$this->assertIsSchemaECMA376Valid();
}

public function testTypeLineSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
Expand Down
Loading