Get DataPointFills
public getDataPointFills ( ) : PhpOffice\PhpPresentation\Style\Fill[] | ||
Résultat | PhpOffice\PhpPresentation\Style\Fill[] |
public function testDataPointFills() { $object = new Series(); $this->assertInternalType('array', $object->getDataPointFills()); $this->assertEmpty($object->getDataPointFills()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getDataPointFill(0)); }
/** * @param Chart $chart * @param Chart\Series $series */ private function writeSeriesStyle(Chart $chart, Chart\Series $series) { $chartType = $chart->getPlotArea()->getType(); // style:style $this->xmlContent->startElement('style:style'); $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries); $this->xmlContent->writeAttribute('style:family', 'chart'); // style:chart-properties $this->xmlContent->startElement('style:chart-properties'); $this->xmlContent->writeAttribute('chart:data-label-number', 'value'); $this->xmlContent->writeAttribute('chart:label-position', 'center'); if ($chartType instanceof AbstractTypePie) { $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion()); } if ($chartType instanceof Line) { //@todo : Permit edit the symbol of a line $this->xmlContent->writeAttribute('chart:symbol-type', 'automatic'); } // > style:chart-properties $this->xmlContent->endElement(); // style:graphic-properties $this->xmlContent->startElement('style:graphic-properties'); if ($chartType instanceof Line || $chartType instanceof Scatter) { //@todo : Permit edit the color and width of a line $this->xmlContent->writeAttribute('svg:stroke-width', '0.079cm'); $this->xmlContent->writeAttribute('svg:stroke-color', '#4a7ebb'); } else { $this->xmlContent->writeAttribute('draw:stroke', 'none'); if (!$chartType instanceof Area) { $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType()); } } $this->xmlContent->writeAttribute('draw:fill-color', '#' . $series->getFill()->getStartColor()->getRGB()); // > style:graphic-properties $this->xmlContent->endElement(); // style:text-properties $this->xmlContent->startElement('style:text-properties'); $this->xmlContent->writeAttribute('fo:color', '#' . $series->getFont()->getColor()->getRGB()); $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName()); $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize() . 'pt'); // > style:text-properties $this->xmlContent->endElement(); // > style:style $this->xmlContent->endElement(); foreach ($series->getDataPointFills() as $idx => $oFill) { // style:style $this->xmlContent->startElement('style:style'); $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries . '_' . $idx); $this->xmlContent->writeAttribute('style:family', 'chart'); // style:graphic-properties $this->xmlContent->startElement('style:graphic-properties'); $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType()); $this->xmlContent->writeAttribute('draw:fill-color', '#' . $oFill->getStartColor()->getRGB()); // > style:graphic-properties $this->xmlContent->endElement(); // > style:style $this->xmlContent->endElement(); } }
/** * @param Chart $chart * @param Chart\Series $series */ private function writeSeriesStyle(Chart $chart, Chart\Series $series) { $chartType = $chart->getPlotArea()->getType(); // style:style $this->xmlContent->startElement('style:style'); $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries); $this->xmlContent->writeAttribute('style:family', 'chart'); // style:chart-properties $this->xmlContent->startElement('style:chart-properties'); $this->xmlContent->writeAttribute('chart:data-label-number', 'value'); $this->xmlContent->writeAttribute('chart:label-position', 'center'); if ($chartType instanceof AbstractTypePie) { $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion()); } if ($chartType instanceof Line || $chartType instanceof Scatter) { $oMarker = $series->getMarker(); /** * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html */ $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none'); /** * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html */ $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol'); if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) { switch ($oMarker->getSymbol()) { case Chart\Marker::SYMBOL_DASH: $symbolName = 'horizontal-bar'; break; case Chart\Marker::SYMBOL_DOT: $symbolName = 'circle'; break; case Chart\Marker::SYMBOL_TRIANGLE: $symbolName = 'arrow-up'; break; default: $symbolName = $oMarker->getSymbol(); break; } $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName); $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', ''); $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize . 'cm'); $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize . 'cm'); } } // > style:chart-properties $this->xmlContent->endElement(); // style:graphic-properties $this->xmlContent->startElement('style:graphic-properties'); if ($chartType instanceof Line || $chartType instanceof Scatter) { $outlineWidth = ''; $outlineColor = ''; $oOutline = $series->getOutline(); if ($oOutline instanceof Outline) { $outlineWidth = $oOutline->getWidth(); if (!empty($outlineWidth)) { $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', ''); } $outlineColor = $oOutline->getFill()->getStartColor()->getRGB(); } if (empty($outlineWidth)) { $outlineWidth = '0.079'; } if (empty($outlineColor)) { $outlineColor = '4a7ebb'; } $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth . 'cm'); $this->xmlContent->writeAttribute('svg:stroke-color', '#' . $outlineColor); } else { $this->xmlContent->writeAttribute('draw:stroke', 'none'); if (!$chartType instanceof Area) { $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType()); } } $this->xmlContent->writeAttribute('draw:fill-color', '#' . $series->getFill()->getStartColor()->getRGB()); // > style:graphic-properties $this->xmlContent->endElement(); // style:text-properties $this->xmlContent->startElement('style:text-properties'); $this->xmlContent->writeAttribute('fo:color', '#' . $series->getFont()->getColor()->getRGB()); $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName()); $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize() . 'pt'); // > style:text-properties $this->xmlContent->endElement(); // > style:style $this->xmlContent->endElement(); foreach ($series->getDataPointFills() as $idx => $oFill) { // style:style $this->xmlContent->startElement('style:style'); $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries . '_' . $idx); $this->xmlContent->writeAttribute('style:family', 'chart'); // style:graphic-properties $this->xmlContent->startElement('style:graphic-properties'); $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType()); $this->xmlContent->writeAttribute('draw:fill-color', '#' . $oFill->getStartColor()->getRGB()); // > style:graphic-properties $this->xmlContent->endElement(); // > style:style $this->xmlContent->endElement(); } }