ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Chart.php
Go to the documentation of this file.
1 <?php
37 
46  public function writeChart(PHPExcel_Chart $pChart = NULL) {
47  // Create XML writer
48  $objWriter = NULL;
49  if ($this->getParentWriter()
50  ->getUseDiskCaching()
51  ) {
53  ->getDiskCachingDirectory());
54  } else {
56  }
57  // Ensure that data series values are up-to-date before we save
58  $pChart->refresh();
59 
60  // XML header
61  $objWriter->startDocument('1.0', 'UTF-8', 'yes');
62 
63  // c:chartSpace
64  $objWriter->startElement('c:chartSpace');
65  $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
66  $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
67  $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
68 
69  $objWriter->startElement('c:date1904');
70  $objWriter->writeAttribute('val', 0);
71  $objWriter->endElement();
72  $objWriter->startElement('c:lang');
73  $objWriter->writeAttribute('val', "en-GB");
74  $objWriter->endElement();
75  $objWriter->startElement('c:roundedCorners');
76  $objWriter->writeAttribute('val', 0);
77  $objWriter->endElement();
78 
80 
81  $objWriter->startElement('c:chart');
82 
83  $this->_writeTitle($pChart->getTitle(), $objWriter);
84 
85  $objWriter->startElement('c:autoTitleDeleted');
86  $objWriter->writeAttribute('val', 0);
87  $objWriter->endElement();
88 
89  $this->_writePlotArea(
90  $pChart->getPlotArea(),
91  $pChart->getXAxisLabel(),
92  $pChart->getYAxisLabel(),
93  $objWriter,
94  $pChart->getWorksheet(),
95  $pChart->getChartAxisX(),
96  $pChart->getChartAxisY(),
97  $pChart->getMajorGridlines(),
98  $pChart->getMinorGridlines()
99  );
100 
101  $this->_writeLegend($pChart->getLegend(), $objWriter);
102 
103  $objWriter->startElement('c:plotVisOnly');
104  $objWriter->writeAttribute('val', 1);
105  $objWriter->endElement();
106 
107  $objWriter->startElement('c:dispBlanksAs');
108  $objWriter->writeAttribute('val', "gap");
109  $objWriter->endElement();
110 
111  $objWriter->startElement('c:showDLblsOverMax');
112  $objWriter->writeAttribute('val', 0);
113  $objWriter->endElement();
114 
115  $objWriter->endElement();
116 
118 
119  $objWriter->endElement();
120 
121  // Return
122  return $objWriter->getData();
123  }
124 
133  private function _writeTitle(PHPExcel_Chart_Title $title = NULL, $objWriter) {
134  if (is_null($title)) {
135  return;
136  }
137 
138  $objWriter->startElement('c:title');
139  $objWriter->startElement('c:tx');
140  $objWriter->startElement('c:rich');
141 
142  $objWriter->startElement('a:bodyPr');
143  $objWriter->endElement();
144 
145  $objWriter->startElement('a:lstStyle');
146  $objWriter->endElement();
147 
148  $objWriter->startElement('a:p');
149 
150  $caption = $title->getCaption();
151  if ((is_array($caption)) && (count($caption) > 0)) {
152  $caption = $caption[0];
153  }
154  $this->getParentWriter()
155  ->getWriterPart('stringtable')
156  ->writeRichTextForCharts($objWriter, $caption, 'a');
157 
158  $objWriter->endElement();
159  $objWriter->endElement();
160  $objWriter->endElement();
161 
162  $layout = $title->getLayout();
164 
165  $objWriter->startElement('c:overlay');
166  $objWriter->writeAttribute('val', 0);
167  $objWriter->endElement();
168 
169  $objWriter->endElement();
170  }
171 
181  if (is_null($legend)) {
182  return;
183  }
184 
185  $objWriter->startElement('c:legend');
186 
187  $objWriter->startElement('c:legendPos');
188  $objWriter->writeAttribute('val', $legend->getPosition());
189  $objWriter->endElement();
190 
191  $layout = $legend->getLayout();
193 
194  $objWriter->startElement('c:overlay');
195  $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
196  $objWriter->endElement();
197 
198  $objWriter->startElement('c:txPr');
199  $objWriter->startElement('a:bodyPr');
200  $objWriter->endElement();
201 
202  $objWriter->startElement('a:lstStyle');
203  $objWriter->endElement();
204 
205  $objWriter->startElement('a:p');
206  $objWriter->startElement('a:pPr');
207  $objWriter->writeAttribute('rtl', 0);
208 
209  $objWriter->startElement('a:defRPr');
210  $objWriter->endElement();
211  $objWriter->endElement();
212 
213  $objWriter->startElement('a:endParaRPr');
214  $objWriter->writeAttribute('lang', "en-US");
215  $objWriter->endElement();
216 
217  $objWriter->endElement();
218  $objWriter->endElement();
219 
220  $objWriter->endElement();
221  }
222 
238  $objWriter,
239  PHPExcel_Worksheet $pSheet,
240  PHPExcel_Chart_Axis $xAxis,
241  PHPExcel_Chart_Axis $yAxis,
242  PHPExcel_Chart_GridLines $majorGridlines,
243  PHPExcel_Chart_GridLines $minorGridlines
244  ) {
245  if (is_null($plotArea)) {
246  return;
247  }
248 
249  $id1 = $id2 = 0;
250  $this->_seriesIndex = 0;
251  $objWriter->startElement('c:plotArea');
252 
253  $layout = $plotArea->getLayout();
254 
256 
257  $chartTypes = self::_getChartType($plotArea);
258  $catIsMultiLevelSeries = $valIsMultiLevelSeries = FALSE;
259  $plotGroupingType = '';
260  foreach ($chartTypes as $chartType) {
261  $objWriter->startElement('c:' . $chartType);
262 
263  $groupCount = $plotArea->getPlotGroupCount();
264  for ($i = 0; $i < $groupCount; ++$i) {
265  $plotGroup = $plotArea->getPlotGroupByIndex($i);
266  $groupType = $plotGroup->getPlotType();
267  if ($groupType == $chartType) {
268 
269  $plotStyle = $plotGroup->getPlotStyle();
270  if ($groupType === PHPExcel_Chart_DataSeries::TYPE_RADARCHART) {
271  $objWriter->startElement('c:radarStyle');
272  $objWriter->writeAttribute('val', $plotStyle);
273  $objWriter->endElement();
274  } elseif ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) {
275  $objWriter->startElement('c:scatterStyle');
276  $objWriter->writeAttribute('val', $plotStyle);
277  $objWriter->endElement();
278  }
279 
280  $this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet);
281  }
282  }
283 
285 
286  if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
287  // Line only, Line3D can't be smoothed
288 
289  $objWriter->startElement('c:smooth');
290  $objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine());
291  $objWriter->endElement();
292  } elseif (($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
294  ) {
295 
296  $objWriter->startElement('c:gapWidth');
297  $objWriter->writeAttribute('val', 150);
298  $objWriter->endElement();
299 
300  if ($plotGroupingType == 'percentStacked' ||
301  $plotGroupingType == 'stacked'
302  ) {
303 
304  $objWriter->startElement('c:overlap');
305  $objWriter->writeAttribute('val', 100);
306  $objWriter->endElement();
307  }
308  } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
309 
310  $objWriter->startElement('c:bubbleScale');
311  $objWriter->writeAttribute('val', 25);
312  $objWriter->endElement();
313 
314  $objWriter->startElement('c:showNegBubbles');
315  $objWriter->writeAttribute('val', 0);
316  $objWriter->endElement();
317  } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) {
318 
319  $objWriter->startElement('c:hiLowLines');
320  $objWriter->endElement();
321 
322  $objWriter->startElement('c:upDownBars');
323 
324  $objWriter->startElement('c:gapWidth');
325  $objWriter->writeAttribute('val', 300);
326  $objWriter->endElement();
327 
328  $objWriter->startElement('c:upBars');
329  $objWriter->endElement();
330 
331  $objWriter->startElement('c:downBars');
332  $objWriter->endElement();
333 
334  $objWriter->endElement();
335  }
336 
337  // Generate 2 unique numbers to use for axId values
338  // $id1 = $id2 = rand(10000000,99999999);
339  // do {
340  // $id2 = rand(10000000,99999999);
341  // } while ($id1 == $id2);
342  $id1 = '75091328';
343  $id2 = '75089408';
344 
345  if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
348  ) {
349 
350  $objWriter->startElement('c:axId');
351  $objWriter->writeAttribute('val', $id1);
352  $objWriter->endElement();
353  $objWriter->startElement('c:axId');
354  $objWriter->writeAttribute('val', $id2);
355  $objWriter->endElement();
356  } else {
357  $objWriter->startElement('c:firstSliceAng');
358  $objWriter->writeAttribute('val', 0);
359  $objWriter->endElement();
360 
361  if ($chartType === PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
362 
363  $objWriter->startElement('c:holeSize');
364  $objWriter->writeAttribute('val', 50);
365  $objWriter->endElement();
366  }
367  }
368 
369  $objWriter->endElement();
370  }
371 
372  if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
375  ) {
376 
377  if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
378  $this->_writeValAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
379  } else {
380  $this->_writeCatAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis);
381  }
382 
383  $this->_writeValAx($objWriter, $plotArea, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
384  }
385 
386  $objWriter->endElement();
387  }
388 
397  private function _writeDataLbls($objWriter, $chartLayout) {
398  $objWriter->startElement('c:dLbls');
399 
400  $objWriter->startElement('c:showLegendKey');
401  $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey();
402  $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1));
403  $objWriter->endElement();
404 
405  $objWriter->startElement('c:showVal');
406  $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
407  $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1));
408  $objWriter->endElement();
409 
410  $objWriter->startElement('c:showCatName');
411  $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName();
412  $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1));
413  $objWriter->endElement();
414 
415  $objWriter->startElement('c:showSerName');
416  $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName();
417  $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1));
418  $objWriter->endElement();
419 
420  $objWriter->startElement('c:showPercent');
421  $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent();
422  $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1));
423  $objWriter->endElement();
424 
425  $objWriter->startElement('c:showBubbleSize');
426  $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize();
427  $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1));
428  $objWriter->endElement();
429 
430  $objWriter->startElement('c:showLeaderLines');
431  $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines();
432  $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1));
433  $objWriter->endElement();
434 
435  $objWriter->endElement();
436  }
437 
451  private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) {
452  $objWriter->startElement('c:catAx');
453 
454  if ($id1 > 0) {
455  $objWriter->startElement('c:axId');
456  $objWriter->writeAttribute('val', $id1);
457  $objWriter->endElement();
458  }
459 
460  $objWriter->startElement('c:scaling');
461  $objWriter->startElement('c:orientation');
462  $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('orientation'));
463  $objWriter->endElement();
464  $objWriter->endElement();
465 
466  $objWriter->startElement('c:delete');
467  $objWriter->writeAttribute('val', 0);
468  $objWriter->endElement();
469 
470  $objWriter->startElement('c:axPos');
471  $objWriter->writeAttribute('val', "b");
472  $objWriter->endElement();
473 
474  if (!is_null($xAxisLabel)) {
475  $objWriter->startElement('c:title');
476  $objWriter->startElement('c:tx');
477  $objWriter->startElement('c:rich');
478 
479  $objWriter->startElement('a:bodyPr');
480  $objWriter->endElement();
481 
482  $objWriter->startElement('a:lstStyle');
483  $objWriter->endElement();
484 
485  $objWriter->startElement('a:p');
486  $objWriter->startElement('a:r');
487 
488  $caption = $xAxisLabel->getCaption();
489  if (is_array($caption)) {
490  $caption = $caption[0];
491  }
492  $objWriter->startElement('a:t');
493  // $objWriter->writeAttribute('xml:space', 'preserve');
495  $objWriter->endElement();
496 
497  $objWriter->endElement();
498  $objWriter->endElement();
499  $objWriter->endElement();
500  $objWriter->endElement();
501 
502  $layout = $xAxisLabel->getLayout();
504 
505  $objWriter->startElement('c:overlay');
506  $objWriter->writeAttribute('val', 0);
507  $objWriter->endElement();
508 
509  $objWriter->endElement();
510 
511  }
512 
513  $objWriter->startElement('c:numFmt');
514  $objWriter->writeAttribute('formatCode', $yAxis->getAxisNumberFormat());
515  $objWriter->writeAttribute('sourceLinked', $yAxis->getAxisNumberSourceLinked());
516  $objWriter->endElement();
517 
518  $objWriter->startElement('c:majorTickMark');
519  $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('major_tick_mark'));
520  $objWriter->endElement();
521 
522  $objWriter->startElement('c:minorTickMark');
523  $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('minor_tick_mark'));
524  $objWriter->endElement();
525 
526  $objWriter->startElement('c:tickLblPos');
527  $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('axis_labels'));
528  $objWriter->endElement();
529 
530  if ($id2 > 0) {
531  $objWriter->startElement('c:crossAx');
532  $objWriter->writeAttribute('val', $id2);
533  $objWriter->endElement();
534 
535  $objWriter->startElement('c:crosses');
536  $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('horizontal_crosses'));
537  $objWriter->endElement();
538  }
539 
540  $objWriter->startElement('c:auto');
541  $objWriter->writeAttribute('val', 1);
542  $objWriter->endElement();
543 
544  $objWriter->startElement('c:lblAlgn');
545  $objWriter->writeAttribute('val', "ctr");
546  $objWriter->endElement();
547 
548  $objWriter->startElement('c:lblOffset');
549  $objWriter->writeAttribute('val', 100);
550  $objWriter->endElement();
551 
552  if ($isMultiLevelSeries) {
553  $objWriter->startElement('c:noMultiLvlLbl');
554  $objWriter->writeAttribute('val', 0);
555  $objWriter->endElement();
556  }
557  $objWriter->endElement();
558  }
559 
573  private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) {
574  $objWriter->startElement('c:valAx');
575 
576  if ($id2 > 0) {
577  $objWriter->startElement('c:axId');
578  $objWriter->writeAttribute('val', $id2);
579  $objWriter->endElement();
580  }
581 
582  $objWriter->startElement('c:scaling');
583  $objWriter->startElement('c:orientation');
584  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('orientation'));
585 
586  if (!is_null($xAxis->getAxisOptionsProperty('maximum'))) {
587  $objWriter->startElement('c:max');
588  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum'));
589  $objWriter->endElement();
590  }
591 
592  if (!is_null($xAxis->getAxisOptionsProperty('minimum'))) {
593  $objWriter->startElement('c:min');
594  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minimum'));
595  $objWriter->endElement();
596  }
597 
598  $objWriter->endElement();
599  $objWriter->endElement();
600 
601  $objWriter->startElement('c:delete');
602  $objWriter->writeAttribute('val', 0);
603  $objWriter->endElement();
604 
605  $objWriter->startElement('c:axPos');
606  $objWriter->writeAttribute('val', "l");
607  $objWriter->endElement();
608 
609  $objWriter->startElement('c:majorGridlines');
610  $objWriter->startElement('c:spPr');
611 
612  if (!is_null($majorGridlines->getLineColorProperty('value'))) {
613  $objWriter->startElement('a:ln');
614  $objWriter->writeAttribute('w', $majorGridlines->getLineStyleProperty('width'));
615  $objWriter->startElement('a:solidFill');
616  $objWriter->startElement("a:{$majorGridlines->getLineColorProperty('type')}");
617  $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('value'));
618  $objWriter->startElement('a:alpha');
619  $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('alpha'));
620  $objWriter->endElement(); //end alpha
621  $objWriter->endElement(); //end srgbClr
622  $objWriter->endElement(); //end solidFill
623 
624  $objWriter->startElement('a:prstDash');
625  $objWriter->writeAttribute('val', $majorGridlines->getLineStyleProperty('dash'));
626  $objWriter->endElement();
627 
628  if ($majorGridlines->getLineStyleProperty('join') == 'miter') {
629  $objWriter->startElement('a:miter');
630  $objWriter->writeAttribute('lim', '800000');
631  $objWriter->endElement();
632  } else {
633  $objWriter->startElement('a:bevel');
634  $objWriter->endElement();
635  }
636 
637  if (!is_null($majorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')))) {
638  $objWriter->startElement('a:headEnd');
639  $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')));
640  $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('head', 'w'));
641  $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('head', 'len'));
642  $objWriter->endElement();
643  }
644 
645  if (!is_null($majorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')))) {
646  $objWriter->startElement('a:tailEnd');
647  $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')));
648  $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('end', 'w'));
649  $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('end', 'len'));
650  $objWriter->endElement();
651  }
652  $objWriter->endElement(); //end ln
653  }
654  $objWriter->startElement('a:effectLst');
655 
656  if (!is_null($majorGridlines->getGlowSize())) {
657  $objWriter->startElement('a:glow');
658  $objWriter->writeAttribute('rad', $majorGridlines->getGlowSize());
659  $objWriter->startElement("a:{$majorGridlines->getGlowColor('type')}");
660  $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('value'));
661  $objWriter->startElement('a:alpha');
662  $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('alpha'));
663  $objWriter->endElement(); //end alpha
664  $objWriter->endElement(); //end schemeClr
665  $objWriter->endElement(); //end glow
666  }
667 
668  if (!is_null($majorGridlines->getShadowProperty('presets'))) {
669  $objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}");
670  if (!is_null($majorGridlines->getShadowProperty('blur'))) {
671  $objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur'));
672  }
673  if (!is_null($majorGridlines->getShadowProperty('distance'))) {
674  $objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance'));
675  }
676  if (!is_null($majorGridlines->getShadowProperty('direction'))) {
677  $objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction'));
678  }
679  if (!is_null($majorGridlines->getShadowProperty('algn'))) {
680  $objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn'));
681  }
682  if (!is_null($majorGridlines->getShadowProperty(array('size', 'sx')))) {
683  $objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(array('size', 'sx')));
684  }
685  if (!is_null($majorGridlines->getShadowProperty(array('size', 'sy')))) {
686  $objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(array('size', 'sy')));
687  }
688  if (!is_null($majorGridlines->getShadowProperty(array('size', 'kx')))) {
689  $objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(array('size', 'kx')));
690  }
691  if (!is_null($majorGridlines->getShadowProperty('rotWithShape'))) {
692  $objWriter->writeAttribute('rotWithShape', $majorGridlines->getShadowProperty('rotWithShape'));
693  }
694  $objWriter->startElement("a:{$majorGridlines->getShadowProperty(array('color', 'type'))}");
695  $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(array('color', 'value')));
696 
697  $objWriter->startElement('a:alpha');
698  $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(array('color', 'alpha')));
699  $objWriter->endElement(); //end alpha
700 
701  $objWriter->endElement(); //end color:type
702  $objWriter->endElement(); //end shadow
703  }
704 
705  if (!is_null($majorGridlines->getSoftEdgesSize())) {
706  $objWriter->startElement('a:softEdge');
707  $objWriter->writeAttribute('rad', $majorGridlines->getSoftEdgesSize());
708  $objWriter->endElement(); //end softEdge
709  }
710 
711  $objWriter->endElement(); //end effectLst
712  $objWriter->endElement(); //end spPr
713  $objWriter->endElement(); //end majorGridLines
714 
715  if ($minorGridlines->getObjectState()) {
716  $objWriter->startElement('c:minorGridlines');
717  $objWriter->startElement('c:spPr');
718 
719  if (!is_null($minorGridlines->getLineColorProperty('value'))) {
720  $objWriter->startElement('a:ln');
721  $objWriter->writeAttribute('w', $minorGridlines->getLineStyleProperty('width'));
722  $objWriter->startElement('a:solidFill');
723  $objWriter->startElement("a:{$minorGridlines->getLineColorProperty('type')}");
724  $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('value'));
725  $objWriter->startElement('a:alpha');
726  $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('alpha'));
727  $objWriter->endElement(); //end alpha
728  $objWriter->endElement(); //end srgbClr
729  $objWriter->endElement(); //end solidFill
730 
731  $objWriter->startElement('a:prstDash');
732  $objWriter->writeAttribute('val', $minorGridlines->getLineStyleProperty('dash'));
733  $objWriter->endElement();
734 
735  if ($minorGridlines->getLineStyleProperty('join') == 'miter') {
736  $objWriter->startElement('a:miter');
737  $objWriter->writeAttribute('lim', '800000');
738  $objWriter->endElement();
739  } else {
740  $objWriter->startElement('a:bevel');
741  $objWriter->endElement();
742  }
743 
744  if (!is_null($minorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')))) {
745  $objWriter->startElement('a:headEnd');
746  $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')));
747  $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('head', 'w'));
748  $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('head', 'len'));
749  $objWriter->endElement();
750  }
751 
752  if (!is_null($minorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')))) {
753  $objWriter->startElement('a:tailEnd');
754  $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')));
755  $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('end', 'w'));
756  $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('end', 'len'));
757  $objWriter->endElement();
758  }
759  $objWriter->endElement(); //end ln
760  }
761 
762  $objWriter->startElement('a:effectLst');
763 
764  if (!is_null($minorGridlines->getGlowSize())) {
765  $objWriter->startElement('a:glow');
766  $objWriter->writeAttribute('rad', $minorGridlines->getGlowSize());
767  $objWriter->startElement("a:{$minorGridlines->getGlowColor('type')}");
768  $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('value'));
769  $objWriter->startElement('a:alpha');
770  $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('alpha'));
771  $objWriter->endElement(); //end alpha
772  $objWriter->endElement(); //end schemeClr
773  $objWriter->endElement(); //end glow
774  }
775 
776  if (!is_null($minorGridlines->getShadowProperty('presets'))) {
777  $objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}");
778  if (!is_null($minorGridlines->getShadowProperty('blur'))) {
779  $objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur'));
780  }
781  if (!is_null($minorGridlines->getShadowProperty('distance'))) {
782  $objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance'));
783  }
784  if (!is_null($minorGridlines->getShadowProperty('direction'))) {
785  $objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction'));
786  }
787  if (!is_null($minorGridlines->getShadowProperty('algn'))) {
788  $objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn'));
789  }
790  if (!is_null($minorGridlines->getShadowProperty(array('size', 'sx')))) {
791  $objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(array('size', 'sx')));
792  }
793  if (!is_null($minorGridlines->getShadowProperty(array('size', 'sy')))) {
794  $objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(array('size', 'sy')));
795  }
796  if (!is_null($minorGridlines->getShadowProperty(array('size', 'kx')))) {
797  $objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(array('size', 'kx')));
798  }
799  if (!is_null($minorGridlines->getShadowProperty('rotWithShape'))) {
800  $objWriter->writeAttribute('rotWithShape', $minorGridlines->getShadowProperty('rotWithShape'));
801  }
802  $objWriter->startElement("a:{$minorGridlines->getShadowProperty(array('color', 'type'))}");
803  $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(array('color', 'value')));
804  $objWriter->startElement('a:alpha');
805  $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(array('color', 'alpha')));
806  $objWriter->endElement(); //end alpha
807  $objWriter->endElement(); //end color:type
808  $objWriter->endElement(); //end shadow
809  }
810 
811  if (!is_null($minorGridlines->getSoftEdgesSize())) {
812  $objWriter->startElement('a:softEdge');
813  $objWriter->writeAttribute('rad', $minorGridlines->getSoftEdgesSize());
814  $objWriter->endElement(); //end softEdge
815  }
816 
817  $objWriter->endElement(); //end effectLst
818  $objWriter->endElement(); //end spPr
819  $objWriter->endElement(); //end minorGridLines
820  }
821 
822  if (!is_null($yAxisLabel)) {
823 
824  $objWriter->startElement('c:title');
825  $objWriter->startElement('c:tx');
826  $objWriter->startElement('c:rich');
827 
828  $objWriter->startElement('a:bodyPr');
829  $objWriter->endElement();
830 
831  $objWriter->startElement('a:lstStyle');
832  $objWriter->endElement();
833 
834  $objWriter->startElement('a:p');
835  $objWriter->startElement('a:r');
836 
837  $caption = $yAxisLabel->getCaption();
838  if (is_array($caption)) {
839  $caption = $caption[0];
840  }
841 
842  $objWriter->startElement('a:t');
843  // $objWriter->writeAttribute('xml:space', 'preserve');
845  $objWriter->endElement();
846 
847  $objWriter->endElement();
848  $objWriter->endElement();
849  $objWriter->endElement();
850  $objWriter->endElement();
851 
852  if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
853  $layout = $yAxisLabel->getLayout();
855  }
856 
857  $objWriter->startElement('c:overlay');
858  $objWriter->writeAttribute('val', 0);
859  $objWriter->endElement();
860 
861  $objWriter->endElement();
862  }
863 
864  $objWriter->startElement('c:numFmt');
865  $objWriter->writeAttribute('formatCode', $xAxis->getAxisNumberFormat());
866  $objWriter->writeAttribute('sourceLinked', $xAxis->getAxisNumberSourceLinked());
867  $objWriter->endElement();
868 
869  $objWriter->startElement('c:majorTickMark');
870  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_tick_mark'));
871  $objWriter->endElement();
872 
873  $objWriter->startElement('c:minorTickMark');
874  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_tick_mark'));
875  $objWriter->endElement();
876 
877  $objWriter->startElement('c:tickLblPos');
878  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('axis_labels'));
879  $objWriter->endElement();
880 
881  $objWriter->startElement('c:spPr');
882 
883  if (!is_null($xAxis->getFillProperty('value'))) {
884  $objWriter->startElement('a:solidFill');
885  $objWriter->startElement("a:" . $xAxis->getFillProperty('type'));
886  $objWriter->writeAttribute('val', $xAxis->getFillProperty('value'));
887  $objWriter->startElement('a:alpha');
888  $objWriter->writeAttribute('val', $xAxis->getFillProperty('alpha'));
889  $objWriter->endElement();
890  $objWriter->endElement();
891  $objWriter->endElement();
892  }
893 
894  $objWriter->startElement('a:ln');
895 
896  $objWriter->writeAttribute('w', $xAxis->getLineStyleProperty('width'));
897  $objWriter->writeAttribute('cap', $xAxis->getLineStyleProperty('cap'));
898  $objWriter->writeAttribute('cmpd', $xAxis->getLineStyleProperty('compound'));
899 
900  if (!is_null($xAxis->getLineProperty('value'))) {
901  $objWriter->startElement('a:solidFill');
902  $objWriter->startElement("a:" . $xAxis->getLineProperty('type'));
903  $objWriter->writeAttribute('val', $xAxis->getLineProperty('value'));
904  $objWriter->startElement('a:alpha');
905  $objWriter->writeAttribute('val', $xAxis->getLineProperty('alpha'));
906  $objWriter->endElement();
907  $objWriter->endElement();
908  $objWriter->endElement();
909  }
910 
911  $objWriter->startElement('a:prstDash');
912  $objWriter->writeAttribute('val', $xAxis->getLineStyleProperty('dash'));
913  $objWriter->endElement();
914 
915  if ($xAxis->getLineStyleProperty('join') == 'miter') {
916  $objWriter->startElement('a:miter');
917  $objWriter->writeAttribute('lim', '800000');
918  $objWriter->endElement();
919  } else {
920  $objWriter->startElement('a:bevel');
921  $objWriter->endElement();
922  }
923 
924  if (!is_null($xAxis->getLineStyleProperty(array('arrow', 'head', 'type')))) {
925  $objWriter->startElement('a:headEnd');
926  $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(array('arrow', 'head', 'type')));
927  $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('head'));
928  $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('head'));
929  $objWriter->endElement();
930  }
931 
932  if (!is_null($xAxis->getLineStyleProperty(array('arrow', 'end', 'type')))) {
933  $objWriter->startElement('a:tailEnd');
934  $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(array('arrow', 'end', 'type')));
935  $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('end'));
936  $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('end'));
937  $objWriter->endElement();
938  }
939 
940  $objWriter->endElement();
941 
942  $objWriter->startElement('a:effectLst');
943 
944  if (!is_null($xAxis->getGlowProperty('size'))) {
945  $objWriter->startElement('a:glow');
946  $objWriter->writeAttribute('rad', $xAxis->getGlowProperty('size'));
947  $objWriter->startElement("a:{$xAxis->getGlowProperty(array('color','type'))}");
948  $objWriter->writeAttribute('val', $xAxis->getGlowProperty(array('color','value')));
949  $objWriter->startElement('a:alpha');
950  $objWriter->writeAttribute('val', $xAxis->getGlowProperty(array('color','alpha')));
951  $objWriter->endElement();
952  $objWriter->endElement();
953  $objWriter->endElement();
954  }
955 
956  if (!is_null($xAxis->getShadowProperty('presets'))) {
957  $objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}");
958 
959  if (!is_null($xAxis->getShadowProperty('blur'))) {
960  $objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur'));
961  }
962  if (!is_null($xAxis->getShadowProperty('distance'))) {
963  $objWriter->writeAttribute('dist', $xAxis->getShadowProperty('distance'));
964  }
965  if (!is_null($xAxis->getShadowProperty('direction'))) {
966  $objWriter->writeAttribute('dir', $xAxis->getShadowProperty('direction'));
967  }
968  if (!is_null($xAxis->getShadowProperty('algn'))) {
969  $objWriter->writeAttribute('algn', $xAxis->getShadowProperty('algn'));
970  }
971  if (!is_null($xAxis->getShadowProperty(array('size','sx')))) {
972  $objWriter->writeAttribute('sx', $xAxis->getShadowProperty(array('size','sx')));
973  }
974  if (!is_null($xAxis->getShadowProperty(array('size','sy')))) {
975  $objWriter->writeAttribute('sy', $xAxis->getShadowProperty(array('size','sy')));
976  }
977  if (!is_null($xAxis->getShadowProperty(array('size','kx')))) {
978  $objWriter->writeAttribute('kx', $xAxis->getShadowProperty(array('size','kx')));
979  }
980  if (!is_null($xAxis->getShadowProperty('rotWithShape'))) {
981  $objWriter->writeAttribute('rotWithShape', $xAxis->getShadowProperty('rotWithShape'));
982  }
983 
984  $objWriter->startElement("a:{$xAxis->getShadowProperty(array('color','type'))}");
985  $objWriter->writeAttribute('val', $xAxis->getShadowProperty(array('color','value')));
986  $objWriter->startElement('a:alpha');
987  $objWriter->writeAttribute('val', $xAxis->getShadowProperty(array('color','alpha')));
988  $objWriter->endElement();
989  $objWriter->endElement();
990 
991  $objWriter->endElement();
992  }
993 
994  if (!is_null($xAxis->getSoftEdgesSize())) {
995  $objWriter->startElement('a:softEdge');
996  $objWriter->writeAttribute('rad', $xAxis->getSoftEdgesSize());
997  $objWriter->endElement();
998  }
999 
1000  $objWriter->endElement(); //effectList
1001  $objWriter->endElement(); //end spPr
1002 
1003  if ($id1 > 0) {
1004  $objWriter->startElement('c:crossAx');
1005  $objWriter->writeAttribute('val', $id2);
1006  $objWriter->endElement();
1007 
1008  if (!is_null($xAxis->getAxisOptionsProperty('horizontal_crosses_value'))) {
1009  $objWriter->startElement('c:crossesAt');
1010  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses_value'));
1011  $objWriter->endElement();
1012  } else {
1013  $objWriter->startElement('c:crosses');
1014  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses'));
1015  $objWriter->endElement();
1016  }
1017 
1018  $objWriter->startElement('c:crossBetween');
1019  $objWriter->writeAttribute('val', "midCat");
1020  $objWriter->endElement();
1021 
1022  if (!is_null($xAxis->getAxisOptionsProperty('major_unit'))) {
1023  $objWriter->startElement('c:majorUnit');
1024  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_unit'));
1025  $objWriter->endElement();
1026  }
1027 
1028  if (!is_null($xAxis->getAxisOptionsProperty('minor_unit'))) {
1029  $objWriter->startElement('c:minorUnit');
1030  $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_unit'));
1031  $objWriter->endElement();
1032  }
1033 
1034  }
1035 
1036  if ($isMultiLevelSeries) {
1037  if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
1038  $objWriter->startElement('c:noMultiLvlLbl');
1039  $objWriter->writeAttribute('val', 0);
1040  $objWriter->endElement();
1041  }
1042  }
1043 
1044  $objWriter->endElement();
1045 
1046  }
1047 
1056  private
1057  static function _getChartType($plotArea) {
1058  $groupCount = $plotArea->getPlotGroupCount();
1059 
1060  if ($groupCount == 1) {
1061  $chartType = array(
1062  $plotArea->getPlotGroupByIndex(0)
1063  ->getPlotType()
1064  );
1065  } else {
1066  $chartTypes = array();
1067  for ($i = 0; $i < $groupCount; ++$i) {
1068  $chartTypes[] = $plotArea->getPlotGroupByIndex($i)
1069  ->getPlotType();
1070  }
1071  $chartType = array_unique($chartTypes);
1072  if (count($chartTypes) == 0) {
1073  throw new PHPExcel_Writer_Exception('Chart is not yet implemented');
1074  }
1075  }
1076 
1077  return $chartType;
1078  }
1079 
1093  private function _writePlotGroup($plotGroup,
1094  $groupType,
1095  $objWriter,
1096  &$catIsMultiLevelSeries,
1097  &$valIsMultiLevelSeries,
1098  &$plotGroupingType,
1099  PHPExcel_Worksheet $pSheet
1100  ) {
1101  if (is_null($plotGroup)) {
1102  return;
1103  }
1104 
1105  if (($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
1107  ) {
1108  $objWriter->startElement('c:barDir');
1109  $objWriter->writeAttribute('val', $plotGroup->getPlotDirection());
1110  $objWriter->endElement();
1111  }
1112 
1113  if (!is_null($plotGroup->getPlotGrouping())) {
1114  $plotGroupingType = $plotGroup->getPlotGrouping();
1115  $objWriter->startElement('c:grouping');
1116  $objWriter->writeAttribute('val', $plotGroupingType);
1117  $objWriter->endElement();
1118  }
1119 
1120  // Get these details before the loop, because we can use the count to check for varyColors
1121  $plotSeriesOrder = $plotGroup->getPlotOrder();
1122  $plotSeriesCount = count($plotSeriesOrder);
1123 
1124  if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) &&
1126  ) {
1127 
1128  if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
1129  if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
1132  ($plotSeriesCount > 1)
1133  ) {
1134  $objWriter->startElement('c:varyColors');
1135  $objWriter->writeAttribute('val', 1);
1136  $objWriter->endElement();
1137  } else {
1138  $objWriter->startElement('c:varyColors');
1139  $objWriter->writeAttribute('val', 0);
1140  $objWriter->endElement();
1141  }
1142  }
1143  }
1144 
1145  foreach ($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) {
1146  $objWriter->startElement('c:ser');
1147 
1148  $objWriter->startElement('c:idx');
1149  $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx);
1150  $objWriter->endElement();
1151 
1152  $objWriter->startElement('c:order');
1153  $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef);
1154  $objWriter->endElement();
1155 
1156  if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
1159  ) {
1160 
1161  $objWriter->startElement('c:dPt');
1162  $objWriter->startElement('c:idx');
1163  $objWriter->writeAttribute('val', 3);
1164  $objWriter->endElement();
1165 
1166  $objWriter->startElement('c:bubble3D');
1167  $objWriter->writeAttribute('val', 0);
1168  $objWriter->endElement();
1169 
1170  $objWriter->startElement('c:spPr');
1171  $objWriter->startElement('a:solidFill');
1172  $objWriter->startElement('a:srgbClr');
1173  $objWriter->writeAttribute('val', 'FF9900');
1174  $objWriter->endElement();
1175  $objWriter->endElement();
1176  $objWriter->endElement();
1177  $objWriter->endElement();
1178  }
1179 
1180  // Labels
1181  $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
1182  if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
1183  $objWriter->startElement('c:tx');
1184  $objWriter->startElement('c:strRef');
1185  $this->_writePlotSeriesLabel($plotSeriesLabel, $objWriter);
1186  $objWriter->endElement();
1187  $objWriter->endElement();
1188  }
1189 
1190  // Formatting for the points
1191  if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) ||
1193  ) {
1194  $objWriter->startElement('c:spPr');
1195  $objWriter->startElement('a:ln');
1196  $objWriter->writeAttribute('w', 12700);
1197  if ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) {
1198  $objWriter->startElement('a:noFill');
1199  $objWriter->endElement();
1200  }
1201  $objWriter->endElement();
1202  $objWriter->endElement();
1203  }
1204 
1205  $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef);
1206  if ($plotSeriesValues) {
1207  $plotSeriesMarker = $plotSeriesValues->getPointMarker();
1208  if ($plotSeriesMarker) {
1209  $objWriter->startElement('c:marker');
1210  $objWriter->startElement('c:symbol');
1211  $objWriter->writeAttribute('val', $plotSeriesMarker);
1212  $objWriter->endElement();
1213 
1214  if ($plotSeriesMarker !== 'none') {
1215  $objWriter->startElement('c:size');
1216  $objWriter->writeAttribute('val', 3);
1217  $objWriter->endElement();
1218  }
1219 
1220  $objWriter->endElement();
1221  }
1222  }
1223 
1224  if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
1227  ) {
1228 
1229  $objWriter->startElement('c:invertIfNegative');
1230  $objWriter->writeAttribute('val', 0);
1231  $objWriter->endElement();
1232  }
1233 
1234  // Category Labels
1235  $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
1236  if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
1237  $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
1238 
1239  if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
1242  ) {
1243 
1244  if (!is_null($plotGroup->getPlotStyle())) {
1245  $plotStyle = $plotGroup->getPlotStyle();
1246  if ($plotStyle) {
1247  $objWriter->startElement('c:explosion');
1248  $objWriter->writeAttribute('val', 25);
1249  $objWriter->endElement();
1250  }
1251  }
1252  }
1253 
1254  if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
1256  ) {
1257  $objWriter->startElement('c:xVal');
1258  } else {
1259  $objWriter->startElement('c:cat');
1260  }
1261 
1262  $this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet);
1263  $objWriter->endElement();
1264  }
1265 
1266  // Values
1267  if ($plotSeriesValues) {
1268  $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
1269 
1270  if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
1272  ) {
1273  $objWriter->startElement('c:yVal');
1274  } else {
1275  $objWriter->startElement('c:val');
1276  }
1277 
1278  $this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet);
1279  $objWriter->endElement();
1280  }
1281 
1282  if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
1283  $this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet);
1284  }
1285 
1286  $objWriter->endElement();
1287 
1288  }
1289 
1290  $this->_seriesIndex += $plotSeriesIdx + 1;
1291  }
1292 
1301  private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) {
1302  if (is_null($plotSeriesLabel)) {
1303  return;
1304  }
1305 
1306  $objWriter->startElement('c:f');
1307  $objWriter->writeRawData($plotSeriesLabel->getDataSource());
1308  $objWriter->endElement();
1309 
1310  $objWriter->startElement('c:strCache');
1311  $objWriter->startElement('c:ptCount');
1312  $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount());
1313  $objWriter->endElement();
1314 
1315  foreach ($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) {
1316  $objWriter->startElement('c:pt');
1317  $objWriter->writeAttribute('idx', $plotLabelKey);
1318 
1319  $objWriter->startElement('c:v');
1320  $objWriter->writeRawData($plotLabelValue);
1321  $objWriter->endElement();
1322  $objWriter->endElement();
1323  }
1324  $objWriter->endElement();
1325 
1326  }
1327 
1339  private function _writePlotSeriesValues($plotSeriesValues,
1340  $objWriter,
1341  $groupType,
1342  $dataType = 'str',
1343  PHPExcel_Worksheet $pSheet
1344  ) {
1345  if (is_null($plotSeriesValues)) {
1346  return;
1347  }
1348 
1349  if ($plotSeriesValues->isMultiLevelSeries()) {
1350  $levelCount = $plotSeriesValues->multiLevelCount();
1351 
1352  $objWriter->startElement('c:multiLvlStrRef');
1353 
1354  $objWriter->startElement('c:f');
1355  $objWriter->writeRawData($plotSeriesValues->getDataSource());
1356  $objWriter->endElement();
1357 
1358  $objWriter->startElement('c:multiLvlStrCache');
1359 
1360  $objWriter->startElement('c:ptCount');
1361  $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1362  $objWriter->endElement();
1363 
1364  for ($level = 0; $level < $levelCount; ++$level) {
1365  $objWriter->startElement('c:lvl');
1366 
1367  foreach ($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
1368  if (isset($plotSeriesValue[$level])) {
1369  $objWriter->startElement('c:pt');
1370  $objWriter->writeAttribute('idx', $plotSeriesKey);
1371 
1372  $objWriter->startElement('c:v');
1373  $objWriter->writeRawData($plotSeriesValue[$level]);
1374  $objWriter->endElement();
1375  $objWriter->endElement();
1376  }
1377  }
1378 
1379  $objWriter->endElement();
1380  }
1381 
1382  $objWriter->endElement();
1383 
1384  $objWriter->endElement();
1385  } else {
1386  $objWriter->startElement('c:' . $dataType . 'Ref');
1387 
1388  $objWriter->startElement('c:f');
1389  $objWriter->writeRawData($plotSeriesValues->getDataSource());
1390  $objWriter->endElement();
1391 
1392  $objWriter->startElement('c:' . $dataType . 'Cache');
1393 
1394  if (($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
1397  ) {
1398 
1399  if (($plotSeriesValues->getFormatCode() !== NULL) &&
1400  ($plotSeriesValues->getFormatCode() !== '')
1401  ) {
1402  $objWriter->startElement('c:formatCode');
1403  $objWriter->writeRawData($plotSeriesValues->getFormatCode());
1404  $objWriter->endElement();
1405  }
1406  }
1407 
1408  $objWriter->startElement('c:ptCount');
1409  $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1410  $objWriter->endElement();
1411 
1412  $dataValues = $plotSeriesValues->getDataValues();
1413  if (!empty($dataValues)) {
1414  if (is_array($dataValues)) {
1415  foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1416  $objWriter->startElement('c:pt');
1417  $objWriter->writeAttribute('idx', $plotSeriesKey);
1418 
1419  $objWriter->startElement('c:v');
1420  $objWriter->writeRawData($plotSeriesValue);
1421  $objWriter->endElement();
1422  $objWriter->endElement();
1423  }
1424  }
1425  }
1426 
1427  $objWriter->endElement();
1428 
1429  $objWriter->endElement();
1430  }
1431  }
1432 
1441  private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) {
1442  if (is_null($plotSeriesValues)) {
1443  return;
1444  }
1445 
1446  $objWriter->startElement('c:bubbleSize');
1447  $objWriter->startElement('c:numLit');
1448 
1449  $objWriter->startElement('c:formatCode');
1450  $objWriter->writeRawData('General');
1451  $objWriter->endElement();
1452 
1453  $objWriter->startElement('c:ptCount');
1454  $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
1455  $objWriter->endElement();
1456 
1457  $dataValues = $plotSeriesValues->getDataValues();
1458  if (!empty($dataValues)) {
1459  if (is_array($dataValues)) {
1460  foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
1461  $objWriter->startElement('c:pt');
1462  $objWriter->writeAttribute('idx', $plotSeriesKey);
1463  $objWriter->startElement('c:v');
1464  $objWriter->writeRawData(1);
1465  $objWriter->endElement();
1466  $objWriter->endElement();
1467  }
1468  }
1469  }
1470 
1471  $objWriter->endElement();
1472  $objWriter->endElement();
1473 
1474  $objWriter->startElement('c:bubble3D');
1475  $objWriter->writeAttribute('val', 0);
1476  $objWriter->endElement();
1477  }
1478 
1488  $objWriter->startElement('c:layout');
1489 
1490  if (!is_null($layout)) {
1491  $objWriter->startElement('c:manualLayout');
1492 
1493  $layoutTarget = $layout->getLayoutTarget();
1494  if (!is_null($layoutTarget)) {
1495  $objWriter->startElement('c:layoutTarget');
1496  $objWriter->writeAttribute('val', $layoutTarget);
1497  $objWriter->endElement();
1498  }
1499 
1500  $xMode = $layout->getXMode();
1501  if (!is_null($xMode)) {
1502  $objWriter->startElement('c:xMode');
1503  $objWriter->writeAttribute('val', $xMode);
1504  $objWriter->endElement();
1505  }
1506 
1507  $yMode = $layout->getYMode();
1508  if (!is_null($yMode)) {
1509  $objWriter->startElement('c:yMode');
1510  $objWriter->writeAttribute('val', $yMode);
1511  $objWriter->endElement();
1512  }
1513 
1514  $x = $layout->getXPosition();
1515  if (!is_null($x)) {
1516  $objWriter->startElement('c:x');
1517  $objWriter->writeAttribute('val', $x);
1518  $objWriter->endElement();
1519  }
1520 
1521  $y = $layout->getYPosition();
1522  if (!is_null($y)) {
1523  $objWriter->startElement('c:y');
1524  $objWriter->writeAttribute('val', $y);
1525  $objWriter->endElement();
1526  }
1527 
1528  $w = $layout->getWidth();
1529  if (!is_null($w)) {
1530  $objWriter->startElement('c:w');
1531  $objWriter->writeAttribute('val', $w);
1532  $objWriter->endElement();
1533  }
1534 
1535  $h = $layout->getHeight();
1536  if (!is_null($h)) {
1537  $objWriter->startElement('c:h');
1538  $objWriter->writeAttribute('val', $h);
1539  $objWriter->endElement();
1540  }
1541 
1542  $objWriter->endElement();
1543  }
1544 
1545  $objWriter->endElement();
1546  }
1547 
1556  $objWriter->startElement('mc:AlternateContent');
1557  $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
1558 
1559  $objWriter->startElement('mc:Choice');
1560  $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart');
1561  $objWriter->writeAttribute('Requires', 'c14');
1562 
1563  $objWriter->startElement('c14:style');
1564  $objWriter->writeAttribute('val', '102');
1565  $objWriter->endElement();
1566  $objWriter->endElement();
1567 
1568  $objWriter->startElement('mc:Fallback');
1569  $objWriter->startElement('c:style');
1570  $objWriter->writeAttribute('val', '2');
1571  $objWriter->endElement();
1572  $objWriter->endElement();
1573 
1574  $objWriter->endElement();
1575  }
1576 
1584  private function _writePrintSettings($objWriter) {
1585  $objWriter->startElement('c:printSettings');
1586 
1587  $objWriter->startElement('c:headerFooter');
1588  $objWriter->endElement();
1589 
1590  $objWriter->startElement('c:pageMargins');
1591  $objWriter->writeAttribute('footer', 0.3);
1592  $objWriter->writeAttribute('header', 0.3);
1593  $objWriter->writeAttribute('r', 0.7);
1594  $objWriter->writeAttribute('l', 0.7);
1595  $objWriter->writeAttribute('t', 0.75);
1596  $objWriter->writeAttribute('b', 0.75);
1597  $objWriter->endElement();
1598 
1599  $objWriter->startElement('c:pageSetup');
1600  $objWriter->writeAttribute('orientation', "portrait");
1601  $objWriter->endElement();
1602 
1603  $objWriter->endElement();
1604  }
1605 
1606 }
getPlotGroupCount()
Get Number of Plot Groups.
Definition: PlotArea.php:75
_writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines)
Write Value Axis.
Definition: Chart.php:573
getPlotGroupByIndex($index)
Get Plot Series by Index.
Definition: PlotArea.php:106
$x
Definition: example_009.php:98
Created by PhpStorm.
Definition: Axis.php:11
$h
_writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
Write Bubble Chart Details.
Definition: Chart.php:1441
writeChart(PHPExcel_Chart $pChart=NULL)
Write charts to XML format.
Definition: Chart.php:46
_writePrintSettings($objWriter)
Write Printer Settings.
Definition: Chart.php:1584
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$w
_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType='str', PHPExcel_Worksheet $pSheet)
Write Plot Series Values.
Definition: Chart.php:1339
$objWriter
$y
Definition: example_007.php:83
Created by PhpStorm.
Definition: GridLines.php:10
_writeTitle(PHPExcel_Chart_Title $title=NULL, $objWriter)
Write Chart Title.
Definition: Chart.php:133
Create styles array
The data for the language used.
static _getChartType($plotArea)
Get the data series type(s) for a chart plot series.
Definition: Chart.php:1057
getLayout()
Get Layout.
Definition: PlotArea.php:66
_writeDataLbls($objWriter, $chartLayout)
Write Data Labels.
Definition: Chart.php:397
_writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType, PHPExcel_Worksheet $pSheet)
Write Plot Group (series of related plots)
Definition: Chart.php:1093
$i
Definition: disco.tpl.php:19
_writePlotArea(PHPExcel_Chart_PlotArea $plotArea, PHPExcel_Chart_Title $xAxisLabel=NULL, PHPExcel_Chart_Title $yAxisLabel=NULL, $objWriter, PHPExcel_Worksheet $pSheet, PHPExcel_Chart_Axis $xAxis, PHPExcel_Chart_Axis $yAxis, PHPExcel_Chart_GridLines $majorGridlines, PHPExcel_Chart_GridLines $minorGridlines)
Write Chart Plot Area.
Definition: Chart.php:235
_writeAlternateContent($objWriter)
Write Alternate Content block.
Definition: Chart.php:1555
_writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis)
Write Category Axis.
Definition: Chart.php:451
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
static ControlCharacterPHP2OOXML($value='')
Convert from PHP control character to OpenXML escaped control character.
Definition: String.php:373
_writeLegend(PHPExcel_Chart_Legend $legend=NULL, $objWriter)
Write Chart Legend.
Definition: Chart.php:180
_writeLayout(PHPExcel_Chart_Layout $layout=NULL, $objWriter)
Write Layout.
Definition: Chart.php:1487
_writePlotSeriesLabel($plotSeriesLabel, $objWriter)
Write Plot Series Label.
Definition: Chart.php:1301