Test Failed
Push — develop ( 90366f...812a46 )
by Adrien
28:16
created

Chart::writeDataLabels()   D

Complexity

Conditions 15
Paths 128

Size

Total Lines 40
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 15

Importance

Changes 0
Metric Value
cc 15
eloc 30
nc 128
nop 2
dl 0
loc 40
ccs 31
cts 31
cp 1
crap 15
rs 4.7582
c 0
b 0
f 0

How to fix   Complexity   

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:

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 13
    public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calculateCellValues = true)
37
    {
38 13
        $this->calculateCellValues = $calculateCellValues;
39
40
        // Create XML writer
41 13
        $objWriter = null;
42 13 View Code Duplication
        if ($this->getParentWriter()->getUseDiskCaching()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
            $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
44
        } else {
45 13
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
46
        }
47
        //    Ensure that data series values are up-to-date before we save
48 13
        if ($this->calculateCellValues) {
49 13
            $pChart->refresh();
50
        }
51
52
        // XML header
53 13
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
54
55
        // c:chartSpace
56 13
        $objWriter->startElement('c:chartSpace');
57 13
        $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
58 13
        $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
59 13
        $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
60
61 13
        $objWriter->startElement('c:date1904');
62 13
        $objWriter->writeAttribute('val', 0);
63 13
        $objWriter->endElement();
64 13
        $objWriter->startElement('c:lang');
65 13
        $objWriter->writeAttribute('val', 'en-GB');
66 13
        $objWriter->endElement();
67 13
        $objWriter->startElement('c:roundedCorners');
68 13
        $objWriter->writeAttribute('val', 0);
69 13
        $objWriter->endElement();
70
71 13
        $this->writeAlternateContent($objWriter);
72
73 13
        $objWriter->startElement('c:chart');
74
75 13
        $this->writeTitle($objWriter, $pChart->getTitle());
76
77 13
        $objWriter->startElement('c:autoTitleDeleted');
78 13
        $objWriter->writeAttribute('val', 0);
79 13
        $objWriter->endElement();
80
81 13
        $this->writePlotArea($objWriter, $pChart->getWorksheet(), $pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $pChart->getChartAxisX(), $pChart->getChartAxisY(), $pChart->getMajorGridlines(), $pChart->getMinorGridlines());
82
83 13
        $this->writeLegend($objWriter, $pChart->getLegend());
84
85 13
        $objWriter->startElement('c:plotVisOnly');
86 13
        $objWriter->writeAttribute('val', 1);
87 13
        $objWriter->endElement();
88
89 13
        $objWriter->startElement('c:dispBlanksAs');
90 13
        $objWriter->writeAttribute('val', 'gap');
91 13
        $objWriter->endElement();
92
93 13
        $objWriter->startElement('c:showDLblsOverMax');
94 13
        $objWriter->writeAttribute('val', 0);
95 13
        $objWriter->endElement();
96
97 13
        $objWriter->endElement();
98
99 13
        $this->writePrintSettings($objWriter);
100
101 13
        $objWriter->endElement();
102
103
        // Return
104 13
        return $objWriter->getData();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $objWriter->getData() could also return false which is incompatible with the documented return type string. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
105
    }
106
107
    /**
108
     * Write Chart Title.
109
     *
110
     * @param XMLWriter $objWriter XML Writer
111
     * @param Title $title
112
     *
113
     * @throws WriterException
114
     */
115 13
    private function writeTitle(XMLWriter $objWriter, Title $title = null)
116
    {
117 13
        if ($title === null) {
118 1
            return;
119
        }
120
121 13
        $objWriter->startElement('c:title');
122 13
        $objWriter->startElement('c:tx');
123 13
        $objWriter->startElement('c:rich');
124
125 13
        $objWriter->startElement('a:bodyPr');
126 13
        $objWriter->endElement();
127
128 13
        $objWriter->startElement('a:lstStyle');
129 13
        $objWriter->endElement();
130
131 13
        $objWriter->startElement('a:p');
132
133 13
        $caption = $title->getCaption();
134 13
        if ((is_array($caption)) && (count($caption) > 0)) {
135 1
            $caption = $caption[0];
136
        }
137 13
        $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 13
        $objWriter->endElement();
140 13
        $objWriter->endElement();
141 13
        $objWriter->endElement();
142
143 13
        $this->writeLayout($objWriter, $title->getLayout());
144
145 13
        $objWriter->startElement('c:overlay');
146 13
        $objWriter->writeAttribute('val', 0);
147 13
        $objWriter->endElement();
148
149 13
        $objWriter->endElement();
150 13
    }
151
152
    /**
153
     * Write Chart Legend.
154
     *
155
     * @param XMLWriter $objWriter XML Writer
156
     * @param Legend $legend
157
     *
158
     * @throws WriterException
159
     */
160 13
    private function writeLegend(XMLWriter $objWriter, Legend $legend = null)
