Complex classes like ObjectsChart often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ObjectsChart, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
23 | class ObjectsChart extends AbstractDecoratorWriter |
||
24 | { |
||
25 | /** |
||
26 | * @var XMLWriter |
||
27 | */ |
||
28 | protected $xmlContent; |
||
29 | /** |
||
30 | * @var mixed |
||
31 | */ |
||
32 | protected $arrayData; |
||
33 | /** |
||
34 | * @var mixed |
||
35 | */ |
||
36 | protected $arrayTitle; |
||
37 | /** |
||
38 | * @var integer |
||
39 | */ |
||
40 | protected $numData; |
||
41 | /** |
||
42 | * @var integer |
||
43 | */ |
||
44 | protected $numSeries; |
||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $rangeCol; |
||
49 | |||
50 | /** |
||
51 | * @return ZipInterface |
||
52 | * @throws \Exception |
||
53 | */ |
||
54 | 62 | public function render() |
|
66 | |||
67 | /** |
||
68 | * @param Chart $chart |
||
69 | * @return string |
||
70 | * @throws \Exception |
||
71 | */ |
||
72 | 24 | protected function writeContentPart(Chart $chart) |
|
195 | |||
196 | /** |
||
197 | * @param Chart $chart |
||
198 | * @throws \Exception |
||
199 | */ |
||
200 | 24 | private function writeAxis(Chart $chart) |
|
241 | |||
242 | 24 | protected function writeGridline($oGridlines, $styleName, $chartClass) |
|
253 | |||
254 | /** |
||
255 | * @param Chart $chart |
||
256 | * @throws \Exception |
||
257 | * @todo Set function in \PhpPresentation\Shape\Chart\Axis for defining width and color of the axis |
||
258 | */ |
||
259 | 24 | protected function writeAxisStyle(Chart $chart) |
|
260 | { |
||
261 | 24 | $chartType = $chart->getPlotArea()->getType(); |
|
262 | |||
263 | // AxisX |
||
264 | // style:style |
||
265 | 24 | $this->xmlContent->startElement('style:style'); |
|
266 | 24 | $this->xmlContent->writeAttribute('style:name', 'styleAxisX'); |
|
267 | 24 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
268 | // style:style > style:chart-properties |
||
269 | 24 | $this->xmlContent->startElement('style:chart-properties'); |
|
270 | 24 | $this->xmlContent->writeAttribute('chart:display-label', 'true'); |
|
271 | 24 | $this->xmlContent->writeAttribute('chart:tick-marks-major-inner', 'false'); |
|
272 | 24 | $this->xmlContent->writeAttribute('chart:tick-marks-major-outer', 'false'); |
|
273 | 24 | if ($chartType instanceof AbstractTypePie) { |
|
274 | 5 | $this->xmlContent->writeAttribute('chart:reverse-direction', 'true'); |
|
275 | } |
||
276 | 24 | if ($chart->getPlotArea()->getAxisX()->getMinBounds() != null) { |
|
|
|||
277 | 1 | $this->xmlContent->writeAttribute('chart:minimum', $chart->getPlotArea()->getAxisX()->getMinBounds()); |
|
278 | } |
||
279 | 24 | if ($chart->getPlotArea()->getAxisX()->getMaxBounds() != null) { |
|
280 | 1 | $this->xmlContent->writeAttribute('chart:maximum', $chart->getPlotArea()->getAxisX()->getMaxBounds()); |
|
281 | } |
||
282 | 24 | $this->xmlContent->endElement(); |
|
283 | // style:style > style:graphic-properties |
||
284 | 24 | $this->xmlContent->startElement('style:graphic-properties'); |
|
285 | 24 | $this->xmlContent->writeAttribute('draw:stroke', 'solid'); |
|
286 | 24 | $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm'); |
|
287 | 24 | $this->xmlContent->writeAttribute('svg:stroke-color', '#878787'); |
|
288 | 24 | $this->xmlContent->endElement(); |
|
289 | // style:style > style:text-properties |
||
290 | 24 | $oFont = $chart->getPlotArea()->getAxisX()->getFont(); |
|
291 | 24 | $this->xmlContent->startElement('style:text-properties'); |
|
292 | 24 | $this->xmlContent->writeAttribute('fo:color', '#'.$oFont->getColor()->getRGB()); |
|
293 | 24 | $this->xmlContent->writeAttribute('fo:font-family', $oFont->getName()); |
|
294 | 24 | $this->xmlContent->writeAttribute('fo:font-size', $oFont->getSize().'pt'); |
|
295 | 24 | $this->xmlContent->writeAttribute('fo:font-style', $oFont->isItalic() ? 'italic' : 'normal'); |
|
296 | 24 | $this->xmlContent->endElement(); |
|
297 | // ##style:style |
||
298 | 24 | $this->xmlContent->endElement(); |
|
299 | |||
300 | // AxisX GridLines Major |
||
301 | 24 | $this->writeGridlineStyle($chart->getPlotArea()->getAxisX()->getMajorGridlines(), 'styleAxisXGridlinesMajor'); |
|
302 | |||
303 | // AxisX GridLines Minor |
||
304 | 24 | $this->writeGridlineStyle($chart->getPlotArea()->getAxisX()->getMinorGridlines(), 'styleAxisXGridlinesMinor'); |
|
305 | |||
306 | // AxisY |
||
307 | // style:style |
||
308 | 24 | $this->xmlContent->startElement('style:style'); |
|
309 | 24 | $this->xmlContent->writeAttribute('style:name', 'styleAxisY'); |
|
310 | 24 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
311 | // style:style > style:chart-properties |
||
312 | 24 | $this->xmlContent->startElement('style:chart-properties'); |
|
313 | 24 | $this->xmlContent->writeAttribute('chart:display-label', 'true'); |
|
314 | 24 | $this->xmlContent->writeAttribute('chart:tick-marks-major-inner', 'false'); |
|
315 | 24 | $this->xmlContent->writeAttribute('chart:tick-marks-major-outer', 'false'); |
|
316 | 24 | if ($chartType instanceof AbstractTypePie) { |
|
317 | 5 | $this->xmlContent->writeAttribute('chart:reverse-direction', 'true'); |
|
318 | } |
||
319 | 24 | if ($chart->getPlotArea()->getAxisY()->getMinBounds() !== null) { |
|
320 | $this->xmlContent->writeAttribute('chart:minimum', $chart->getPlotArea()->getAxisY()->getMinBounds()); |
||
321 | } |
||
322 | 24 | if ($chart->getPlotArea()->getAxisY()->getMaxBounds() !== null) { |
|
323 | $this->xmlContent->writeAttribute('chart:maximum', $chart->getPlotArea()->getAxisY()->getMaxBounds()); |
||
324 | } |
||
325 | 24 | $this->xmlContent->endElement(); |
|
326 | // style:graphic-properties |
||
327 | 24 | $this->xmlContent->startElement('style:graphic-properties'); |
|
328 | 24 | $this->xmlContent->writeAttribute('draw:stroke', 'solid'); |
|
329 | 24 | $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm'); |
|
330 | 24 | $this->xmlContent->writeAttribute('svg:stroke-color', '#878787'); |
|
331 | 24 | $this->xmlContent->endElement(); |
|
332 | // style:style > style:text-properties |
||
333 | 24 | $oFont = $chart->getPlotArea()->getAxisY()->getFont(); |
|
334 | 24 | $this->xmlContent->startElement('style:text-properties'); |
|
335 | 24 | $this->xmlContent->writeAttribute('fo:color', '#'.$oFont->getColor()->getRGB()); |
|
336 | 24 | $this->xmlContent->writeAttribute('fo:font-family', $oFont->getName()); |
|
337 | 24 | $this->xmlContent->writeAttribute('fo:font-size', $oFont->getSize().'pt'); |
|
338 | 24 | $this->xmlContent->writeAttribute('fo:font-style', $oFont->isItalic() ? 'italic' : 'normal'); |
|
339 | 24 | $this->xmlContent->endElement(); |
|
340 | // ## style:style |
||
341 | 24 | $this->xmlContent->endElement(); |
|
342 | |||
343 | // AxisY GridLines Major |
||
344 | 24 | $this->writeGridlineStyle($chart->getPlotArea()->getAxisY()->getMajorGridlines(), 'styleAxisYGridlinesMajor'); |
|
345 | |||
346 | // AxisY GridLines Minor |
||
347 | 24 | $this->writeGridlineStyle($chart->getPlotArea()->getAxisY()->getMinorGridlines(), 'styleAxisYGridlinesMinor'); |
|
348 | 24 | } |
|
349 | |||
350 | /** |
||
351 | * @param Chart\Gridlines $oGridlines |
||
352 | * @param string $styleName |
||
353 | */ |
||
354 | 24 | protected function writeGridlineStyle($oGridlines, $styleName) |
|
371 | |||
372 | /** |
||
373 | * @param Chart $chart |
||
374 | */ |
||
375 | 24 | private function writeChartStyle(Chart $chart) |
|
390 | |||
391 | 24 | private function writeFloor() |
|
399 | |||
400 | 24 | private function writeFloorStyle() |
|
418 | |||
419 | /** |
||
420 | * @param Chart $chart |
||
421 | */ |
||
422 | 24 | private function writeLegend(Chart $chart) |
|
423 | { |
||
424 | // chart:legend |
||
425 | 24 | $this->xmlContent->startElement('chart:legend'); |
|
426 | 24 | switch ($chart->getLegend()->getPosition()) { |
|
427 | 24 | case Chart\Legend::POSITION_BOTTOM: |
|
428 | 1 | $position = 'bottom'; |
|
429 | 1 | break; |
|
430 | 24 | case Chart\Legend::POSITION_LEFT: |
|
431 | 1 | $position = 'start'; |
|
432 | 1 | break; |
|
433 | 24 | case Chart\Legend::POSITION_TOP: |
|
434 | 1 | $position = 'top'; |
|
435 | 1 | break; |
|
436 | 24 | case Chart\Legend::POSITION_TOPRIGHT: |
|
437 | 1 | $position = 'top-end'; |
|
438 | 1 | break; |
|
439 | 24 | case Chart\Legend::POSITION_RIGHT: |
|
440 | default: |
||
441 | 24 | $position = 'end'; |
|
442 | 24 | break; |
|
443 | } |
||
444 | 24 | $this->xmlContent->writeAttribute('chart:legend-position', $position); |
|
445 | 24 | $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetX()), 3) . 'cm'); |
|
446 | 24 | $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetY()), 3) . 'cm'); |
|
447 | 24 | $this->xmlContent->writeAttribute('style:legend-expansion', 'high'); |
|
448 | 24 | $this->xmlContent->writeAttribute('chart:style-name', 'styleLegend'); |
|
449 | // > chart:legend |
||
450 | 24 | $this->xmlContent->endElement(); |
|
451 | 24 | } |
|
452 | |||
453 | /** |
||
454 | * @param Chart $chart |
||
455 | */ |
||
456 | 24 | private function writeLegendStyle(Chart $chart) |
|
478 | |||
479 | /** |
||
480 | * @param Chart $chart |
||
481 | * @throws \Exception |
||
482 | */ |
||
483 | 24 | private function writePlotArea(Chart $chart) |
|
534 | |||
535 | /** |
||
536 | * @param Chart $chart |
||
537 | * @throws \Exception |
||
538 | * @link : http://books.evc-cit.info/odbook/ch08.html#chart-plot-area-section |
||
539 | */ |
||
540 | 24 | private function writePlotAreaStyle(Chart $chart) |
|
588 | |||
589 | /** |
||
590 | * @param Chart $chart |
||
591 | * @param Chart\Series $series |
||
592 | * @throws \Exception |
||
593 | */ |
||
594 | 22 | private function writeSeries(Chart $chart, Chart\Series $series) |
|
595 | { |
||
596 | 22 | $chartType = $chart->getPlotArea()->getType(); |
|
597 | |||
598 | 22 | $numRange = count($series->getValues()); |
|
599 | // chart:series |
||
600 | 22 | $this->xmlContent->startElement('chart:series'); |
|
601 | 22 | $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$'.$this->rangeCol.'$2:.$'.$this->rangeCol.'$'.($numRange+1)); |
|
602 | 22 | $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$'.$this->rangeCol.'$1'); |
|
603 | // if ($chartType instanceof Area) { |
||
604 | // $this->xmlContent->writeAttribute('chart:class', 'chart:area'); |
||
605 | // } elseif ($chartType instanceof AbstractTypeBar) { |
||
606 | // $this->xmlContent->writeAttribute('chart:class', 'chart:bar'); |
||
607 | // } elseif ($chartType instanceof Line) { |
||
608 | // $this->xmlContent->writeAttribute('chart:class', 'chart:line'); |
||
609 | // } elseif ($chartType instanceof AbstractTypePie) { |
||
610 | // $this->xmlContent->writeAttribute('chart:class', 'chart:circle'); |
||
611 | // } elseif ($chartType instanceof Scatter) { |
||
612 | // $this->xmlContent->writeAttribute('chart:class', 'chart:scatter'); |
||
613 | // } |
||
614 | 22 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries); |
|
615 | 22 | if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) { |
|
616 | 17 | $dataPointFills = $series->getDataPointFills(); |
|
617 | |||
618 | 17 | $incRepeat = $numRange; |
|
619 | 17 | if (!empty($dataPointFills)) { |
|
620 | 4 | $inc = 0; |
|
621 | 4 | $incRepeat = 1; |
|
622 | 4 | $newFill = new Fill(); |
|
623 | do { |
||
624 | 4 | if ($series->getDataPointFill($inc)->getHashCode() !== $newFill->getHashCode()) { |
|
625 | // chart:data-point |
||
626 | 4 | $this->xmlContent->startElement('chart:data-point'); |
|
627 | 4 | $this->xmlContent->writeAttribute('chart:repeated', $incRepeat); |
|
628 | // > chart:data-point |
||
629 | 4 | $this->xmlContent->endElement(); |
|
630 | 4 | $incRepeat = 1; |
|
631 | |||
632 | // chart:data-point |
||
633 | 4 | $this->xmlContent->startElement('chart:data-point'); |
|
634 | 4 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc); |
|
635 | // > chart:data-point |
||
636 | 4 | $this->xmlContent->endElement(); |
|
637 | } |
||
638 | 4 | $inc++; |
|
639 | 4 | $incRepeat++; |
|
640 | 4 | } while ($inc < $numRange); |
|
641 | 4 | $incRepeat--; |
|
642 | } |
||
643 | // chart:data-point |
||
644 | 17 | $this->xmlContent->startElement('chart:data-point'); |
|
645 | 17 | $this->xmlContent->writeAttribute('chart:repeated', $incRepeat); |
|
646 | // > chart:data-point |
||
647 | 17 | $this->xmlContent->endElement(); |
|
648 | 5 | } elseif ($chartType instanceof AbstractTypePie) { |
|
649 | 5 | $count = count($series->getDataPointFills()); |
|
650 | 5 | for ($inc = 0; $inc < $count; $inc++) { |
|
651 | // chart:data-point |
||
652 | 3 | $this->xmlContent->startElement('chart:data-point'); |
|
653 | 3 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc); |
|
654 | // > chart:data-point |
||
655 | 3 | $this->xmlContent->endElement(); |
|
656 | } |
||
657 | } |
||
658 | |||
659 | // > chart:series |
||
660 | 22 | $this->xmlContent->endElement(); |
|
661 | 22 | } |
|
662 | |||
663 | /** |
||
664 | * @param Chart $chart |
||
665 | * @param Chart\Series $series |
||
666 | * @throws \Exception |
||
667 | */ |
||
668 | 22 | private function writeSeriesStyle(Chart $chart, Chart\Series $series) |
|
669 | { |
||
670 | 22 | $chartType = $chart->getPlotArea()->getType(); |
|
671 | |||
672 | // style:style |
||
673 | 22 | $this->xmlContent->startElement('style:style'); |
|
674 | 22 | $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries); |
|
675 | 22 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
676 | // style:chart-properties |
||
677 | 22 | $this->xmlContent->startElement('style:chart-properties'); |
|
678 | 22 | if ($series->hasShowValue()) { |
|
679 | 22 | if ($series->hasShowPercentage()) { |
|
680 | 1 | $this->xmlContent->writeAttribute('chart:data-label-number', 'value-and-percentage'); |
|
681 | } else { |
||
682 | 22 | $this->xmlContent->writeAttribute('chart:data-label-number', 'value'); |
|
683 | } |
||
684 | } else { |
||
685 | 1 | if ($series->hasShowPercentage()) { |
|
686 | 1 | $this->xmlContent->writeAttribute('chart:data-label-number', 'percentage'); |
|
687 | } |
||
688 | } |
||
689 | 22 | if ($series->hasShowCategoryName()) { |
|
690 | 1 | $this->xmlContent->writeAttribute('chart:data-label-text', 'true'); |
|
691 | } |
||
692 | 22 | $this->xmlContent->writeAttribute('chart:label-position', 'center'); |
|
693 | 22 | if ($chartType instanceof AbstractTypePie) { |
|
694 | 5 | $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion()); |
|
695 | } |
||
696 | 22 | if ($chartType instanceof Line || $chartType instanceof Scatter) { |
|
697 | 9 | $oMarker = $series->getMarker(); |
|
698 | /** |
||
699 | * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html |
||
700 | */ |
||
701 | 9 | $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none'); |
|
702 | /** |
||
703 | * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html |
||
704 | */ |
||
705 | 9 | $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol'); |
|
706 | 9 | if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) { |
|
707 | 2 | switch ($oMarker->getSymbol()) { |
|
708 | 2 | case Chart\Marker::SYMBOL_DASH: |
|
709 | 2 | $symbolName = 'horizontal-bar'; |
|
710 | 2 | break; |
|
711 | 2 | case Chart\Marker::SYMBOL_DOT: |
|
712 | 2 | $symbolName = 'circle'; |
|
713 | 2 | break; |
|
714 | 2 | case Chart\Marker::SYMBOL_TRIANGLE: |
|
715 | 2 | $symbolName = 'arrow-up'; |
|
716 | 2 | break; |
|
717 | default: |
||
718 | 2 | $symbolName = $oMarker->getSymbol(); |
|
719 | 2 | break; |
|
720 | } |
||
721 | 2 | $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName); |
|
722 | 2 | $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', ''); |
|
723 | 2 | $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize.'cm'); |
|
724 | 2 | $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize.'cm'); |
|
725 | } |
||
726 | } |
||
727 | |||
728 | 22 | $separator = $series->getSeparator(); |
|
729 | 22 | if (!empty($separator)) { |
|
730 | // style:chart-properties/chart:label-separator |
||
731 | 1 | $this->xmlContent->startElement('chart:label-separator'); |
|
732 | 1 | if ($separator == PHP_EOL) { |
|
733 | $this->xmlContent->writeRaw('<text:p><text:line-break /></text:p>'); |
||
734 | } else { |
||
735 | 1 | $this->xmlContent->writeElement('text:p', $separator); |
|
736 | } |
||
737 | 1 | $this->xmlContent->endElement(); |
|
738 | } |
||
739 | |||
740 | // > style:chart-properties |
||
741 | 22 | $this->xmlContent->endElement(); |
|
742 | // style:graphic-properties |
||
743 | 22 | $this->xmlContent->startElement('style:graphic-properties'); |
|
744 | 22 | if ($chartType instanceof Line || $chartType instanceof Scatter) { |
|
745 | 9 | $outlineWidth = ''; |
|
746 | 9 | $outlineColor = ''; |
|
747 | |||
748 | 9 | $oOutline = $series->getOutline(); |
|
749 | 9 | if ($oOutline instanceof Outline) { |
|
750 | 2 | $outlineWidth = $oOutline->getWidth(); |
|
751 | 2 | if (!empty($outlineWidth)) { |
|
752 | 2 | $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', ''); |
|
753 | } |
||
754 | 2 | $outlineColor = $oOutline->getFill()->getStartColor()->getRGB(); |
|
755 | } |
||
756 | 9 | if (empty($outlineWidth)) { |
|
757 | 9 | $outlineWidth = '0.079'; |
|
758 | } |
||
759 | 9 | if (empty($outlineColor)) { |
|
760 | 9 | $outlineColor = '4a7ebb'; |
|
761 | } |
||
762 | 9 | $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth.'cm'); |
|
763 | 9 | $this->xmlContent->writeAttribute('svg:stroke-color', '#'.$outlineColor); |
|
764 | } else { |
||
765 | 13 | $this->xmlContent->writeAttribute('draw:stroke', 'none'); |
|
766 | 13 | if (!($chartType instanceof Area)) { |
|
767 | 12 | $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType()); |
|
768 | } |
||
769 | } |
||
770 | 22 | $this->xmlContent->writeAttribute('draw:fill-color', '#'.$series->getFill()->getStartColor()->getRGB()); |
|
771 | // > style:graphic-properties |
||
772 | 22 | $this->xmlContent->endElement(); |
|
773 | // style:text-properties |
||
774 | 22 | $this->xmlContent->startElement('style:text-properties'); |
|
775 | 22 | $this->xmlContent->writeAttribute('fo:color', '#'.$series->getFont()->getColor()->getRGB()); |
|
776 | 22 | $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName()); |
|
777 | 22 | $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize().'pt'); |
|
778 | // > style:text-properties |
||
779 | 22 | $this->xmlContent->endElement(); |
|
780 | |||
781 | // > style:style |
||
782 | 22 | $this->xmlContent->endElement(); |
|
783 | |||
784 | 22 | foreach ($series->getDataPointFills() as $idx => $oFill) { |
|
785 | // style:style |
||
786 | 7 | $this->xmlContent->startElement('style:style'); |
|
787 | 7 | $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries.'_'.$idx); |
|
788 | 7 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
789 | // style:graphic-properties |
||
790 | 7 | $this->xmlContent->startElement('style:graphic-properties'); |
|
791 | 7 | $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType()); |
|
792 | 7 | $this->xmlContent->writeAttribute('draw:fill-color', '#'.$oFill->getStartColor()->getRGB()); |
|
793 | // > style:graphic-properties |
||
794 | 7 | $this->xmlContent->endElement(); |
|
795 | // > style:style |
||
796 | 7 | $this->xmlContent->endElement(); |
|
797 | } |
||
798 | 22 | } |
|
799 | |||
800 | /** |
||
801 | */ |
||
802 | 24 | private function writeTable() |
|
896 | |||
897 | /** |
||
898 | * @param Title $oTitle |
||
899 | */ |
||
900 | 24 | private function writeTitle(Title $oTitle) |
|
901 | { |
||
902 | 24 | if (!$oTitle->isVisible()) { |
|
903 | 1 | return; |
|
904 | } |
||
905 | // chart:title |
||
906 | 24 | $this->xmlContent->startElement('chart:title'); |
|
907 | 24 | $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm'); |
|
908 | 24 | $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm'); |
|
909 | 24 | $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle'); |
|
910 | // > text:p |
||
911 | 24 | $this->xmlContent->startElement('text:p'); |
|
912 | 24 | $this->xmlContent->text($oTitle->getText()); |
|
913 | 24 | $this->xmlContent->endElement(); |
|
914 | // > chart:title |
||
915 | 24 | $this->xmlContent->endElement(); |
|
916 | 24 | } |
|
917 | |||
918 | /** |
||
919 | * @param Title $oTitle |
||
920 | */ |
||
921 | 24 | private function writeTitleStyle(Title $oTitle) |
|
922 | { |
||
923 | 24 | if (!$oTitle->isVisible()) { |
|
924 | 1 | return; |
|
925 | } |
||
926 | // style:style |
||
927 | 24 | $this->xmlContent->startElement('style:style'); |
|
928 | 24 | $this->xmlContent->writeAttribute('style:name', 'styleTitle'); |
|
929 | 24 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
930 | // style:text-properties |
||
931 | 24 | $this->xmlContent->startElement('style:text-properties'); |
|
932 | 24 | $this->xmlContent->writeAttribute('fo:color', '#'.$oTitle->getFont()->getColor()->getRGB()); |
|
933 | 24 | $this->xmlContent->writeAttribute('fo:font-family', $oTitle->getFont()->getName()); |
|
934 | 24 | $this->xmlContent->writeAttribute('fo:font-size', $oTitle->getFont()->getSize().'pt'); |
|
935 | 24 | $this->xmlContent->writeAttribute('fo:font-style', $oTitle->getFont()->isItalic() ? 'italic' : 'normal'); |
|
936 | // > style:text-properties |
||
937 | 24 | $this->xmlContent->endElement(); |
|
938 | // > style:style |
||
939 | 24 | $this->xmlContent->endElement(); |
|
940 | 24 | } |
|
941 | |||
942 | 24 | private function writeWall() |
|
949 | |||
950 | /** |
||
951 | * @param Chart $chart |
||
952 | * @throws \Exception |
||
953 | */ |
||
954 | 24 | private function writeWallStyle(Chart $chart) |
|
979 | } |
||
980 |