Failed Conditions
Push — develop ( 00003f...12bf08 )
by Adrien
28:26
created

Chart::writePlotArea()   F

Complexity

Conditions 22
Paths 274

Size

Total Lines 121
Code Lines 84

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 82
CRAP Score 22.0008

Importance

Changes 0
Metric Value
cc 22
eloc 84
nc 274
nop 9
dl 0
loc 121
ccs 82
cts 83
cp 0.988
crap 22.0008
rs 2.4083
c 0
b 0
f 0

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
4
5
use PhpOffice\PhpSpreadsheet\Chart\Axis;
6
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
7
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
8
use PhpOffice\PhpSpreadsheet\Chart\GridLines;
9
use PhpOffice\PhpSpreadsheet\Chart\Layout;
10
use PhpOffice\PhpSpreadsheet\Chart\Legend;
11
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
12
use PhpOffice\PhpSpreadsheet\Chart\Title;
13
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
14
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
15
use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException;
16
17
class Chart extends WriterPart
18
{
19
    protected $calculateCellValues;
20
21
    /**
22
     * @var int
23
     */
24
    private $seriesIndex;
25
26
    /**
27
     * Write charts to XML format.
28
     *
29
     * @param \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart
30
     * @param mixed $calculateCellValues
31
     *
32
     * @throws WriterException
33
     *
34
     * @return string XML Output
35
     */
36 14
    public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calculateCellValues = true)
37
    {
38 14
        $this->calculateCellValues = $calculateCellValues;
39
40
        // Create XML writer
41 14
        $objWriter = null;
42 14
        if ($this->getParentWriter()->getUseDiskCaching()) {
43
            $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
44
        } else {
45 14
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
46
        }
47
        //    Ensure that data series values are up-to-date before we save
48 14
        if ($this->calculateCellValues) {
49 14
            $pChart->refresh();
50
        }
51
52
        // XML header
53 14
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
54
55
        // c:chartSpace
56 14
        $objWriter->startElement('c:chartSpace');
57 14
        $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
58 14
        $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
59 14
        $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
60
61 14
        $objWriter->startElement('c:date1904');
62 14
        $objWriter->writeAttribute('val', 0);
63 14
        $objWriter->endElement();
64 14
        $objWriter->startElement('c:lang');
65 14
        $objWriter->writeAttribute('val', 'en-GB');
66 14
        $objWriter->endElement();
67 14
        $objWriter->startElement('c:roundedCorners');
68 14
        $objWriter->writeAttribute('val', 0);
69 14
        $objWriter->endElement();
70
71 14
        $this->writeAlternateContent($objWriter);
72
73 14
        $objWriter->startElement('c:chart');
74
75 14
        $this->writeTitle($objWriter, $pChart->getTitle());
76
77 14
        $objWriter->startElement('c:autoTitleDeleted');
78 14
        $objWriter->writeAttribute('val', 0);
79 14
        $objWriter->endElement();
80
81 14
        $this->writePlotArea($objWriter, $pChart->getWorksheet(), $pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $pChart->getChartAxisX(), $pChart->getChartAxisY(), $pChart->getMajorGridlines(), $pChart->getMinorGridlines());
82
83 14
        $this->writeLegend($objWriter, $pChart->getLegend());
84
85 14
        $objWriter->startElement('c:plotVisOnly');
86 14
        $objWriter->writeAttribute('val', 1);
87 14
        $objWriter->endElement();
88
89 14
        $objWriter->startElement('c:dispBlanksAs');
90 14
        $objWriter->writeAttribute('val', 'gap');
91 14
        $objWriter->endElement();
92
93 14
        $objWriter->startElement('c:showDLblsOverMax');
94 14
        $objWriter->writeAttribute('val', 0);
95 14
        $objWriter->endElement();
96
97 14
        $objWriter->endElement();
98
99 14
        $this->writePrintSettings($objWriter);
100
101 14
        $objWriter->endElement();
102
103
        // Return
104 14
        return $objWriter->getData();
105
    }
106
107
    /**
108
     * Write Chart Title.
109
     *
110
     * @param XMLWriter $objWriter XML Writer
111
     * @param Title $title
112
     *
113
     * @throws WriterException
114
     */
115 14
    private function writeTitle(XMLWriter $objWriter, Title $title = null)
116
    {
117 14
        if ($title === null) {
118 1
            return;
119
        }
120
121 14
        $objWriter->startElement('c:title');
122 14
        $objWriter->startElement('c:tx');
123 14
        $objWriter->startElement('c:rich');
124
125 14
        $objWriter->startElement('a:bodyPr');
126 14
        $objWriter->endElement();
127
128 14
        $objWriter->startElement('a:lstStyle');
129 14
        $objWriter->endElement();
130
131 14
        $objWriter->startElement('a:p');
132
133 14
        $caption = $title->getCaption();
134 14
        if ((is_array($caption)) && (count($caption) > 0)) {
0 ignored issues
show
introduced by
The condition is_array($caption) is always false.
Loading history...
135 1
            $caption = $caption[0];
136
        }
137 14
        $this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a');
0 ignored issues
show
Bug introduced by
The method writeRichTextForCharts() does not exist on PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart. It seems like you code against a sub-type of PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart such as PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

137
        $this->getParentWriter()->getWriterPart('stringtable')->/** @scrutinizer ignore-call */ writeRichTextForCharts($objWriter, $caption, 'a');
Loading history...
138
139 14
        $objWriter->endElement();
140 14
        $objWriter->endElement();
141 14
        $objWriter->endElement();
142
143 14
        $this->writeLayout($objWriter, $title->getLayout());
144
145 14
        $objWriter->startElement('c:overlay');
146 14
        $objWriter->writeAttribute('val', 0);
147 14
        $objWriter->endElement();
148
149 14
        $objWriter->endElement();
150 14
    }
151
152
    /**
153
     * Write Chart Legend.
154
     *
155
     * @param XMLWriter $objWriter XML Writer
156
     * @param Legend $legend
157
     *
158
     * @throws WriterException
159
     */
160 14
    private function writeLegend(XMLWriter $objWriter, Legend $legend = null)
161
    {
162 14
        if ($legend === null) {
163 3
            return;
164
        }
165
166 14
        $objWriter->startElement('c:legend');
167
168 14
        $objWriter->startElement('c:legendPos');
169 14
        $objWriter->writeAttribute('val', $legend->getPosition());
170 14
        $objWriter->endElement();
171
172 14
        $this->writeLayout($objWriter, $legend->getLayout());
173
174 14
        $objWriter->startElement('c:overlay');
175 14
        $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
176 14
        $objWriter->endElement();
177
178 14
        $objWriter->startElement('c:txPr');
179 14
        $objWriter->startElement('a:bodyPr');
180 14
        $objWriter->endElement();
181
182 14
        $objWriter->startElement('a:lstStyle');
183 14
        $objWriter->endElement();
184
185 14
        $objWriter->startElement('a:p');
186 14
        $objWriter->startElement('a:pPr');
187 14
        $objWriter->writeAttribute('rtl', 0);
188
189 14
        $objWriter->startElement('a:defRPr');
190 14
        $objWriter->endElement();
191 14
        $objWriter->endElement();
192
193 14
        $objWriter->startElement('a:endParaRPr');
194 14
        $objWriter->writeAttribute('lang', 'en-US');
195 14
        $objWriter->endElement();
196
197 14
        $objWriter->endElement();
198 14
        $objWriter->endElement();
199
200 14
        $objWriter->endElement();
201 14
    }
202
203
    /**
204
     * Write Chart Plot Area.
205
     *
206
     * @param XMLWriter $objWriter XML Writer
207
     * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet
208
     * @param PlotArea $plotArea
209
     * @param Title $xAxisLabel
210
     * @param Title $yAxisLabel
211
     * @param Axis $xAxis
212
     * @param Axis $yAxis
213
     * @param null|GridLines $majorGridlines
214
     * @param null|GridLines $minorGridlines
215
     *
216
     * @throws WriterException
217
     */
218 14
    private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null)
0 ignored issues
show
Unused Code introduced by
The parameter $pSheet is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

