setDlblNumFormat() public method

Set Data Label NumFormat
public setDlblNumFormat ( string $value = '' ) : Series
$value string
return Series
Exemplo n.º 1
0
 public function testDataLabelNumFormat()
 {
     $object = new Series();
     $this->assertEmpty($object->getDlblNumFormat());
     $this->assertFalse($object->hasDlblNumFormat());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Series', $object->setDlblNumFormat('#%'));
     $this->assertEquals('#%', $object->getDlblNumFormat());
     $this->assertTrue($object->hasDlblNumFormat());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Series', $object->setDlblNumFormat());
     $this->assertEmpty($object->getDlblNumFormat());
     $this->assertFalse($object->hasDlblNumFormat());
 }
Exemplo n.º 2
0
function fnSlide_BarPercentStacked(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);
    $Series1Sum = array_sum($series1Data);
    foreach ($series1Data as $CatName => $Value) {
        $series1Data[$CatName] = round($Value / $Series1Sum, 2);
    }
    $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);
    $Series2Sum = array_sum($series2Data);
    foreach ($series2Data as $CatName => $Value) {
        $series2Data[$CatName] = round($Value / $Series2Sum, 2);
    }
    $series3Data = array('Jan' => 233, 'Feb' => 146, 'Mar' => 238, 'Apr' => 175, 'May' => 108, 'Jun' => 257, 'Jul' => 199, 'Aug' => 201, 'Sep' => 88, 'Oct' => 147, 'Nov' => 287, 'Dec' => 105);
    $Series3Sum = array_sum($series3Data);
    foreach ($series3Data as $CatName => $Value) {
        $series3Data[$CatName] = round($Value / $Series3Sum, 2);
    }
    // Create a bar chart (that should be inserted in a shape)
    echo date('H:i:s') . ' Create a percent stacked horizontal bar chart (that should be inserted in a chart shape)' . EOL;
    $PercentStackedBarChartHoriz = new Bar();
    $series1 = new Series('2009', $series1Data);
    $series1->setShowSeriesName(false);
    $series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD'));
    $series1->getFont()->getColor()->setRGB('00FF00');
    $series1->setShowValue(true);
    $series1->setShowPercentage(false);
    // Set Data Label Format For Chart To Display Percent
    $series1->setDlblNumFormat('#%');
    $series2 = new Series('2010', $series2Data);
    $series2->setShowSeriesName(false);
    $series2->getFont()->getColor()->setRGB('FF0000');
    $series2->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFC0504D'));
    $series2->setShowValue(true);
    $series2->setShowPercentage(false);
    $series2->setDlblNumFormat('#%');
    $series3 = new Series('2011', $series3Data);
    $series3->setShowSeriesName(false);
    $series3->getFont()->getColor()->setRGB('FF0000');
    $series3->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF804DC0'));
    $series3->setShowValue(true);
    $series3->setShowPercentage(false);
    $series3->setDlblNumFormat('#%');
    $PercentStackedBarChartHoriz->addSeries($series1);
    $PercentStackedBarChartHoriz->addSeries($series2);
    $PercentStackedBarChartHoriz->addSeries($series3);
    $PercentStackedBarChartHoriz->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
    $PercentStackedBarChartHoriz->setBarDirection(Bar3D::DIRECTION_HORIZONTAL);
    // 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($PercentStackedBarChartHoriz);
    $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getLegend()->getFont()->setItalic(true);
}