161
    {
162 13
        if ($legend === null) {
163 2
            return;
164
        }
165
166 13
        $objWriter->startElement('c:legend');
167
168 13
        $objWriter->startElement('c:legendPos');
169 13
        $objWriter->writeAttribute('val', $legend->getPosition());
170 13
        $objWriter->endElement();
171
172 13
        $this->writeLayout($objWriter, $legend->getLayout());
173
174 13
        $objWriter->startElement('c:overlay');
175 13
        $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
176 13
        $objWriter->endElement();
177
178 13
        $objWriter->startElement('c:txPr');
179 13
        $objWriter->startElement('a:bodyPr');
180 13
        $objWriter->endElement();
181
182 13
        $objWriter->startElement('a:lstStyle');
183 13
        $objWriter->endElement();
184
185 13
        $objWriter->startElement('a:p');
186 13
        $objWriter->startElement('a:pPr');
187 13
        $objWriter->writeAttribute('rtl', 0);
188
189 13
        $objWriter->startElement('a:defRPr');
190 13
        $objWriter->endElement();
191 13
        $objWriter->endElement();
192
193 13
        $objWriter->startElement('a:endParaRPr');
194 13
        $objWriter->writeAttribute('lang', 'en-US');
195 13
        $objWriter->endElement();
196
197 13
        $objWriter->endElement();
198 13
        $objWriter->endElement();
199
200 13
        $objWriter->endElement();
201 13
    }
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
     *
214
     * @throws WriterException
215
     */
216 13
    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

216
    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...
217
    {
218 13
        if ($plotArea === null) {
219
            return;
220
        }
221
222 13
        $id1 = $id2 = 0;
223 13
        $this->seriesIndex = 0;
224 13
        $objWriter->startElement('c:plotArea');
225
226 13
        $layout = $plotArea->getLayout();
227
228 13
        $this->writeLayout($objWriter, $layout);
229
230 13
        $chartTypes = self::getChartType($plotArea);
231 13
        $catIsMultiLevelSeries = $valIsMultiLevelSeries = false;
232 13
        $plotGroupingType = '';
233 13
        foreach ($chartTypes as $chartType) {
234 13
            $objWriter->startElement('c:' . $chartType);
235
236 13
            $groupCount = $plotArea->getPlotGroupCount();
237 13
            for ($i = 0; $i < $groupCount; ++$i) {
238 13
                $plotGroup = $plotArea->getPlotGroupByIndex($i);
239 13
                $groupType = $plotGroup->getPlotType();
240 13
                if ($groupType == $chartType) {
241 13
                    $plotStyle = $plotGroup->getPlotStyle();
242 13
                    if ($groupType === DataSeries::TYPE_RADARCHART) {
243 2
                        $objWriter->startElement('c:radarStyle');
244 2
                        $objWriter->writeAttribute('val', $plotStyle);
245 2
                        $objWriter->endElement();
246 12
                    } elseif ($groupType === DataSeries::TYPE_SCATTERCHART) {
247 2
                        $objWriter->startElement('c:scatterStyle');
248 2
                        $objWriter->writeAttribute('val', $plotStyle);
249 2
                        $objWriter->endElement();
250
                    }
251
252 13
                    $this->writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType);
253
                }
254
            }
255
256 13
            $this->writeDataLabels($objWriter, $layout);
257
258 13
            if ($chartType === DataSeries::TYPE_LINECHART) {
259
                //    Line only, Line3D can't be smoothed
260 3
                $objWriter->startElement('c:smooth');
261 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...
262 3
                $objWriter->endElement();
263 12
            } elseif (($chartType === DataSeries::TYPE_BARCHART) || ($chartType === DataSeries::TYPE_BARCHART_3D)) {
264 7
                $objWriter->startElement('c:gapWidth');
265 7
                $objWriter->writeAttribute('val', 150);
266 7
                $objWriter->endElement();
267
268 7
                if ($plotGroupingType == 'percentStacked' || $plotGroupingType == 'stacked') {
269 2
                    $objWriter->startElement('c:overlap');
270 2
                    $objWriter->writeAttribute('val', 100);
271 7
                    $objWriter->endElement();
272
                }
273 8 View Code Duplication
            } elseif ($chartType === DataSeries::TYPE_BUBBLECHART) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
274 1
                $objWriter->startElement('c:bubbleScale');
275 1
                $objWriter->writeAttribute('val', 25);
276 1
                $objWriter->endElement();
277
278 1
                $objWriter->startElement('c:showNegBubbles');
279 1
                $objWriter->writeAttribute('val', 0);
280 1
                $objWriter->endElement();
281 8
            } elseif ($chartType === DataSeries::TYPE_STOCKCHART) {
282 2
                $objWriter->startElement('c:hiLowLines');
283 2
                $objWriter->endElement();
284
285 2
                $objWriter->startElement('c:upDownBars');
286
287 2
                $objWriter->startElement('c:gapWidth');
288 2
                $objWriter->writeAttribute('val', 300);
289 2
                $objWriter->endElement();
290
291 2
                $objWriter->startElement('c:upBars');
292 2
                $objWriter->endElement();
293
294 2
                $objWriter->startElement('c:downBars');
295 2
                $objWriter->endElement();
296
297 2
                $objWriter->endElement();
298
            }