218
    private function writePlotArea(XMLWriter $objWriter, /** @scrutinizer ignore-unused */ \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
219
    {
220 14
        if ($plotArea === null) {
221
            return;
222
        }
223
224 14
        $id1 = $id2 = 0;
225 14
        $this->seriesIndex = 0;
226 14
        $objWriter->startElement('c:plotArea');
227
228 14
        $layout = $plotArea->getLayout();
229
230 14
        $this->writeLayout($objWriter, $layout);
231
232 14
        $chartTypes = self::getChartType($plotArea);
233 14
        $catIsMultiLevelSeries = $valIsMultiLevelSeries = false;
234 14
        $plotGroupingType = '';
235 14
        foreach ($chartTypes as $chartType) {
236 14
            $objWriter->startElement('c:' . $chartType);
237
238 14
            $groupCount = $plotArea->getPlotGroupCount();
239 14
            for ($i = 0; $i < $groupCount; ++$i) {
240 14
                $plotGroup = $plotArea->getPlotGroupByIndex($i);
241 14
                $groupType = $plotGroup->getPlotType();
242 14
                if ($groupType == $chartType) {
243 14
                    $plotStyle = $plotGroup->getPlotStyle();
244 14
                    if ($groupType === DataSeries::TYPE_RADARCHART) {
245 2
                        $objWriter->startElement('c:radarStyle');
246 2
                        $objWriter->writeAttribute('val', $plotStyle);
247 2
                        $objWriter->endElement();
248 13
                    } elseif ($groupType === DataSeries::TYPE_SCATTERCHART) {
249 2
                        $objWriter->startElement('c:scatterStyle');
250 2
                        $objWriter->writeAttribute('val', $plotStyle);
251 2
                        $objWriter->endElement();
252
                    }
253
254 14
                    $this->writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType);
255
                }
256
            }
257
258 14
            $this->writeDataLabels($objWriter, $layout);
259
260 14
            if ($chartType === DataSeries::TYPE_LINECHART) {
261
                //    Line only, Line3D can't be smoothed
262 3
                $objWriter->startElement('c:smooth');
263 3
                $objWriter->writeAttribute('val', (int) $plotGroup->getSmoothLine());
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $plotGroup does not seem to be defined for all execution paths leading up to this point.
Loading history...
264 3
                $objWriter->endElement();
265 13
            } elseif (($chartType === DataSeries::TYPE_BARCHART) || ($chartType === DataSeries::TYPE_BARCHART_3D)) {
266 7
                $objWriter->startElement('c:gapWidth');
267 7
                $objWriter->writeAttribute('val', 150);
268 7
                $objWriter->endElement();
269
270 7
                if ($plotGroupingType == 'percentStacked' || $plotGroupingType == 'stacked') {
271 2
                    $objWriter->startElement('c:overlap');
272 2
                    $objWriter->writeAttribute('val', 100);
273 7
                    $objWriter->endElement();
274
                }
275 9
            } elseif ($chartType === DataSeries::TYPE_BUBBLECHART) {
276 1
                $objWriter->startElement('c:bubbleScale');
277 1
                $objWriter->writeAttribute('val', 25);
278 1
                $objWriter->endElement();
279
280 1
                $objWriter->startElement('c:showNegBubbles');
281 1
                $objWriter->writeAttribute('val', 0);
282 1
                $objWriter->endElement();
283 9
            } elseif ($chartType === DataSeries::TYPE_STOCKCHART) {
284 2
                $objWriter->startElement('c:hiLowLines');
285 2
                $objWriter->endElement();
286
287 2
                $objWriter->startElement('c:upDownBars');
288
289 2
                $objWriter->startElement('c:gapWidth');
290 2
                $objWriter->writeAttribute('val', 300);
291 2
                $objWriter->endElement();
292
293 2
                $objWriter->startElement('c:upBars');
294 2
                $objWriter->endElement();
295
296 2
                $objWriter->startElement('c:downBars');
297 2
                $objWriter->endElement();
298
299 2
                $objWriter->endElement();
300
            }
301
302
            //    Generate 2 unique numbers to use for axId values
303 14
            $id1 = '75091328';
304 14
            $id2 = '75089408';
305
306 14
            if (($chartType !== DataSeries::TYPE_PIECHART) && ($chartType !== DataSeries::TYPE_PIECHART_3D) && ($chartType !== DataSeries::TYPE_DONUTCHART)) {
307 12
                $objWriter->startElement('c:axId');
308 12
                $objWriter->writeAttribute('val', $id1);
309 12
                $objWriter->endElement();
310 12
                $objWriter->startElement('c:axId');
311 12
                $objWriter->writeAttribute('val', $id2);
312 12
                $objWriter->endElement();
313
            } else {
314 3
                $objWriter->startElement('c:firstSliceAng');
315 3
                $objWriter->writeAttribute('val', 0);
316 3
                $objWriter->endElement();
317
318 3
                if ($chartType === DataSeries::TYPE_DONUTCHART) {
319 3
                    $objWriter->startElement('c:holeSize');
320 3
                    $objWriter->writeAttribute('val', 50);
321 3
                    $objWriter->endElement();
322
                }
323
            }
324
325 14
            $objWriter->endElement();
326
        }
327
328 14
        if (($chartType !== DataSeries::TYPE_PIECHART) && ($chartType !== DataSeries::TYPE_PIECHART_3D) && ($chartType !== DataSeries::TYPE_DONUTCHART)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $chartType seems to be defined by a foreach iteration on line 235. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
329 12
            if ($chartType === DataSeries::TYPE_BUBBLECHART) {
330 1
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines);
3 ignored issues
show
Bug introduced by
It seems like $xAxis can also be of type null; however, parameter $xAxis of PhpOffice\PhpSpreadsheet...Chart::writeValueAxis() does only seem to accept PhpOffice\PhpSpreadsheet\Chart\Axis, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

330
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, /** @scrutinizer ignore-type */ $xAxis, $majorGridlines, $minorGridlines);
Loading history...
Bug introduced by
It seems like $minorGridlines can also be of type null; however, parameter $minorGridlines of PhpOffice\PhpSpreadsheet...Chart::writeValueAxis() does only seem to accept PhpOffice\PhpSpreadsheet\Chart\GridLines, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

330
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $majorGridlines, /** @scrutinizer ignore-type */ $minorGridlines);
Loading history...
Bug introduced by
It seems like $majorGridlines can also be of type null; however, parameter $majorGridlines of PhpOffice\PhpSpreadsheet...Chart::writeValueAxis() does only seem to accept PhpOffice\PhpSpreadsheet\Chart\GridLines, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

330
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, /** @scrutinizer ignore-type */ $majorGridlines, $minorGridlines);
Loading history...
331
            } else {
332 12
                $this->writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $catIsMultiLevelSeries, $yAxis);
1 ignored issue
show
Bug introduced by
It seems like $yAxis can also be of type null; however, parameter $yAxis of PhpOffice\PhpSpreadsheet...rt::writeCategoryAxis() does only seem to accept PhpOffice\PhpSpreadsheet\Chart\Axis, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

332
                $this->writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $catIsMultiLevelSeries, /** @scrutinizer ignore-type */ $yAxis);
Loading history...
333
            }
334
335 12
            $this->writeValueAxis($objWriter, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines);
336
        }
337
338 14
        $objWriter->endElement();
339 14
    }
340
341
    /**
342
     * Write Data Labels.
343
     *
344
     * @param XMLWriter $objWriter XML Writer
345
     * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $chartLayout Chart layout
346
     */
347 14
    private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = null)
348
    {
349 14
        $objWriter->startElement('c:dLbls');
350
351 14
        $objWriter->startElement('c:showLegendKey');
352 14
        $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey();
353 14
        $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1));
354 14
        $objWriter->endElement();
355
356 14
        $objWriter->startElement('c:showVal');
357 14
        $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
358 14
        $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1));
359 14
        $objWriter->endElement();
360
361 14
        $objWriter->startElement('c:showCatName');
362 14
        $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName();
363 14
        $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1));
364 14
        $objWriter->endElement();
365
366 14
        $objWriter->startElement('c:showSerName');
367 14
        $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName();
368 14
        $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1));
369 14
        $objWriter->endElement();
370
371 14
        $objWriter->startElement('c:showPercent');
372 14
        $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent();
373 14
        $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1));
374 14
        $objWriter->endElement();
375
376 14
        $objWriter->startElement('c:showBubbleSize');
377 14
        $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize();
378 14
        $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1));
379 14
        $objWriter->endElement();
380
381 14
        $objWriter->startElement('c:showLeaderLines');
382 14
        $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines();
383 14
        $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1));
384 14
        $objWriter->endElement();
385
386 14
        $objWriter->endElement();
387 14
    }
