Skip to content

Commit cc2b16c

Browse files
committed
Merge pull request #190 from Progi1984/issue169
#169
2 parents 1b84fa8 + 42c0f58 commit cc2b16c

28 files changed

+1153
-189
lines changed

CHANGELOG.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

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

1114
### Features
12-
- ODPresentation / PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116
13-
- ODPresentation Writer : Thumbnail of the presentation - @Progi1984 GH-125
14-
- PowerPoint2007 Writer : Thumbnail of the presentation - @Progi1984 GH-125
15-
- ODPresentation Writer : Add Font Support For Chart Axis - @jrking4 GH-186
16-
- PowerPoint2007 Writer : Add Font Support For Chart Axis - @jrking4 GH-186
17-
- PowerPoint2007 / Serialized Writer : Support for Zip Adapter - @Progi1984 GH-176
15+
- ODPresentation & PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116
16+
- ODPresentation & PowerPoint2007 Writer : Thumbnail of the presentation - @Progi1984 GH-125
17+
- ODPresentation & PowerPoint2007 Writer : Marker of Series in Line & Scatter chart is customizable - @Progi1984 GH-169
18+
- ODPresentation & PowerPoint2007 Writer : Outline of Series in Line & Scatter chart is customizable - @Progi1984 GH-169
19+
- PowerPoint2007 & Serialized Writer : Support for Zip Adapter - @Progi1984 GH-176
20+
- ODPresentation & PowerPoint2007 Writer : Add Font Support For Chart Axis - @jrking4 GH-186
1821

1922
## 0.6.0 - 2016-01-24
2023

docs/shapes_chart.rst

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Example:
99

1010
.. code-block:: php
1111
12-
$chartShape = $slide->createChartShape();
13-
12+
$chartShape = $slide->createChartShape();
13+
1414
Parts
1515
-----
1616

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

2323
.. code-block:: php
2424
25-
$chartShape = $slide->createChartShape();
26-
$oLine = new Line();
27-
$oShape->getPlotArea()->setType($oLine);
28-
// Hide the title
29-
$oShape->getTitle()->setVisible(false);
30-
25+
$chartShape = $slide->createChartShape();
26+
$oLine = new Line();
27+
$oShape->getPlotArea()->setType($oLine);
28+
// Hide the title
29+
$oShape->getTitle()->setVisible(false);
30+
31+
Series
32+
^^^^^^
33+
34+
You can custom the font of a serie.
35+
36+
.. code-block:: php
37+
$oSeries = new Series('Downloads', $seriesData);
38+
// Define the size
39+
$oSeries->getFont()->setSize(25);
40+
41+
You can custom the marker of a serie, for Line & Scatter charts.
42+
43+
.. code-block:: php
44+
use \PhpOffice\PhpPresentation\Shape\Chart\Marker;
45+
46+
$oSeries = new Series('Downloads', $seriesData);
47+
$oMarker = $oSeries->getMarker();
48+
$oMarker->setSymbol(Marker::SYMBOL_DASH)->setSize(10);
49+
50+
You can custom the line of a serie, for Line & Scatter charts.
51+
52+
.. code-block:: php
53+
use \PhpOffice\PhpPresentation\Style\Outline;
54+
55+
$oOutline = new Outline();
56+
// Define the color
57+
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
58+
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
59+
// Define the width (in points)
60+
$oOutline->setWidth(2);
61+
62+
$oSeries = new Series('Downloads', $seriesData);
63+
$oSeries->setOutline($oOutline);
64+
65+
You can define the position of the data label.
66+
Each position is described in `MSDN <https://msdn.microsoft.com/en-us/library/mt459417(v=office.12).aspx>`_
67+
68+
.. code-block:: php
69+
70+
$oSeries = new Series('Downloads', $seriesData);
71+
$oSeries->setLabelPosition(Series::LABEL_INSIDEEND);
72+
3173
Types
3274
-----
3375

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