299
300
            //    Generate 2 unique numbers to use for axId values
301 13
            $id1 = '75091328';
302 13
            $id2 = '75089408';
303
304 13
            if (($chartType !== DataSeries::TYPE_PIECHART) && ($chartType !== DataSeries::TYPE_PIECHART_3D) && ($chartType !== DataSeries::TYPE_DONUTCHART)) {
305 12
                $objWriter->startElement('c:axId');
306 12
                $objWriter->writeAttribute('val', $id1);
307 12
                $objWriter->endElement();
308 12
                $objWriter->startElement('c:axId');
309 12
                $objWriter->writeAttribute('val', $id2);
310 12
                $objWriter->endElement();
311 View Code Duplication
            } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
312 2
                $objWriter->startElement('c:firstSliceAng');
313 2
                $objWriter->writeAttribute('val', 0);
314 2
                $objWriter->endElement();
315
316 2
                if ($chartType === DataSeries::TYPE_DONUTCHART) {
317 2
                    $objWriter->startElement('c:holeSize');
318 2
                    $objWriter->writeAttribute('val', 50);
319 2
                    $objWriter->endElement();
320
                }
321
            }
322
323 13
            $objWriter->endElement();
324
        }
325
326 13
        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 233. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
327 12
            if ($chartType === DataSeries::TYPE_BUBBLECHART) {
328 1
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines);
3 ignored issues
show
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

328
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, /** @scrutinizer ignore-type */ $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

328
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $majorGridlines, /** @scrutinizer ignore-type */ $minorGridlines);
Loading history...
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

328
                $this->writeValueAxis($objWriter, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, /** @scrutinizer ignore-type */ $xAxis, $majorGridlines, $minorGridlines);
Loading history...
329
            } else {
330 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

330
                $this->writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $catIsMultiLevelSeries, /** @scrutinizer ignore-type */ $yAxis);
Loading history...
331
            }
332
333 12
            $this->writeValueAxis($objWriter, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines);
334
        }
335
336 13
        $objWriter->endElement();
337 13
    }
338
339
    /**
340
     * Write Data Labels.
341
     *
342
     * @param XMLWriter $objWriter XML Writer
343
     * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $chartLayout Chart layout
344
     *
345
     * @throws WriterException
346
     */
347 13
    private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = null)
348
    {
349 13
        $objWriter->startElement('c:dLbls');
350
351 13
        $objWriter->startElement('c:showLegendKey');
352 13
        $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey();
353 13
        $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1));
354 13
        $objWriter->endElement();
355
356 13
        $objWriter->startElement('c:showVal');
357 13
        $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
358 13
        $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1));
359 13
        $objWriter->endElement();
360
361 13
        $objWriter->startElement('c:showCatName');
362 13
        $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName();
363 13
        $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1));
364 13
        $objWriter->endElement();
365
366 13
        $objWriter->startElement('c:showSerName');
367 13
        $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName();
368 13
        $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1));
369 13
        $objWriter->endElement();
370
371 13
        $objWriter->startElement('c:showPercent');
372 13
        $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent();
373 13
        $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1));
374 13
        $objWriter->endElement();
375
376 13
        $objWriter->startElement('c:showBubbleSize');
377 13
        $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize();
378 13
        $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1));
379 13
        $objWriter->endElement();
380
381 13
        $objWriter->startElement('c:showLeaderLines');
382 13
        $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines();
383 13
        $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1));
384 13
        $objWriter->endElement();
385
386 13
        $objWriter->endElement();
387 13
    }
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 View Code Duplication
        if ($xAxisLabel !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)) {
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) {
537
            $objWriter->startElement('c:max');
538
            $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum'));
539
            $objWriter->endElement();
540
        }