388
389
    /**
390
     * Write Category Axis.
391
     *
392
     * @param XMLWriter $objWriter XML Writer
393
     * @param Title $xAxisLabel
394
     * @param string $id1
395
     * @param string $id2
396
     * @param bool $isMultiLevelSeries
397
     * @param Axis $yAxis
398
     *
399
     * @throws WriterException
400
     */
401 12
    private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis)
402
    {
403 12
        $objWriter->startElement('c:catAx');
404
405 12
        if ($id1 > 0) {
406 12
            $objWriter->startElement('c:axId');
407 12
            $objWriter->writeAttribute('val', $id1);
408 12
            $objWriter->endElement();
409
        }
410
411 12
        $objWriter->startElement('c:scaling');
412 12
        $objWriter->startElement('c:orientation');
413 12
        $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('orientation'));
414 12
        $objWriter->endElement();
415 12
        $objWriter->endElement();
416
417 12
        $objWriter->startElement('c:delete');
418 12
        $objWriter->writeAttribute('val', 0);
419 12
        $objWriter->endElement();
420
421 12
        $objWriter->startElement('c:axPos');
422 12
        $objWriter->writeAttribute('val', 'b');
423 12
        $objWriter->endElement();
424
425 12
        if ($xAxisLabel !== null) {
426 3
            $objWriter->startElement('c:title');
427 3
            $objWriter->startElement('c:tx');
428 3
            $objWriter->startElement('c:rich');
429
430 3
            $objWriter->startElement('a:bodyPr');
431 3
            $objWriter->endElement();
432
433 3
            $objWriter->startElement('a:lstStyle');
434 3
            $objWriter->endElement();
435
436 3
            $objWriter->startElement('a:p');
437 3
            $objWriter->startElement('a:r');
438
439 3
            $caption = $xAxisLabel->getCaption();
440 3
            if (is_array($caption)) {
0 ignored issues
show
introduced by
The condition is_array($caption) is always false.
Loading history...
441 1
                $caption = $caption[0];
442
            }
443 3
            $objWriter->startElement('a:t');
444 3
            $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($caption));
445 3
            $objWriter->endElement();
446
447 3
            $objWriter->endElement();
448 3
            $objWriter->endElement();
449 3
            $objWriter->endElement();
450 3
            $objWriter->endElement();
451
452 3
            $layout = $xAxisLabel->getLayout();
453 3
            $this->writeLayout($objWriter, $layout);
454
455 3
            $objWriter->startElement('c:overlay');
456 3
            $objWriter->writeAttribute('val', 0);
457 3
            $objWriter->endElement();
458
459 3
            $objWriter->endElement();
460
        }
461
462 12
        $objWriter->startElement('c:numFmt');
463 12
        $objWriter->writeAttribute('formatCode', $yAxis->getAxisNumberFormat());
464 12
        $objWriter->writeAttribute('sourceLinked', $yAxis->getAxisNumberSourceLinked());
465 12
        $objWriter->endElement();
466
467 12
        $objWriter->startElement('c:majorTickMark');
468 12
        $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('major_tick_mark'));
469 12
        $objWriter->endElement();
470
471 12
        $objWriter->startElement('c:minorTickMark');
472 12
        $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('minor_tick_mark'));
473 12
        $objWriter->endElement();
474
475 12
        $objWriter->startElement('c:tickLblPos');
476 12
        $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('axis_labels'));
477 12
        $objWriter->endElement();
478
479 12
        if ($id2 > 0) {
480 12
            $objWriter->startElement('c:crossAx');
481 12
            $objWriter->writeAttribute('val', $id2);
482 12
            $objWriter->endElement();
483
484 12
            $objWriter->startElement('c:crosses');
485 12
            $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('horizontal_crosses'));
486 12
            $objWriter->endElement();
487
        }
488
489 12
        $objWriter->startElement('c:auto');
490 12
        $objWriter->writeAttribute('val', 1);
491 12
        $objWriter->endElement();
492
493 12
        $objWriter->startElement('c:lblAlgn');
494 12
        $objWriter->writeAttribute('val', 'ctr');
495 12
        $objWriter->endElement();
496
497 12
        $objWriter->startElement('c:lblOffset');
498 12
        $objWriter->writeAttribute('val', 100);
499 12
        $objWriter->endElement();
500
501 12
        if ($isMultiLevelSeries) {
502 2
            $objWriter->startElement('c:noMultiLvlLbl');
503 2
            $objWriter->writeAttribute('val', 0);
504 2
            $objWriter->endElement();
505
        }
506 12
        $objWriter->endElement();
507 12
    }
508
509
    /**
510
     * Write Value Axis.
511
     *
512
     * @param XMLWriter $objWriter XML Writer
513
     * @param Title $yAxisLabel
514
     * @param string $groupType Chart type
515
     * @param string $id1
516
     * @param string $id2
517
     * @param bool $isMultiLevelSeries
518
     * @param Axis $xAxis
519
     * @param GridLines $majorGridlines
520
     * @param GridLines $minorGridlines
521
     *
522
     * @throws WriterException
523
     */
524 12
    private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines)
525
    {
526 12
        $objWriter->startElement('c:valAx');
527
528 12
        if ($id2 > 0) {
529 12
            $objWriter->startElement('c:axId');
530 12
            $objWriter->writeAttribute('val', $id2);
531 12
            $objWriter->endElement();
532
        }
533
534 12
        $objWriter->startElement('c:scaling');
535
536 12
        if ($xAxis->getAxisOptionsProperty('maximum') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getAxisOptionsPr...rty('maximum') !== null is always true.
Loading history...
537
            $objWriter->startElement('c:max');
538
            $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum'));
539
            $objWriter->endElement();
540
        }
541
542 12
        if ($xAxis->getAxisOptionsProperty('minimum') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getAxisOptionsPr...rty('minimum') !== null is always true.
Loading history...
543
            $objWriter->startElement('c:min');
544
            $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minimum'));
545
            $objWriter->endElement();
546
        }
547
548 12
        $objWriter->startElement('c:orientation');
549 12
        $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('orientation'));
550
551 12
        $objWriter->endElement();
552 12
        $objWriter->endElement();
553
554 12
        $objWriter->startElement('c:delete');
555 12
        $objWriter->writeAttribute('val', 0);
556 12
        $objWriter->endElement();
557
558 12
        $objWriter->startElement('c:axPos');
559 12
        $objWriter->writeAttribute('val', 'l');
560 12
        $objWriter->endElement();
561
562 12
        $objWriter->startElement('c:majorGridlines');
563 12
        $objWriter->startElement('c:spPr');
564
565 12
        if ($majorGridlines->getLineColorProperty('value') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getLine...perty('value') !== null is always true.
Loading history...
566
            $objWriter->startElement('a:ln');
567
            $objWriter->writeAttribute('w', $majorGridlines->getLineStyleProperty('width'));
568
            $objWriter->startElement('a:solidFill');
569
            $objWriter->startElement("a:{$majorGridlines->getLineColorProperty('type')}");
570
            $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('value'));
571
            $objWriter->startElement('a:alpha');
572
            $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('alpha'));
573
            $objWriter->endElement(); //end alpha
574
            $objWriter->endElement(); //end srgbClr
575
            $objWriter->endElement(); //end solidFill
576
577
            $objWriter->startElement('a:prstDash');
578
            $objWriter->writeAttribute('val', $majorGridlines->getLineStyleProperty('dash'));
579
            $objWriter->endElement();
580
581
            if ($majorGridlines->getLineStyleProperty('join') == 'miter') {
582
                $objWriter->startElement('a:miter');
583
                $objWriter->writeAttribute('lim', '800000');
584
                $objWriter->endElement();
585
            } else {
586
                $objWriter->startElement('a:bevel');
587
                $objWriter->endElement();
588
            }
589
590
            if ($majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getLine...ead', 'type')) !== null is always true.
Loading history...
591
                $objWriter->startElement('a:headEnd');
592
                $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
593
                $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('head', 'w'));
594
                $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('head', 'len'));
595
                $objWriter->endElement();
596
            }
597
598
            if ($majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getLine...end', 'type')) !== null is always true.
Loading history...
599
                $objWriter->startElement('a:tailEnd');
600
                $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
601
                $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('end', 'w'));
602
                $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('end', 'len'));
603
                $objWriter->endElement();
604
            }
605
            $objWriter->endElement(); //end ln
606
        }
607 12
        $objWriter->startElement('a:effectLst');
