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
|
|
|
use PhpOffice\PhpPresentation\Style\Font; |
22
|
|
|
use PhpOffice\PhpPresentation\Style\Outline; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* \PhpOffice\PhpPresentation\Shape\Chart\Axis |
26
|
|
|
*/ |
27
|
|
|
class Axis implements ComparableInterface |
28
|
|
|
{ |
29
|
|
|
const AXIS_X = 'x'; |
30
|
|
|
const AXIS_Y = 'y'; |
31
|
|
|
|
32
|
|
|
const TICK_MARK_NONE = 'none'; |
33
|
|
|
const TICK_MARK_CROSS = 'cross'; |
34
|
|
|
const TICK_MARK_INSIDE = 'in'; |
35
|
|
|
const TICK_MARK_OUTSIDE = 'out'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Title |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $title = 'Axis Title'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Format code |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $formatCode = ''; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Font |
53
|
|
|
* |
54
|
|
|
* @var \PhpOffice\PhpPresentation\Style\Font |
55
|
|
|
*/ |
56
|
|
|
private $font; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var Gridlines |
60
|
|
|
*/ |
61
|
|
|
protected $majorGridlines; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var Gridlines |
65
|
|
|
*/ |
66
|
|
|
protected $minorGridlines; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var int |
70
|
|
|
*/ |
71
|
|
|
protected $minBounds; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var int |
75
|
|
|
*/ |
76
|
|
|
protected $maxBounds; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var string |
80
|
|
|
*/ |
81
|
|
|
protected $minorTickMark = self::TICK_MARK_NONE; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var string |
85
|
|
|
*/ |
86
|
|
|
protected $majorTickMark = self::TICK_MARK_NONE; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var float |
90
|
|
|
*/ |
91
|
|
|
protected $minorUnit; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var float |
95
|
|
|
*/ |
96
|
|
|
protected $majorUnit; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var Outline |
100
|
|
|
*/ |
101
|
|
|
protected $outline; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance |
105
|
|
|
* |
106
|
|
|
* @param string $title Title |
107
|
|
|
*/ |
108
|
75 |
|
public function __construct($title = 'Axis Title') |
109
|
|
|
{ |
110
|
75 |
|
$this->title = $title; |
111
|
75 |
|
$this->outline = new Outline(); |
112
|
75 |
|
$this->font = new Font(); |
113
|
75 |
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get Title |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
26 |
|
public function getTitle() |
121
|
|
|
{ |
122
|
26 |
|
return $this->title; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Set Title |
127
|
|
|
* |
128
|
|
|
* @param string $value |
129
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis |
130
|
|
|
*/ |
131
|
1 |
|
public function setTitle($value = 'Axis Title') |
132
|
|
|
{ |
133
|
1 |
|
$this->title = $value; |
134
|
|
|
|
135
|
1 |
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get font |
140
|
|
|
* |
141
|
|
|
* @return \PhpOffice\PhpPresentation\Style\Font |
142
|
|
|
*/ |
143
|
49 |
|
public function getFont() |
144
|
|
|
{ |
145
|
49 |
|
return $this->font; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set font |
150
|
|
|
* |
151
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font |
152
|
|
|
* @throws \Exception |
153
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
154
|
|
|
*/ |
155
|
1 |
|
public function setFont(Font $pFont = null) |
156
|
|
|
{ |
157
|
1 |
|
$this->font = $pFont; |
158
|
1 |
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Get Format Code |
163
|
|
|
* |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
25 |
|
public function getFormatCode() |
167
|
|
|
{ |
168
|
25 |
|
return $this->formatCode; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Set Format Code |
173
|
|
|
* |
174
|
|
|
* @param string $value |
175
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis |
176
|
|
|
*/ |
177
|
1 |
|
public function setFormatCode($value = '') |
178
|
|
|
{ |
179
|
1 |
|
$this->formatCode = $value; |
180
|
|
|
|
181
|
1 |
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return int|null |
186
|
|
|
*/ |
187
|
48 |
|
public function getMinBounds() |
188
|
|
|
{ |
189
|
48 |
|
return $this->minBounds; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param int|null $minBounds |
194
|
|
|
* @return Axis |
195
|
|
|
*/ |
196
|
3 |
|
public function setMinBounds($minBounds = null) |
197
|
|
|
{ |
198
|
3 |
|
$this->minBounds = is_null($minBounds) ? null : (int)$minBounds; |
199
|
3 |
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @return int|null |
204
|
|
|
*/ |
205
|
48 |
|
public function getMaxBounds() |
206
|
|
|
{ |
207
|
48 |
|
return $this->maxBounds; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param int|null $maxBounds |
212
|
|
|
* @return Axis |
213
|
|
|
*/ |
214
|
3 |
|
public function setMaxBounds($maxBounds = null) |
215
|
|
|
{ |
216
|
3 |
|
$this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds; |
217
|
3 |
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return Gridlines |
222
|
|
|
*/ |
223
|
49 |
|
public function getMajorGridlines() |
224
|
|
|
{ |
225
|
49 |
|
return $this->majorGridlines; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param Gridlines $majorGridlines |
230
|
|
|
* @return Axis |
231
|
|
|
*/ |
232
|
3 |
|
public function setMajorGridlines(Gridlines $majorGridlines) |
233
|
|
|
{ |
234
|
3 |
|
$this->majorGridlines = $majorGridlines; |
235
|
3 |
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return Gridlines |
240
|
|
|
*/ |
241
|
49 |
|
public function getMinorGridlines() |
242
|
|
|
{ |
243
|
49 |
|
return $this->minorGridlines; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param Gridlines $minorGridlines |
248
|
|
|
* @return Axis |
249
|
|
|
*/ |
250
|
3 |
|
public function setMinorGridlines(Gridlines $minorGridlines) |
251
|
|
|
{ |
252
|
3 |
|
$this->minorGridlines = $minorGridlines; |
253
|
3 |
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @return string |
258
|
|
|
*/ |
259
|
25 |
|
public function getMinorTickMark() |
260
|
|
|
{ |
261
|
25 |
|
return $this->minorTickMark; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param string $pTickMark |
266
|
|
|
* @return Axis |
267
|
|
|
*/ |
268
|
2 |
|
public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE) |
269
|
|
|
{ |
270
|
2 |
|
$this->minorTickMark = $pTickMark; |
271
|
2 |
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @return string |
276
|
|
|
*/ |
277
|
25 |
|
public function getMajorTickMark() |
278
|
|
|
{ |
279
|
25 |
|
return $this->majorTickMark; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @param string $pTickMark |
284
|
|
|
* @return Axis |
285
|
|
|
*/ |
286
|
2 |
|
public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE) |
287
|
|
|
{ |
288
|
2 |
|
$this->majorTickMark = $pTickMark; |
289
|
2 |
|
return $this; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @return float |
294
|
|
|
*/ |
295
|
25 |
|
public function getMinorUnit() |
296
|
|
|
{ |
297
|
25 |
|
return $this->minorUnit; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @param float $pUnit |
302
|
|
|
* @return Axis |
303
|
|
|
*/ |
304
|
2 |
|
public function setMinorUnit($pUnit = null) |
305
|
|
|
{ |
306
|
2 |
|
$this->minorUnit = $pUnit; |
307
|
2 |
|
return $this; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @return float |
312
|
|
|
*/ |
313
|
25 |
|
public function getMajorUnit() |
314
|
|
|
{ |
315
|
25 |
|
return $this->majorUnit; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @param float $pUnit |
320
|
|
|
* @return Axis |
321
|
|
|
*/ |
322
|
2 |
|
public function setMajorUnit($pUnit = null) |
323
|
|
|
{ |
324
|
2 |
|
$this->majorUnit = $pUnit; |
325
|
2 |
|
return $this; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @return Outline |
330
|
|
|
*/ |
331
|
24 |
|
public function getOutline() |
332
|
|
|
{ |
333
|
24 |
|
return $this->outline; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* @param Outline $outline |
338
|
|
|
* @return Axis |
339
|
|
|
*/ |
340
|
|
|
public function setOutline($outline) |
341
|
|
|
{ |
342
|
|
|
$this->outline = $outline; |
343
|
|
|
return $this; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Get hash code |
348
|
|
|
* |
349
|
|
|
* @return string Hash code |
350
|
|
|
*/ |
351
|
54 |
|
public function getHashCode() |
352
|
|
|
{ |
353
|
54 |
|
return md5($this->title . $this->formatCode . __CLASS__); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* Hash index |
358
|
|
|
* |
359
|
|
|
* @var string |
360
|
|
|
*/ |
361
|
|
|
private $hashIndex; |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* Get hash index |
365
|
|
|
* |
366
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
367
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
368
|
|
|
* |
369
|
|
|
* @return string Hash index |
370
|
|
|
*/ |
371
|
1 |
|
public function getHashIndex() |
372
|
|
|
{ |
373
|
1 |
|
return $this->hashIndex; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* Set hash index |
378
|
|
|
* |
379
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
380
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
381
|
|
|
* |
382
|
|
|
* @param string $value Hash index |
383
|
|
|
*/ |
384
|
1 |
|
public function setHashIndex($value) |
385
|
|
|
{ |
386
|
1 |
|
$this->hashIndex = $value; |
387
|
1 |
|
return $this; |
388
|
|
|
} |
389
|
|
|
} |
390
|
|
|
|