541
542 12
        if ($xAxis->getAxisOptionsProperty('minimum') !== null) {
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 View Code Duplication
        if ($majorGridlines->getLineColorProperty('value') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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) {
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) {
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 View Code Duplication
        if ($majorGridlines->getGlowSize() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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 View Code Duplication
        if ($majorGridlines->getShadowProperty('presets') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Bug introduced by
'presets' of type string is incompatible with the type array expected by parameter $elements of PhpOffice\PhpSpreadsheet...es::getShadowProperty(). ( Ignorable by Annotation )

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

621
        if ($majorGridlines->getShadowProperty(/** @scrutinizer ignore-type */ 'presets') !== null) {
Loading history...
622
            $objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}");
623
            if ($majorGridlines->getShadowProperty('blur') !== null) {
624
                $objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur'));
625
            }
626
            if ($majorGridlines->getShadowProperty('distance') !== null) {
627
                $objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance'));
628
            }
629
            if ($majorGridlines->getShadowProperty('direction') !== null) {
630
                $objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction'));
631
            }
632
            if ($majorGridlines->getShadowProperty('algn') !== null) {
633
                $objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn'));
634
            }
635
            if ($majorGridlines->getShadowProperty(['size', 'sx']) !== null) {
636
                $objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(['size', 'sx']));
637
            }
638
            if ($majorGridlines->getShadowProperty(['size', 'sy']) !== null) {
639
                $objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(['size', 'sy']));
640
            }
641
            if ($majorGridlines->getShadowProperty(['size', 'kx']) !== null) {
642
                $objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(['size', 'kx']));
643
            }
644
            if ($majorGridlines->getShadowProperty('rotWithShape') !== null) {
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 View Code Duplication
        if ($majorGridlines->getSoftEdgesSize() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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 View Code Duplication
            if ($minorGridlines->getLineColorProperty('value') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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) {
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) {
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 View Code Duplication
            if ($minorGridlines->getGlowSize() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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 View Code Duplication
            if ($minorGridlines->getShadowProperty('presets') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
730
                $objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}");
731
                if ($minorGridlines->getShadowProperty('blur') !== null) {
732
                    $objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur'));
733
                }
734
                if ($minorGridlines->getShadowProperty('distance') !== null) {
735
                    $objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance'));
736
                }
737
                if ($minorGridlines->getShadowProperty('direction') !== null) {
738
                    $objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction'));
739
                }
740
                if ($minorGridlines->getShadowProperty('algn') !== null) {
741
                    $objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn'));
742
                }
743
                if ($minorGridlines->getShadowProperty(['size', 'sx']) !== null) {
744
                    $objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(['size', 'sx']));
745
                }
746
                if ($minorGridlines->getShadowProperty(['size', 'sy']) !== null) {
747
                    $objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(['size', 'sy']));
748
                }
749
                if ($minorGridlines->getShadowProperty(['size', 'kx']) !== null) {
750
                    $objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(['size', 'kx']));
751
                }
752
                if ($minorGridlines->getShadowProperty('rotWithShape') !== null) {
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 View Code Duplication
            if ($minorGridlines->getSoftEdgesSize() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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 View Code Duplication
        if ($yAxisLabel !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)) {
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 View Code Duplication
        if ($xAxis->getFillProperty('value') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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 View Code Duplication
        if ($xAxis->getLineProperty('value') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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) {
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) {
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) {
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 View Code Duplication
        if ($xAxis->getShadowProperty('presets') !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
908
            $objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}");
909
910
            if ($xAxis->getShadowProperty('blur') !== null) {
911
                $objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur'));
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']));
1 ignored issue
show
Bug introduced by
It seems like $xAxis->getShadowProperty(array('size', 'sx')) 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

923
                $objWriter->writeAttribute('sx', /** @scrutinizer ignore-type */ $xAxis->getShadowProperty(['size', 'sx']));
Loading history...
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 View Code Duplication
        if ($xAxis->getSoftEdgesSize() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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) {
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) {
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) {
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 13
    private static function getChartType($plotArea)
1007
    {
1008 13
        $groupCount = $plotArea->getPlotGroupCount();
1009
1010 13
        if ($groupCount == 1) {
1011 12
            $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 13
        return $chartType;
1024
    }
1025
1026
    /**
1027
     * Write Plot Group (series of related plots).
1028
     *
1029
     * @param DataSeries $plotGroup
1030
     * @param string $groupType Type of plot for dataseries
1031
     * @param XMLWriter $objWriter XML Writer
1032
     * @param bool &$catIsMultiLevelSeries Is category a multi-series category
1033
     * @param bool &$valIsMultiLevelSeries Is value set a multi-series set
1034
     * @param string &$plotGroupingType Type of grouping for multi-series values
1035
     *
1036
     * @throws WriterException
1037
     */
1038 13
    private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType)
1039
    {
1040 13
        if ($plotGroup === null) {
1041
            return;
1042
        }
1043
1044 13
        if (($groupType == DataSeries::TYPE_BARCHART) || ($groupType == DataSeries::TYPE_BARCHART_3D)) {
1045 7
            $objWriter->startElement('c:barDir');
1046 7
            $objWriter->writeAttribute('val', $plotGroup->getPlotDirection());
1047 7
            $objWriter->endElement();
1048
        }
1049
1050 13
        if ($plotGroup->getPlotGrouping() !== null) {
1051 9
            $plotGroupingType = $plotGroup->getPlotGrouping();
1052 9
            $objWriter->startElement('c:grouping');
1053 9
            $objWriter->writeAttribute('val', $plotGroupingType);
1054 9
            $objWriter->endElement();
1055
        }
1056
1057
        //    Get these details before the loop, because we can use the count to check for varyColors
1058 13
        $plotSeriesOrder = $plotGroup->getPlotOrder();
1059 13
        $plotSeriesCount = count($plotSeriesOrder);
0 ignored issues
show
Bug introduced by
$plotSeriesOrder of type string is incompatible with the type Countable|array expected by parameter $var of count(). ( Ignorable by Annotation )

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

1059
        $plotSeriesCount = count(/** @scrutinizer ignore-type */ $plotSeriesOrder);
Loading history...
1060
1061 13
        if (($groupType !== DataSeries::TYPE_RADARCHART) && ($groupType !== DataSeries::TYPE_STOCKCHART)) {
1062 11
            if ($groupType !== DataSeries::TYPE_LINECHART) {
1063 10
                if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART) || ($plotSeriesCount > 1)) {
1064 9
                    $objWriter->startElement('c:varyColors');
1065 9
                    $objWriter->writeAttribute('val', 1);
1066 9
                    $objWriter->endElement();
1067
                } else {
1068 2
                    $objWriter->startElement('c:varyColors');
1069 2
                    $objWriter->writeAttribute('val', 0);
1070 2
                    $objWriter->endElement();
1071
                }
1072
            }
1073
        }
1074
1075 13
        foreach ($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) {
0 ignored issues
show
Bug introduced by
The expression $plotSeriesOrder of type string is not traversable.
Loading history...
1076 13
            $objWriter->startElement('c:ser');
1077
1078 13
            $plotLabel = $plotGroup->getPlotLabelByIndex($plotSeriesIdx);
1079 13
            if ($plotLabel) {
1080 13
                $fillColor = $plotLabel->getFillColor();
1081 13
                if ($fillColor !== null) {
1082
                    $objWriter->startElement('c:spPr');
1083
                    $objWriter->startElement('a:solidFill');
1084
                    $objWriter->startElement('a:srgbClr');
1085
                    $objWriter->writeAttribute('val', $fillColor);
1086
                    $objWriter->endElement();
1087
                    $objWriter->endElement();
1088
                    $objWriter->endElement();
1089
                }
1090
            }
1091
1092 13
            $objWriter->startElement('c:idx');
1093 13
            $objWriter->writeAttribute('val', $this->seriesIndex + $plotSeriesIdx);
1094 13
            $objWriter->endElement();
1095
1096 13
            $objWriter->startElement('c:order');
1097 13
            $objWriter->writeAttribute('val', $this->seriesIndex + $plotSeriesRef);
1098 13
            $objWriter->endElement();
1099
1100 13
            if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART)) {
1101 2
                $objWriter->startElement('c:dPt');
1102 2
                $objWriter->startElement('c:idx');
1103 2
                $objWriter->writeAttribute('val', 3);
1104 2
                $objWriter->endElement();
1105
1106 2
                $objWriter->startElement('c:bubble3D');
1107 2
                $objWriter->writeAttribute('val', 0);
1108 2
                $objWriter->endElement();
1109
1110 2
                $objWriter->startElement('c:spPr');
1111 2
                $objWriter->startElement('a:solidFill');
1112 2
                $objWriter->startElement('a:srgbClr');
1113 2
                $objWriter->writeAttribute('val', 'FF9900');
1114 2
                $objWriter->endElement();
1115 2
                $objWriter->endElement();
1116 2
                $objWriter->endElement();
1117 2
                $objWriter->endElement();
1118
            }
1119
1120
            //    Labels
1121 13
            $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
1122 13
            if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
1123 13
                $objWriter->startElement('c:tx');
1124 13
                $objWriter->startElement('c:strRef');
1125 13
                $this->writePlotSeriesLabel($plotSeriesLabel, $objWriter);
1126 13
                $objWriter->endElement();
1127 13
                $objWriter->endElement();
1128
            }
1129
1130
            //    Formatting for the points
1131 13
            if (($groupType == DataSeries::TYPE_LINECHART) || ($groupType == DataSeries::TYPE_STOCKCHART)) {
1132 4
                $objWriter->startElement('c:spPr');
1133 4
                $objWriter->startElement('a:ln');
1134 4
                $objWriter->writeAttribute('w', 12700);
1135 4
                if ($groupType == DataSeries::TYPE_STOCKCHART) {
1136 2
                    $objWriter->startElement('a:noFill');
1137 2
                    $objWriter->endElement();
1138
                }
1139 4
                $objWriter->endElement();
1140 4
                $objWriter->endElement();
1141
            }
1142
1143 13
            $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef);
1144 13
            if ($plotSeriesValues) {
1145 13
                $plotSeriesMarker = $plotSeriesValues->getPointMarker();
1146 13
                if ($plotSeriesMarker) {
1147 1
                    $objWriter->startElement('c:marker');
1148 1
                    $objWriter->startElement('c:symbol');
1149 1
                    $objWriter->writeAttribute('val', $plotSeriesMarker);
1150 1
                    $objWriter->endElement();
1151
1152 1
                    if ($plotSeriesMarker !== 'none') {
1153 1
                        $objWriter->startElement('c:size');
1154 1
                        $objWriter->writeAttribute('val', 3);
1155 1
                        $objWriter->endElement();
1156
                    }
1157
1158 1
                    $objWriter->endElement();
1159
                }
1160
            }
1161
1162 13
            if (($groupType === DataSeries::TYPE_BARCHART) || ($groupType === DataSeries::TYPE_BARCHART_3D) || ($groupType === DataSeries::TYPE_BUBBLECHART)) {
1163 7
                $objWriter->startElement('c:invertIfNegative');
1164 7
                $objWriter->writeAttribute('val', 0);
1165 7
                $objWriter->endElement();
1166
            }
1167
1168
            //    Category Labels
1169 13
            $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
1170 13
            if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
1171 13
                $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
1172
1173 13
                if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART)) {
1174 2
                    if ($plotGroup->getPlotStyle() !== null) {
1175 1
                        $plotStyle = $plotGroup->getPlotStyle();
1176 1
                        if ($plotStyle) {
1177 1
                            $objWriter->startElement('c:explosion');
1178 1
                            $objWriter->writeAttribute('val', 25);
1179 1
                            $objWriter->endElement();
1180
                        }
1181
                    }
1182
                }
1183
1184 13
                if (($groupType === DataSeries::TYPE_BUBBLECHART) || ($groupType === DataSeries::TYPE_SCATTERCHART)) {
1185 2
                    $objWriter->startElement('c:xVal');
1186
                } else {
1187 12
                    $objWriter->startElement('c:cat');
1188
                }
1189
1190 13
                $this->writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str');
1191 13
                $objWriter->endElement();
1192
            }
1193
1194
            //    Values
1195 13
            if ($plotSeriesValues) {
1196 13
                $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
1197
1198 13
                if (($groupType === DataSeries::TYPE_BUBBLECHART) || ($groupType === DataSeries::TYPE_SCATTERCHART)) {
1199 2
                    $objWriter->startElement('c:yVal');
1200
                } else {
1201 12
                    $objWriter->startElement('c:val');
1202
                }
1203
1204 13
                $this->writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num');
1205 13
                $objWriter->endElement();
1206
            }
1207
1208 13
            if ($groupType === DataSeries::TYPE_BUBBLECHART) {
1209 1
                $this->writeBubbles($plotSeriesValues, $objWriter);
1210
            }
1211
1212 13
            $objWriter->endElement();
1213
        }