608
609 12
        if ($majorGridlines->getGlowSize() !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getGlowSize() !== null is always true.
Loading history...
610
            $objWriter->startElement('a:glow');
611
            $objWriter->writeAttribute('rad', $majorGridlines->getGlowSize());
612
            $objWriter->startElement("a:{$majorGridlines->getGlowColor('type')}");
613
            $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('value'));
614
            $objWriter->startElement('a:alpha');
615
            $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('alpha'));
616
            $objWriter->endElement(); //end alpha
617
            $objWriter->endElement(); //end schemeClr
618
            $objWriter->endElement(); //end glow
619
        }
620
621 12
        if ($majorGridlines->getShadowProperty('presets') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...rty('presets') !== null is always true.
Loading history...
622
            $objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}");
623
            if ($majorGridlines->getShadowProperty('blur') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...operty('blur') !== null is always true.
Loading history...
624
                $objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur'));
625
            }
626
            if ($majorGridlines->getShadowProperty('distance') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...ty('distance') !== null is always true.
Loading history...
627
                $objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance'));
628
            }
629
            if ($majorGridlines->getShadowProperty('direction') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...y('direction') !== null is always true.
Loading history...
630
                $objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction'));
631
            }
632
            if ($majorGridlines->getShadowProperty('algn') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...operty('algn') !== null is always true.
Loading history...
633
                $objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn'));
634
            }
635
            if ($majorGridlines->getShadowProperty(['size', 'sx']) !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...'size', 'sx')) !== null is always true.
Loading history...
636
                $objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(['size', 'sx']));
637
            }
638
            if ($majorGridlines->getShadowProperty(['size', 'sy']) !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...'size', 'sy')) !== null is always true.
Loading history...
639
                $objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(['size', 'sy']));
640
            }
641
            if ($majorGridlines->getShadowProperty(['size', 'kx']) !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...'size', 'kx')) !== null is always true.
Loading history...
642
                $objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(['size', 'kx']));
643
            }
644
            if ($majorGridlines->getShadowProperty('rotWithShape') !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getShad...rotWithShape') !== null is always true.
Loading history...
645
                $objWriter->writeAttribute('rotWithShape', $majorGridlines->getShadowProperty('rotWithShape'));
646
            }
647
            $objWriter->startElement("a:{$majorGridlines->getShadowProperty(['color', 'type'])}");
648
            $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(['color', 'value']));
649
650
            $objWriter->startElement('a:alpha');
651
            $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(['color', 'alpha']));
652
            $objWriter->endElement(); //end alpha
653
654
            $objWriter->endElement(); //end color:type
655
            $objWriter->endElement(); //end shadow
656
        }
657
658 12
        if ($majorGridlines->getSoftEdgesSize() !== null) {
0 ignored issues
show
introduced by
The condition $majorGridlines->getSoftEdgesSize() !== null is always true.
Loading history...
659
            $objWriter->startElement('a:softEdge');
660
            $objWriter->writeAttribute('rad', $majorGridlines->getSoftEdgesSize());
661
            $objWriter->endElement(); //end softEdge
662
        }
663
664 12
        $objWriter->endElement(); //end effectLst
665 12
        $objWriter->endElement(); //end spPr
666 12
        $objWriter->endElement(); //end majorGridLines
667
668 12
        if ($minorGridlines->getObjectState()) {
669
            $objWriter->startElement('c:minorGridlines');
670
            $objWriter->startElement('c:spPr');
671
672
            if ($minorGridlines->getLineColorProperty('value') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getLine...perty('value') !== null is always true.
Loading history...
673
                $objWriter->startElement('a:ln');
674
                $objWriter->writeAttribute('w', $minorGridlines->getLineStyleProperty('width'));
675
                $objWriter->startElement('a:solidFill');
676
                $objWriter->startElement("a:{$minorGridlines->getLineColorProperty('type')}");
677
                $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('value'));
678
                $objWriter->startElement('a:alpha');
679
                $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('alpha'));
680
                $objWriter->endElement(); //end alpha
681
                $objWriter->endElement(); //end srgbClr
682
                $objWriter->endElement(); //end solidFill
683
684
                $objWriter->startElement('a:prstDash');
685
                $objWriter->writeAttribute('val', $minorGridlines->getLineStyleProperty('dash'));
686
                $objWriter->endElement();
687
688
                if ($minorGridlines->getLineStyleProperty('join') == 'miter') {
689
                    $objWriter->startElement('a:miter');
690
                    $objWriter->writeAttribute('lim', '800000');
691
                    $objWriter->endElement();
692
                } else {
693
                    $objWriter->startElement('a:bevel');
694
                    $objWriter->endElement();
695
                }
696
697
                if ($minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getLine...ead', 'type')) !== null is always true.
Loading history...
698
                    $objWriter->startElement('a:headEnd');
699
                    $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
700
                    $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('head', 'w'));
701
                    $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('head', 'len'));
702
                    $objWriter->endElement();
703
                }
704
705
                if ($minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getLine...end', 'type')) !== null is always true.
Loading history...
706
                    $objWriter->startElement('a:tailEnd');
707
                    $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
708
                    $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('end', 'w'));
709
                    $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('end', 'len'));
710
                    $objWriter->endElement();
711
                }
712
                $objWriter->endElement(); //end ln
713
            }
714
715
            $objWriter->startElement('a:effectLst');
716
717
            if ($minorGridlines->getGlowSize() !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getGlowSize() !== null is always true.
Loading history...
718
                $objWriter->startElement('a:glow');
719
                $objWriter->writeAttribute('rad', $minorGridlines->getGlowSize());
720
                $objWriter->startElement("a:{$minorGridlines->getGlowColor('type')}");
721
                $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('value'));
722
                $objWriter->startElement('a:alpha');
723
                $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('alpha'));
724
                $objWriter->endElement(); //end alpha
725
                $objWriter->endElement(); //end schemeClr
726
                $objWriter->endElement(); //end glow
727
            }
728
729
            if ($minorGridlines->getShadowProperty('presets') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...rty('presets') !== null is always true.
Loading history...
730
                $objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}");
731
                if ($minorGridlines->getShadowProperty('blur') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...operty('blur') !== null is always true.
Loading history...
732
                    $objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur'));
733
                }
734
                if ($minorGridlines->getShadowProperty('distance') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...ty('distance') !== null is always true.
Loading history...
735
                    $objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance'));
736
                }
737
                if ($minorGridlines->getShadowProperty('direction') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...y('direction') !== null is always true.
Loading history...
738
                    $objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction'));
739
                }
740
                if ($minorGridlines->getShadowProperty('algn') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...operty('algn') !== null is always true.
Loading history...
741
                    $objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn'));
742
                }
743
                if ($minorGridlines->getShadowProperty(['size', 'sx']) !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...'size', 'sx')) !== null is always true.
Loading history...
744
                    $objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(['size', 'sx']));
745
                }
746
                if ($minorGridlines->getShadowProperty(['size', 'sy']) !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...'size', 'sy')) !== null is always true.
Loading history...
747
                    $objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(['size', 'sy']));
748
                }
749
                if ($minorGridlines->getShadowProperty(['size', 'kx']) !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...'size', 'kx')) !== null is always true.
Loading history...
750
                    $objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(['size', 'kx']));
751
                }
752
                if ($minorGridlines->getShadowProperty('rotWithShape') !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getShad...rotWithShape') !== null is always true.
Loading history...
753
                    $objWriter->writeAttribute('rotWithShape', $minorGridlines->getShadowProperty('rotWithShape'));
754
                }
755
                $objWriter->startElement("a:{$minorGridlines->getShadowProperty(['color', 'type'])}");
756
                $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(['color', 'value']));
757
                $objWriter->startElement('a:alpha');
758
                $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(['color', 'alpha']));
759
                $objWriter->endElement(); //end alpha
760
                $objWriter->endElement(); //end color:type
761
                $objWriter->endElement(); //end shadow
762
            }
763
764
            if ($minorGridlines->getSoftEdgesSize() !== null) {
0 ignored issues
show
introduced by
The condition $minorGridlines->getSoftEdgesSize() !== null is always true.
Loading history...
765
                $objWriter->startElement('a:softEdge');
766
                $objWriter->writeAttribute('rad', $minorGridlines->getSoftEdgesSize());
767
                $objWriter->endElement(); //end softEdge
768
            }
769
770
            $objWriter->endElement(); //end effectLst
771
            $objWriter->endElement(); //end spPr
772
            $objWriter->endElement(); //end minorGridLines
773
        }
