Skip to content

Commit e360b05

Browse files
committed
FIXED : #32 : Sample_07_Chart.php : PPTX
1 parent 6385c5a commit e360b05

File tree

4 files changed

+43
-35
lines changed

4 files changed

+43
-35
lines changed

samples/Sample_07_Chart.php

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PhpOffice\PhpPowerpoint\Style\Border;
1313
use PhpOffice\PhpPowerpoint\Style\Color;
1414
use PhpOffice\PhpPowerpoint\Style\Fill;
15+
use PhpOffice\PhpPowerpoint\Style\Shadow;
1516

1617
// Create new PHPPowerPoint object
1718
echo date('H:i:s') . ' Create new PHPPowerPoint object'.EOL;
@@ -31,6 +32,13 @@
3132
echo date('H:i:s') . ' Remove first slide'.EOL;
3233
$objPHPPowerPoint->removeSlideByIndex(0);
3334

35+
// Set Style
36+
$oFill = new Fill();
37+
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
38+
39+
$oShadow = new Shadow();
40+
$oShadow->setVisible(true)->setDirection(45)->setDistance(10);
41+
3442
// Create templated slide
3543
echo date('H:i:s') . ' Create templated slide'.EOL;
3644
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
@@ -62,13 +70,8 @@
6270
->setWidth(700)
6371
->setOffsetX(120)
6472
->setOffsetY(80);
65-
$shape->getShadow()->setVisible(true)
66-
->setDirection(45)
67-
->setDistance(10);
68-
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)
69-
->setStartColor(new Color('FFE06B20'))
70-
->setEndColor(new Color('FFFFFFFF'))
71-
->setRotation(270);
73+
$shape->setShadow($oShadow);
74+
$shape->setFill($oFill);
7275
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
7376
$shape->getTitle()->setText('PHPPowerPoint Monthly Downloads');
7477
$shape->getTitle()->getFont()->setItalic(true);
@@ -106,13 +109,8 @@
106109
->setWidth(700)
107110
->setOffsetX(120)
108111
->setOffsetY(80);
109-
$shape->getShadow()->setVisible(true)
110-
->setDirection(45)
111-
->setDistance(10);
112-
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)
113-
->setStartColor(new Color('FFE06B20'))
114-
->setEndColor(new Color('FFFFFFFF'))
115-
->setRotation(270);
112+
$shape->setShadow($oShadow);
113+
$shape->setFill($oFill);
116114
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
117115
$shape->getTitle()->setText('PHPPowerPoint Daily Downloads');
118116
$shape->getTitle()->getFont()->setItalic(true);
@@ -146,13 +144,8 @@
146144
->setWidth(700)
147145
->setOffsetX(120)
148146
->setOffsetY(80);
149-
$shape->getShadow()->setVisible(true)
150-
->setDirection(45)
151-
->setDistance(10);
152-
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)
153-
->setStartColor(new Color('FFE06B20'))
154-
->setEndColor(new Color('FFFFFFFF'))
155-
->setRotation(270);
147+
$shape->setShadow($oShadow);
148+
$shape->setFill($oFill);
156149
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
157150
$shape->getTitle()->setText('PHPPowerPoint Daily Downloads');
158151
$shape->getTitle()->getFont()->setItalic(true);
@@ -187,13 +180,8 @@
187180
->setWidth(700)
188181
->setOffsetX(120)
189182
->setOffsetY(80);
190-
$shape->getShadow()->setVisible(true)
191-
->setDirection(45)
192-
->setDistance(10);
193-
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)
194-
->setStartColor(new Color('FFE06B20'))
195-
->setEndColor(new Color('FFFFFFFF'))
196-
->setRotation(270);
183+
$shape->setShadow($oShadow);
184+
$shape->setFill($oFill);
197185
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
198186
$shape->getTitle()->setText('PHPPowerPoint Daily Downloads');
199187
$shape->getTitle()->getFont()->setItalic(true);

src/PhpPowerpoint/AbstractShape.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace PhpOffice\PhpPowerpoint;
1919

2020
use PhpOffice\PhpPowerpoint\Shape\Hyperlink;
21+
use PhpOffice\PhpPowerpoint\Style\Fill;
2122
use PhpOffice\PhpPowerpoint\Style\Shadow;
2223

2324
/**
@@ -307,6 +308,17 @@ public function getFill()
307308
return $this->fill;
308309
}
309310

311+
/**
312+
* Set Fill
313+
* @param \PhpOffice\PhpPowerpoint\Style\Fill $pValue
314+
* @return \PhpOffice\PhpPowerpoint\AbstractShape
315+
*/
316+
public function setFill(Fill $pValue = null)
317+
{
318+
$this->fill = $pValue;
319+
return $this;
320+
}
321+
310322
/**
311323
* Get Border
312324
*

src/PhpPowerpoint/Writer/PowerPoint2007/Chart.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,6 @@ protected function writeLayout(XMLWriter $objWriter, $subject)
888888
}
889889

890890
$objWriter->endElement();
891-
892891
$objWriter->endElement();
893892
}
894893

@@ -1060,12 +1059,11 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, $include
10601059
$axisYData = array_values($series->getValues());
10611060

10621061
// c:val
1063-
if (class_exists('PHPExcel_Cell')) {
1064-
$objWriter->startElement('c:val');
1065-
$coords = ($includeSheet ? 'Sheet1!$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
1066-
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
1067-
$objWriter->endElement();
1068-
}
1062+
$objWriter->startElement('c:val');
1063+
$coords = ($includeSheet ? 'Sheet1!$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
1064+
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
1065+
$objWriter->endElement();
1066+
10691067
$objWriter->endElement();
10701068

10711069
++$seriesIndex;

tests/PhpPowerpoint/Tests/AbstractShapeTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function testConstruct()
4848
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Style\\Shadow', $object->getShadow());
4949
}
5050

51+
public function testFill()
52+
{
53+
$object = new RichText();
54+
55+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\AbstractShape', $object->setFill());
56+
$this->assertNull($object->getFill());
57+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\AbstractShape', $object->setFill(new Fill()));
58+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Style\\Fill', $object->getFill());
59+
}
60+
5161
public function testHeight()
5262
{
5363
$object = new RichText();

0 commit comments

Comments
 (0)