1214
1215 13
        $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 1075. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
1216 13
    }
1217
1218
    /**
1219
     * Write Plot Series Label.
1220
     *
1221
     * @param DataSeriesValues $plotSeriesLabel
1222
     * @param XMLWriter $objWriter XML Writer
1223
     *
1224
     * @throws WriterException
1225
     */
1226 13
    private function writePlotSeriesLabel($plotSeriesLabel, $objWriter)
1227
    {
1228 13
        if ($plotSeriesLabel === null) {
1229
            return;
1230
        }
1231
1232 13
        $objWriter->startElement('c:f');
1233 13
        $objWriter->writeRawData($plotSeriesLabel->getDataSource());
1234 13
        $objWriter->endElement();
1235
1236 13
        $objWriter->startElement('c:strCache');
1237 13
        $objWriter->startElement('c:ptCount');
1238 13
        $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount());
1239 13
        $objWriter->endElement();
1240
1241 13
        foreach ($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) {
1242 13
            $objWriter->startElement('c:pt');
1243 13
            $objWriter->writeAttribute('idx', $plotLabelKey);
1244
1245 13
            $objWriter->startElement('c:v');
1246 13
            $objWriter->writeRawData($plotLabelValue);
1247 13
            $objWriter->endElement();
1248 13
            $objWriter->endElement();
1249
        }