774
775 12
        if ($yAxisLabel !== null) {
776 10
            $objWriter->startElement('c:title');
777 10
            $objWriter->startElement('c:tx');
778 10
            $objWriter->startElement('c:rich');
779
780 10
            $objWriter->startElement('a:bodyPr');
781 10
            $objWriter->endElement();
782
783 10
            $objWriter->startElement('a:lstStyle');
784 10
            $objWriter->endElement();
785
786 10
            $objWriter->startElement('a:p');
787 10
            $objWriter->startElement('a:r');
788
789 10
            $caption = $yAxisLabel->getCaption();
790 10
            if (is_array($caption)) {
0 ignored issues
show
introduced by
The condition is_array($caption) is always false.
Loading history...
791 1
                $caption = $caption[0];
792
            }
793
794 10
            $objWriter->startElement('a:t');
795 10
            $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($caption));
796 10
            $objWriter->endElement();
797
798 10
            $objWriter->endElement();
799 10
            $objWriter->endElement();
800 10
            $objWriter->endElement();
801 10
            $objWriter->endElement();
802
803 10
            if ($groupType !== DataSeries::TYPE_BUBBLECHART) {
804 10
                $layout = $yAxisLabel->getLayout();
805 10
                $this->writeLayout($objWriter, $layout);
806
            }
807
808 10
            $objWriter->startElement('c:overlay');
809 10
            $objWriter->writeAttribute('val', 0);
810 10
            $objWriter->endElement();
811
812 10
            $objWriter->endElement();
813
        }
814
815 12
        $objWriter->startElement('c:numFmt');
816 12
        $objWriter->writeAttribute('formatCode', $xAxis->getAxisNumberFormat());
817 12
        $objWriter->writeAttribute('sourceLinked', $xAxis->getAxisNumberSourceLinked());
818 12
        $objWriter->endElement();
819
820 12
        $objWriter->startElement('c:majorTickMark');
821 12
        $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_tick_mark'));
822 12
        $objWriter->endElement();
823
824 12
        $objWriter->startElement('c:minorTickMark');
825 12
        $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_tick_mark'));
826 12
        $objWriter->endElement();
827
828 12
        $objWriter->startElement('c:tickLblPos');
829 12
        $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('axis_labels'));
830 12
        $objWriter->endElement();
831
832 12
        $objWriter->startElement('c:spPr');
833
834 12
        if ($xAxis->getFillProperty('value') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getFillProperty('value') !== null is always true.
Loading history...
835
            $objWriter->startElement('a:solidFill');
836
            $objWriter->startElement('a:' . $xAxis->getFillProperty('type'));
837
            $objWriter->writeAttribute('val', $xAxis->getFillProperty('value'));
838
            $objWriter->startElement('a:alpha');
839
            $objWriter->writeAttribute('val', $xAxis->getFillProperty('alpha'));
840
            $objWriter->endElement();
841
            $objWriter->endElement();
842
            $objWriter->endElement();
843
        }
844
845 12
        $objWriter->startElement('a:ln');
846
847 12
        $objWriter->writeAttribute('w', $xAxis->getLineStyleProperty('width'));
848 12
        $objWriter->writeAttribute('cap', $xAxis->getLineStyleProperty('cap'));
849 12
        $objWriter->writeAttribute('cmpd', $xAxis->getLineStyleProperty('compound'));
850
851 12
        if ($xAxis->getLineProperty('value') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getLineProperty('value') !== null is always true.
Loading history...
852
            $objWriter->startElement('a:solidFill');
853
            $objWriter->startElement('a:' . $xAxis->getLineProperty('type'));
854
            $objWriter->writeAttribute('val', $xAxis->getLineProperty('value'));
855
            $objWriter->startElement('a:alpha');
856
            $objWriter->writeAttribute('val', $xAxis->getLineProperty('alpha'));
857
            $objWriter->endElement();
858
            $objWriter->endElement();
859
            $objWriter->endElement();
860
        }
861
862 12
        $objWriter->startElement('a:prstDash');
863 12
        $objWriter->writeAttribute('val', $xAxis->getLineStyleProperty('dash'));
864 12
        $objWriter->endElement();
865
866 12
        if ($xAxis->getLineStyleProperty('join') == 'miter') {
867
            $objWriter->startElement('a:miter');
868
            $objWriter->writeAttribute('lim', '800000');
869
            $objWriter->endElement();
870
        } else {
871 12
            $objWriter->startElement('a:bevel');
872 12
            $objWriter->endElement();
873
        }
874
875 12
        if ($xAxis->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getLineStyleProp...ead', 'type')) !== null is always true.
Loading history...
876
            $objWriter->startElement('a:headEnd');
877
            $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'head', 'type']));
878
            $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('head'));
879
            $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('head'));
880
            $objWriter->endElement();
881
        }
882
883 12
        if ($xAxis->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getLineStyleProp...end', 'type')) !== null is always true.
Loading history...
884
            $objWriter->startElement('a:tailEnd');
885
            $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'end', 'type']));
886
            $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('end'));
887
            $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('end'));
888
            $objWriter->endElement();
889
        }
890
891 12
        $objWriter->endElement();
892
893 12
        $objWriter->startElement('a:effectLst');
894
895 12
        if ($xAxis->getGlowProperty('size') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getGlowProperty('size') !== null is always true.
Loading history...
896
            $objWriter->startElement('a:glow');
897
            $objWriter->writeAttribute('rad', $xAxis->getGlowProperty('size'));
898
            $objWriter->startElement("a:{$xAxis->getGlowProperty(['color', 'type'])}");
899
            $objWriter->writeAttribute('val', $xAxis->getGlowProperty(['color', 'value']));
900
            $objWriter->startElement('a:alpha');
901
            $objWriter->writeAttribute('val', $xAxis->getGlowProperty(['color', 'alpha']));
902
            $objWriter->endElement();
903
            $objWriter->endElement();
904
            $objWriter->endElement();
905
        }
906
907 12
        if ($xAxis->getShadowProperty('presets') !== null) {
908
            $objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}");
909
910
            if ($xAxis->getShadowProperty('blur') !== null) {
911
                $objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur'));
1 ignored issue
show
Bug introduced by
It seems like $xAxis->getShadowProperty('blur') can also be of type array; however, parameter $value of XMLWriter::writeAttribute() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

911
                $objWriter->writeAttribute('blurRad', /** @scrutinizer ignore-type */ $xAxis->getShadowProperty('blur'));
Loading history...
912
            }
913
            if ($xAxis->getShadowProperty('distance') !== null) {
914
                $objWriter->writeAttribute('dist', $xAxis->getShadowProperty('distance'));
915
            }
916
            if ($xAxis->getShadowProperty('direction') !== null) {
917
                $objWriter->writeAttribute('dir', $xAxis->getShadowProperty('direction'));
918
            }
919
            if ($xAxis->getShadowProperty('algn') !== null) {
920
                $objWriter->writeAttribute('algn', $xAxis->getShadowProperty('algn'));
921
            }
922
            if ($xAxis->getShadowProperty(['size', 'sx']) !== null) {
923
                $objWriter->writeAttribute('sx', $xAxis->getShadowProperty(['size', 'sx']));
924
            }
925
            if ($xAxis->getShadowProperty(['size', 'sy']) !== null) {
926
                $objWriter->writeAttribute('sy', $xAxis->getShadowProperty(['size', 'sy']));
927
            }
928
            if ($xAxis->getShadowProperty(['size', 'kx']) !== null) {
929
                $objWriter->writeAttribute('kx', $xAxis->getShadowProperty(['size', 'kx']));
930
            }
931
            if ($xAxis->getShadowProperty('rotWithShape') !== null) {
932
                $objWriter->writeAttribute('rotWithShape', $xAxis->getShadowProperty('rotWithShape'));
933
            }
934
935
            $objWriter->startElement("a:{$xAxis->getShadowProperty(['color', 'type'])}");
936
            $objWriter->writeAttribute('val', $xAxis->getShadowProperty(['color', 'value']));
937
            $objWriter->startElement('a:alpha');
938
            $objWriter->writeAttribute('val', $xAxis->getShadowProperty(['color', 'alpha']));
939
            $objWriter->endElement();
940
            $objWriter->endElement();
941
942
            $objWriter->endElement();
943
        }
944
945 12
        if ($xAxis->getSoftEdgesSize() !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getSoftEdgesSize() !== null is always true.
Loading history...
946
            $objWriter->startElement('a:softEdge');
947
            $objWriter->writeAttribute('rad', $xAxis->getSoftEdgesSize());
948
            $objWriter->endElement();
949
        }