4789
.. code-block:: php
4890
49-
$oBarChart = new Bar();
50-
$oBarChart->addSeries($oSeries1);
51-
$oBarChart->addSeries($oSeries2);
52-
$oBarChart->addSeries($oSeries3);
53-
$oBarChart->setBarGrouping(Bar::GROUPING_CLUSTERED);
54-
// OR
55-
$oBarChart->setBarGrouping(Bar::GROUPING_STACKED);
56-
// OR
57-
$oBarChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
91+
$oBarChart = new Bar();
92+
$oBarChart->addSeries($oSeries1);
93+
$oBarChart->addSeries($oSeries2);
94+
$oBarChart->addSeries($oSeries3);
95+
$oBarChart->setBarGrouping(Bar::GROUPING_CLUSTERED);
96+
// OR
97+
$oBarChart->setBarGrouping(Bar::GROUPING_STACKED);
98+
// OR
99+
$oBarChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
58100
59101
- Bar::GROUPING_CLUSTERED
60102
.. image:: images/chart_columns_52x60.png

samples/Sample_05_Chart.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function fnSlide_Area(PhpPresentation $objPHPPresentation) {
4545
$series->setShowSeriesName(true);
4646
$series->setShowValue(true);
4747
$series->getFill()->setStartColor(new Color('FF93A9CE'));
48+
$series->setLabelPosition(Series::LABEL_INSIDEEND);
4849
$areaChart->addSeries($series);
4950

5051
// Create a shape (chart)
@@ -210,6 +211,7 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation) {
210211
$shape->getLegend()->getBorder()->setLineStyle( Border::LINE_SINGLE );
211212
$shape->getLegend()->getFont()->setItalic( true );
212213
}
214+
213215
function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
214216
global $oFill;
215217
global $oShadow;
@@ -493,17 +495,19 @@ function fnSlide_Scatter(PhpPresentation $objPHPPresentation) {
493495
$lineChart = new Scatter();
494496
$series = new Series('Downloads', $seriesData);
495497
$series->setShowSeriesName(true);
498+
$series->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_DASH);
499+
$series->getMarker()->setSize(10);
496500
$lineChart->addSeries($series);
497501

498502
// Create a shape (chart)
499503
echo date('H:i:s') . ' Create a shape (chart)'.EOL;
500504
$shape = $currentSlide->createChartShape();
501505
$shape->setName('PHPPresentation Daily Download Distribution')
502-
->setResizeProportional(false)
503-
->setHeight(550)
504-
->setWidth(700)
505-
->setOffsetX(120)
506-
->setOffsetY(80);
506+
->setResizeProportional(false)
507+
->setHeight(550)
508+
->setWidth(700)
509+
->setOffsetX(120)
510+
->setOffsetY(80);
507511
$shape->setShadow($oShadow);
508512
$shape->setFill($oFill);
509513
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);

samples/Sample_05_Chart_Line.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// Set properties
2222
echo date('H:i:s') . ' Set properties' . EOL;
23-
$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');
23+
$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');
2424

2525
// Remove first slide
2626
echo date('H:i:s') . ' Remove first slide' . EOL;
@@ -36,13 +36,13 @@
3636
// Generate sample data for chart
3737
echo date('H:i:s') . ' Generate sample data for chart' . EOL;
3838
$seriesData = array(
39-
'Monday' => 12,
40-
'Tuesday' => 15,
41-
'Wednesday' => 13,
42-
'Thursday' => 17,
43-
'Friday' => 14,
44-
'Saturday' => 9,
45-
'Sunday' => 7
39+
'Monday' => 12,
40+
'Tuesday' => 15,
41+
'Wednesday' => 13,
42+
'Thursday' => 17,
43+
'Friday' => 14,
44+
'Saturday' => 9,
45+
'Sunday' => 7
4646
);
4747

4848
// Create templated slide
@@ -77,8 +77,18 @@
7777
$currentSlide = createTemplatedSlide($objPHPPresentation);
7878