1250 13
        $objWriter->endElement();
1251 13
    }
1252
1253
    /**
1254
     * Write Plot Series Values.
1255
     *
1256
     * @param DataSeriesValues $plotSeriesValues
1257
     * @param XMLWriter $objWriter XML Writer
1258
     * @param string $groupType Type of plot for dataseries
1259
     * @param string $dataType Datatype of series values
1260
     *
1261
     * @throws WriterException
1262
     */
1263 13
    private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str')
1264
    {
1265 13
        if ($plotSeriesValues === null) {
1266
            return;
1267
        }
1268
1269 13
        if ($plotSeriesValues->isMultiLevelSeries()) {
1270 2
            $levelCount = $plotSeriesValues->multiLevelCount();
1271
1272 2
            $objWriter->startElement('c:multiLvlStrRef');
1273
1274 2
            $objWriter->startElement('c:f');
1275 2
            $objWriter->writeRawData($plotSeriesValues->getDataSource());
1276 2
            $objWriter->endElement();
1277
1278 2
            $objWriter->startElement('c:multiLvlStrCache');
1279
1280 2
            $objWriter->startElement('c:ptCount');
1281 2
            $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1282 2
            $objWriter->endElement();
1283
1284 2
            for ($level = 0; $level < $levelCount; ++$level) {
1285 2
                $objWriter->startElement('c:lvl');
1286
1287 2
                foreach ($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
1288 2
                    if (isset($plotSeriesValue[$level])) {
1289 2
                        $objWriter->startElement('c:pt');
1290 2
                        $objWriter->writeAttribute('idx', $plotSeriesKey);
1291
1292 2
                        $objWriter->startElement('c:v');
1293 2
                        $objWriter->writeRawData($plotSeriesValue[$level]);
1294 2
                        $objWriter->endElement();
1295 2
                        $objWriter->endElement();
1296
                    }
1297
                }
1298
1299 2
                $objWriter->endElement();
1300
            }
1301
1302 2
            $objWriter->endElement();
1303
1304 2
            $objWriter->endElement();
1305
        } else {
1306 13
            $objWriter->startElement('c:' . $dataType . 'Ref');
1307
1308 13
            $objWriter->startElement('c:f');
1309 13
            $objWriter->writeRawData($plotSeriesValues->getDataSource());
1310 13
            $objWriter->endElement();
1311
1312 13
            $objWriter->startElement('c:' . $dataType . 'Cache');
1313
1314 13
            if (($groupType != DataSeries::TYPE_PIECHART) && ($groupType != DataSeries::TYPE_PIECHART_3D) && ($groupType != DataSeries::TYPE_DONUTCHART)) {
1315 12
                if (($plotSeriesValues->getFormatCode() !== null) && ($plotSeriesValues->getFormatCode() !== '')) {
1316 1
                    $objWriter->startElement('c:formatCode');
1317 1
                    $objWriter->writeRawData($plotSeriesValues->getFormatCode());
1318 1
                    $objWriter->endElement();
1319
                }
1320
            }
1321
1322 13
            $objWriter->startElement('c:ptCount');
1323 13
            $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1324 13
            $objWriter->endElement();
1325
1326 13
            $dataValues = $plotSeriesValues->getDataValues();
1327 13
            if (!empty($dataValues)) {
1328 13
                if (is_array($dataValues)) {
1329 13
                    foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1330 13
                        $objWriter->startElement('c:pt');
1331 13
                        $objWriter->writeAttribute('idx', $plotSeriesKey);
1332
1333 13
                        $objWriter->startElement('c:v');
1334 13
                        $objWriter->writeRawData($plotSeriesValue);
1335 13
                        $objWriter->endElement();
1336 13
                        $objWriter->endElement();
1337
                    }
1338
                }
1339
            }
1340
1341 13
            $objWriter->endElement();
1342
1343 13
            $objWriter->endElement();
1344
        }