950
951 12
        $objWriter->endElement(); //effectList
952 12
        $objWriter->endElement(); //end spPr
953
954 12
        if ($id1 > 0) {
955 12
            $objWriter->startElement('c:crossAx');
956 12
            $objWriter->writeAttribute('val', $id2);
957 12
            $objWriter->endElement();
958
959 12
            if ($xAxis->getAxisOptionsProperty('horizontal_crosses_value') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getAxisOptionsPr...rosses_value') !== null is always true.
Loading history...
960
                $objWriter->startElement('c:crossesAt');
961
                $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses_value'));
962
                $objWriter->endElement();
963
            } else {
964 12
                $objWriter->startElement('c:crosses');
965 12
                $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses'));
966 12
                $objWriter->endElement();
967
            }
968
969 12
            $objWriter->startElement('c:crossBetween');
970 12
            $objWriter->writeAttribute('val', 'midCat');
971 12
            $objWriter->endElement();
972
973 12
            if ($xAxis->getAxisOptionsProperty('major_unit') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getAxisOptionsPr...('major_unit') !== null is always true.
Loading history...
974
                $objWriter->startElement('c:majorUnit');
975
                $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_unit'));
976
                $objWriter->endElement();
977
            }
978
979 12
            if ($xAxis->getAxisOptionsProperty('minor_unit') !== null) {
0 ignored issues
show
introduced by
The condition $xAxis->getAxisOptionsPr...('minor_unit') !== null is always true.
Loading history...
980
                $objWriter->startElement('c:minorUnit');
981
                $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_unit'));
982
                $objWriter->endElement();
983
            }
984
        }
985
986 12
        if ($isMultiLevelSeries) {
987 1
            if ($groupType !== DataSeries::TYPE_BUBBLECHART) {
988
                $objWriter->startElement('c:noMultiLvlLbl');
989
                $objWriter->writeAttribute('val', 0);
990
                $objWriter->endElement();
991
            }
992
        }
993
994 12
        $objWriter->endElement();
995 12
    }
996
997
    /**
998
     * Get the data series type(s) for a chart plot series.
999
     *
1000
     * @param PlotArea $plotArea
1001
     *
1002
     * @throws WriterException
1003
     *
1004
     * @return array|string
1005
     */
1006 14
    private static function getChartType($plotArea)
1007
    {
1008 14
        $groupCount = $plotArea->getPlotGroupCount();
1009
1010 14
        if ($groupCount == 1) {
0 ignored issues
show
introduced by
The condition $groupCount == 1 is always false.
Loading history...
1011 13
            $chartType = [$plotArea->getPlotGroupByIndex(0)->getPlotType()];
1012
        } else {
1013 2
            $chartTypes = [];
1014 2
            for ($i = 0; $i < $groupCount; ++$i) {
1015 2
                $chartTypes[] = $plotArea->getPlotGroupByIndex($i)->getPlotType();
1016
            }
1017 2
            $chartType = array_unique($chartTypes);
1018 2
            if (count($chartTypes) == 0) {
1019
                throw new WriterException('Chart is not yet implemented');
1020
            }
1021
        }
1022
1023 14
        return $chartType;
1024
    }
1025
1026
    /**
1027
     * Method writing plot series values.
1028
     *
1029
     * @param XMLWriter $objWriter XML Writer
1030
     * @param int       $val       value for idx (default: 3)
1031
     * @param string    $fillColor hex color (default: FF9900)
1032
     *
1033
     * @return XMLWriter XML Writer
1034
     */
1035 3
    private function writePlotSeriesValuesElement($objWriter, $val = 3, $fillColor = 'FF9900')
1036
    {
1037 3
        $objWriter->startElement('c:dPt');
1038 3
        $objWriter->startElement('c:idx');
1039 3
        $objWriter->writeAttribute('val', $val);
1040 3
        $objWriter->endElement();
1041
1042 3
        $objWriter->startElement('c:bubble3D');
1043 3
        $objWriter->writeAttribute('val', 0);
1044 3
        $objWriter->endElement();
1045
1046 3
        $objWriter->startElement('c:spPr');
1047 3
        $objWriter->startElement('a:solidFill');
1048 3
        $objWriter->startElement('a:srgbClr');
1049 3
        $objWriter->writeAttribute('val', $fillColor);
1050 3
        $objWriter->endElement();
1051 3
        $objWriter->endElement();
1052 3
        $objWriter->endElement();
1053 3
        $objWriter->endElement();
1054
1055 3
        return $objWriter;
1056
    }
1057
1058
    /**
1059
     * Write Plot Group (series of related plots).
1060
     *
1061
     * @param DataSeries $plotGroup
1062
     * @param string $groupType Type of plot for dataseries
1063
     * @param XMLWriter $objWriter XML Writer
1064
     * @param bool &$catIsMultiLevelSeries Is category a multi-series category
1065
     * @param bool &$valIsMultiLevelSeries Is value set a multi-series set
1066
     * @param string &$plotGroupingType Type of grouping for multi-series values
1067
     *
1068
     * @throws WriterException
1069
     */
1070 14
    private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType)
1071
    {
1072 14
        if ($plotGroup === null) {
1073
            return;
1074
        }
1075
1076 14
        if (($groupType == DataSeries::TYPE_BARCHART) || ($groupType == DataSeries::TYPE_BARCHART_3D)) {
1077 7
            $objWriter->startElement('c:barDir');
1078 7
            $objWriter->writeAttribute('val', $plotGroup->getPlotDirection());
1079 7
            $objWriter->endElement();
1080
        }
1081
1082 14
        if ($plotGroup->getPlotGrouping() !== null) {
0 ignored issues
show
introduced by
The condition $plotGroup->getPlotGrouping() !== null is always true.
Loading history...
1083 9
            $plotGroupingType = $plotGroup->getPlotGrouping();
1084 9
            $objWriter->startElement('c:grouping');
1085 9
            $objWriter->writeAttribute('val', $plotGroupingType);
1086 9
            $objWriter->endElement();
1087
        }
1088
1089
        //    Get these details before the loop, because we can use the count to check for varyColors
1090 14
        $plotSeriesOrder = $plotGroup->getPlotOrder();
1091 14
        $plotSeriesCount = count($plotSeriesOrder);
1092
1093 14
        if (($groupType !== DataSeries::TYPE_RADARCHART) && ($groupType !== DataSeries::TYPE_STOCKCHART)) {
1094 12
            if ($groupType !== DataSeries::TYPE_LINECHART) {
1095 11
                if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART) || ($plotSeriesCount > 1)) {
1096 10
                    $objWriter->startElement('c:varyColors');
1097 10
                    $objWriter->writeAttribute('val', 1);
1098 10
                    $objWriter->endElement();
1099
                } else {
1100 2
                    $objWriter->startElement('c:varyColors');
1101 2
                    $objWriter->writeAttribute('val', 0);
1102 2
                    $objWriter->endElement();
1103
                }
1104
            }
1105
        }
1106
1107 14
        foreach ($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) {
1108 14
            $objWriter->startElement('c:ser');
1109
1110 14
            $plotLabel = $plotGroup->getPlotLabelByIndex($plotSeriesIdx);
1111 14
            if ($plotLabel) {
1112 14
                $fillColor = $plotLabel->getFillColor();
1113 14
                if ($fillColor !== null && !is_array($fillColor)) {
1114
                    $objWriter->startElement('c:spPr');
1115
                    $objWriter->startElement('a:solidFill');
1116
                    $objWriter->startElement('a:srgbClr');
1117
                    $objWriter->writeAttribute('val', $fillColor);
1118
                    $objWriter->endElement();
1119
                    $objWriter->endElement();
1120
                    $objWriter->endElement();
1121
                }
1122
            }
1123
1124 14
            $objWriter->startElement('c:idx');
1125 14
            $objWriter->writeAttribute('val', $this->seriesIndex + $plotSeriesIdx);
1126 14
            $objWriter->endElement();
1127
1128 14
            $objWriter->startElement('c:order');
1129 14
            $objWriter->writeAttribute('val', $this->seriesIndex + $plotSeriesRef);
1130 14
            $objWriter->endElement();
1131
1132
            //    Values
1133 14
            $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef);
