|
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; |
|
19
|
|
|
|
|
20
|
|
|
use PhpOffice\PhpPresentation\ComparableInterface; |
|
21
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Legend; |
|
22
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\PlotArea; |
|
23
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\Title; |
|
24
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart\View3D; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Chart element |
|
28
|
|
|
*/ |
|
29
|
|
|
class Chart extends AbstractGraphic implements ComparableInterface |
|
30
|
|
|
{ |
|
31
|
|
|
/* possible values for $this->>displayBlankAs (dispBlanksAs "display blank as") options */ |
|
32
|
|
|
const BLANKS_GAP = 'gap'; |
|
33
|
|
|
const BLANKS_ZERO = 'zero'; |
|
34
|
|
|
const BLANKS_SPAN = 'span'; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Title |
|
38
|
|
|
* |
|
39
|
|
|
* @var \PhpOffice\PhpPresentation\Shape\Chart\Title |
|
40
|
|
|
*/ |
|
41
|
|
|
private $title; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Legend |
|
45
|
|
|
* |
|
46
|
|
|
* @var \PhpOffice\PhpPresentation\Shape\Chart\Legend |
|
47
|
|
|
*/ |
|
48
|
|
|
private $legend; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Plot area |
|
52
|
|
|
* |
|
53
|
|
|
* @var \PhpOffice\PhpPresentation\Shape\Chart\PlotArea |
|
54
|
|
|
*/ |
|
55
|
|
|
private $plotArea; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* View 3D |
|
59
|
|
|
* |
|
60
|
|
|
* @var \PhpOffice\PhpPresentation\Shape\Chart\View3D |
|
61
|
|
|
*/ |
|
62
|
|
|
private $view3D; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation |
|
66
|
|
|
* |
|
67
|
|
|
* @var bool |
|
68
|
|
|
*/ |
|
69
|
|
|
private $includeSpreadsheet = false; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* How to display blank (missing) values? Not set by default. |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
private $displayBlankAs; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Create a new Chart |
|
79
|
|
|
*/ |
|
80
|
65 |
|
public function __construct() |
|
81
|
|
|
{ |
|
82
|
|
|
// Initialize |
|
83
|
65 |
|
$this->title = new Title(); |
|
84
|
65 |
|
$this->legend = new Legend(); |
|
85
|
65 |
|
$this->plotArea = new PlotArea(); |
|
86
|
65 |
|
$this->view3D = new View3D(); |
|
87
|
|
|
|
|
88
|
|
|
// Initialize parent |
|
89
|
65 |
|
parent::__construct(); |
|
90
|
65 |
|
} |
|
91
|
|
|
|
|
92
|
1 |
|
public function __clone() |
|
93
|
|
|
{ |
|
94
|
1 |
|
parent::__clone(); |
|
95
|
|
|
|
|
96
|
1 |
|
$this->title = clone $this->title; |
|
97
|
1 |
|
$this->legend = clone $this->legend; |
|
98
|
1 |
|
$this->plotArea = clone $this->plotArea; |
|
99
|
1 |
|
$this->view3D = clone $this->view3D; |
|
100
|
1 |
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get Title |
|
104
|
|
|
* |
|
105
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title |
|
106
|
|
|
*/ |
|
107
|
61 |
|
public function getTitle() |
|
108
|
|
|
{ |
|
109
|
61 |
|
return $this->title; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Get Legend |
|
114
|
|
|
* |
|
115
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend |
|
116
|
|
|
*/ |
|
117
|
60 |
|
public function getLegend() |
|
118
|
|
|
{ |
|
119
|
60 |
|
return $this->legend; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Get PlotArea |
|
124
|
|
|
* |
|
125
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea |
|
126
|
|
|
*/ |
|
127
|
61 |
|
public function getPlotArea() |
|
128
|
|
|
{ |
|
129
|
61 |
|
return $this->plotArea; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Get View3D |
|
134
|
|
|
* |
|
135
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D |
|
136
|
|
|
*/ |
|
137
|
37 |
|
public function getView3D() |
|
138
|
|
|
{ |
|
139
|
37 |
|
return $this->view3D; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation |
|
144
|
|
|
* |
|
145
|
|
|
* @return boolean |
|
146
|
|
|
*/ |
|
147
|
35 |
|
public function hasIncludedSpreadsheet() |
|
148
|
|
|
{ |
|
149
|
35 |
|
return $this->includeSpreadsheet; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* How missing/blank values are displayed on chart (dispBlanksAs property) |
|
154
|
|
|
* |
|
155
|
|
|
* @return string |
|
156
|
|
|
*/ |
|
157
|
35 |
|
public function getDisplayBlankAs() |
|
158
|
|
|
{ |
|
159
|
35 |
|
return $this->displayBlankAs; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation |
|
164
|
|
|
* |
|
165
|
|
|
* @param boolean $value |
|
166
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart |
|
167
|
|
|
*/ |
|
168
|
1 |
|
public function setIncludeSpreadsheet($value = false) |
|
169
|
|
|
{ |
|
170
|
1 |
|
$this->includeSpreadsheet = $value; |
|
171
|
1 |
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Define a way to display missing/blank values (dispBlanksAs property) |
|
176
|
|
|
* |
|
177
|
|
|
* @param string $value |
|
178
|
|
|
* @return string |
|
179
|
|
|
* @throws \Exception |
|
180
|
|
|
*/ |
|
181
|
2 |
|
public function setDisplayBlankAs($value) |
|
182
|
|
|
{ |
|
183
|
2 |
|
$allowedValues = array(self::BLANKS_GAP, self::BLANKS_SPAN, self::BLANKS_ZERO); |
|
184
|
2 |
|
if (!in_array($value, $allowedValues)) { |
|
185
|
1 |
|
throw new \Exception("Unknown value: " . $value); |
|
186
|
|
|
} |
|
187
|
1 |
|
$this->displayBlankAs = $value; |
|
188
|
1 |
|
return $this->displayBlankAs; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Get indexed filename (using image index) |
|
193
|
|
|
* |
|
194
|
|
|
* @return string |
|
195
|
|
|
*/ |
|
196
|
35 |
|
public function getIndexedFilename() |
|
197
|
|
|
{ |
|
198
|
35 |
|
return 'chart' . $this->getImageIndex() . '.xml'; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Get hash code |
|
203
|
|
|
* |
|
204
|
|
|
* @return string Hash code |
|
205
|
|
|
*/ |
|
206
|
59 |
|
public function getHashCode() |
|
207
|
|
|
{ |
|
208
|
59 |
|
return md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__); |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|