ObjectsC 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <?php
  2. namespace PhpOffice\PhpPresentation\Tests\Writer\ODPresentation;
  3. use PhpOffice\Common\Drawing as CommonDrawing;
  4. use PhpOffice\PhpPresentation\Shape\Chart\Gridlines;
  5. use PhpOffice\PhpPresentation\Shape\Chart\Marker;
  6. use PhpOffice\PhpPresentation\Shape\Chart\Series;
  7. use PhpOffice\PhpPresentation\Shape\Chart\Type\Area;
  8. use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar;
  9. use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D;
  10. use PhpOffice\PhpPresentation\Shape\Chart\Type\Line;
  11. use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie;
  12. use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie3D;
  13. use PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter;
  14. use PhpOffice\PhpPresentation\Style\Color;
  15. use PhpOffice\PhpPresentation\Style\Fill;
  16. use PhpOffice\PhpPresentation\Style\Outline;
  17. use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
  18. use PhpOffice\PhpPresentation\Writer\ODPresentation;
  19. /**
  20. * Test class for PhpOffice\PhpPresentation\Writer\ODPresentation\Manifest
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Writer\ODPresentation\ObjectsChart
  23. */
  24. class ObjectsChartTest extends PhpPresentationTestCase
  25. {
  26. protected $writerName = 'ODPresentation';
  27. public function testAxisFont()
  28. {
  29. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  30. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  31. $oBar = new Bar();
  32. $oBar->addSeries($oSeries);
  33. $oShape->getPlotArea()->setType($oBar);
  34. $oShape->getPlotArea()->getAxisX()->getFont()->getColor()->setRGB('AABBCC');
  35. $oShape->getPlotArea()->getAxisX()->getFont()->setItalic(true);
  36. $oShape->getPlotArea()->getAxisY()->getFont()->getColor()->setRGB('00FF00');
  37. $oShape->getPlotArea()->getAxisY()->getFont()->setSize(16);
  38. $oShape->getPlotArea()->getAxisY()->getFont()->setName('Arial');
  39. $this->assertZipFileExists('Object 1/content.xml');
  40. $element = '/office:document-content/office:body/office:chart/chart:chart';
  41. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  42. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:bar');
  43. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:text-properties';
  44. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  45. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:color', '#AABBCC');
  46. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-style', 'italic');
  47. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-size', '10pt');
  48. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-family', 'Calibri');
  49. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:text-properties';
  50. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  51. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:color', '#00FF00');
  52. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-style', 'normal');
  53. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-size', '16pt');
  54. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-family', 'Arial');
  55. }
  56. public function testLegend()
  57. {
  58. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  59. $oSeries->setShowSeriesName(true);
  60. $oLine = new Line();
  61. $oLine->addSeries($oSeries);
  62. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  63. $oChart->getPlotArea()->setType($oLine);
  64. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
  65. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  66. $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows';
  67. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  68. $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row';
  69. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  70. $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell';
  71. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  72. $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell[@office:value-type=\'string\']';
  73. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  74. }
  75. public function testTitleVisibility()
  76. {
  77. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  78. $oLine = new Line();
  79. $oShape->getPlotArea()->setType($oLine);
  80. $elementTitle = '/office:document-content/office:body/office:chart/chart:chart/chart:title';
  81. $elementStyle = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleTitle\']';
  82. $this->assertTrue($oShape->getTitle()->isVisible());
  83. $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
  84. $this->assertZipXmlElementExists('Object 1/content.xml', $elementTitle);
  85. $this->assertZipXmlElementExists('Object 1/content.xml', $elementStyle);
  86. $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
  87. $this->resetPresentationFile();
  88. $this->assertZipXmlElementNotExists('Object 1/content.xml', $elementTitle);
  89. $this->assertZipXmlElementNotExists('Object 1/content.xml', $elementStyle);
  90. }
  91. public function testTypeArea()
  92. {
  93. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  94. $oSeries->getFill()->setStartColor(new Color('FF93A9CE'));
  95. $oArea = new Area();
  96. $oArea->addSeries($oSeries);
  97. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  98. $oChart->getPlotArea()->setType($oArea);
  99. $element = '/office:document-content/office:body/office:chart/chart:chart';
  100. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  101. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:area');
  102. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series';
  103. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  104. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:area');
  105. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties';
  106. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  107. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'draw:fill');
  108. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'draw:fill-color');
  109. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'draw:fill-color', '#93A9CE');
  110. }
  111. public function testTypeAxisBounds()
  112. {
  113. $value = rand(0, 100);
  114. $oSeries = new Series('Downloads', array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2));
  115. $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
  116. $oLine = new Line();
  117. $oLine->addSeries($oSeries);
  118. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  119. $oShape->getPlotArea()->setType($oLine);
  120. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:chart-properties';
  121. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:minimum');
  122. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:maximum');
  123. $oShape->getPlotArea()->getAxisX()->setMinBounds($value);
  124. $this->resetPresentationFile();
  125. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:maximum');
  126. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:minimum');
  127. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:minimum', $value);
  128. $oShape->getPlotArea()->getAxisX()->setMinBounds(null);
  129. $oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
  130. $this->resetPresentationFile();
  131. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:minimum');
  132. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:maximum');
  133. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:maximum', $value);
  134. $oShape->getPlotArea()->getAxisX()->setMinBounds($value);
  135. $oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
  136. $this->resetPresentationFile();
  137. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:minimum');
  138. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:minimum', $value);
  139. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:maximum');
  140. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:maximum', $value);
  141. }
  142. public function testTypeBar()
  143. {
  144. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  145. $oSeries->setShowSeriesName(true);
  146. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  147. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  148. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  149. $oBar = new Bar();
  150. $oBar->addSeries($oSeries);
  151. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  152. $oChart->getPlotArea()->setType($oBar);
  153. $element = '/office:document-content/office:body/office:chart/chart:chart';
  154. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  155. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:bar');
  156. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series/chart:data-point';
  157. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  158. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  159. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  160. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:vertical', 'false');
  161. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:three-dimensional');
  162. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
  163. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:stacked', 'false');
  164. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:overlap', '0');
  165. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:percentage');
  166. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
  167. }
  168. public function testTypeBarGroupingStacked()
  169. {
  170. $oBar = new Bar();
  171. $oBar->addSeries(new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2)));
  172. $oBar->setBarGrouping(Bar::GROUPING_STACKED);
  173. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  174. $oChart->getPlotArea()->setType($oBar);
  175. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  176. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  177. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:stacked', 'true');
  178. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:overlap', '100');
  179. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:percentage');
  180. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
  181. }
  182. public function testTypeBarGroupingPercentStacked()
  183. {
  184. $oBar = new Bar();
  185. $oBar->addSeries(new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2)));
  186. $oBar->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
  187. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  188. $oChart->getPlotArea()->setType($oBar);
  189. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  190. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  191. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:stacked', 'true');
  192. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:overlap', '100');
  193. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:percentage', 'true');
  194. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'percentage');
  195. }
  196. public function testTypeBarHorizontal()
  197. {
  198. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  199. $oSeries->setShowSeriesName(true);
  200. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  201. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  202. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  203. $oBar = new Bar();
  204. $oBar->setBarDirection(Bar::DIRECTION_HORIZONTAL);
  205. $oBar->addSeries($oSeries);
  206. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  207. $oChart->getPlotArea()->setType($oBar);
  208. $element = '/office:document-content/office:body/office:chart/chart:chart';
  209. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  210. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:bar');
  211. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  212. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  213. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:vertical', 'true');
  214. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:three-dimensional');
  215. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
  216. }
  217. public function testTypeBar3D()
  218. {
  219. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  220. $oSeries->setShowSeriesName(true);
  221. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  222. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  223. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  224. $oBar3D = new Bar3D();
  225. $oBar3D->addSeries($oSeries);
  226. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  227. $oChart->getPlotArea()->setType($oBar3D);
  228. $element = '/office:document-content/office:body/office:chart/chart:chart';
  229. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  230. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:bar');
  231. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series/chart:data-point';
  232. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  233. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  234. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  235. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:vertical', 'false');
  236. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:three-dimensional');
  237. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:three-dimensional', 'true');
  238. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
  239. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:right-angled-axes', 'true');
  240. }
  241. public function testTypeBar3DHorizontal()
  242. {
  243. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  244. $oSeries->setShowSeriesName(true);
  245. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  246. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  247. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  248. $oBar3D = new Bar3D();
  249. $oBar3D->setBarDirection(Bar3D::DIRECTION_HORIZONTAL);
  250. $oBar3D->addSeries($oSeries);
  251. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  252. $oChart->getPlotArea()->setType($oBar3D);
  253. $element = '/office:document-content/office:body/office:chart/chart:chart';
  254. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  255. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:bar');
  256. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
  257. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  258. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:vertical', 'true');
  259. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:three-dimensional');
  260. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:three-dimensional', 'true');
  261. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
  262. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:right-angled-axes', 'true');
  263. }
  264. public function testTypeLine()
  265. {
  266. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  267. $oSeries->setShowSeriesName(true);
  268. $oLine = new Line();
  269. $oLine->addSeries($oSeries);
  270. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  271. $oChart->getPlotArea()->setType($oLine);
  272. $element = '/office:document-content/office:body/office:chart/chart:chart';
  273. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  274. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:line');
  275. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:chart-properties';
  276. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  277. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:tick-marks-major-inner', 'false');
  278. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:tick-marks-major-outer', 'false');
  279. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:graphic-properties';
  280. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  281. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-width', '0.026cm');
  282. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-color', '#878787');
  283. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:chart-properties';
  284. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  285. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:tick-marks-major-inner', 'false');
  286. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:tick-marks-major-outer', 'false');
  287. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:graphic-properties';
  288. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  289. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-width', '0.026cm');
  290. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-color', '#878787');
  291. }
  292. public function testTypeLineGridlines()
  293. {
  294. $arrayTests = array(
  295. array(
  296. 'dimension' => 'x',
  297. 'styleName' => 'styleAxisXGridlinesMajor',
  298. 'styleClass' => 'major',
  299. 'methodAxis' => 'getAxisX',
  300. 'methodGrid' => 'setMajorGridlines'
  301. ),
  302. array(
  303. 'dimension' => 'x',
  304. 'styleName' => 'styleAxisXGridlinesMinor',
  305. 'styleClass' => 'minor',
  306. 'methodAxis' => 'getAxisX',
  307. 'methodGrid' => 'setMinorGridlines'
  308. ),
  309. array(
  310. 'dimension' => 'y',
  311. 'styleName' => 'styleAxisYGridlinesMajor',
  312. 'styleClass' => 'major',
  313. 'methodAxis' => 'getAxisY',
  314. 'methodGrid' => 'setMajorGridlines'
  315. ),
  316. array(
  317. 'dimension' => 'y',
  318. 'styleName' => 'styleAxisYGridlinesMinor',
  319. 'styleClass' => 'minor',
  320. 'methodAxis' => 'getAxisY',
  321. 'methodGrid' => 'setMinorGridlines'
  322. ),
  323. );
  324. $expectedColor = new Color(Color::COLOR_BLUE);
  325. foreach ($arrayTests as $arrayTest) {
  326. $this->resetPresentationFile();
  327. $this->oPresentation->removeSlideByIndex(0)->createSlide();
  328. $expectedSizePts = rand(1, 100);
  329. $expectedSizeCm = number_format(CommonDrawing::pointsToCentimeters($expectedSizePts), 2, '.', '').'cm';
  330. $expectedElementGrid = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:axis[@chart:dimension=\''.$arrayTest['dimension'].'\']/chart:grid';
  331. $expectedElementStyle = '/office:document-content/office:automatic-styles/style:style[@style:name=\''.$arrayTest['styleName'].'\']/style:graphic-properties';
  332. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  333. $oLine = new Line();
  334. $oLine->addSeries(new Series('Downloads', array(
  335. 'A' => 1,
  336. 'B' => 2,
  337. 'C' => 4,
  338. 'D' => 3,
  339. 'E' => 2,
  340. )));
  341. $oShape->getPlotArea()->setType($oLine);
  342. $oGridlines = new Gridlines();
  343. $oGridlines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($expectedColor);
  344. $oGridlines->getOutline()->setWidth($expectedSizePts);
  345. $oShape->getPlotArea()->{$arrayTest['methodAxis']}()->{$arrayTest['methodGrid']}($oGridlines);
  346. $this->assertZipFileExists('Object 1/content.xml');
  347. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElementGrid);
  348. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElementGrid, 'chart:style-name');
  349. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElementGrid, 'chart:style-name', $arrayTest['styleName']);
  350. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElementGrid, 'chart:class');
  351. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElementGrid, 'chart:class', $arrayTest['styleClass']);
  352. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElementStyle);
  353. $this->assertZipXmlAttributeStartsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-width', $expectedSizeCm);
  354. $this->assertZipXmlAttributeEndsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-width', 'cm');
  355. $this->assertZipXmlAttributeStartsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-color', '#');
  356. $this->assertZipXmlAttributeEndsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-color', $expectedColor->getRGB());
  357. }
  358. }
  359. public function testTypeLineMarker()
  360. {
  361. $expectedSymbol1 = Marker::SYMBOL_PLUS;
  362. $expectedSymbol2 = Marker::SYMBOL_DASH;
  363. $expectedSymbol3 = Marker::SYMBOL_DOT;
  364. $expectedSymbol4 = Marker::SYMBOL_TRIANGLE;
  365. $expectedSymbol5 = Marker::SYMBOL_NONE;
  366. $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:chart-properties';
  367. $expectedSize = rand(1, 100);
  368. $expectedSizeCm = number_format(CommonDrawing::pointsToCentimeters($expectedSize), 2, '.', '').'cm';
  369. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  370. $oLine = new Line();
  371. $oSeries = new Series('Downloads', array(
  372. 'A' => 1,
  373. 'B' => 2,
  374. 'C' => 4,
  375. 'D' => 3,
  376. 'E' => 2,
  377. ));
  378. $oSeries->getMarker()->setSymbol($expectedSymbol1)->setSize($expectedSize);
  379. $oLine->addSeries($oSeries);
  380. $oShape->getPlotArea()->setType($oLine);
  381. $this->assertZipFileExists('Object 1/content.xml');
  382. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  383. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', $expectedSymbol1);
  384. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-width', $expectedSizeCm);
  385. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-height', $expectedSizeCm);
  386. $oSeries->getMarker()->setSymbol($expectedSymbol2);
  387. $oLine->setSeries(array($oSeries));
  388. $this->resetPresentationFile();
  389. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'horizontal-bar');
  390. $oSeries->getMarker()->setSymbol($expectedSymbol3);
  391. $oLine->setSeries(array($oSeries));
  392. $this->resetPresentationFile();
  393. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'circle');
  394. $oSeries->getMarker()->setSymbol($expectedSymbol4);
  395. $oLine->setSeries(array($oSeries));
  396. $this->resetPresentationFile();
  397. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'arrow-up');
  398. $oSeries->getMarker()->setSymbol($expectedSymbol5);
  399. $oLine->setSeries(array($oSeries));
  400. $this->resetPresentationFile();
  401. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-name');
  402. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-width');
  403. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-height');
  404. }
  405. public function testTypeLineSeriesOutline()
  406. {
  407. $expectedWidth = rand(1, 100);
  408. $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '').'cm';
  409. $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
  410. $oColor = new Color(Color::COLOR_YELLOW);
  411. $oOutline = new Outline();
  412. $oOutline->getFill()->setFillType(Fill::FILL_SOLID);
  413. $oOutline->getFill()->setStartColor($oColor);
  414. $oOutline->setWidth($expectedWidth); // (in points)
  415. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  416. $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
  417. $oLine = new Line();
  418. $oSeries = new Series('Downloads', array(
  419. 'A' => 1,
  420. 'B' => 2,
  421. 'C' => 4,
  422. 'D' => 3,
  423. 'E' => 2,
  424. ));
  425. $oLine->addSeries($oSeries);
  426. $oShape->getPlotArea()->setType($oLine);
  427. $this->assertZipFileExists('Object 1/content.xml');
  428. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  429. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-width');
  430. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', '0.079cm');
  431. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
  432. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#4a7ebb');
  433. $oSeries->setOutline($oOutline);
  434. $oLine->setSeries(array($oSeries));
  435. $this->resetPresentationFile();
  436. $this->assertZipFileExists('Object 1/content.xml');
  437. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  438. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-width');
  439. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', $expectedWidthCm);
  440. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
  441. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#' . $oColor->getRGB());
  442. }
  443. public function testTypePie()
  444. {
  445. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  446. $oSeries->setShowSeriesName(true);
  447. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  448. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  449. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  450. $oPie = new Pie();
  451. $oPie->addSeries($oSeries);
  452. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  453. $oChart->getPlotArea()->setType($oPie);
  454. $element = '/office:document-content/office:body/office:chart/chart:chart';
  455. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  456. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:circle');
  457. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series/chart:data-point';
  458. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  459. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:chart-properties';
  460. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  461. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
  462. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:chart-properties';
  463. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  464. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
  465. }
  466. public function testTypePie3D()
  467. {
  468. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  469. $oSeries->setShowSeriesName(true);
  470. $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
  471. $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
  472. $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
  473. $oPie3D = new Pie3D();
  474. $oPie3D->addSeries($oSeries);
  475. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  476. $oChart->getPlotArea()->setType($oPie3D);
  477. $element = '/office:document-content/office:body/office:chart/chart:chart';
  478. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  479. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:circle');
  480. $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series/chart:data-point';
  481. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  482. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisX\']/style:chart-properties';
  483. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  484. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
  485. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:chart-properties';
  486. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  487. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
  488. }
  489. public function testTypePie3DExplosion()
  490. {
  491. $value = rand(0, 100);
  492. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  493. $oSeries->setShowSeriesName(true);
  494. $oPie3D = new Pie3D();
  495. $oPie3D->setExplosion($value);
  496. $oPie3D->addSeries($oSeries);
  497. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  498. $oChart->getPlotArea()->setType($oPie3D);
  499. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:chart-properties';
  500. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  501. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:pie-offset', $value);
  502. }
  503. public function testTypeScatter()
  504. {
  505. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  506. $oSeries->setShowSeriesName(true);
  507. $oScatter = new Scatter();
  508. $oScatter->addSeries($oSeries);
  509. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  510. $oChart->getPlotArea()->setType($oScatter);
  511. $element = '/office:document-content/office:body/office:chart/chart:chart';
  512. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  513. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:scatter');
  514. }
  515. public function testTypeScatterMarker()
  516. {
  517. $expectedSymbol1 = Marker::SYMBOL_PLUS;
  518. $expectedSymbol2 = Marker::SYMBOL_DASH;
  519. $expectedSymbol3 = Marker::SYMBOL_DOT;
  520. $expectedSymbol4 = Marker::SYMBOL_TRIANGLE;
  521. $expectedSymbol5 = Marker::SYMBOL_NONE;
  522. $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:chart-properties';
  523. $expectedSize = rand(1, 100);
  524. $expectedSizeCm = number_format(CommonDrawing::pointsToCentimeters($expectedSize), 2, '.', '').'cm';
  525. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  526. $oScatter = new Scatter();
  527. $oSeries = new Series('Downloads', array(
  528. 'A' => 1,
  529. 'B' => 2,
  530. 'C' => 4,
  531. 'D' => 3,
  532. 'E' => 2,
  533. ));
  534. $oSeries->getMarker()->setSymbol($expectedSymbol1)->setSize($expectedSize);
  535. $oScatter->addSeries($oSeries);
  536. $oShape->getPlotArea()->setType($oScatter);
  537. $this->assertZipFileExists('Object 1/content.xml');
  538. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  539. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', $expectedSymbol1);
  540. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-width', $expectedSizeCm);
  541. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-height', $expectedSizeCm);
  542. $oSeries->getMarker()->setSymbol($expectedSymbol2);
  543. $oScatter->setSeries(array($oSeries));
  544. $this->resetPresentationFile();
  545. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'horizontal-bar');
  546. $oSeries->getMarker()->setSymbol($expectedSymbol3);
  547. $oScatter->setSeries(array($oSeries));
  548. $this->resetPresentationFile();
  549. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'circle');
  550. $oSeries->getMarker()->setSymbol($expectedSymbol4);
  551. $oScatter->setSeries(array($oSeries));
  552. $this->resetPresentationFile();
  553. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'arrow-up');
  554. $oSeries->getMarker()->setSymbol($expectedSymbol5);
  555. $oScatter->setSeries(array($oSeries));
  556. $this->resetPresentationFile();
  557. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-name');
  558. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-width');
  559. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-height');
  560. }
  561. public function testTypeScatterSeriesOutline()
  562. {
  563. $expectedWidth = rand(1, 100);
  564. $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '').'cm';
  565. $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
  566. $oColor = new Color(Color::COLOR_YELLOW);
  567. $oOutline = new Outline();
  568. $oOutline->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($oColor);
  569. $oOutline->setWidth($expectedWidth); // (in points)
  570. $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
  571. $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
  572. $oScatter = new Scatter();
  573. $oSeries = new Series('Downloads', array(
  574. 'A' => 1,
  575. 'B' => 2,
  576. 'C' => 4,
  577. 'D' => 3,
  578. 'E' => 2,
  579. ));
  580. $oScatter->addSeries($oSeries);
  581. $oShape->getPlotArea()->setType($oScatter);
  582. $this->assertZipFileExists('Object 1/content.xml');
  583. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  584. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-width');
  585. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', '0.079cm');
  586. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
  587. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#4a7ebb');
  588. $oSeries->setOutline($oOutline);
  589. $oScatter->setSeries(array($oSeries));
  590. $this->resetPresentationFile();
  591. $this->assertZipFileExists('Object 1/content.xml');
  592. $this->assertZipXmlElementExists('Object 1/content.xml', $expectedElement);
  593. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-width');
  594. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', $expectedWidthCm);
  595. $this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
  596. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#' . $oColor->getRGB());
  597. }
  598. public function testSeries()
  599. {
  600. $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
  601. $oPie = new Pie();
  602. $oPie->addSeries($oSeries);
  603. $oChart = $this->oPresentation->getActiveSlide()->createChartShape();
  604. $oChart->getPlotArea()->setType($oPie);
  605. $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:chart-properties';
  606. // $showCategoryName = false / $showPercentage = false / $showValue = true
  607. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  608. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
  609. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
  610. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
  611. $oSeries->setShowValue(false);
  612. $this->resetPresentationFile();
  613. // $showCategoryName = false / $showPercentage = false / $showValue = false
  614. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  615. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-number');
  616. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
  617. // $showCategoryName = false / $showPercentage = true / $showValue = true
  618. $oSeries->setShowValue(true);
  619. $oSeries->setShowPercentage(true);
  620. $this->resetPresentationFile();
  621. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  622. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
  623. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value-and-percentage');
  624. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
  625. // $showCategoryName = false / $showPercentage = true / $showValue = false
  626. $oSeries->setShowValue(false);
  627. $this->resetPresentationFile();
  628. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  629. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
  630. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'percentage');
  631. $this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
  632. // $showCategoryName = false / $showPercentage = true / $showValue = false
  633. $oSeries->setShowCategoryName(true);
  634. $this->resetPresentationFile();
  635. $this->assertZipXmlElementExists('Object 1/content.xml', $element);
  636. $this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-text');
  637. $this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-text', 'true');
  638. }
  639. }