1134
1135 14
            if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART)) {
1136 3
                $fillColorValues = $plotSeriesValues->getFillColor();
1137 3
                if ($fillColorValues !== null && is_array($fillColorValues)) {
1138 1
                    foreach ($plotSeriesValues->getDataValues() as $dataKey => $dataValue) {
1139 1
                        $this->writePlotSeriesValuesElement($objWriter, $dataKey, (isset($fillColorValues[$dataKey]) ? $fillColorValues[$dataKey] : 'FF9900'));
1140
                    }
1141
                } else {
1142 2
                    $this->writePlotSeriesValuesElement($objWriter);
1143
                }
1144
            }
1145
1146
            //    Labels
1147 14
            $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
1148 14
            if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
1149 14
                $objWriter->startElement('c:tx');
1150 14
                $objWriter->startElement('c:strRef');
1151 14
                $this->writePlotSeriesLabel($plotSeriesLabel, $objWriter);
1152 14
                $objWriter->endElement();
1153 14
                $objWriter->endElement();
1154
            }
1155
1156
            //    Formatting for the points
1157 14
            if (($groupType == DataSeries::TYPE_LINECHART) || ($groupType == DataSeries::TYPE_STOCKCHART)) {
1158 4
                $plotLineWidth = 12700;
1159 4
                if ($plotSeriesValues) {
1160 4
                    $plotLineWidth = $plotSeriesValues->getLineWidth();
1161
                }
1162
1163 4
                $objWriter->startElement('c:spPr');
1164 4
                $objWriter->startElement('a:ln');
1165 4
                $objWriter->writeAttribute('w', $plotLineWidth);
1166 4
                if ($groupType == DataSeries::TYPE_STOCKCHART) {
1167 2
                    $objWriter->startElement('a:noFill');
1168 2
                    $objWriter->endElement();
1169
                }
1170 4
                $objWriter->endElement();
1171 4
                $objWriter->endElement();
1172
            }
1173
1174 14
            if ($plotSeriesValues) {
1175 14
                $plotSeriesMarker = $plotSeriesValues->getPointMarker();
1176 14
                if ($plotSeriesMarker) {
1177 1
                    $objWriter->startElement('c:marker');
1178 1
                    $objWriter->startElement('c:symbol');
1179 1
                    $objWriter->writeAttribute('val', $plotSeriesMarker);
1180 1
                    $objWriter->endElement();
1181
1182 1
                    if ($plotSeriesMarker !== 'none') {
1183 1
                        $objWriter->startElement('c:size');
1184 1
                        $objWriter->writeAttribute('val', 3);
1185 1
                        $objWriter->endElement();
1186
                    }
1187
1188 1
                    $objWriter->endElement();
1189
                }
1190
            }
1191
1192 14
            if (($groupType === DataSeries::TYPE_BARCHART) || ($groupType === DataSeries::TYPE_BARCHART_3D) || ($groupType === DataSeries::TYPE_BUBBLECHART)) {
1193 7
                $objWriter->startElement('c:invertIfNegative');
1194 7
                $objWriter->writeAttribute('val', 0);
1195 7
                $objWriter->endElement();
1196
            }
1197
1198
            //    Category Labels
1199 14
            $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
1200 14
            if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
1201 14
                $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
1202
1203 14
                if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART)) {
1204 3
                    if ($plotGroup->getPlotStyle() !== null) {
1205 1
                        $plotStyle = $plotGroup->getPlotStyle();
1206 1
                        if ($plotStyle) {
1207 1
                            $objWriter->startElement('c:explosion');
1208 1
                            $objWriter->writeAttribute('val', 25);
1209 1
                            $objWriter->endElement();
1210
                        }
1211
                    }
1212
                }
1213
1214 14
                if (($groupType === DataSeries::TYPE_BUBBLECHART) || ($groupType === DataSeries::TYPE_SCATTERCHART)) {
1215 2
                    $objWriter->startElement('c:xVal');
1216
                } else {
1217 13
                    $objWriter->startElement('c:cat');
1218
                }
1219
1220 14
                $this->writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str');
1221 14
                $objWriter->endElement();
1222
            }
1223
1224
            //    Values
1225 14
            if ($plotSeriesValues) {
1226 14
                $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
1227
1228 14
                if (($groupType === DataSeries::TYPE_BUBBLECHART) || ($groupType === DataSeries::TYPE_SCATTERCHART)) {
1229 2
                    $objWriter->startElement('c:yVal');
1230
                } else {
1231 13
                    $objWriter->startElement('c:val');
1232
                }
1233
1234 14
                $this->writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num');
1235 14
                $objWriter->endElement();
1236
            }
1237
1238 14
            if ($groupType === DataSeries::TYPE_BUBBLECHART) {
1239 1
                $this->writeBubbles($plotSeriesValues, $objWriter);
1240
            }
1241
1242 14
            $objWriter->endElement();
1243
        }
1244
1245 14
        $this->seriesIndex += $plotSeriesIdx + 1;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $plotSeriesIdx seems to be defined by a foreach iteration on line 1107. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
1246 14
    }
1247
1248
    /**
1249
     * Write Plot Series Label.
1250
     *
1251
     * @param DataSeriesValues $plotSeriesLabel
1252
     * @param XMLWriter $objWriter XML Writer
1253
     */
1254 14
    private function writePlotSeriesLabel($plotSeriesLabel, $objWriter)
1255
    {
1256 14
        if ($plotSeriesLabel === null) {
1257
            return;
1258
        }
1259
1260 14
        $objWriter->startElement('c:f');
1261 14
        $objWriter->writeRawData($plotSeriesLabel->getDataSource());
1262 14
        $objWriter->endElement();
1263
1264 14
        $objWriter->startElement('c:strCache');
1265 14
        $objWriter->startElement('c:ptCount');
1266 14
        $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount());
1267 14
        $objWriter->endElement();
1268
1269 14
        foreach ($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) {
1270 14
            $objWriter->startElement('c:pt');
1271 14
            $objWriter->writeAttribute('idx', $plotLabelKey);
1272
1273 14
            $objWriter->startElement('c:v');
1274 14
            $objWriter->writeRawData($plotLabelValue);
1275 14
            $objWriter->endElement();
1276 14
            $objWriter->endElement();
1277
        }
1278 14
        $objWriter->endElement();
1279 14
    }
1280
1281
    /**
1282
     * Write Plot Series Values.
1283
     *
1284
     * @param DataSeriesValues $plotSeriesValues
1285
     * @param XMLWriter $objWriter XML Writer
1286
     * @param string $groupType Type of plot for dataseries
1287
     * @param string $dataType Datatype of series values
1288
     */
1289 14
    private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str')
1290
    {
1291 14
        if ($plotSeriesValues === null) {
1292
            return;
1293
        }
1294
1295 14
        if ($plotSeriesValues->isMultiLevelSeries()) {
1296 2
            $levelCount = $plotSeriesValues->multiLevelCount();
1297
1298 2
            $objWriter->startElement('c:multiLvlStrRef');
1299
1300 2
            $objWriter->startElement('c:f');
1301 2
            $objWriter->writeRawData($plotSeriesValues->getDataSource());
1302 2
            $objWriter->endElement();
1303
1304 2
            $objWriter->startElement('c:multiLvlStrCache');
1305
1306 2
            $objWriter->startElement('c:ptCount');
1307 2
            $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1308 2
            $objWriter->endElement();
1309
1310 2
            for ($level = 0; $level < $levelCount; ++$level) {
1311 2
                $objWriter->startElement('c:lvl');
1312
1313 2
                foreach ($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
1314 2
                    if (isset($plotSeriesValue[$level])) {
1315 2
                        $objWriter->startElement('c:pt');
1316 2
                        $objWriter->writeAttribute('idx', $plotSeriesKey);
1317
1318 2
                        $objWriter->startElement('c:v');
1319 2
                        $objWriter->writeRawData($plotSeriesValue[$level]);
1320 2
                        $objWriter->endElement();
1321 2
                        $objWriter->endElement();
1322
                    }
1323
                }
1324
1325 2
                $objWriter->endElement();
1326
            }
1327
1328 2
            $objWriter->endElement();
1329
1330 2
            $objWriter->endElement();
1331
        } else {
1332 14
            $objWriter->startElement('c:' . $dataType . 'Ref');
1333
1334 14
            $objWriter->startElement('c:f');
1335 14
            $objWriter->writeRawData($plotSeriesValues->getDataSource());
1336 14
            $objWriter->endElement();
1337
1338 14
            $objWriter->startElement('c:' . $dataType . 'Cache');
1339
1340 14
            if (($groupType != DataSeries::TYPE_PIECHART) && ($groupType != DataSeries::TYPE_PIECHART_3D) && ($groupType != DataSeries::TYPE_DONUTCHART)) {
1341 12
                if (($plotSeriesValues->getFormatCode() !== null) && ($plotSeriesValues->getFormatCode() !== '')) {
1342 1
                    $objWriter->startElement('c:formatCode');
1343 1
                    $objWriter->writeRawData($plotSeriesValues->getFormatCode());
1344 1
                    $objWriter->endElement();
1345
                }
1346
            }
1347
1348 14
            $objWriter->startElement('c:ptCount');
1349 14
            $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1350 14
            $objWriter->endElement();
1351
1352 14
            $dataValues = $plotSeriesValues->getDataValues();
1353 14
            if (!empty($dataValues)) {
1354 14
                if (is_array($dataValues)) {
0 ignored issues
show
introduced by
The condition is_array($dataValues) is always true.
Loading history...
1355 14
                    foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1356 14
                        $objWriter->startElement('c:pt');
1357 14
                        $objWriter->writeAttribute('idx', $plotSeriesKey);
1358
1359 14
                        $objWriter->startElement('c:v');
1360 14
                        $objWriter->writeRawData($plotSeriesValue);
1361 14
                        $objWriter->endElement();
1362 14
                        $objWriter->endElement();
1363
                    }
1364
                }
1365
            }
1366
1367 14
            $objWriter->endElement();
1368
1369 14
            $objWriter->endElement();
1370
        }
