1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHPPresentation - A pure PHP library for reading and writing |
4
|
|
|
* presentations documents. |
5
|
|
|
* |
6
|
|
|
* PHPPresentation is free software distributed under the terms of the GNU Lesser |
7
|
|
|
* General Public License version 3 as published by the Free Software Foundation. |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please read the LICENSE |
10
|
|
|
* file that was distributed with this source code. For the full list of |
11
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/PHPOffice/PHPPresentation |
14
|
|
|
* @copyright 2009-2015 PHPPresentation contributors |
15
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007; |
19
|
|
|
|
20
|
|
|
use PhpOffice\PhpPresentation\PhpPresentation; |
21
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Legend; |
22
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\PlotArea; |
23
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Title; |
24
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar; |
25
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Area; |
26
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar; |
27
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D; |
28
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Line; |
29
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie; |
30
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie3D; |
31
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter; |
32
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart as ShapeChart; |
33
|
|
|
use PhpOffice\Common\Drawing as CommonDrawing; |
34
|
|
|
use PhpOffice\Common\XMLWriter; |
35
|
|
|
use PhpOffice\PhpPresentation\Style\Border; |
36
|
|
|
use PhpOffice\PhpPresentation\Style\Fill; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* \PhpOffice\PhpPresentation\Writer\PowerPoint2007\Chart |
40
|
|
|
*/ |
41
|
|
|
class Chart extends Slide |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* Write chart to XML format |
45
|
|
|
* |
46
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart $chart |
47
|
|
|
* @return string XML Output |
48
|
|
|
* @throws \Exception |
49
|
|
|
*/ |
50
|
21 |
|
public function writeChart(ShapeChart $chart = null) |
51
|
|
|
{ |
52
|
|
|
// Check slide |
53
|
21 |
|
if (is_null($chart)) { |
54
|
1 |
|
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\Chart object passed."); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// Create XML writer |
58
|
20 |
|
$objWriter = $this->getXMLWriter(); |
59
|
|
|
|
60
|
|
|
// XML header |
61
|
20 |
|
$objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
62
|
|
|
|
63
|
|
|
// c:chartSpace |
64
|
20 |
|
$objWriter->startElement('c:chartSpace'); |
65
|
20 |
|
$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); |
66
|
20 |
|
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
67
|
20 |
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
68
|
|
|
|
69
|
|
|
// c:date1904 |
70
|
20 |
|
$objWriter->startElement('c:date1904'); |
71
|
20 |
|
$objWriter->writeAttribute('val', '1'); |
72
|
20 |
|
$objWriter->endElement(); |
73
|
|
|
|
74
|
|
|
// c:lang |
75
|
20 |
|
$objWriter->startElement('c:lang'); |
76
|
20 |
|
$objWriter->writeAttribute('val', 'en-US'); |
77
|
20 |
|
$objWriter->endElement(); |
78
|
|
|
|
79
|
|
|
// c:chart |
80
|
20 |
|
$objWriter->startElement('c:chart'); |
81
|
|
|
|
82
|
|
|
// Title? |
83
|
20 |
|
if ($chart->getTitle()->isVisible()) { |
84
|
|
|
// Write title |
85
|
20 |
|
$this->writeTitle($objWriter, $chart->getTitle()); |
86
|
20 |
|
} |
87
|
|
|
|
88
|
|
|
// c:autoTitleDeleted |
89
|
20 |
|
$objWriter->startElement('c:autoTitleDeleted'); |
90
|
20 |
|
$objWriter->writeAttribute('val', $chart->getTitle()->isVisible() ? '0' : '1'); |
91
|
20 |
|
$objWriter->endElement(); |
92
|
|
|
|
93
|
|
|
// c:view3D |
94
|
20 |
|
$objWriter->startElement('c:view3D'); |
95
|
|
|
|
96
|
|
|
// c:rotX |
97
|
20 |
|
$objWriter->startElement('c:rotX'); |
98
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationX()); |
99
|
20 |
|
$objWriter->endElement(); |
100
|
|
|
|
101
|
|
|
// c:hPercent |
102
|
20 |
|
$objWriter->startElement('c:hPercent'); |
103
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->getHeightPercent()); |
104
|
20 |
|
$objWriter->endElement(); |
105
|
|
|
|
106
|
|
|
// c:rotY |
107
|
20 |
|
$objWriter->startElement('c:rotY'); |
108
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationY()); |
109
|
20 |
|
$objWriter->endElement(); |
110
|
|
|
|
111
|
|
|
// c:depthPercent |
112
|
20 |
|
$objWriter->startElement('c:depthPercent'); |
113
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent()); |
114
|
20 |
|
$objWriter->endElement(); |
115
|
|
|
|
116
|
|
|
// c:rAngAx |
117
|
20 |
|
$objWriter->startElement('c:rAngAx'); |
118
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->hasRightAngleAxes() ? '1' : '0'); |
119
|
20 |
|
$objWriter->endElement(); |
120
|
|
|
|
121
|
|
|
// c:perspective |
122
|
20 |
|
$objWriter->startElement('c:perspective'); |
123
|
20 |
|
$objWriter->writeAttribute('val', $chart->getView3D()->getPerspective()); |
124
|
20 |
|
$objWriter->endElement(); |
125
|
|
|
|
126
|
20 |
|
$objWriter->endElement(); |
127
|
|
|
|
128
|
|
|
// Write plot area |
129
|
20 |
|
$this->writePlotArea($objWriter, $chart->getPlotArea(), $chart); |
130
|
|
|
|
131
|
|
|
// Legend? |
132
|
19 |
|
if ($chart->getLegend()->isVisible()) { |
133
|
|
|
// Write legend |
134
|
19 |
|
$this->writeLegend($objWriter, $chart->getLegend()); |
135
|
19 |
|
} |
136
|
|
|
|
137
|
|
|
// c:plotVisOnly |
138
|
19 |
|
$objWriter->startElement('c:plotVisOnly'); |
139
|
19 |
|
$objWriter->writeAttribute('val', '1'); |
140
|
19 |
|
$objWriter->endElement(); |
141
|
|
|
|
142
|
19 |
|
$objWriter->endElement(); |
143
|
|
|
|
144
|
|
|
// c:spPr |
145
|
19 |
|
$objWriter->startElement('c:spPr'); |
146
|
|
|
|
147
|
|
|
// Fill |
148
|
19 |
|
$this->writeFill($objWriter, $chart->getFill()); |
149
|
|
|
|
150
|
|
|
// Border |
151
|
19 |
|
if ($chart->getBorder()->getLineStyle() != Border::LINE_NONE) { |
152
|
|
|
$this->writeBorder($objWriter, $chart->getBorder(), ''); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
// Shadow |
156
|
19 |
|
if ($chart->getShadow()->isVisible()) { |
157
|
|
|
// a:effectLst |
158
|
|
|
$objWriter->startElement('a:effectLst'); |
159
|
|
|
|
160
|
|
|
// a:outerShdw |
161
|
|
|
$objWriter->startElement('a:outerShdw'); |
162
|
|
|
$objWriter->writeAttribute('blurRad', CommonDrawing::pixelsToEmu($chart->getShadow()->getBlurRadius())); |
163
|
|
|
$objWriter->writeAttribute('dist', CommonDrawing::pixelsToEmu($chart->getShadow()->getDistance())); |
164
|
|
|
$objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle($chart->getShadow()->getDirection())); |
165
|
|
|
$objWriter->writeAttribute('algn', $chart->getShadow()->getAlignment()); |
166
|
|
|
$objWriter->writeAttribute('rotWithShape', '0'); |
167
|
|
|
|
168
|
|
|
// a:srgbClr |
169
|
|
|
$objWriter->startElement('a:srgbClr'); |
170
|
|
|
$objWriter->writeAttribute('val', $chart->getShadow()->getColor()->getRGB()); |
171
|
|
|
|
172
|
|
|
// a:alpha |
173
|
|
|
$objWriter->startElement('a:alpha'); |
174
|
|
|
$objWriter->writeAttribute('val', $chart->getShadow()->getAlpha() * 1000); |
175
|
|
|
$objWriter->endElement(); |
176
|
|
|
|
177
|
|
|
$objWriter->endElement(); |
178
|
|
|
|
179
|
|
|
$objWriter->endElement(); |
180
|
|
|
|
181
|
|
|
$objWriter->endElement(); |
182
|
|
|
} |
183
|
|
|
|
184
|
19 |
|
$objWriter->endElement(); |
185
|
|
|
|
186
|
|
|
// External data? |
187
|
19 |
|
if ($chart->hasIncludedSpreadsheet()) { |
188
|
|
|
// c:externalData |
189
|
|
|
$objWriter->startElement('c:externalData'); |
190
|
|
|
$objWriter->writeAttribute('r:id', 'rId1'); |
191
|
|
|
|
192
|
|
|
// c:autoUpdate |
193
|
|
|
$objWriter->startElement('c:autoUpdate'); |
194
|
|
|
$objWriter->writeAttribute('val', '0'); |
195
|
|
|
$objWriter->endElement(); |
196
|
|
|
|
197
|
|
|
$objWriter->endElement(); |
198
|
|
|
} |
199
|
|
|
|
200
|
19 |
|
$objWriter->endElement(); |
201
|
|
|
|
202
|
|
|
// Return |
203
|
19 |
|
return $objWriter->getData(); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Write chart to XML format |
208
|
|
|
* |
209
|
|
|
* @param PhpPresentation $presentation |
210
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart $chart |
211
|
|
|
* @param string $tempName |
212
|
|
|
* @return string String output |
213
|
|
|
* @throws \Exception |
214
|
|
|
*/ |
215
|
|
|
public function writeSpreadsheet(PhpPresentation $presentation, $chart, $tempName) |
216
|
|
|
{ |
217
|
|
|
// Need output? |
218
|
|
|
if (!$chart->hasIncludedSpreadsheet()) { |
219
|
|
|
throw new \Exception('No spreadsheet output is required for the given chart.'); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
// Verify PHPExcel |
223
|
|
|
if (!class_exists('PHPExcel')) { |
224
|
|
|
throw new \Exception('PHPExcel has not been loaded. Include PHPExcel.php in your script, e.g. require_once \'PHPExcel.php\'.'); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
// Create new spreadsheet |
228
|
|
|
$workbook = new \PHPExcel(); |
229
|
|
|
|
230
|
|
|
// Set properties |
231
|
|
|
$title = $chart->getTitle()->getText(); |
232
|
|
|
if (strlen($title) == 0) { |
233
|
|
|
$title = 'Chart'; |
234
|
|
|
} |
235
|
|
|
$workbook->getProperties()->setCreator($presentation->getProperties()->getCreator())->setLastModifiedBy($presentation->getProperties()->getLastModifiedBy())->setTitle($title); |
|
|
|
|
236
|
|
|
|
237
|
|
|
// Add chart data |
238
|
|
|
$sheet = $workbook->setActiveSheetIndex(0); |
239
|
|
|
$sheet->setTitle('Sheet1'); |
240
|
|
|
|
241
|
|
|
// Write series |
242
|
|
|
$seriesIndex = 0; |
243
|
|
|
foreach ($chart->getPlotArea()->getType()->getData() as $series) { |
244
|
|
|
// Title |
245
|
|
|
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, 1, $series->getTitle()); |
246
|
|
|
|
247
|
|
|
// X-axis |
248
|
|
|
$axisXData = array_keys($series->getValues()); |
249
|
|
|
$numAxisXData = count($axisXData); |
250
|
|
|
for ($i = 0; $i < $numAxisXData; $i++) { |
251
|
|
|
$sheet->setCellValueByColumnAndRow(0, $i + 2, $axisXData[$i]); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
// Y-axis |
255
|
|
|
$axisYData = array_values($series->getValues()); |
256
|
|
|
$numAxisYData = count($axisYData); |
257
|
|
|
for ($i = 0; $i < $numAxisYData; $i++) { |
258
|
|
|
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, $i + 2, $axisYData[$i]); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
++$seriesIndex; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
// Save to string |
265
|
|
|
$writer = \PHPExcel_IOFactory::createWriter($workbook, 'Excel2007'); |
266
|
|
|
$writer->save($tempName); |
267
|
|
|
|
268
|
|
|
// Load file in memory |
269
|
|
|
$returnValue = file_get_contents($tempName); |
270
|
|
|
if (@unlink($tempName) === false) { |
271
|
|
|
throw new \Exception('The file '.$tempName.' could not removed.'); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
return $returnValue; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Write element with value attribute |
279
|
|
|
* |
280
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
281
|
|
|
* @param string $elementName |
282
|
|
|
* @param string $value |
283
|
|
|
*/ |
284
|
17 |
|
protected function writeElementWithValAttribute($objWriter, $elementName, $value) |
285
|
|
|
{ |
286
|
17 |
|
$objWriter->startElement($elementName); |
287
|
17 |
|
$objWriter->writeAttribute('val', $value); |
288
|
17 |
|
$objWriter->endElement(); |
289
|
17 |
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Write single value or reference |
293
|
|
|
* |
294
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
295
|
|
|
* @param boolean $isReference |
296
|
|
|
* @param mixed $value |
297
|
|
|
* @param string $reference |
298
|
|
|
*/ |
299
|
17 |
|
protected function writeSingleValueOrReference($objWriter, $isReference, $value, $reference) |
300
|
|
|
{ |
301
|
17 |
|
if (!$isReference) { |
302
|
|
|
// Value |
303
|
17 |
|
$objWriter->writeElement('c:v', $value); |
304
|
17 |
|
} else { |
305
|
|
|
// Reference and cache |
306
|
|
|
$objWriter->startElement('c:strRef'); |
307
|
|
|
$objWriter->writeElement('c:f', $reference); |
308
|
|
|
$objWriter->startElement('c:strCache'); |
309
|
|
|
$objWriter->startElement('c:ptCount'); |
310
|
|
|
$objWriter->writeAttribute('val', '1'); |
311
|
|
|
$objWriter->endElement(); |
312
|
|
|
|
313
|
|
|
$objWriter->startElement('c:pt'); |
314
|
|
|
$objWriter->writeAttribute('idx', '0'); |
315
|
|
|
$objWriter->writeElement('c:v', $value); |
316
|
|
|
$objWriter->endElement(); |
317
|
|
|
$objWriter->endElement(); |
318
|
|
|
$objWriter->endElement(); |
319
|
|
|
} |
320
|
17 |
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Write series value or reference |
324
|
|
|
* |
325
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
326
|
|
|
* @param boolean $isReference |
327
|
|
|
* @param mixed $values |
328
|
|
|
* @param string $reference |
329
|
|
|
*/ |
330
|
17 |
|
protected function writeMultipleValuesOrReference($objWriter, $isReference, $values, $reference) |
331
|
|
|
{ |
332
|
|
|
// c:strLit / c:numLit |
333
|
|
|
// c:strRef / c:numRef |
334
|
17 |
|
$referenceType = ($isReference ? 'Ref' : 'Lit'); |
335
|
17 |
|
if (is_int($values[0]) || is_float($values[0])) { |
336
|
17 |
|
$dataType = 'num'; |
337
|
17 |
|
} else { |
338
|
17 |
|
$dataType = 'str'; |
339
|
|
|
} |
340
|
17 |
|
$objWriter->startElement('c:' . $dataType . $referenceType); |
341
|
|
|
|
342
|
17 |
|
$numValues = count($values); |
343
|
17 |
|
if (!$isReference) { |
344
|
|
|
// Value |
345
|
|
|
|
346
|
|
|
// c:ptCount |
347
|
17 |
|
$objWriter->startElement('c:ptCount'); |
348
|
17 |
|
$objWriter->writeAttribute('val', count($values)); |
349
|
17 |
|
$objWriter->endElement(); |
350
|
|
|
|
351
|
|
|
// Add points |
352
|
17 |
|
for ($i = 0; $i < $numValues; $i++) { |
353
|
|
|
// c:pt |
354
|
17 |
|
$objWriter->startElement('c:pt'); |
355
|
17 |
|
$objWriter->writeAttribute('idx', $i); |
356
|
17 |
|
$objWriter->writeElement('c:v', $values[$i]); |
357
|
17 |
|
$objWriter->endElement(); |
358
|
17 |
|
} |
359
|
17 |
|
} else { |
360
|
|
|
// Reference |
361
|
|
|
$objWriter->writeElement('c:f', $reference); |
362
|
|
|
$objWriter->startElement('c:' . $dataType . 'Cache'); |
363
|
|
|
|
364
|
|
|
// c:ptCount |
365
|
|
|
$objWriter->startElement('c:ptCount'); |
366
|
|
|
$objWriter->writeAttribute('val', count($values)); |
367
|
|
|
$objWriter->endElement(); |
368
|
|
|
|
369
|
|
|
// Add points |
370
|
|
|
for ($i = 0; $i < $numValues; $i++) { |
371
|
|
|
// c:pt |
372
|
|
|
$objWriter->startElement('c:pt'); |
373
|
|
|
$objWriter->writeAttribute('idx', $i); |
374
|
|
|
$objWriter->writeElement('c:v', $values[$i]); |
375
|
|
|
$objWriter->endElement(); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
$objWriter->endElement(); |
379
|
|
|
} |
380
|
|
|
|
381
|
17 |
|
$objWriter->endElement(); |
382
|
17 |
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Write Title |
386
|
|
|
* |
387
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
388
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Title $subject |
389
|
|
|
* @throws \Exception |
390
|
|
|
*/ |
391
|
20 |
|
protected function writeTitle(XMLWriter $objWriter, Title $subject) |
392
|
|
|
{ |
393
|
|
|
// c:title |
394
|
20 |
|
$objWriter->startElement('c:title'); |
395
|
|
|
|
396
|
|
|
// c:tx |
397
|
20 |
|
$objWriter->startElement('c:tx'); |
398
|
|
|
|
399
|
|
|
// c:rich |
400
|
20 |
|
$objWriter->startElement('c:rich'); |
401
|
|
|
|
402
|
|
|
// a:bodyPr |
403
|
20 |
|
$objWriter->writeElement('a:bodyPr', null); |
404
|
|
|
|
405
|
|
|
// a:lstStyle |
406
|
20 |
|
$objWriter->writeElement('a:lstStyle', null); |
407
|
|
|
|
408
|
|
|
// a:p |
409
|
20 |
|
$objWriter->startElement('a:p'); |
410
|
|
|
|
411
|
|
|
// a:pPr |
412
|
20 |
|
$objWriter->startElement('a:pPr'); |
413
|
20 |
|
$objWriter->writeAttribute('algn', $subject->getAlignment()->getHorizontal()); |
414
|
20 |
|
$objWriter->writeAttribute('fontAlgn', $subject->getAlignment()->getVertical()); |
415
|
20 |
|
$objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginLeft())); |
416
|
20 |
|
$objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginRight())); |
417
|
20 |
|
$objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($subject->getAlignment()->getIndent())); |
418
|
20 |
|
$objWriter->writeAttribute('lvl', $subject->getAlignment()->getLevel()); |
419
|
|
|
|
420
|
|
|
// a:defRPr |
421
|
20 |
|
$objWriter->writeElement('a:defRPr', null); |
422
|
|
|
|
423
|
20 |
|
$objWriter->endElement(); |
424
|
|
|
|
425
|
|
|
// a:r |
426
|
20 |
|
$objWriter->startElement('a:r'); |
427
|
|
|
|
428
|
|
|
// a:rPr |
429
|
20 |
|
$objWriter->startElement('a:rPr'); |
430
|
20 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
431
|
20 |
|
$objWriter->writeAttribute('dirty', '0'); |
432
|
|
|
|
433
|
20 |
|
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false')); |
434
|
20 |
|
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false')); |
435
|
20 |
|
$objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
436
|
20 |
|
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100)); |
437
|
20 |
|
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline()); |
438
|
|
|
|
439
|
20 |
|
if ($subject->getFont()->isSuperScript() || $subject->getFont()->isSubScript()) { |
440
|
|
|
if ($subject->getFont()->isSuperScript()) { |
441
|
|
|
$objWriter->writeAttribute('baseline', '30000'); |
442
|
|
|
} elseif ($subject->getFont()->isSubScript()) { |
443
|
|
|
$objWriter->writeAttribute('baseline', '-25000'); |
444
|
|
|
} |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
// Font - a:solidFill |
448
|
20 |
|
$objWriter->startElement('a:solidFill'); |
449
|
|
|
|
450
|
|
|
// a:srgbClr |
451
|
20 |
|
$objWriter->startElement('a:srgbClr'); |
452
|
20 |
|
$objWriter->writeAttribute('val', $subject->getFont()->getColor()->getRGB()); |
453
|
20 |
|
$objWriter->endElement(); |
454
|
|
|
|
455
|
20 |
|
$objWriter->endElement(); |
456
|
|
|
|
457
|
|
|
// Font - a:latin |
458
|
20 |
|
$objWriter->startElement('a:latin'); |
459
|
20 |
|
$objWriter->writeAttribute('typeface', $subject->getFont()->getName()); |
460
|
20 |
|
$objWriter->endElement(); |
461
|
|
|
|
462
|
20 |
|
$objWriter->endElement(); |
463
|
|
|
|
464
|
|
|
// a:t |
465
|
20 |
|
$objWriter->writeElement('a:t', $subject->getText()); |
466
|
|
|
|
467
|
20 |
|
$objWriter->endElement(); |
468
|
|
|
|
469
|
|
|
// a:endParaRPr |
470
|
20 |
|
$objWriter->startElement('a:endParaRPr'); |
471
|
20 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
472
|
20 |
|
$objWriter->writeAttribute('dirty', '0'); |
473
|
20 |
|
$objWriter->endElement(); |
474
|
|
|
|
475
|
20 |
|
$objWriter->endElement(); |
476
|
|
|
|
477
|
20 |
|
$objWriter->endElement(); |
478
|
|
|
|
479
|
20 |
|
$objWriter->endElement(); |
480
|
|
|
|
481
|
|
|
// Write layout |
482
|
20 |
|
$this->writeLayout($objWriter, $subject); |
483
|
|
|
|
484
|
|
|
// c:overlay |
485
|
20 |
|
$objWriter->startElement('c:overlay'); |
486
|
20 |
|
$objWriter->writeAttribute('val', '0'); |
487
|
20 |
|
$objWriter->endElement(); |
488
|
|
|
|
489
|
20 |
|
$objWriter->endElement(); |
490
|
20 |
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Write Plot Area |
494
|
|
|
* |
495
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
496
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\PlotArea $subject |
497
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart $chart |
498
|
|
|
* @throws \Exception |
499
|
|
|
*/ |
500
|
20 |
|
protected function writePlotArea(XMLWriter $objWriter, PlotArea $subject, ShapeChart $chart) |
501
|
|
|
{ |
502
|
|
|
// c:plotArea |
503
|
20 |
|
$objWriter->startElement('c:plotArea'); |
504
|
|
|
|
505
|
|
|
// Write layout |
506
|
20 |
|
$this->writeLayout($objWriter, $subject); |
507
|
|
|
|
508
|
|
|
// Write chart |
509
|
20 |
|
$chartType = $subject->getType(); |
510
|
20 |
|
if ($chartType instanceof Area) { |
511
|
1 |
|
$this->writeTypeArea($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
512
|
20 |
|
} elseif ($chartType instanceof Bar) { |
513
|
1 |
|
$this->writeTypeBar($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
514
|
19 |
|
} elseif ($chartType instanceof Bar3D) { |
515
|
5 |
|
$this->writeTypeBar3D($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
516
|
18 |
|
} elseif ($chartType instanceof Pie) { |
517
|
1 |
|
$this->writeTypePie($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
518
|
13 |
|
} elseif ($chartType instanceof Pie3D) { |
519
|
4 |
|
$this->writeTypePie3D($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
520
|
12 |
|
} elseif ($chartType instanceof Line) { |
521
|
4 |
|
$this->writeTypeLine($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
522
|
8 |
|
} elseif ($chartType instanceof Scatter) { |
523
|
3 |
|
$this->writeTypeScatter($objWriter, $chartType, $chart->hasIncludedSpreadsheet()); |
524
|
3 |
|
} else { |
525
|
1 |
|
throw new \Exception('The chart type provided could not be rendered.'); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
// Write X axis? |
529
|
19 |
|
if ($chartType->hasAxisX()) { |
530
|
|
|
// c:catAx (Axis X) |
531
|
14 |
|
$objWriter->startElement('c:catAx'); |
532
|
|
|
|
533
|
|
|
// c:axId |
534
|
14 |
|
$objWriter->startElement('c:axId'); |
535
|
14 |
|
$objWriter->writeAttribute('val', '52743552'); |
536
|
14 |
|
$objWriter->endElement(); |
537
|
|
|
|
538
|
|
|
// c:scaling |
539
|
14 |
|
$objWriter->startElement('c:scaling'); |
540
|
|
|
|
541
|
|
|
// c:orientation |
542
|
14 |
|
$objWriter->startElement('c:orientation'); |
543
|
14 |
|
$objWriter->writeAttribute('val', 'minMax'); |
544
|
14 |
|
$objWriter->endElement(); |
545
|
|
|
|
546
|
14 |
|
$objWriter->endElement(); |
547
|
|
|
|
548
|
|
|
// c:axPos |
549
|
14 |
|
$objWriter->startElement('c:axPos'); |
550
|
14 |
|
$objWriter->writeAttribute('val', 'b'); |
551
|
14 |
|
$objWriter->endElement(); |
552
|
|
|
|
553
|
|
|
// c:numFmt |
554
|
14 |
|
$objWriter->startElement('c:numFmt'); |
555
|
14 |
|
$objWriter->writeAttribute('formatCode', $subject->getAxisX()->getFormatCode()); |
556
|
14 |
|
$objWriter->writeAttribute('sourceLinked', '0'); |
557
|
14 |
|
$objWriter->endElement(); |
558
|
|
|
|
559
|
|
|
// c:majorTickMark |
560
|
14 |
|
$objWriter->startElement('c:majorTickMark'); |
561
|
14 |
|
$objWriter->writeAttribute('val', 'none'); |
562
|
14 |
|
$objWriter->endElement(); |
563
|
|
|
|
564
|
|
|
// c:tickLblPos |
565
|
14 |
|
$objWriter->startElement('c:tickLblPos'); |
566
|
14 |
|
$objWriter->writeAttribute('val', 'nextTo'); |
567
|
14 |
|
$objWriter->endElement(); |
568
|
|
|
|
569
|
|
|
// c:txPr |
570
|
14 |
|
$objWriter->startElement('c:txPr'); |
571
|
|
|
|
572
|
|
|
// a:bodyPr |
573
|
14 |
|
$objWriter->writeElement('a:bodyPr', null); |
574
|
|
|
|
575
|
|
|
// a:lstStyle |
576
|
14 |
|
$objWriter->writeElement('a:lstStyle', null); |
577
|
|
|
|
578
|
|
|
// a:p |
579
|
14 |
|
$objWriter->startElement('a:p'); |
580
|
|
|
|
581
|
|
|
// a:pPr |
582
|
14 |
|
$objWriter->startElement('a:pPr'); |
583
|
|
|
|
584
|
|
|
// a:defRPr |
585
|
14 |
|
$objWriter->writeElement('a:defRPr', null); |
586
|
|
|
|
587
|
14 |
|
$objWriter->endElement(); |
588
|
|
|
|
589
|
|
|
// a:r |
590
|
14 |
|
$objWriter->startElement('a:r'); |
591
|
|
|
|
592
|
|
|
// a:rPr |
593
|
14 |
|
$objWriter->startElement('a:rPr'); |
594
|
14 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
595
|
14 |
|
$objWriter->writeAttribute('dirty', '0'); |
596
|
14 |
|
$objWriter->endElement(); |
597
|
|
|
|
598
|
|
|
// a:t |
599
|
14 |
|
$objWriter->writeElement('a:t', $subject->getAxisX()->getTitle()); |
600
|
|
|
|
601
|
14 |
|
$objWriter->endElement(); |
602
|
|
|
|
603
|
|
|
// a:endParaRPr |
604
|
14 |
|
$objWriter->startElement('a:endParaRPr'); |
605
|
14 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
606
|
14 |
|
$objWriter->writeAttribute('dirty', '0'); |
607
|
14 |
|
$objWriter->endElement(); |
608
|
|
|
|
609
|
14 |
|
$objWriter->endElement(); |
610
|
|
|
|
611
|
14 |
|
$objWriter->endElement(); |
612
|
|
|
|
613
|
|
|
// c:crossAx |
614
|
14 |
|
$objWriter->startElement('c:crossAx'); |
615
|
14 |
|
$objWriter->writeAttribute('val', '52749440'); |
616
|
14 |
|
$objWriter->endElement(); |
617
|
|
|
|
618
|
|
|
// c:crosses |
619
|
14 |
|
$objWriter->startElement('c:crosses'); |
620
|
14 |
|
$objWriter->writeAttribute('val', 'autoZero'); |
621
|
14 |
|
$objWriter->endElement(); |
622
|
|
|
|
623
|
|
|
// c:lblAlgn |
624
|
14 |
|
$objWriter->startElement('c:lblAlgn'); |
625
|
14 |
|
$objWriter->writeAttribute('val', 'ctr'); |
626
|
14 |
|
$objWriter->endElement(); |
627
|
|
|
|
628
|
|
|
// c:lblOffset |
629
|
14 |
|
$objWriter->startElement('c:lblOffset'); |
630
|
14 |
|
$objWriter->writeAttribute('val', '100'); |
631
|
14 |
|
$objWriter->endElement(); |
632
|
|
|
|
633
|
14 |
|
$objWriter->endElement(); |
634
|
14 |
|
} |
635
|
|
|
|
636
|
|
|
// Write Y axis? |
637
|
19 |
|
if ($chartType->hasAxisY()) { |
638
|
|
|
// c:valAx (Axis Y) |
639
|
14 |
|
$objWriter->startElement('c:valAx'); |
640
|
|
|
|
641
|
|
|
// c:axId |
642
|
14 |
|
$objWriter->startElement('c:axId'); |
643
|
14 |
|
$objWriter->writeAttribute('val', '52749440'); |
644
|
14 |
|
$objWriter->endElement(); |
645
|
|
|
|
646
|
|
|
// c:scaling |
647
|
14 |
|
$objWriter->startElement('c:scaling'); |
648
|
|
|
|
649
|
|
|
// c:orientation |
650
|
14 |
|
$objWriter->startElement('c:orientation'); |
651
|
14 |
|
$objWriter->writeAttribute('val', 'minMax'); |
652
|
14 |
|
$objWriter->endElement(); |
653
|
|
|
|
654
|
|
|
// ## c:scaling |
655
|
14 |
|
$objWriter->endElement(); |
656
|
|
|
|
657
|
|
|
// c:axPos |
658
|
14 |
|
$objWriter->startElement('c:axPos'); |
659
|
14 |
|
$objWriter->writeAttribute('val', 'l'); |
660
|
14 |
|
$objWriter->endElement(); |
661
|
|
|
|
662
|
|
|
// c:numFmt |
663
|
14 |
|
$objWriter->startElement('c:numFmt'); |
664
|
14 |
|
$objWriter->writeAttribute('formatCode', $subject->getAxisY()->getFormatCode()); |
665
|
14 |
|
$objWriter->writeAttribute('sourceLinked', '0'); |
666
|
14 |
|
$objWriter->endElement(); |
667
|
|
|
|
668
|
|
|
// c:majorTickMark |
669
|
14 |
|
$objWriter->startElement('c:majorTickMark'); |
670
|
14 |
|
$objWriter->writeAttribute('val', 'none'); |
671
|
14 |
|
$objWriter->endElement(); |
672
|
|
|
|
673
|
|
|
// c:tickLblPos |
674
|
14 |
|
$objWriter->startElement('c:tickLblPos'); |
675
|
14 |
|
$objWriter->writeAttribute('val', 'nextTo'); |
676
|
14 |
|
$objWriter->endElement(); |
677
|
|
|
|
678
|
|
|
// c:txPr |
679
|
14 |
|
$objWriter->startElement('c:txPr'); |
680
|
|
|
|
681
|
|
|
// a:bodyPr |
682
|
14 |
|
$objWriter->writeElement('a:bodyPr', null); |
683
|
|
|
|
684
|
|
|
// a:lstStyle |
685
|
14 |
|
$objWriter->writeElement('a:lstStyle', null); |
686
|
|
|
|
687
|
|
|
// a:p |
688
|
14 |
|
$objWriter->startElement('a:p'); |
689
|
|
|
|
690
|
|
|
// a:pPr |
691
|
14 |
|
$objWriter->startElement('a:pPr'); |
692
|
|
|
|
693
|
|
|
// a:defRPr |
694
|
14 |
|
$objWriter->writeElement('a:defRPr', null); |
695
|
|
|
|
696
|
|
|
// ## a:pPr |
697
|
14 |
|
$objWriter->endElement(); |
698
|
|
|
|
699
|
|
|
// a:r |
700
|
14 |
|
$objWriter->startElement('a:r'); |
701
|
|
|
|
702
|
|
|
// a:rPr |
703
|
14 |
|
$objWriter->startElement('a:rPr'); |
704
|
14 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
705
|
14 |
|
$objWriter->writeAttribute('dirty', '0'); |
706
|
14 |
|
$objWriter->endElement(); |
707
|
|
|
|
708
|
|
|
// a:t |
709
|
14 |
|
$objWriter->writeElement('a:t', $subject->getAxisY()->getTitle()); |
710
|
|
|
|
711
|
|
|
// ## a:r |
712
|
14 |
|
$objWriter->endElement(); |
713
|
|
|
|
714
|
|
|
// a:endParaRPr |
715
|
14 |
|
$objWriter->startElement('a:endParaRPr'); |
716
|
14 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
717
|
14 |
|
$objWriter->writeAttribute('dirty', '0'); |
718
|
14 |
|
$objWriter->endElement(); |
719
|
|
|
|
720
|
|
|
// ## a:p |
721
|
14 |
|
$objWriter->endElement(); |
722
|
|
|
|
723
|
|
|
// ## c:txPr |
724
|
14 |
|
$objWriter->endElement(); |
725
|
|
|
|
726
|
|
|
// c:crossAx |
727
|
14 |
|
$objWriter->startElement('c:crossAx'); |
728
|
14 |
|
$objWriter->writeAttribute('val', '52743552'); |
729
|
14 |
|
$objWriter->endElement(); |
730
|
|
|
|
731
|
|
|
// c:crosses |
732
|
14 |
|
$objWriter->startElement('c:crosses'); |
733
|
14 |
|
$objWriter->writeAttribute('val', 'autoZero'); |
734
|
14 |
|
$objWriter->endElement(); |
735
|
|
|
|
736
|
|
|
// c:crossBetween |
737
|
14 |
|
$objWriter->startElement('c:crossBetween'); |
738
|
14 |
|
$objWriter->writeAttribute('val', 'between'); |
739
|
14 |
|
$objWriter->endElement(); |
740
|
|
|
|
741
|
14 |
|
$objWriter->endElement(); |
742
|
14 |
|
} |
743
|
|
|
|
744
|
19 |
|
$objWriter->endElement(); |
745
|
19 |
|
} |
746
|
|
|
|
747
|
|
|
/** |
748
|
|
|
* Write Legend |
749
|
|
|
* |
750
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
751
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Legend $subject |
752
|
|
|
* @throws \Exception |
753
|
|
|
*/ |
754
|
19 |
|
protected function writeLegend(XMLWriter $objWriter, Legend $subject) |
755
|
|
|
{ |
756
|
|
|
// c:legend |
757
|
19 |
|
$objWriter->startElement('c:legend'); |
758
|
|
|
|
759
|
|
|
// c:legendPos |
760
|
19 |
|
$objWriter->startElement('c:legendPos'); |
761
|
19 |
|
$objWriter->writeAttribute('val', $subject->getPosition()); |
762
|
19 |
|
$objWriter->endElement(); |
763
|
|
|
|
764
|
|
|
// Write layout |
765
|
19 |
|
$this->writeLayout($objWriter, $subject); |
766
|
|
|
|
767
|
|
|
// c:overlay |
768
|
19 |
|
$objWriter->startElement('c:overlay'); |
769
|
19 |
|
$objWriter->writeAttribute('val', '0'); |
770
|
19 |
|
$objWriter->endElement(); |
771
|
|
|
|
772
|
|
|
// c:spPr |
773
|
19 |
|
$objWriter->startElement('c:spPr'); |
774
|
|
|
|
775
|
|
|
// Fill |
776
|
19 |
|
$this->writeFill($objWriter, $subject->getFill()); |
777
|
|
|
|
778
|
|
|
// Border |
779
|
19 |
|
if ($subject->getBorder()->getLineStyle() != Border::LINE_NONE) { |
780
|
19 |
|
$this->writeBorder($objWriter, $subject->getBorder(), ''); |
781
|
19 |
|
} |
782
|
|
|
|
783
|
19 |
|
$objWriter->endElement(); |
784
|
|
|
|
785
|
|
|
// c:txPr |
786
|
19 |
|
$objWriter->startElement('c:txPr'); |
787
|
|
|
|
788
|
|
|
// a:bodyPr |
789
|
19 |
|
$objWriter->writeElement('a:bodyPr', null); |
790
|
|
|
|
791
|
|
|
// a:lstStyle |
792
|
19 |
|
$objWriter->writeElement('a:lstStyle', null); |
793
|
|
|
|
794
|
|
|
// a:p |
795
|
19 |
|
$objWriter->startElement('a:p'); |
796
|
|
|
|
797
|
|
|
// a:pPr |
798
|
19 |
|
$objWriter->startElement('a:pPr'); |
799
|
19 |
|
$objWriter->writeAttribute('algn', $subject->getAlignment()->getHorizontal()); |
800
|
19 |
|
$objWriter->writeAttribute('fontAlgn', $subject->getAlignment()->getVertical()); |
801
|
19 |
|
$objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginLeft())); |
802
|
19 |
|
$objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginRight())); |
803
|
19 |
|
$objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($subject->getAlignment()->getIndent())); |
804
|
19 |
|
$objWriter->writeAttribute('lvl', $subject->getAlignment()->getLevel()); |
805
|
|
|
|
806
|
|
|
// a:defRPr |
807
|
19 |
|
$objWriter->startElement('a:defRPr'); |
808
|
|
|
|
809
|
19 |
|
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false')); |
810
|
19 |
|
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false')); |
811
|
19 |
|
$objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
812
|
19 |
|
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100)); |
813
|
19 |
|
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline()); |
814
|
|
|
|
815
|
19 |
|
if ($subject->getFont()->isSuperScript() || $subject->getFont()->isSubScript()) { |
816
|
|
|
if ($subject->getFont()->isSuperScript()) { |
817
|
|
|
$objWriter->writeAttribute('baseline', '30000'); |
818
|
|
|
} elseif ($subject->getFont()->isSubScript()) { |
819
|
|
|
$objWriter->writeAttribute('baseline', '-25000'); |
820
|
|
|
} |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
// Font - a:solidFill |
824
|
19 |
|
$objWriter->startElement('a:solidFill'); |
825
|
|
|
|
826
|
|
|
// a:srgbClr |
827
|
19 |
|
$objWriter->startElement('a:srgbClr'); |
828
|
19 |
|
$objWriter->writeAttribute('val', $subject->getFont()->getColor()->getRGB()); |
829
|
19 |
|
$objWriter->endElement(); |
830
|
|
|
|
831
|
19 |
|
$objWriter->endElement(); |
832
|
|
|
|
833
|
|
|
// Font - a:latin |
834
|
19 |
|
$objWriter->startElement('a:latin'); |
835
|
19 |
|
$objWriter->writeAttribute('typeface', $subject->getFont()->getName()); |
836
|
19 |
|
$objWriter->endElement(); |
837
|
|
|
|
838
|
19 |
|
$objWriter->endElement(); |
839
|
|
|
|
840
|
19 |
|
$objWriter->endElement(); |
841
|
|
|
|
842
|
|
|
// a:endParaRPr |
843
|
19 |
|
$objWriter->startElement('a:endParaRPr'); |
844
|
19 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
845
|
19 |
|
$objWriter->writeAttribute('dirty', '0'); |
846
|
19 |
|
$objWriter->endElement(); |
847
|
|
|
|
848
|
19 |
|
$objWriter->endElement(); |
849
|
|
|
|
850
|
19 |
|
$objWriter->endElement(); |
851
|
|
|
|
852
|
19 |
|
$objWriter->endElement(); |
853
|
19 |
|
} |
854
|
|
|
|
855
|
|
|
/** |
856
|
|
|
* Write Layout |
857
|
|
|
* |
858
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
859
|
|
|
* @param mixed $subject |
860
|
|
|
* @throws \Exception |
861
|
|
|
*/ |
862
|
20 |
|
protected function writeLayout(XMLWriter $objWriter, $subject) |
863
|
|
|
{ |
864
|
|
|
// c:layout |
865
|
20 |
|
$objWriter->startElement('c:layout'); |
866
|
|
|
|
867
|
|
|
// c:manualLayout |
868
|
20 |
|
$objWriter->startElement('c:manualLayout'); |
869
|
|
|
// c:xMode |
870
|
20 |
|
$objWriter->startElement('c:xMode'); |
871
|
20 |
|
$objWriter->writeAttribute('val', 'edge'); |
872
|
20 |
|
$objWriter->endElement(); |
873
|
|
|
|
874
|
|
|
// c:yMode |
875
|
20 |
|
$objWriter->startElement('c:yMode'); |
876
|
20 |
|
$objWriter->writeAttribute('val', 'edge'); |
877
|
20 |
|
$objWriter->endElement(); |
878
|
|
|
|
879
|
20 |
|
if ($subject->getOffsetX() != 0) { |
880
|
|
|
// c:x |
881
|
20 |
|
$objWriter->startElement('c:x'); |
882
|
20 |
|
$objWriter->writeAttribute('val', $subject->getOffsetX()); |
883
|
20 |
|
$objWriter->endElement(); |
884
|
20 |
|
} |
885
|
|
|
|
886
|
20 |
|
if ($subject->getOffsetY() != 0) { |
887
|
|
|
// c:y |
888
|
20 |
|
$objWriter->startElement('c:y'); |
889
|
20 |
|
$objWriter->writeAttribute('val', $subject->getOffsetY()); |
890
|
20 |
|
$objWriter->endElement(); |
891
|
20 |
|
} |
892
|
|
|
|
893
|
20 |
|
if ($subject->getWidth() != 0) { |
894
|
|
|
// c:w |
895
|
|
|
$objWriter->startElement('c:w'); |
896
|
|
|
$objWriter->writeAttribute('val', $subject->getWidth()); |
897
|
|
|
$objWriter->endElement(); |
898
|
|
|
} |
899
|
|
|
|
900
|
20 |
|
if ($subject->getHeight() != 0) { |
901
|
|
|
// c:h |
902
|
|
|
$objWriter->startElement('c:h'); |
903
|
|
|
$objWriter->writeAttribute('val', $subject->getHeight()); |
904
|
|
|
$objWriter->endElement(); |
905
|
|
|
} |
906
|
|
|
|
907
|
20 |
|
$objWriter->endElement(); |
908
|
20 |
|
$objWriter->endElement(); |
909
|
20 |
|
} |
910
|
|
|
|
911
|
|
|
/** |
912
|
|
|
* Write Type Line |
913
|
|
|
* |
914
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
915
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Area $subject |
916
|
|
|
* @param boolean $includeSheet |
917
|
|
|
* @throws \Exception |
918
|
|
|
*/ |
919
|
1 |
|
protected function writeTypeArea(XMLWriter $objWriter, Area $subject, $includeSheet = false) |
920
|
|
|
{ |
921
|
|
|
// c:lineChart |
922
|
1 |
|
$objWriter->startElement('c:areaChart'); |
923
|
|
|
|
924
|
|
|
// c:grouping |
925
|
1 |
|
$objWriter->startElement('c:grouping'); |
926
|
1 |
|
$objWriter->writeAttribute('val', 'standard'); |
927
|
1 |
|
$objWriter->endElement(); |
928
|
|
|
|
929
|
|
|
// Write series |
930
|
1 |
|
$seriesIndex = 0; |
931
|
1 |
|
foreach ($subject->getData() as $series) { |
932
|
|
|
// c:ser |
933
|
1 |
|
$objWriter->startElement('c:ser'); |
934
|
|
|
|
935
|
|
|
// c:idx |
936
|
1 |
|
$objWriter->startElement('c:idx'); |
937
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
938
|
1 |
|
$objWriter->endElement(); |
939
|
|
|
|
940
|
|
|
// c:order |
941
|
1 |
|
$objWriter->startElement('c:order'); |
942
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
943
|
1 |
|
$objWriter->endElement(); |
944
|
|
|
|
945
|
|
|
// c:tx |
946
|
1 |
|
$objWriter->startElement('c:tx'); |
947
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
948
|
1 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
949
|
1 |
|
$objWriter->endElement(); |
950
|
|
|
|
951
|
|
|
// c:dLbls |
952
|
1 |
|
$objWriter->startElement('c:dLbls'); |
953
|
|
|
|
954
|
|
|
// c:txPr |
955
|
1 |
|
$objWriter->startElement('c:txPr'); |
956
|
|
|
|
957
|
|
|
// a:bodyPr |
958
|
1 |
|
$objWriter->writeElement('a:bodyPr', null); |
959
|
|
|
|
960
|
|
|
// a:lstStyle |
961
|
1 |
|
$objWriter->writeElement('a:lstStyle', null); |
962
|
|
|
|
963
|
|
|
// a:p |
964
|
1 |
|
$objWriter->startElement('a:p'); |
965
|
|
|
|
966
|
|
|
// a:pPr |
967
|
1 |
|
$objWriter->startElement('a:pPr'); |
968
|
|
|
|
969
|
|
|
// a:defRPr |
970
|
1 |
|
$objWriter->startElement('a:defRPr'); |
971
|
|
|
|
972
|
1 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
973
|
1 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
974
|
1 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
975
|
1 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
976
|
1 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
977
|
|
|
|
978
|
1 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
979
|
|
|
if ($series->getFont()->isSuperScript()) { |
980
|
|
|
$objWriter->writeAttribute('baseline', '30000'); |
981
|
|
|
} elseif ($series->getFont()->isSubScript()) { |
982
|
|
|
$objWriter->writeAttribute('baseline', '-25000'); |
983
|
|
|
} |
984
|
|
|
} |
985
|
|
|
|
986
|
|
|
// Font - a:solidFill |
987
|
1 |
|
$objWriter->startElement('a:solidFill'); |
988
|
|
|
|
989
|
|
|
// a:srgbClr |
990
|
1 |
|
$objWriter->startElement('a:srgbClr'); |
991
|
1 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
992
|
1 |
|
$objWriter->endElement(); |
993
|
|
|
|
994
|
1 |
|
$objWriter->endElement(); |
995
|
|
|
|
996
|
|
|
// Font - a:latin |
997
|
1 |
|
$objWriter->startElement('a:latin'); |
998
|
1 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
999
|
1 |
|
$objWriter->endElement(); |
1000
|
|
|
|
1001
|
1 |
|
$objWriter->endElement(); |
1002
|
|
|
|
1003
|
1 |
|
$objWriter->endElement(); |
1004
|
|
|
|
1005
|
|
|
// a:endParaRPr |
1006
|
1 |
|
$objWriter->startElement('a:endParaRPr'); |
1007
|
1 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1008
|
1 |
|
$objWriter->writeAttribute('dirty', '0'); |
1009
|
1 |
|
$objWriter->endElement(); |
1010
|
|
|
|
1011
|
1 |
|
$objWriter->endElement(); |
1012
|
|
|
|
1013
|
1 |
|
$objWriter->endElement(); |
1014
|
|
|
|
1015
|
|
|
// c:showVal |
1016
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1017
|
|
|
|
1018
|
|
|
// c:showCatName |
1019
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1020
|
|
|
|
1021
|
|
|
// c:showSerName |
1022
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1023
|
|
|
|
1024
|
|
|
// c:showPercent |
1025
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1026
|
|
|
|
1027
|
|
|
// c:showLeaderLines |
1028
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1029
|
|
|
|
1030
|
1 |
|
$objWriter->endElement(); |
1031
|
|
|
|
1032
|
1 |
|
if ($series->getFill()->getFillType() != Fill::FILL_NONE) { |
1033
|
|
|
// c:spPr |
1034
|
|
|
$objWriter->startElement('c:spPr'); |
1035
|
|
|
// Write fill |
1036
|
|
|
$this->writeFill($objWriter, $series->getFill()); |
1037
|
|
|
// ## c:spPr |
1038
|
|
|
$objWriter->endElement(); |
1039
|
|
|
} |
1040
|
|
|
|
1041
|
|
|
// Write X axis data |
1042
|
1 |
|
$axisXData = array_keys($series->getValues()); |
1043
|
|
|
|
1044
|
|
|
// c:cat |
1045
|
1 |
|
$objWriter->startElement('c:cat'); |
1046
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1047
|
1 |
|
$objWriter->endElement(); |
1048
|
|
|
|
1049
|
|
|
// Write Y axis data |
1050
|
1 |
|
$axisYData = array_values($series->getValues()); |
1051
|
|
|
|
1052
|
|
|
// c:val |
1053
|
1 |
|
$objWriter->startElement('c:val'); |
1054
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
1055
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
1056
|
1 |
|
$objWriter->endElement(); |
1057
|
|
|
|
1058
|
1 |
|
$objWriter->endElement(); |
1059
|
|
|
|
1060
|
1 |
|
++$seriesIndex; |
1061
|
1 |
|
} |
1062
|
|
|
|
1063
|
|
|
// c:marker |
1064
|
1 |
|
$objWriter->startElement('c:marker'); |
1065
|
1 |
|
$objWriter->writeAttribute('val', '1'); |
1066
|
1 |
|
$objWriter->endElement(); |
1067
|
|
|
|
1068
|
|
|
// c:smooth |
1069
|
1 |
|
$objWriter->startElement('c:smooth'); |
1070
|
1 |
|
$objWriter->writeAttribute('val', '0'); |
1071
|
1 |
|
$objWriter->endElement(); |
1072
|
|
|
|
1073
|
|
|
// c:axId |
1074
|
1 |
|
$objWriter->startElement('c:axId'); |
1075
|
1 |
|
$objWriter->writeAttribute('val', '52743552'); |
1076
|
1 |
|
$objWriter->endElement(); |
1077
|
|
|
|
1078
|
|
|
// c:axId |
1079
|
1 |
|
$objWriter->startElement('c:axId'); |
1080
|
1 |
|
$objWriter->writeAttribute('val', '52749440'); |
1081
|
1 |
|
$objWriter->endElement(); |
1082
|
|
|
|
1083
|
1 |
|
$objWriter->endElement(); |
1084
|
1 |
|
} |
1085
|
|
|
|
1086
|
|
|
|
1087
|
|
|
/** |
1088
|
|
|
* Write Type Bar3D |
1089
|
|
|
* |
1090
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1091
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar $subject |
1092
|
|
|
* @param boolean $includeSheet |
1093
|
|
|
* @throws \Exception |
1094
|
|
|
*/ |
1095
|
1 |
|
protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, $includeSheet = false) |
1096
|
|
|
{ |
1097
|
|
|
// c:bar3DChart |
1098
|
1 |
|
$objWriter->startElement('c:barChart'); |
1099
|
|
|
|
1100
|
|
|
// c:barDir |
1101
|
1 |
|
$objWriter->startElement('c:barDir'); |
1102
|
1 |
|
$objWriter->writeAttribute('val', $subject->getBarDirection()); |
1103
|
1 |
|
$objWriter->endElement(); |
1104
|
|
|
|
1105
|
|
|
// c:grouping |
1106
|
1 |
|
$objWriter->startElement('c:grouping'); |
1107
|
1 |
|
$objWriter->writeAttribute('val', $subject->getBarGrouping()); |
1108
|
1 |
|
$objWriter->endElement(); |
1109
|
|
|
|
1110
|
|
|
// Write series |
1111
|
1 |
|
$seriesIndex = 0; |
1112
|
1 |
|
foreach ($subject->getData() as $series) { |
1113
|
|
|
// c:ser |
1114
|
1 |
|
$objWriter->startElement('c:ser'); |
1115
|
|
|
|
1116
|
|
|
// c:idx |
1117
|
1 |
|
$objWriter->startElement('c:idx'); |
1118
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1119
|
1 |
|
$objWriter->endElement(); |
1120
|
|
|
|
1121
|
|
|
// c:order |
1122
|
1 |
|
$objWriter->startElement('c:order'); |
1123
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1124
|
1 |
|
$objWriter->endElement(); |
1125
|
|
|
|
1126
|
|
|
// c:tx |
1127
|
1 |
|
$objWriter->startElement('c:tx'); |
1128
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
1129
|
1 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
1130
|
1 |
|
$objWriter->endElement(); |
1131
|
|
|
|
1132
|
|
|
// Fills for points? |
1133
|
1 |
|
$dataPointFills = $series->getDataPointFills(); |
1134
|
1 |
|
foreach ($dataPointFills as $key => $value) { |
1135
|
|
|
// c:dPt |
1136
|
1 |
|
$objWriter->startElement('c:dPt'); |
1137
|
|
|
|
1138
|
|
|
// c:idx |
1139
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:idx', $key); |
1140
|
|
|
|
1141
|
1 |
|
if ($value->getFillType() != Fill::FILL_NONE) { |
1142
|
|
|
// c:spPr |
1143
|
1 |
|
$objWriter->startElement('c:spPr'); |
1144
|
|
|
// Write fill |
1145
|
1 |
|
$this->writeFill($objWriter, $value); |
1146
|
|
|
// ## c:spPr |
1147
|
1 |
|
$objWriter->endElement(); |
1148
|
1 |
|
} |
1149
|
|
|
|
1150
|
|
|
// ## c:dPt |
1151
|
1 |
|
$objWriter->endElement(); |
1152
|
1 |
|
} |
1153
|
|
|
|
1154
|
|
|
// c:dLbls |
1155
|
1 |
|
$objWriter->startElement('c:dLbls'); |
1156
|
|
|
|
1157
|
1 |
|
if ($series->hasDlblNumFormat()) { |
1158
|
|
|
//c:numFmt |
1159
|
|
|
$objWriter->startElement('c:numFmt'); |
1160
|
|
|
$objWriter->writeAttribute('formatCode', $series->getDlblNumFormat()); |
1161
|
|
|
$objWriter->writeAttribute('sourceLinked', '0'); |
1162
|
|
|
$objWriter->endElement(); |
1163
|
|
|
} |
1164
|
|
|
|
1165
|
|
|
// c:txPr |
1166
|
1 |
|
$objWriter->startElement('c:txPr'); |
1167
|
|
|
|
1168
|
|
|
// a:bodyPr |
1169
|
1 |
|
$objWriter->writeElement('a:bodyPr', null); |
1170
|
|
|
|
1171
|
|
|
// a:lstStyle |
1172
|
1 |
|
$objWriter->writeElement('a:lstStyle', null); |
1173
|
|
|
|
1174
|
|
|
// a:p |
1175
|
1 |
|
$objWriter->startElement('a:p'); |
1176
|
|
|
|
1177
|
|
|
// a:pPr |
1178
|
1 |
|
$objWriter->startElement('a:pPr'); |
1179
|
|
|
|
1180
|
|
|
// a:defRPr |
1181
|
1 |
|
$objWriter->startElement('a:defRPr'); |
1182
|
|
|
|
1183
|
1 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
1184
|
1 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
1185
|
1 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1186
|
1 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
1187
|
1 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
1188
|
|
|
|
1189
|
1 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
1190
|
|
|
if ($series->getFont()->isSuperScript()) { |
1191
|
|
|
$objWriter->writeAttribute('baseline', '30000'); |
1192
|
|
|
} elseif ($series->getFont()->isSubScript()) { |
1193
|
|
|
$objWriter->writeAttribute('baseline', '-25000'); |
1194
|
|
|
} |
1195
|
|
|
} |
1196
|
|
|
|
1197
|
|
|
// Font - a:solidFill |
1198
|
1 |
|
$objWriter->startElement('a:solidFill'); |
1199
|
|
|
|
1200
|
|
|
// a:srgbClr |
1201
|
1 |
|
$objWriter->startElement('a:srgbClr'); |
1202
|
1 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
1203
|
1 |
|
$objWriter->endElement(); |
1204
|
|
|
|
1205
|
1 |
|
$objWriter->endElement(); |
1206
|
|
|
|
1207
|
|
|
// Font - a:latin |
1208
|
1 |
|
$objWriter->startElement('a:latin'); |
1209
|
1 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
1210
|
1 |
|
$objWriter->endElement(); |
1211
|
|
|
|
1212
|
1 |
|
$objWriter->endElement(); |
1213
|
|
|
|
1214
|
1 |
|
$objWriter->endElement(); |
1215
|
|
|
|
1216
|
|
|
// a:endParaRPr |
1217
|
1 |
|
$objWriter->startElement('a:endParaRPr'); |
1218
|
1 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1219
|
1 |
|
$objWriter->writeAttribute('dirty', '0'); |
1220
|
1 |
|
$objWriter->endElement(); |
1221
|
|
|
|
1222
|
1 |
|
$objWriter->endElement(); |
1223
|
|
|
|
1224
|
1 |
|
$objWriter->endElement(); |
1225
|
|
|
|
1226
|
|
|
// c:showVal |
1227
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1228
|
|
|
|
1229
|
|
|
// c:showCatName |
1230
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1231
|
|
|
|
1232
|
|
|
// c:showSerName |
1233
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1234
|
|
|
|
1235
|
|
|
// c:showPercent |
1236
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1237
|
|
|
|
1238
|
|
|
// c:showLeaderLines |
1239
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1240
|
|
|
|
1241
|
1 |
|
$objWriter->endElement(); |
1242
|
|
|
|
1243
|
|
|
// c:spPr |
1244
|
1 |
|
if ($series->getFill()->getFillType() != Fill::FILL_NONE) { |
1245
|
|
|
// c:spPr |
1246
|
|
|
$objWriter->startElement('c:spPr'); |
1247
|
|
|
// Write fill |
1248
|
|
|
$this->writeFill($objWriter, $series->getFill()); |
1249
|
|
|
// ## c:spPr |
1250
|
|
|
$objWriter->endElement(); |
1251
|
|
|
} |
1252
|
|
|
|
1253
|
|
|
// Write X axis data |
1254
|
1 |
|
$axisXData = array_keys($series->getValues()); |
1255
|
|
|
|
1256
|
|
|
// c:cat |
1257
|
1 |
|
$objWriter->startElement('c:cat'); |
1258
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1259
|
1 |
|
$objWriter->endElement(); |
1260
|
|
|
|
1261
|
|
|
// Write Y axis data |
1262
|
1 |
|
$axisYData = array_values($series->getValues()); |
1263
|
|
|
|
1264
|
|
|
// c:val |
1265
|
1 |
|
$objWriter->startElement('c:val'); |
1266
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
1267
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
1268
|
1 |
|
$objWriter->endElement(); |
1269
|
|
|
|
1270
|
1 |
|
$objWriter->endElement(); |
1271
|
|
|
|
1272
|
1 |
|
++$seriesIndex; |
1273
|
1 |
|
} |
1274
|
|
|
|
1275
|
|
|
// c:overlap |
1276
|
1 |
|
$objWriter->startElement('c:overlap'); |
1277
|
1 |
|
if ($subject->getBarGrouping() == Bar::GROUPING_CLUSTERED) { |
1278
|
1 |
|
$objWriter->writeAttribute('val', '0'); |
1279
|
1 |
|
} elseif ($subject->getBarGrouping() == Bar::GROUPING_STACKED || $subject->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) { |
1280
|
|
|
$objWriter->writeAttribute('val', '100'); |
1281
|
|
|
} |
1282
|
1 |
|
$objWriter->endElement(); |
1283
|
|
|
|
1284
|
|
|
// c:gapWidth |
1285
|
1 |
|
$objWriter->startElement('c:gapWidth'); |
1286
|
1 |
|
$objWriter->writeAttribute('val', '75'); |
1287
|
1 |
|
$objWriter->endElement(); |
1288
|
|
|
|
1289
|
|
|
// c:shape |
1290
|
1 |
|
$objWriter->startElement('c:shape'); |
1291
|
1 |
|
$objWriter->writeAttribute('val', 'box'); |
1292
|
1 |
|
$objWriter->endElement(); |
1293
|
|
|
|
1294
|
|
|
// c:axId |
1295
|
1 |
|
$objWriter->startElement('c:axId'); |
1296
|
1 |
|
$objWriter->writeAttribute('val', '52743552'); |
1297
|
1 |
|
$objWriter->endElement(); |
1298
|
|
|
|
1299
|
|
|
// c:axId |
1300
|
1 |
|
$objWriter->startElement('c:axId'); |
1301
|
1 |
|
$objWriter->writeAttribute('val', '52749440'); |
1302
|
1 |
|
$objWriter->endElement(); |
1303
|
|
|
|
1304
|
|
|
// c:axId |
1305
|
1 |
|
$objWriter->startElement('c:axId'); |
1306
|
1 |
|
$objWriter->writeAttribute('val', '0'); |
1307
|
1 |
|
$objWriter->endElement(); |
1308
|
|
|
|
1309
|
1 |
|
$objWriter->endElement(); |
1310
|
1 |
|
} |
1311
|
|
|
|
1312
|
|
|
/** |
1313
|
|
|
* Write Type Bar3D |
1314
|
|
|
* |
1315
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1316
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D $subject |
1317
|
|
|
* @param boolean $includeSheet |
1318
|
|
|
* @throws \Exception |
1319
|
|
|
*/ |
1320
|
5 |
|
protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, $includeSheet = false) |
1321
|
|
|
{ |
1322
|
|
|
// c:bar3DChart |
1323
|
5 |
|
$objWriter->startElement('c:bar3DChart'); |
1324
|
|
|
|
1325
|
|
|
// c:barDir |
1326
|
5 |
|
$objWriter->startElement('c:barDir'); |
1327
|
5 |
|
$objWriter->writeAttribute('val', $subject->getBarDirection()); |
1328
|
5 |
|
$objWriter->endElement(); |
1329
|
|
|
|
1330
|
|
|
// c:grouping |
1331
|
5 |
|
$objWriter->startElement('c:grouping'); |
1332
|
5 |
|
$objWriter->writeAttribute('val', $subject->getBarGrouping()); |
1333
|
5 |
|
$objWriter->endElement(); |
1334
|
|
|
|
1335
|
|
|
// Write series |
1336
|
5 |
|
$seriesIndex = 0; |
1337
|
5 |
|
foreach ($subject->getData() as $series) { |
1338
|
|
|
// c:ser |
1339
|
4 |
|
$objWriter->startElement('c:ser'); |
1340
|
|
|
|
1341
|
|
|
// c:idx |
1342
|
4 |
|
$objWriter->startElement('c:idx'); |
1343
|
4 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1344
|
4 |
|
$objWriter->endElement(); |
1345
|
|
|
|
1346
|
|
|
// c:order |
1347
|
4 |
|
$objWriter->startElement('c:order'); |
1348
|
4 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1349
|
4 |
|
$objWriter->endElement(); |
1350
|
|
|
|
1351
|
|
|
// c:tx |
1352
|
4 |
|
$objWriter->startElement('c:tx'); |
1353
|
4 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
1354
|
4 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
1355
|
4 |
|
$objWriter->endElement(); |
1356
|
|
|
|
1357
|
|
|
// Fills for points? |
1358
|
4 |
|
$dataPointFills = $series->getDataPointFills(); |
1359
|
4 |
|
foreach ($dataPointFills as $key => $value) { |
1360
|
|
|
// c:dPt |
1361
|
1 |
|
$objWriter->startElement('c:dPt'); |
1362
|
|
|
|
1363
|
|
|
// c:idx |
1364
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:idx', $key); |
1365
|
|
|
|
1366
|
1 |
|
if ($value->getFillType() != Fill::FILL_NONE) { |
1367
|
|
|
// c:spPr |
1368
|
1 |
|
$objWriter->startElement('c:spPr'); |
1369
|
|
|
// Write fill |
1370
|
1 |
|
$this->writeFill($objWriter, $value); |
1371
|
|
|
// ## c:spPr |
1372
|
1 |
|
$objWriter->endElement(); |
1373
|
1 |
|
} |
1374
|
|
|
|
1375
|
|
|
// ## c:dPt |
1376
|
1 |
|
$objWriter->endElement(); |
1377
|
4 |
|
} |
1378
|
|
|
|
1379
|
|
|
// c:dLbls |
1380
|
4 |
|
$objWriter->startElement('c:dLbls'); |
1381
|
|
|
|
1382
|
|
|
// c:txPr |
1383
|
4 |
|
$objWriter->startElement('c:txPr'); |
1384
|
|
|
|
1385
|
|
|
// a:bodyPr |
1386
|
4 |
|
$objWriter->writeElement('a:bodyPr', null); |
1387
|
|
|
|
1388
|
|
|
// a:lstStyle |
1389
|
4 |
|
$objWriter->writeElement('a:lstStyle', null); |
1390
|
|
|
|
1391
|
|
|
// a:p |
1392
|
4 |
|
$objWriter->startElement('a:p'); |
1393
|
|
|
|
1394
|
|
|
// a:pPr |
1395
|
4 |
|
$objWriter->startElement('a:pPr'); |
1396
|
|
|
|
1397
|
|
|
// a:defRPr |
1398
|
4 |
|
$objWriter->startElement('a:defRPr'); |
1399
|
|
|
|
1400
|
4 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
1401
|
4 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
1402
|
4 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1403
|
4 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
1404
|
4 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
1405
|
|
|
|
1406
|
4 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
1407
|
2 |
|
if ($series->getFont()->isSuperScript()) { |
1408
|
1 |
|
$objWriter->writeAttribute('baseline', '30000'); |
1409
|
2 |
|
} elseif ($series->getFont()->isSubScript()) { |
1410
|
1 |
|
$objWriter->writeAttribute('baseline', '-25000'); |
1411
|
1 |
|
} |
1412
|
2 |
|
} |
1413
|
|
|
|
1414
|
|
|
// Font - a:solidFill |
1415
|
4 |
|
$objWriter->startElement('a:solidFill'); |
1416
|
|
|
|
1417
|
|
|
// a:srgbClr |
1418
|
4 |
|
$objWriter->startElement('a:srgbClr'); |
1419
|
4 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
1420
|
4 |
|
$objWriter->endElement(); |
1421
|
|
|
|
1422
|
4 |
|
$objWriter->endElement(); |
1423
|
|
|
|
1424
|
|
|
// Font - a:latin |
1425
|
4 |
|
$objWriter->startElement('a:latin'); |
1426
|
4 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
1427
|
4 |
|
$objWriter->endElement(); |
1428
|
|
|
|
1429
|
4 |
|
$objWriter->endElement(); |
1430
|
|
|
|
1431
|
4 |
|
$objWriter->endElement(); |
1432
|
|
|
|
1433
|
|
|
// a:endParaRPr |
1434
|
4 |
|
$objWriter->startElement('a:endParaRPr'); |
1435
|
4 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1436
|
4 |
|
$objWriter->writeAttribute('dirty', '0'); |
1437
|
4 |
|
$objWriter->endElement(); |
1438
|
|
|
|
1439
|
4 |
|
$objWriter->endElement(); |
1440
|
|
|
|
1441
|
4 |
|
$objWriter->endElement(); |
1442
|
|
|
|
1443
|
|
|
// c:showVal |
1444
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1445
|
|
|
|
1446
|
|
|
// c:showCatName |
1447
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1448
|
|
|
|
1449
|
|
|
// c:showSerName |
1450
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1451
|
|
|
|
1452
|
|
|
// c:showPercent |
1453
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1454
|
|
|
|
1455
|
|
|
// c:showLeaderLines |
1456
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1457
|
|
|
|
1458
|
4 |
|
$objWriter->endElement(); |
1459
|
|
|
|
1460
|
|
|
// c:spPr |
1461
|
4 |
|
if ($series->getFill()->getFillType() != Fill::FILL_NONE) { |
1462
|
|
|
// c:spPr |
1463
|
|
|
$objWriter->startElement('c:spPr'); |
1464
|
|
|
// Write fill |
1465
|
|
|
$this->writeFill($objWriter, $series->getFill()); |
1466
|
|
|
// ## c:spPr |
1467
|
|
|
$objWriter->endElement(); |
1468
|
|
|
} |
1469
|
|
|
|
1470
|
|
|
// Write X axis data |
1471
|
4 |
|
$axisXData = array_keys($series->getValues()); |
1472
|
|
|
|
1473
|
|
|
// c:cat |
1474
|
4 |
|
$objWriter->startElement('c:cat'); |
1475
|
4 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1476
|
4 |
|
$objWriter->endElement(); |
1477
|
|
|
|
1478
|
|
|
// Write Y axis data |
1479
|
4 |
|
$axisYData = array_values($series->getValues()); |
1480
|
|
|
|
1481
|
|
|
// c:val |
1482
|
4 |
|
$objWriter->startElement('c:val'); |
1483
|
4 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
1484
|
4 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
1485
|
4 |
|
$objWriter->endElement(); |
1486
|
|
|
|
1487
|
4 |
|
$objWriter->endElement(); |
1488
|
|
|
|
1489
|
4 |
|
++$seriesIndex; |
1490
|
5 |
|
} |
1491
|
|
|
|
1492
|
|
|
// c:gapWidth |
1493
|
5 |
|
$objWriter->startElement('c:gapWidth'); |
1494
|
5 |
|
$objWriter->writeAttribute('val', '75'); |
1495
|
5 |
|
$objWriter->endElement(); |
1496
|
|
|
|
1497
|
|
|
// c:shape |
1498
|
5 |
|
$objWriter->startElement('c:shape'); |
1499
|
5 |
|
$objWriter->writeAttribute('val', 'box'); |
1500
|
5 |
|
$objWriter->endElement(); |
1501
|
|
|
|
1502
|
|
|
// c:axId |
1503
|
5 |
|
$objWriter->startElement('c:axId'); |
1504
|
5 |
|
$objWriter->writeAttribute('val', '52743552'); |
1505
|
5 |
|
$objWriter->endElement(); |
1506
|
|
|
|
1507
|
|
|
// c:axId |
1508
|
5 |
|
$objWriter->startElement('c:axId'); |
1509
|
5 |
|
$objWriter->writeAttribute('val', '52749440'); |
1510
|
5 |
|
$objWriter->endElement(); |
1511
|
|
|
|
1512
|
|
|
// c:axId |
1513
|
5 |
|
$objWriter->startElement('c:axId'); |
1514
|
5 |
|
$objWriter->writeAttribute('val', '0'); |
1515
|
5 |
|
$objWriter->endElement(); |
1516
|
|
|
|
1517
|
5 |
|
$objWriter->endElement(); |
1518
|
5 |
|
} |
1519
|
|
|
|
1520
|
|
|
/** |
1521
|
|
|
* Write Type Pie |
1522
|
|
|
* |
1523
|
|
|
* @param \PhpOffice\PhpPresentation\Shared\XMLWriter $objWriter XML Writer |
1524
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Pie $subject |
1525
|
|
|
* @param boolean $includeSheet |
1526
|
|
|
* @throws \Exception |
1527
|
|
|
*/ |
1528
|
1 |
|
protected function writeTypePie(XMLWriter $objWriter, Pie $subject, $includeSheet = false) |
1529
|
|
|
{ |
1530
|
|
|
// c:pieChart |
1531
|
1 |
|
$objWriter->startElement('c:pieChart'); |
1532
|
|
|
|
1533
|
|
|
// c:varyColors |
1534
|
1 |
|
$objWriter->startElement('c:varyColors'); |
1535
|
1 |
|
$objWriter->writeAttribute('val', '1'); |
1536
|
1 |
|
$objWriter->endElement(); |
1537
|
|
|
|
1538
|
|
|
// Write series |
1539
|
1 |
|
$seriesIndex = 0; |
1540
|
1 |
|
foreach ($subject->getData() as $series) { |
1541
|
|
|
// c:ser |
1542
|
1 |
|
$objWriter->startElement('c:ser'); |
1543
|
|
|
|
1544
|
|
|
// c:idx |
1545
|
1 |
|
$objWriter->startElement('c:idx'); |
1546
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1547
|
1 |
|
$objWriter->endElement(); |
1548
|
|
|
|
1549
|
|
|
// c:order |
1550
|
1 |
|
$objWriter->startElement('c:order'); |
1551
|
1 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1552
|
1 |
|
$objWriter->endElement(); |
1553
|
|
|
|
1554
|
|
|
// c:tx |
1555
|
1 |
|
$objWriter->startElement('c:tx'); |
1556
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
1557
|
1 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
1558
|
1 |
|
$objWriter->endElement(); |
1559
|
|
|
|
1560
|
|
|
// Fills for points? |
1561
|
1 |
|
$dataPointFills = $series->getDataPointFills(); |
1562
|
1 |
|
foreach ($dataPointFills as $key => $value) { |
1563
|
|
|
// c:dPt |
1564
|
1 |
|
$objWriter->startElement('c:dPt'); |
1565
|
|
|
|
1566
|
|
|
// c:idx |
1567
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:idx', $key); |
1568
|
|
|
|
1569
|
|
|
// c:spPr |
1570
|
1 |
|
$objWriter->startElement('c:spPr'); |
1571
|
|
|
|
1572
|
|
|
// Write fill |
1573
|
1 |
|
$this->writeFill($objWriter, $value); |
1574
|
|
|
|
1575
|
1 |
|
$objWriter->endElement(); |
1576
|
|
|
|
1577
|
1 |
|
$objWriter->endElement(); |
1578
|
1 |
|
} |
1579
|
|
|
|
1580
|
|
|
// c:dLbls |
1581
|
1 |
|
$objWriter->startElement('c:dLbls'); |
1582
|
|
|
|
1583
|
|
|
// c:txPr |
1584
|
1 |
|
$objWriter->startElement('c:txPr'); |
1585
|
|
|
|
1586
|
|
|
// a:bodyPr |
1587
|
1 |
|
$objWriter->writeElement('a:bodyPr', null); |
1588
|
|
|
|
1589
|
|
|
// a:lstStyle |
1590
|
1 |
|
$objWriter->writeElement('a:lstStyle', null); |
1591
|
|
|
|
1592
|
|
|
// a:p |
1593
|
1 |
|
$objWriter->startElement('a:p'); |
1594
|
|
|
|
1595
|
|
|
// a:pPr |
1596
|
1 |
|
$objWriter->startElement('a:pPr'); |
1597
|
|
|
|
1598
|
|
|
// a:defRPr |
1599
|
1 |
|
$objWriter->startElement('a:defRPr'); |
1600
|
|
|
|
1601
|
1 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
1602
|
1 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
1603
|
1 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1604
|
1 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
1605
|
1 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
1606
|
|
|
|
1607
|
1 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
1608
|
|
|
if ($series->getFont()->isSuperScript()) { |
1609
|
|
|
$objWriter->writeAttribute('baseline', '30000'); |
1610
|
|
|
} elseif ($series->getFont()->isSubScript()) { |
1611
|
|
|
$objWriter->writeAttribute('baseline', '-25000'); |
1612
|
|
|
} |
1613
|
|
|
} |
1614
|
|
|
|
1615
|
|
|
// Font - a:solidFill |
1616
|
1 |
|
$objWriter->startElement('a:solidFill'); |
1617
|
|
|
|
1618
|
|
|
// a:srgbClr |
1619
|
1 |
|
$objWriter->startElement('a:srgbClr'); |
1620
|
1 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
1621
|
1 |
|
$objWriter->endElement(); |
1622
|
|
|
|
1623
|
1 |
|
$objWriter->endElement(); |
1624
|
|
|
|
1625
|
|
|
// Font - a:latin |
1626
|
1 |
|
$objWriter->startElement('a:latin'); |
1627
|
1 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
1628
|
1 |
|
$objWriter->endElement(); |
1629
|
|
|
|
1630
|
1 |
|
$objWriter->endElement(); |
1631
|
|
|
|
1632
|
1 |
|
$objWriter->endElement(); |
1633
|
|
|
|
1634
|
|
|
// a:endParaRPr |
1635
|
1 |
|
$objWriter->startElement('a:endParaRPr'); |
1636
|
1 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1637
|
1 |
|
$objWriter->writeAttribute('dirty', '0'); |
1638
|
1 |
|
$objWriter->endElement(); |
1639
|
|
|
|
1640
|
1 |
|
$objWriter->endElement(); |
1641
|
|
|
|
1642
|
1 |
|
$objWriter->endElement(); |
1643
|
|
|
|
1644
|
|
|
// c:dLblPos |
1645
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:dLblPos', $series->getLabelPosition()); |
1646
|
|
|
|
1647
|
|
|
// c:showVal |
1648
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1649
|
|
|
|
1650
|
|
|
// c:showCatName |
1651
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1652
|
|
|
|
1653
|
|
|
// c:showSerName |
1654
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1655
|
|
|
|
1656
|
|
|
// c:showPercent |
1657
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1658
|
|
|
|
1659
|
|
|
// c:showLeaderLines |
1660
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1661
|
|
|
|
1662
|
1 |
|
$objWriter->endElement(); |
1663
|
|
|
|
1664
|
|
|
// Write X axis data |
1665
|
1 |
|
$axisXData = array_keys($series->getValues()); |
1666
|
|
|
|
1667
|
|
|
// c:cat |
1668
|
1 |
|
$objWriter->startElement('c:cat'); |
1669
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1670
|
1 |
|
$objWriter->endElement(); |
1671
|
|
|
|
1672
|
|
|
// Write Y axis data |
1673
|
1 |
|
$axisYData = array_values($series->getValues()); |
1674
|
|
|
|
1675
|
|
|
// c:val |
1676
|
1 |
|
$objWriter->startElement('c:val'); |
1677
|
1 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
1678
|
1 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
1679
|
1 |
|
$objWriter->endElement(); |
1680
|
|
|
|
1681
|
1 |
|
$objWriter->endElement(); |
1682
|
|
|
|
1683
|
1 |
|
++$seriesIndex; |
1684
|
1 |
|
} |
1685
|
|
|
|
1686
|
1 |
|
$objWriter->endElement(); |
1687
|
1 |
|
} |
1688
|
|
|
|
1689
|
|
|
/** |
1690
|
|
|
* Write Type Pie3D |
1691
|
|
|
* |
1692
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1693
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Pie3D $subject |
1694
|
|
|
* @param boolean $includeSheet |
1695
|
|
|
* @throws \Exception |
1696
|
|
|
*/ |
1697
|
4 |
|
protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, $includeSheet = false) |
1698
|
|
|
{ |
1699
|
|
|
// c:pie3DChart |
1700
|
4 |
|
$objWriter->startElement('c:pie3DChart'); |
1701
|
|
|
|
1702
|
|
|
// c:varyColors |
1703
|
4 |
|
$objWriter->startElement('c:varyColors'); |
1704
|
4 |
|
$objWriter->writeAttribute('val', '1'); |
1705
|
4 |
|
$objWriter->endElement(); |
1706
|
|
|
|
1707
|
|
|
// Write series |
1708
|
4 |
|
$seriesIndex = 0; |
1709
|
4 |
|
foreach ($subject->getData() as $series) { |
1710
|
|
|
// c:ser |
1711
|
4 |
|
$objWriter->startElement('c:ser'); |
1712
|
|
|
|
1713
|
|
|
// c:idx |
1714
|
4 |
|
$objWriter->startElement('c:idx'); |
1715
|
4 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1716
|
4 |
|
$objWriter->endElement(); |
1717
|
|
|
|
1718
|
|
|
// c:order |
1719
|
4 |
|
$objWriter->startElement('c:order'); |
1720
|
4 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1721
|
4 |
|
$objWriter->endElement(); |
1722
|
|
|
|
1723
|
|
|
// c:tx |
1724
|
4 |
|
$objWriter->startElement('c:tx'); |
1725
|
4 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
1726
|
4 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
1727
|
4 |
|
$objWriter->endElement(); |
1728
|
|
|
|
1729
|
|
|
// c:explosion |
1730
|
4 |
|
$objWriter->startElement('c:explosion'); |
1731
|
4 |
|
$objWriter->writeAttribute('val', $subject->getExplosion()); |
1732
|
4 |
|
$objWriter->endElement(); |
1733
|
|
|
|
1734
|
|
|
// Fills for points? |
1735
|
4 |
|
$dataPointFills = $series->getDataPointFills(); |
1736
|
4 |
|
foreach ($dataPointFills as $key => $value) { |
1737
|
|
|
// c:dPt |
1738
|
1 |
|
$objWriter->startElement('c:dPt'); |
1739
|
|
|
|
1740
|
|
|
// c:idx |
1741
|
1 |
|
$this->writeElementWithValAttribute($objWriter, 'c:idx', $key); |
1742
|
|
|
|
1743
|
|
|
// c:spPr |
1744
|
1 |
|
$objWriter->startElement('c:spPr'); |
1745
|
|
|
|
1746
|
|
|
// Write fill |
1747
|
1 |
|
$this->writeFill($objWriter, $value); |
1748
|
|
|
|
1749
|
1 |
|
$objWriter->endElement(); |
1750
|
|
|
|
1751
|
1 |
|
$objWriter->endElement(); |
1752
|
4 |
|
} |
1753
|
|
|
|
1754
|
|
|
// c:dLbls |
1755
|
4 |
|
$objWriter->startElement('c:dLbls'); |
1756
|
|
|
|
1757
|
|
|
// c:txPr |
1758
|
4 |
|
$objWriter->startElement('c:txPr'); |
1759
|
|
|
|
1760
|
|
|
// a:bodyPr |
1761
|
4 |
|
$objWriter->writeElement('a:bodyPr', null); |
1762
|
|
|
|
1763
|
|
|
// a:lstStyle |
1764
|
4 |
|
$objWriter->writeElement('a:lstStyle', null); |
1765
|
|
|
|
1766
|
|
|
// a:p |
1767
|
4 |
|
$objWriter->startElement('a:p'); |
1768
|
|
|
|
1769
|
|
|
// a:pPr |
1770
|
4 |
|
$objWriter->startElement('a:pPr'); |
1771
|
|
|
|
1772
|
|
|
// a:defRPr |
1773
|
4 |
|
$objWriter->startElement('a:defRPr'); |
1774
|
|
|
|
1775
|
4 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
1776
|
4 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
1777
|
4 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1778
|
4 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
1779
|
4 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
1780
|
|
|
|
1781
|
4 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
1782
|
2 |
|
if ($series->getFont()->isSuperScript()) { |
1783
|
1 |
|
$objWriter->writeAttribute('baseline', '30000'); |
1784
|
2 |
|
} elseif ($series->getFont()->isSubScript()) { |
1785
|
1 |
|
$objWriter->writeAttribute('baseline', '-25000'); |
1786
|
1 |
|
} |
1787
|
2 |
|
} |
1788
|
|
|
|
1789
|
|
|
// Font - a:solidFill |
1790
|
4 |
|
$objWriter->startElement('a:solidFill'); |
1791
|
|
|
|
1792
|
|
|
// a:srgbClr |
1793
|
4 |
|
$objWriter->startElement('a:srgbClr'); |
1794
|
4 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
1795
|
4 |
|
$objWriter->endElement(); |
1796
|
|
|
|
1797
|
4 |
|
$objWriter->endElement(); |
1798
|
|
|
|
1799
|
|
|
// Font - a:latin |
1800
|
4 |
|
$objWriter->startElement('a:latin'); |
1801
|
4 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
1802
|
4 |
|
$objWriter->endElement(); |
1803
|
|
|
|
1804
|
4 |
|
$objWriter->endElement(); |
1805
|
|
|
|
1806
|
4 |
|
$objWriter->endElement(); |
1807
|
|
|
|
1808
|
|
|
// a:endParaRPr |
1809
|
4 |
|
$objWriter->startElement('a:endParaRPr'); |
1810
|
4 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1811
|
4 |
|
$objWriter->writeAttribute('dirty', '0'); |
1812
|
4 |
|
$objWriter->endElement(); |
1813
|
|
|
|
1814
|
4 |
|
$objWriter->endElement(); |
1815
|
|
|
|
1816
|
4 |
|
$objWriter->endElement(); |
1817
|
|
|
|
1818
|
|
|
// c:dLblPos |
1819
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:dLblPos', $series->getLabelPosition()); |
1820
|
|
|
|
1821
|
|
|
// c:showVal |
1822
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1823
|
|
|
|
1824
|
|
|
// c:showCatName |
1825
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1826
|
|
|
|
1827
|
|
|
// c:showSerName |
1828
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1829
|
|
|
|
1830
|
|
|
// c:showPercent |
1831
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1832
|
|
|
|
1833
|
|
|
// c:showLeaderLines |
1834
|
4 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1835
|
|
|
|
1836
|
4 |
|
$objWriter->endElement(); |
1837
|
|
|
|
1838
|
|
|
// Write X axis data |
1839
|
4 |
|
$axisXData = array_keys($series->getValues()); |
1840
|
|
|
|
1841
|
|
|
// c:cat |
1842
|
4 |
|
$objWriter->startElement('c:cat'); |
1843
|
4 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1844
|
4 |
|
$objWriter->endElement(); |
1845
|
|
|
|
1846
|
|
|
// Write Y axis data |
1847
|
4 |
|
$axisYData = array_values($series->getValues()); |
1848
|
|
|
|
1849
|
|
|
// c:val |
1850
|
4 |
|
$objWriter->startElement('c:val'); |
1851
|
4 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
1852
|
4 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
1853
|
4 |
|
$objWriter->endElement(); |
1854
|
|
|
|
1855
|
4 |
|
$objWriter->endElement(); |
1856
|
|
|
|
1857
|
4 |
|
++$seriesIndex; |
1858
|
4 |
|
} |
1859
|
|
|
|
1860
|
4 |
|
$objWriter->endElement(); |
1861
|
4 |
|
} |
1862
|
|
|
|
1863
|
|
|
/** |
1864
|
|
|
* Write Type Line |
1865
|
|
|
* |
1866
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1867
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Line $subject |
1868
|
|
|
* @param boolean $includeSheet |
1869
|
|
|
* @throws \Exception |
1870
|
|
|
*/ |
1871
|
4 |
|
protected function writeTypeLine(XMLWriter $objWriter, Line $subject, $includeSheet = false) |
1872
|
|
|
{ |
1873
|
|
|
// c:lineChart |
1874
|
4 |
|
$objWriter->startElement('c:lineChart'); |
1875
|
|
|
|
1876
|
|
|
// c:grouping |
1877
|
4 |
|
$objWriter->startElement('c:grouping'); |
1878
|
4 |
|
$objWriter->writeAttribute('val', 'standard'); |
1879
|
4 |
|
$objWriter->endElement(); |
1880
|
|
|
|
1881
|
|
|
// Write series |
1882
|
4 |
|
$seriesIndex = 0; |
1883
|
4 |
|
foreach ($subject->getData() as $series) { |
1884
|
|
|
// c:ser |
1885
|
3 |
|
$objWriter->startElement('c:ser'); |
1886
|
|
|
|
1887
|
|
|
// c:idx |
1888
|
3 |
|
$objWriter->startElement('c:idx'); |
1889
|
3 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1890
|
3 |
|
$objWriter->endElement(); |
1891
|
|
|
|
1892
|
|
|
// c:order |
1893
|
3 |
|
$objWriter->startElement('c:order'); |
1894
|
3 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
1895
|
3 |
|
$objWriter->endElement(); |
1896
|
|
|
|
1897
|
|
|
// c:tx |
1898
|
3 |
|
$objWriter->startElement('c:tx'); |
1899
|
3 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
1900
|
3 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
1901
|
3 |
|
$objWriter->endElement(); |
1902
|
|
|
|
1903
|
|
|
// c:dLbls |
1904
|
3 |
|
$objWriter->startElement('c:dLbls'); |
1905
|
|
|
|
1906
|
|
|
// c:txPr |
1907
|
3 |
|
$objWriter->startElement('c:txPr'); |
1908
|
|
|
|
1909
|
|
|
// a:bodyPr |
1910
|
3 |
|
$objWriter->writeElement('a:bodyPr', null); |
1911
|
|
|
|
1912
|
|
|
// a:lstStyle |
1913
|
3 |
|
$objWriter->writeElement('a:lstStyle', null); |
1914
|
|
|
|
1915
|
|
|
// a:p |
1916
|
3 |
|
$objWriter->startElement('a:p'); |
1917
|
|
|
|
1918
|
|
|
// a:pPr |
1919
|
3 |
|
$objWriter->startElement('a:pPr'); |
1920
|
|
|
|
1921
|
|
|
// a:defRPr |
1922
|
3 |
|
$objWriter->startElement('a:defRPr'); |
1923
|
|
|
|
1924
|
3 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
1925
|
3 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
1926
|
3 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1927
|
3 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
1928
|
3 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
1929
|
|
|
|
1930
|
3 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
1931
|
2 |
|
if ($series->getFont()->isSuperScript()) { |
1932
|
1 |
|
$objWriter->writeAttribute('baseline', '30000'); |
1933
|
2 |
|
} elseif ($series->getFont()->isSubScript()) { |
1934
|
1 |
|
$objWriter->writeAttribute('baseline', '-25000'); |
1935
|
1 |
|
} |
1936
|
2 |
|
} |
1937
|
|
|
|
1938
|
|
|
// Font - a:solidFill |
1939
|
3 |
|
$objWriter->startElement('a:solidFill'); |
1940
|
|
|
|
1941
|
|
|
// a:srgbClr |
1942
|
3 |
|
$objWriter->startElement('a:srgbClr'); |
1943
|
3 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
1944
|
3 |
|
$objWriter->endElement(); |
1945
|
|
|
|
1946
|
3 |
|
$objWriter->endElement(); |
1947
|
|
|
|
1948
|
|
|
// Font - a:latin |
1949
|
3 |
|
$objWriter->startElement('a:latin'); |
1950
|
3 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
1951
|
3 |
|
$objWriter->endElement(); |
1952
|
|
|
|
1953
|
3 |
|
$objWriter->endElement(); |
1954
|
|
|
|
1955
|
3 |
|
$objWriter->endElement(); |
1956
|
|
|
|
1957
|
|
|
// a:endParaRPr |
1958
|
3 |
|
$objWriter->startElement('a:endParaRPr'); |
1959
|
3 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
1960
|
3 |
|
$objWriter->writeAttribute('dirty', '0'); |
1961
|
3 |
|
$objWriter->endElement(); |
1962
|
|
|
|
1963
|
3 |
|
$objWriter->endElement(); |
1964
|
|
|
|
1965
|
3 |
|
$objWriter->endElement(); |
1966
|
|
|
|
1967
|
|
|
// c:showVal |
1968
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
1969
|
|
|
|
1970
|
|
|
// c:showCatName |
1971
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
1972
|
|
|
|
1973
|
|
|
// c:showSerName |
1974
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
1975
|
|
|
|
1976
|
|
|
// c:showPercent |
1977
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
1978
|
|
|
|
1979
|
|
|
// c:showLeaderLines |
1980
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
1981
|
|
|
|
1982
|
3 |
|
$objWriter->endElement(); |
1983
|
|
|
|
1984
|
3 |
|
if ($series->getFill()->getFillType() != Fill::FILL_NONE) { |
1985
|
|
|
// c:spPr |
1986
|
|
|
$objWriter->startElement('c:spPr'); |
1987
|
|
|
// Write fill |
1988
|
|
|
$this->writeFill($objWriter, $series->getFill()); |
1989
|
|
|
// ## c:spPr |
1990
|
|
|
$objWriter->endElement(); |
1991
|
|
|
} |
1992
|
|
|
|
1993
|
|
|
// Write X axis data |
1994
|
3 |
|
$axisXData = array_keys($series->getValues()); |
1995
|
|
|
|
1996
|
|
|
// c:cat |
1997
|
3 |
|
$objWriter->startElement('c:cat'); |
1998
|
3 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
1999
|
3 |
|
$objWriter->endElement(); |
2000
|
|
|
|
2001
|
|
|
// Write Y axis data |
2002
|
3 |
|
$axisYData = array_values($series->getValues()); |
2003
|
|
|
|
2004
|
|
|
// c:val |
2005
|
3 |
|
$objWriter->startElement('c:val'); |
2006
|
3 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
2007
|
3 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
2008
|
3 |
|
$objWriter->endElement(); |
2009
|
|
|
|
2010
|
3 |
|
$objWriter->endElement(); |
2011
|
|
|
|
2012
|
3 |
|
++$seriesIndex; |
2013
|
4 |
|
} |
2014
|
|
|
|
2015
|
|
|
// c:marker |
2016
|
4 |
|
$objWriter->startElement('c:marker'); |
2017
|
4 |
|
$objWriter->writeAttribute('val', '1'); |
2018
|
4 |
|
$objWriter->endElement(); |
2019
|
|
|
|
2020
|
|
|
// c:smooth |
2021
|
4 |
|
$objWriter->startElement('c:smooth'); |
2022
|
4 |
|
$objWriter->writeAttribute('val', '0'); |
2023
|
4 |
|
$objWriter->endElement(); |
2024
|
|
|
|
2025
|
|
|
// c:axId |
2026
|
4 |
|
$objWriter->startElement('c:axId'); |
2027
|
4 |
|
$objWriter->writeAttribute('val', '52743552'); |
2028
|
4 |
|
$objWriter->endElement(); |
2029
|
|
|
|
2030
|
|
|
// c:axId |
2031
|
4 |
|
$objWriter->startElement('c:axId'); |
2032
|
4 |
|
$objWriter->writeAttribute('val', '52749440'); |
2033
|
4 |
|
$objWriter->endElement(); |
2034
|
|
|
|
2035
|
4 |
|
$objWriter->endElement(); |
2036
|
4 |
|
} |
2037
|
|
|
|
2038
|
|
|
/** |
2039
|
|
|
* Write Type Scatter |
2040
|
|
|
* |
2041
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
2042
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter $subject |
2043
|
|
|
* @param boolean $includeSheet |
2044
|
|
|
* @throws \Exception |
2045
|
|
|
*/ |
2046
|
3 |
|
protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, $includeSheet = false) |
2047
|
|
|
{ |
2048
|
|
|
// c:scatterChart |
2049
|
3 |
|
$objWriter->startElement('c:scatterChart'); |
2050
|
|
|
|
2051
|
|
|
// c:scatterStyle |
2052
|
3 |
|
$objWriter->startElement('c:scatterStyle'); |
2053
|
3 |
|
$objWriter->writeAttribute('val', 'lineMarker'); |
2054
|
3 |
|
$objWriter->endElement(); |
2055
|
|
|
|
2056
|
|
|
// c:varyColors |
2057
|
3 |
|
$objWriter->startElement('c:varyColors'); |
2058
|
3 |
|
$objWriter->writeAttribute('val', '0'); |
2059
|
3 |
|
$objWriter->endElement(); |
2060
|
|
|
|
2061
|
|
|
// Write series |
2062
|
3 |
|
$seriesIndex = 0; |
2063
|
3 |
|
foreach ($subject->getData() as $series) { |
2064
|
|
|
// c:ser |
2065
|
3 |
|
$objWriter->startElement('c:ser'); |
2066
|
|
|
|
2067
|
|
|
// c:idx |
2068
|
3 |
|
$objWriter->startElement('c:idx'); |
2069
|
3 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
2070
|
3 |
|
$objWriter->endElement(); |
2071
|
|
|
|
2072
|
|
|
// c:order |
2073
|
3 |
|
$objWriter->startElement('c:order'); |
2074
|
3 |
|
$objWriter->writeAttribute('val', $seriesIndex); |
2075
|
3 |
|
$objWriter->endElement(); |
2076
|
|
|
|
2077
|
|
|
// c:tx |
2078
|
3 |
|
$objWriter->startElement('c:tx'); |
2079
|
3 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : ''); |
2080
|
3 |
|
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); |
2081
|
3 |
|
$objWriter->endElement(); |
2082
|
|
|
|
2083
|
|
|
// c:marker |
2084
|
3 |
|
$objWriter->startElement('c:marker'); |
2085
|
|
|
|
2086
|
|
|
// c:marker |
2087
|
3 |
|
$objWriter->startElement('c:symbol'); |
2088
|
3 |
|
$objWriter->writeAttribute('val', 'none'); // Marker style |
2089
|
|
|
//$objWriter->writeAttribute('size', '7'); // Marker size |
2090
|
3 |
|
$objWriter->endElement(); |
2091
|
|
|
|
2092
|
3 |
|
$objWriter->endElement(); |
2093
|
|
|
|
2094
|
|
|
// c:dLbls |
2095
|
3 |
|
$objWriter->startElement('c:dLbls'); |
2096
|
|
|
|
2097
|
|
|
// c:txPr |
2098
|
3 |
|
$objWriter->startElement('c:txPr'); |
2099
|
|
|
|
2100
|
|
|
// a:bodyPr |
2101
|
3 |
|
$objWriter->writeElement('a:bodyPr', null); |
2102
|
|
|
|
2103
|
|
|
// a:lstStyle |
2104
|
3 |
|
$objWriter->writeElement('a:lstStyle', null); |
2105
|
|
|
|
2106
|
|
|
// a:p |
2107
|
3 |
|
$objWriter->startElement('a:p'); |
2108
|
|
|
|
2109
|
|
|
// a:pPr |
2110
|
3 |
|
$objWriter->startElement('a:pPr'); |
2111
|
|
|
|
2112
|
|
|
// a:defRPr |
2113
|
3 |
|
$objWriter->startElement('a:defRPr'); |
2114
|
|
|
|
2115
|
3 |
|
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false')); |
2116
|
3 |
|
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false')); |
2117
|
3 |
|
$objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
2118
|
3 |
|
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100)); |
2119
|
3 |
|
$objWriter->writeAttribute('u', $series->getFont()->getUnderline()); |
2120
|
|
|
|
2121
|
3 |
|
if ($series->getFont()->isSuperScript() || $series->getFont()->isSubScript()) { |
2122
|
2 |
|
if ($series->getFont()->isSuperScript()) { |
2123
|
1 |
|
$objWriter->writeAttribute('baseline', '30000'); |
2124
|
2 |
|
} elseif ($series->getFont()->isSubScript()) { |
2125
|
1 |
|
$objWriter->writeAttribute('baseline', '-25000'); |
2126
|
1 |
|
} |
2127
|
2 |
|
} |
2128
|
|
|
|
2129
|
|
|
// Font - a:solidFill |
2130
|
3 |
|
$objWriter->startElement('a:solidFill'); |
2131
|
|
|
|
2132
|
|
|
// a:srgbClr |
2133
|
3 |
|
$objWriter->startElement('a:srgbClr'); |
2134
|
3 |
|
$objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB()); |
2135
|
3 |
|
$objWriter->endElement(); |
2136
|
|
|
|
2137
|
3 |
|
$objWriter->endElement(); |
2138
|
|
|
|
2139
|
|
|
// Font - a:latin |
2140
|
3 |
|
$objWriter->startElement('a:latin'); |
2141
|
3 |
|
$objWriter->writeAttribute('typeface', $series->getFont()->getName()); |
2142
|
3 |
|
$objWriter->endElement(); |
2143
|
|
|
|
2144
|
3 |
|
$objWriter->endElement(); |
2145
|
|
|
|
2146
|
3 |
|
$objWriter->endElement(); |
2147
|
|
|
|
2148
|
|
|
// a:endParaRPr |
2149
|
3 |
|
$objWriter->startElement('a:endParaRPr'); |
2150
|
3 |
|
$objWriter->writeAttribute('lang', 'en-US'); |
2151
|
3 |
|
$objWriter->writeAttribute('dirty', '0'); |
2152
|
3 |
|
$objWriter->endElement(); |
2153
|
|
|
|
2154
|
3 |
|
$objWriter->endElement(); |
2155
|
|
|
|
2156
|
3 |
|
$objWriter->endElement(); |
2157
|
|
|
|
2158
|
|
|
// c:showLegendKey |
2159
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLegendKey', '0'); |
2160
|
|
|
|
2161
|
|
|
// c:showVal |
2162
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0'); |
2163
|
|
|
|
2164
|
|
|
// c:showCatName |
2165
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0'); |
2166
|
|
|
|
2167
|
|
|
// c:showSerName |
2168
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0'); |
2169
|
|
|
|
2170
|
|
|
// c:showPercent |
2171
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0'); |
2172
|
|
|
|
2173
|
|
|
// c:showLeaderLines |
2174
|
3 |
|
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0'); |
2175
|
|
|
|
2176
|
3 |
|
$objWriter->endElement(); |
2177
|
|
|
|
2178
|
3 |
|
if ($series->getFill()->getFillType() != Fill::FILL_NONE) { |
2179
|
|
|
// c:spPr |
2180
|
|
|
$objWriter->startElement('c:spPr'); |
2181
|
|
|
// Write fill |
2182
|
|
|
$this->writeFill($objWriter, $series->getFill()); |
2183
|
|
|
// ## c:spPr |
2184
|
|
|
$objWriter->endElement(); |
2185
|
|
|
} |
2186
|
|
|
|
2187
|
|
|
// Write X axis data |
2188
|
3 |
|
$axisXData = array_keys($series->getValues()); |
2189
|
|
|
|
2190
|
|
|
// c:xVal |
2191
|
3 |
|
$objWriter->startElement('c:xVal'); |
2192
|
3 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData))); |
2193
|
3 |
|
$objWriter->endElement(); |
2194
|
|
|
|
2195
|
|
|
// Write Y axis data |
2196
|
3 |
|
$axisYData = array_values($series->getValues()); |
2197
|
|
|
|
2198
|
|
|
// c:yVal |
2199
|
3 |
|
$objWriter->startElement('c:yVal'); |
2200
|
3 |
|
$coords = ($includeSheet ? 'Sheet1!$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . \PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : ''); |
2201
|
3 |
|
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords); |
2202
|
3 |
|
$objWriter->endElement(); |
2203
|
|
|
|
2204
|
|
|
// c:smooth |
2205
|
3 |
|
$objWriter->startElement('c:smooth'); |
2206
|
3 |
|
$objWriter->writeAttribute('val', '0'); |
2207
|
3 |
|
$objWriter->endElement(); |
2208
|
|
|
|
2209
|
3 |
|
$objWriter->endElement(); |
2210
|
|
|
|
2211
|
3 |
|
++$seriesIndex; |
2212
|
3 |
|
} |
2213
|
|
|
|
2214
|
|
|
// c:axId |
2215
|
3 |
|
$objWriter->startElement('c:axId'); |
2216
|
3 |
|
$objWriter->writeAttribute('val', '52743552'); |
2217
|
3 |
|
$objWriter->endElement(); |
2218
|
|
|
|
2219
|
|
|
// c:axId |
2220
|
3 |
|
$objWriter->startElement('c:axId'); |
2221
|
3 |
|
$objWriter->writeAttribute('val', '52749440'); |
2222
|
3 |
|
$objWriter->endElement(); |
2223
|
|
|
|
2224
|
3 |
|
$objWriter->endElement(); |
2225
|
3 |
|
} |
2226
|
|
|
} |
2227
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.