7979
// Create a line chart (that should be inserted in a shape)
80+
$oOutline = new \PhpOffice\PhpPresentation\Style\Outline();
81+
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
82+
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
83+
$oOutline->setWidth(2);
84+
8085
echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL;
8186
$lineChart1 = clone $lineChart;
87+
$series1 = $lineChart1->getSeries();
88+
$series1[0]->setOutline($oOutline);
89+
$series1[0]->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_DIAMOND);
90+
$series1[0]->getMarker()->setSize(7);
91+
$lineChart1->setSeries($series1);
8292

8393
// Create a shape (chart)
8494
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
@@ -98,9 +108,11 @@
98108
// Create a line chart (that should be inserted in a shape)
99109
echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL;
100110
$lineChart2 = clone $lineChart;
101-
$series2 = $lineChart2->getData();
102-
$series2[0]->getFill()->setFillType(Fill::FILL_SOLID);
103-
$lineChart2->setData($series2);
111+
$series2 = $lineChart2->getSeries();
112+
$series2[0]->getFont()->setSize(25);
113+
$series2[0]->getMarker()->setSymbol(\PhpOffice\PhpPresentation\Shape\Chart\Marker::SYMBOL_TRIANGLE);
114+
$series2[0]->getMarker()->setSize(10);
115+
$lineChart2->setSeries($series2);
104116

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

119131
if (!CLI) {
120-
include_once 'Sample_Footer.php';
132+
include_once 'Sample_Footer.php';
121133
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* This file is part of PHPPresentation - A pure PHP library for reading and writing
4+
* presentations documents.
5+
*
6+
* PHPPresentation is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12+
*
13+
* @link https://github.com/PHPOffice/PHPPresentation
14+
* @copyright 2009-2015 PHPPresentation contributors
15+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16+
*/
17+
18+
namespace PhpOffice\PhpPresentation\Shape\Chart;
19+
20+
use PhpOffice\PhpPresentation\ComparableInterface;
21+
22+
/**
23+
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
24+
*/
25+
class Marker
26+
{
27+
const SYMBOL_CIRCLE = 'circle';
28+
const SYMBOL_DASH = 'dash';
29+
const SYMBOL_DIAMOND = 'diamond';
30+
const SYMBOL_DOT = 'dot';
31+
const SYMBOL_NONE = 'none';
32+
const SYMBOL_PLUS = 'plus';
33+
const SYMBOL_SQUARE = 'square';
34+
const SYMBOL_STAR = 'star';
35+
const SYMBOL_TRIANGLE = 'triangle';
36+
const SYMBOL_X = 'x';
37+
38+
public static $arraySymbol = array(
39+
self::SYMBOL_CIRCLE,
40+
self::SYMBOL_DASH,
41+
self::SYMBOL_DIAMOND,
42+
self::SYMBOL_DOT,
43+
self::SYMBOL_NONE,
44+
self::SYMBOL_PLUS,
45+
self::SYMBOL_SQUARE,
46+
self::SYMBOL_STAR,
47+
self::SYMBOL_TRIANGLE,
48+
self::SYMBOL_X
49+
);
50+
51+
/**
52+
* @var string
53+
*/
54+
protected $symbol = self::SYMBOL_NONE;
55+
56+
/**
57+
* @var int
58+
*/
59+
protected $size = 5;
60+
61+
/**
62+
* @return string
63+
*/
64+
public function getSymbol()
65+
{
66+
return $this->symbol;
67+
}
68+
69+
/**
70+
* @param string $symbol
71+
* @return Marker
72+
*/
73+
public function setSymbol($symbol = self::SYMBOL_NONE)
74+
{
75+
$this->symbol = $symbol;
76+
77+
return $this;
78+
}
79+
80+
/**
81+
* @return int
82+
*/
83+
public function getSize()
84+
{
85+
return $this->size;
86+
}
87+
88+
/**
89+
* @param int $size
90+
* @return Marker
91+
*/
92+
public function setSize($size = 5)
93+
{
94+
$this->size = $size;
95+
96+
return $this;
97+
}
98+
}

0 commit comments

Comments
 (0)