getFill() public méthode

Get Fill
public getFill ( ) : PhpOffice\PhpPresentation\Style\Fill
Résultat PhpOffice\PhpPresentation\Style\Fill
 public function testTypeArea()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oArea = new Area();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
     $oArea->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oArea);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
 public function testChartArea()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->getFill()->setStartColor(new Color('FF93A9CE'));
     $oArea = new Area();
     $oArea->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oArea);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'draw:fill', 'Object 1/content.xml'));
     $this->assertTrue($pres->attributeElementExists($element, 'draw:fill-color', 'Object 1/content.xml'));
     $this->assertEquals('#93A9CE', $pres->getElementAttribute($element, 'draw:fill-color', 'Object 1/content.xml'));
 }
Exemple #3
0
 public function testHashCode()
 {
     $object = new Series();
     $this->assertEquals(md5($object->getFill()->getHashCode() . $object->getFont()->getHashCode() . var_export($object->getValues(), true) . var_export($object, true) . get_class($object)), $object->getHashCode());
 }
 /**
  * @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();
     }
 }
function fnSlide_Bar3D(PhpPresentation $objPHPPresentation)
{
    global $oFill;
    global $oShadow;
    // Create templated slide
    echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
    $currentSlide = createTemplatedSlide($objPHPPresentation);
    // Generate sample data for first chart
    echo date('H:i:s') . ' Generate sample data for chart' . EOL;
    $series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
    $series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
    // Create a bar chart (that should be inserted in a shape)
    echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)' . EOL;
    $bar3DChart = new Bar3D();
    $series1 = new Series('2009', $series1Data);
    $series1->setShowSeriesName(true);
    $series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD'));
    $series1->getFont()->getColor()->setRGB('00FF00');
    $series1->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
    $series2 = new Series('2010', $series2Data);
    $series2->setShowSeriesName(true);
    $series2->getFont()->getColor()->setRGB('FF0000');
    $series2->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFC0504D'));
    $bar3DChart->addSeries($series1);
    $bar3DChart->addSeries($series2);
    // Create a shape (chart)
    echo date('H:i:s') . ' Create a shape (chart)' . EOL;
    $shape = $currentSlide->createChartShape();
    $shape->setName('PHPPresentation Monthly Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
    $shape->setShadow($oShadow);
    $shape->setFill($oFill);
    $shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getTitle()->setText('PHPPresentation Monthly Downloads');
    $shape->getTitle()->getFont()->setItalic(true);
    $shape->getTitle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
    $shape->getPlotArea()->getAxisX()->setTitle('Month');
    $shape->getPlotArea()->getAxisY()->setTitle('Downloads');
    $shape->getPlotArea()->setType($bar3DChart);
    $shape->getView3D()->setRightAngleAxes(true);
    $shape->getView3D()->setRotationX(20);
    $shape->getView3D()->setRotationY(20);
    $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getLegend()->getFont()->setItalic(true);
}
 /**
  * @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();
     }
 }