Skip to content

Commit

Permalink
Merge pull request #190 from Progi1984/issue169
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Mar 7, 2016
2 parents 1b84fa8 + 42c0f58 commit cc2b16c
Show file tree
Hide file tree
Showing 28 changed files with 1,153 additions and 189 deletions.
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@

### Changes
- PhpOffice\PhpPresentation\Writer\PowerPoint2007 : Move to Design Pattern Decorator - @Progi1984
- PhpOffice\PhpPresentation\Shape\Type\AbstracType\getData has been deprecated for PhpOffice\PhpPresentation\Shape\Type\AbstracType\getSeries - @Progi1984 GH-169
- PhpOffice\PhpPresentation\Shape\Type\AbstracType\setData has been deprecated for PhpOffice\PhpPresentation\Shape\Type\AbstracType\setSeries - @Progi1984 GH-169
- Added documentation for chart series (font, outline, marker) - @Progi1984 GH-169

### Features
- ODPresentation / PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116
- ODPresentation Writer : Thumbnail of the presentation - @Progi1984 GH-125
- PowerPoint2007 Writer : Thumbnail of the presentation - @Progi1984 GH-125
- ODPresentation Writer : Add Font Support For Chart Axis - @jrking4 GH-186
- PowerPoint2007 Writer : Add Font Support For Chart Axis - @jrking4 GH-186
- PowerPoint2007 / Serialized Writer : Support for Zip Adapter - @Progi1984 GH-176
- ODPresentation & PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116
- ODPresentation & PowerPoint2007 Writer : Thumbnail of the presentation - @Progi1984 GH-125
- ODPresentation & PowerPoint2007 Writer : Marker of Series in Line & Scatter chart is customizable - @Progi1984 GH-169
- ODPresentation & PowerPoint2007 Writer : Outline of Series in Line & Scatter chart is customizable - @Progi1984 GH-169
- PowerPoint2007 & Serialized Writer : Support for Zip Adapter - @Progi1984 GH-176
- ODPresentation & PowerPoint2007 Writer : Add Font Support For Chart Axis - @jrking4 GH-186

## 0.6.0 - 2016-01-24

Expand Down
76 changes: 59 additions & 17 deletions docs/shapes_chart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Example:

.. code-block:: php
$chartShape = $slide->createChartShape();
$chartShape = $slide->createChartShape();
Parts
-----

Expand All @@ -22,12 +22,54 @@ For hiding it, you define its visibility to false.

.. code-block:: php
$chartShape = $slide->createChartShape();
$oLine = new Line();
$oShape->getPlotArea()->setType($oLine);
// Hide the title
$oShape->getTitle()->setVisible(false);
$chartShape = $slide->createChartShape();
$oLine = new Line();
$oShape->getPlotArea()->setType($oLine);
// Hide the title
$oShape->getTitle()->setVisible(false);
Series
^^^^^^

You can custom the font of a serie.

.. code-block:: php
$oSeries = new Series('Downloads', $seriesData);
// Define the size
$oSeries->getFont()->setSize(25);
You can custom the marker of a serie, for Line & Scatter charts.

.. code-block:: php
use \PhpOffice\PhpPresentation\Shape\Chart\Marker;
$oSeries = new Series('Downloads', $seriesData);
$oMarker = $oSeries->getMarker();
$oMarker->setSymbol(Marker::SYMBOL_DASH)->setSize(10);
You can custom the line of a serie, for Line & Scatter charts.

.. code-block:: php
use \PhpOffice\PhpPresentation\Style\Outline;
$oOutline = new Outline();
// Define the color
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
// Define the width (in points)
$oOutline->setWidth(2);
$oSeries = new Series('Downloads', $seriesData);
$oSeries->setOutline($oOutline);
You can define the position of the data label.
Each position is described in `MSDN <https://msdn.microsoft.com/en-us/library/mt459417(v=office.12).aspx>`_

.. code-block:: php
$oSeries = new Series('Downloads', $seriesData);
$oSeries->setLabelPosition(Series::LABEL_INSIDEEND);
Types
-----

Expand All @@ -46,15 +88,15 @@ You can stack multiples series in a same chart. After adding multiples series, y

.. code-block:: php
$oBarChart = new Bar();
$oBarChart->addSeries($oSeries1);
$oBarChart->addSeries($oSeries2);
$oBarChart->addSeries($oSeries3);
$oBarChart->setBarGrouping(Bar::GROUPING_CLUSTERED);
// OR
$oBarChart->setBarGrouping(Bar::GROUPING_STACKED);
// OR
$oBarChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
$oBarChart = new Bar();
$oBarChart->addSeries($oSeries1);
$oBarChart->addSeries($oSeries2);
$oBarChart->addSeries($oSeries3);
$oBarChart->setBarGrouping(Bar::GROUPING_CLUSTERED);
// OR
$oBarChart->setBarGrouping(Bar::GROUPING_STACKED);
// OR
$oBarChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
- Bar::GROUPING_CLUSTERED
.. image:: images/chart_columns_52x60.png
Expand Down
14 changes: 9 additions & 5 deletions samples/Sample_05_Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function fnSlide_Area(PhpPresentation $objPHPPresentation) {
$series->setShowSeriesName(true);
$series->setShowValue(true);
$series->getFill()->setStartColor(new Color('FF93A9CE'));
$series->setLabelPosition(Series::LABEL_INSIDEEND);
$areaChart->addSeries($series);

// Create a shape (chart)
Expand Down Expand Up @@ -210,6 +211,7 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation) {
$shape->getLegend()->getBorder()->setLineStyle( Border::LINE_SINGLE );
$shape->getLegend()->getFont()->setItalic( true );
}