1345 13
    }
1346
1347
    /**
1348
     * Write Bubble Chart Details.
1349
     *
1350
     * @param DataSeriesValues $plotSeriesValues
1351
     * @param XMLWriter $objWriter XML Writer
1352
     *
1353
     * @throws WriterException
1354
     */
1355 1
    private function writeBubbles($plotSeriesValues, $objWriter)
1356
    {
1357 1
        if ($plotSeriesValues === null) {
1358
            return;
1359
        }
1360
1361 1
        $objWriter->startElement('c:bubbleSize');
1362 1
        $objWriter->startElement('c:numLit');
1363
1364 1
        $objWriter->startElement('c:formatCode');
1365 1
        $objWriter->writeRawData('General');
1366 1
        $objWriter->endElement();
1367
1368 1
        $objWriter->startElement('c:ptCount');
1369 1
        $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1370 1
        $objWriter->endElement();
1371
1372 1
        $dataValues = $plotSeriesValues->getDataValues();
1373 1
        if (!empty($dataValues)) {
1374 1
            if (is_array($dataValues)) {
1375 1
                foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1376 1
                    $objWriter->startElement('c:pt');
1377 1
                    $objWriter->writeAttribute('idx', $plotSeriesKey);
1378 1
                    $objWriter->startElement('c:v');
1379 1
                    $objWriter->writeRawData(1);
1380 1
                    $objWriter->endElement();
1381 1
                    $objWriter->endElement();
1382
                }
1383
            }
1384
        }
1385
1386 1
        $objWriter->endElement();
1387 1
        $objWriter->endElement();
1388
1389 1
        $objWriter->startElement('c:bubble3D');
1390 1
        $objWriter->writeAttribute('val', 0);
1391 1
        $objWriter->endElement();
1392 1
    }