1371 14
    }
1372
1373
    /**
1374
     * Write Bubble Chart Details.
1375
     *
1376
     * @param DataSeriesValues $plotSeriesValues
1377
     * @param XMLWriter $objWriter XML Writer
1378
     */
1379 1
    private function writeBubbles($plotSeriesValues, $objWriter)
1380
    {
1381 1
        if ($plotSeriesValues === null) {
1382
            return;
1383
        }
1384
1385 1
        $objWriter->startElement('c:bubbleSize');
1386 1
        $objWriter->startElement('c:numLit');
1387
1388 1
        $objWriter->startElement('c:formatCode');
1389 1
        $objWriter->writeRawData('General');
1390 1
        $objWriter->endElement();
1391
1392 1
        $objWriter->startElement('c:ptCount');
1393 1
        $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1394 1
        $objWriter->endElement();
1395
1396 1
        $dataValues = $plotSeriesValues->getDataValues();
1397 1
        if (!empty($dataValues)) {
1398 1
            if (is_array($dataValues)) {
0 ignored issues
show
introduced by
The condition is_array($dataValues) is always true.
Loading history...
1399 1
                foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1400 1
                    $objWriter->startElement('c:pt');
1401 1
                    $objWriter->writeAttribute('idx', $plotSeriesKey);
1402 1
                    $objWriter->startElement('c:v');
1403 1
                    $objWriter->writeRawData(1);
1404 1
                    $objWriter->endElement();
1405 1
                    $objWriter->endElement();
1406
                }
1407
            }
1408
        }
1409
1410 1
        $objWriter->endElement();
1411 1
        $objWriter->endElement();
1412
1413 1
        $objWriter->startElement('c:bubble3D');
1414 1
        $objWriter->writeAttribute('val', 0);
1415 1
        $objWriter->endElement();
1416 1
    }
1417
1418
    /**
1419
     * Write Layout.
1420
     *
1421
     * @param XMLWriter $objWriter XML Writer
1422
     * @param Layout $layout
1423
     */
1424 14
    private function writeLayout(XMLWriter $objWriter, Layout $layout = null)
1425
    {
1426 14
        $objWriter->startElement('c:layout');
1427
1428 14
        if ($layout !== null) {
1429 4
            $objWriter->startElement('c:manualLayout');
1430
1431 4
            $layoutTarget = $layout->getLayoutTarget();
1432 4
            if ($layoutTarget !== null) {
0 ignored issues
show
introduced by
The condition $layoutTarget !== null is always true.
Loading history...
1433 1
                $objWriter->startElement('c:layoutTarget');
1434 1
                $objWriter->writeAttribute('val', $layoutTarget);
1435 1
                $objWriter->endElement();
1436
            }
1437
1438 4
            $xMode = $layout->getXMode();
1439 4
            if ($xMode !== null) {
0 ignored issues
show
introduced by
The condition $xMode !== null is always true.
Loading history...
1440 1
                $objWriter->startElement('c:xMode');
1441 1
                $objWriter->writeAttribute('val', $xMode);
1442 1
                $objWriter->endElement();
1443
            }
1444
1445 4
            $yMode = $layout->getYMode();
1446 4
            if ($yMode !== null) {
0 ignored issues
show
introduced by
The condition $yMode !== null is always true.
Loading history...
1447 1
                $objWriter->startElement('c:yMode');
1448 1
                $objWriter->writeAttribute('val', $yMode);
1449 1
                $objWriter->endElement();
1450
            }
1451
1452 4
            $x = $layout->getXPosition();
1453 4
            if ($x !== null) {
0 ignored issues
show
introduced by
The condition $x !== null is always true.
Loading history...
1454 1
                $objWriter->startElement('c:x');
1455 1
                $objWriter->writeAttribute('val', $x);
1456 1
                $objWriter->endElement();
1457
            }
1458
1459 4
            $y = $layout->getYPosition();
1460 4
            if ($y !== null) {
0 ignored issues
show
introduced by
The condition $y !== null is always true.
Loading history...
1461 1
                $objWriter->startElement('c:y');
1462 1
                $objWriter->writeAttribute('val', $y);
1463 1
                $objWriter->endElement();
1464
            }
1465
1466 4
            $w = $layout->getWidth();
1467 4
            if ($w !== null) {
0 ignored issues
show
introduced by
The condition $w !== null is always true.
Loading history...
1468 1
                $objWriter->startElement('c:w');
1469 1
                $objWriter->writeAttribute('val', $w);
1470 1
                $objWriter->endElement();
1471
            }
1472
1473 4
            $h = $layout->getHeight();
1474 4
            if ($h !== null) {
0 ignored issues
show
introduced by
The condition $h !== null is always true.
Loading history...
1475 1
                $objWriter->startElement('c:h');
1476 1
                $objWriter->writeAttribute('val', $h);
1477 1
                $objWriter->endElement();
1478
            }
1479
1480 4
            $objWriter->endElement();
1481
        }
1482
1483 14
        $objWriter->endElement();
1484 14
    }
1485
1486
    /**
1487
     * Write Alternate Content block.
1488
     *
1489
     * @param XMLWriter $objWriter XML Writer
1490
     */
1491 14
    private function writeAlternateContent($objWriter)
1492
    {
1493 14
        $objWriter->startElement('mc:AlternateContent');
1494 14
        $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
1495
1496 14
        $objWriter->startElement('mc:Choice');
1497 14
        $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart');
1498 14
        $objWriter->writeAttribute('Requires', 'c14');
1499
1500 14
        $objWriter->startElement('c14:style');
1501 14
        $objWriter->writeAttribute('val', '102');
1502 14
        $objWriter->endElement();
1503 14
        $objWriter->endElement();
1504
1505 14
        $objWriter->startElement('mc:Fallback');
1506 14
        $objWriter->startElement('c:style');
1507 14
        $objWriter->writeAttribute('val', '2');
1508 14
        $objWriter->endElement();
1509 14
        $objWriter->endElement();
1510
1511 14
        $objWriter->endElement();
1512 14
    }
1513
1514
    /**
1515
     * Write Printer Settings.
1516
     *
1517
     * @param XMLWriter $objWriter XML Writer
1518
     */
1519 14
    private function writePrintSettings($objWriter)
1520
    {
1521 14
        $objWriter->startElement('c:printSettings');
1522
1523 14
        $objWriter->startElement('c:headerFooter');
1524 14
        $objWriter->endElement();
1525
1526 14
        $objWriter->startElement('c:pageMargins');
1527 14
        $objWriter->writeAttribute('footer', 0.3);
1528 14
        $objWriter->writeAttribute('header', 0.3);
1529 14
        $objWriter->writeAttribute('r', 0.7);
1530 14
        $objWriter->writeAttribute('l', 0.7);
1531 14
        $objWriter->writeAttribute('t', 0.75);
1532 14
        $objWriter->writeAttribute('b', 0.75);
1533 14
        $objWriter->endElement();
1534
1535 14
        $objWriter->startElement('c:pageSetup');
1536 14
        $objWriter->writeAttribute('orientation', 'portrait');
1537 14
        $objWriter->endElement();
1538
1539 14
        $objWriter->endElement();
1540 14
    }
1541
}
1542