function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
global $oFill;
global $oShadow;
Expand Down Expand Up @@ -493,17 +495,19 @@ function fnSlide_Scatter(PhpPresentation $objPHPPresentation) {
$lineChart = new Scatter();
$series = new Series('Downloads', $seriesData);
$series->setShowSeriesName(true);
$series->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_DASH);
$series->getMarker()->setSize(10);
$lineChart->addSeries($series);

// Create a shape (chart)
echo date('H:i:s') . ' Create a shape (chart)'.EOL;
$shape = $currentSlide->createChartShape();
$shape->setName('PHPPresentation Daily Download Distribution')
->setResizeProportional(false)
->setHeight(550)
->setWidth(700)
->setOffsetX(120)
->setOffsetY(80);
->setResizeProportional(false)
->setHeight(550)
->setWidth(700)
->setOffsetX(120)
->setOffsetY(80);
$shape->setShadow($oShadow);
$shape->setFill($oFill);
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
Expand Down
36 changes: 24 additions & 12 deletions samples/Sample_05_Chart_Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 07 Title')->setSubject('Sample 07 Subject')->setDescription('Sample 07 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 07 Title')->setSubject('Sample 07 Subject')->setDescription('Sample 07 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');

// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
Expand All @@ -36,13 +36,13 @@
// Generate sample data for chart
echo date('H:i:s') . ' Generate sample data for chart' . EOL;
$seriesData = array(
'Monday' => 12,
'Tuesday' => 15,
'Wednesday' => 13,
'Thursday' => 17,
'Friday' => 14,
'Saturday' => 9,
'Sunday' => 7
'Monday' => 12,
'Tuesday' => 15,
'Wednesday' => 13,
'Thursday' => 17,
'Friday' => 14,
'Saturday' => 9,
'Sunday' => 7
);

// Create templated slide
Expand Down Expand Up @@ -77,8 +77,18 @@
$currentSlide = createTemplatedSlide($objPHPPresentation);

// Create a line chart (that should be inserted in a shape)
$oOutline = new \PhpOffice\PhpPresentation\Style\Outline();
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
$oOutline->setWidth(2);

echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL;
$lineChart1 = clone $lineChart;
$series1 = $lineChart1->getSeries();
$series1[0]->setOutline($oOutline);
$series1[0]->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_DIAMOND);
$series1[0]->getMarker()->setSize(7);
$lineChart1->setSeries($series1);

// Create a shape (chart)
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
Expand All @@ -98,9 +108,11 @@
// Create a line chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL;
$lineChart2 = clone $lineChart;
$series2 = $lineChart2->getData();
$series2[0]->getFill()->setFillType(Fill::FILL_SOLID);
$lineChart2->setData($series2);
$series2 = $lineChart2->getSeries();
$series2[0]->getFont()->setSize(25);
$series2[0]->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_TRIANGLE);
$series2[0]->getMarker()->setSize(10);
$lineChart2->setSeries($series2);

// Create a shape (chart)
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
Expand All @@ -117,5 +129,5 @@
echo EOL . write($objPHPPresentation, basename(__FILE__, '.php'), $writers);

if (!CLI) {
include_once 'Sample_Footer.php';
include_once 'Sample_Footer.php';
}
98 changes: 98 additions & 0 deletions src/PhpPresentation/Shape/Chart/Marker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/**
* This file is part of PHPPresentation - A pure PHP library for reading and writing
* presentations documents.
*
* PHPPresentation is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
*
* @link https://github.com/PHPOffice/PHPPresentation
* @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

namespace PhpOffice\PhpPresentation\Shape\Chart;

use PhpOffice\PhpPresentation\ComparableInterface;

/**
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
*/
class Marker
{
const SYMBOL_CIRCLE = 'circle';
const SYMBOL_DASH = 'dash';
const SYMBOL_DIAMOND = 'diamond';
const SYMBOL_DOT = 'dot';
const SYMBOL_NONE = 'none';
const SYMBOL_PLUS = 'plus';
const SYMBOL_SQUARE = 'square';
const SYMBOL_STAR = 'star';
const SYMBOL_TRIANGLE = 'triangle';
const SYMBOL_X = 'x';

public static $arraySymbol = array(
self::SYMBOL_CIRCLE,
self::SYMBOL_DASH,
self::SYMBOL_DIAMOND,
self::SYMBOL_DOT,
self::SYMBOL_NONE,
self::SYMBOL_PLUS,
self::SYMBOL_SQUARE,
self::SYMBOL_STAR,
self::SYMBOL_TRIANGLE,
self::SYMBOL_X
);

/**
* @var string
*/
protected $symbol = self::SYMBOL_NONE;

/**
* @var int
*/
protected $size = 5;

/**
* @return string
*/
public function getSymbol()
{
return $this->symbol;
}

/**
* @param string $symbol
* @return Marker
*/
public function setSymbol($symbol = self::SYMBOL_NONE)
{
$this->symbol = $symbol;

return $this;
}

/**
* @return int
*/
public function getSize()
{
return $this->size;
}

/**
* @param int $size
* @return Marker
*/
public function setSize($size = 5)
{
$this->size = $size;

return $this;
}
}
Loading

0 comments on commit cc2b16c

Please sign in to comment.