1393
1394
    /**
1395
     * Write Layout.
1396
     *
1397
     * @param XMLWriter $objWriter XML Writer
1398
     * @param Layout $layout
1399
     *
1400
     * @throws WriterException
1401
     */
1402 13
    private function writeLayout(XMLWriter $objWriter, Layout $layout = null)
1403
    {
1404 13
        $objWriter->startElement('c:layout');
1405
1406 13
        if ($layout !== null) {
1407 3
            $objWriter->startElement('c:manualLayout');
1408
1409 3
            $layoutTarget = $layout->getLayoutTarget();
1410 3
            if ($layoutTarget !== null) {
1411 1
                $objWriter->startElement('c:layoutTarget');
1412 1
                $objWriter->writeAttribute('val', $layoutTarget);
1413 1
                $objWriter->endElement();
1414
            }
1415
1416 3
            $xMode = $layout->getXMode();
1417 3
            if ($xMode !== null) {
1418 1
                $objWriter->startElement('c:xMode');
1419 1
                $objWriter->writeAttribute('val', $xMode);
1420 1
                $objWriter->endElement();
1421
            }
1422
1423 3
            $yMode = $layout->getYMode();
1424 3
            if ($yMode !== null) {
1425 1
                $objWriter->startElement('c:yMode');
1426 1
                $objWriter->writeAttribute('val', $yMode);
1427 1
                $objWriter->endElement();
1428
            }
1429
1430 3
            $x = $layout->getXPosition();
1431 3
            if ($x !== null) {
1432 1
                $objWriter->startElement('c:x');
1433 1
                $objWriter->writeAttribute('val', $x);
1434 1
                $objWriter->endElement();
1435
            }
1436
1437 3
            $y = $layout->getYPosition();
1438 3
            if ($y !== null) {
1439 1
                $objWriter->startElement('c:y');
1440 1
                $objWriter->writeAttribute('val', $y);
1441 1
                $objWriter->endElement();
1442
            }
1443
1444 3
            $w = $layout->getWidth();
1445 3
            if ($w !== null) {
1446 1
                $objWriter->startElement('c:w');
1447 1
                $objWriter->writeAttribute('val', $w);
1448 1
                $objWriter->endElement();
1449
            }
1450
1451 3
            $h = $layout->getHeight();
1452 3
            if ($h !== null) {
1453 1
                $objWriter->startElement('c:h');
1454 1
                $objWriter->writeAttribute('val', $h);
1455 1
                $objWriter->endElement();
1456
            }
1457
1458 3
            $objWriter->endElement();
1459
        }
1460
1461 13
        $objWriter->endElement();
1462 13
    }
1463
1464
    /**
1465
     * Write Alternate Content block.
1466
     *
1467
     * @param XMLWriter $objWriter XML Writer
1468
     *
1469
     * @throws WriterException
1470
     */
1471 13
    private function writeAlternateContent($objWriter)
1472
    {
1473 13
        $objWriter->startElement('mc:AlternateContent');
1474 13
        $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
1475
1476 13
        $objWriter->startElement('mc:Choice');
1477 13
        $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart');
1478 13
        $objWriter->writeAttribute('Requires', 'c14');
1479
1480 13
        $objWriter->startElement('c14:style');
1481 13
        $objWriter->writeAttribute('val', '102');
1482 13
        $objWriter->endElement();
1483 13
        $objWriter->endElement();
1484
1485 13
        $objWriter->startElement('mc:Fallback');
1486 13
        $objWriter->startElement('c:style');
1487 13
        $objWriter->writeAttribute('val', '2');
1488 13
        $objWriter->endElement();
1489 13
        $objWriter->endElement();
1490
1491 13
        $objWriter->endElement();
1492 13
    }
1493
1494
    /**
1495
     * Write Printer Settings.
1496
     *
1497
     * @param XMLWriter $objWriter XML Writer
1498
     *
1499
     * @throws WriterException
1500
     */
1501 13
    private function writePrintSettings($objWriter)
1502
    {
1503 13
        $objWriter->startElement('c:printSettings');
1504
1505 13
        $objWriter->startElement('c:headerFooter');
1506 13
        $objWriter->endElement();
1507
1508 13
        $objWriter->startElement('c:pageMargins');
1509 13
        $objWriter->writeAttribute('footer', 0.3);
1510 13
        $objWriter->writeAttribute('header', 0.3);
1511 13
        $objWriter->writeAttribute('r', 0.7);
1512 13
        $objWriter->writeAttribute('l', 0.7);
1513 13
        $objWriter->writeAttribute('t', 0.75);
1514 13
        $objWriter->writeAttribute('b', 0.75);
1515 13
        $objWriter->endElement();
1516
1517 13
        $objWriter->startElement('c:pageSetup');
1518 13
        $objWriter->writeAttribute('orientation', 'portrait');
1519 13
        $objWriter->endElement();
1520
1521 13
        $objWriter->endElement();
1522 13
    }
1523
}
1524