Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2388 jpm 1
<?php
2
/**
3
 * PHPExcel
4
 *
5
 * Copyright (c) 2006 - 2013 PHPExcel
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 *
21
 * @category	PHPExcel
22
 * @package		PHPExcel_Chart
23
 * @copyright	Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
24
 * @license		http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
25
 * @version		##VERSION##, ##DATE##
26
 */
27
 
28
 
29
/**
30
 * PHPExcel_Chart
31
 *
32
 * @category	PHPExcel
33
 * @package		PHPExcel_Chart
34
 * @copyright	Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
35
 */
36
class PHPExcel_Chart
37
{
38
	/**
39
	 * Chart Name
40
	 *
41
	 * @var string
42
	 */
43
	private $_name = '';
44
 
45
	/**
46
	 * Worksheet
47
	 *
48
	 * @var PHPExcel_Worksheet
49
	 */
50
	private $_worksheet = null;
51
 
52
	/**
53
	 * Chart Title
54
	 *
55
	 * @var PHPExcel_Chart_Title
56
	 */
57
	private $_title = null;
58
 
59
	/**
60
	 * Chart Legend
61
	 *
62
	 * @var PHPExcel_Chart_Legend
63
	 */
64
	private $_legend = null;
65
 
66
	/**
67
	 * X-Axis Label
68
	 *
69
	 * @var PHPExcel_Chart_Title
70
	 */
71
	private $_xAxisLabel = null;
72
 
73
	/**
74
	 * Y-Axis Label
75
	 *
76
	 * @var PHPExcel_Chart_Title
77
	 */
78
	private $_yAxisLabel = null;
79
 
80
	/**
81
	 * Chart Plot Area
82
	 *
83
	 * @var PHPExcel_Chart_PlotArea
84
	 */
85
	private $_plotArea = null;
86
 
87
	/**
88
	 * Plot Visible Only
89
	 *
90
	 * @var boolean
91
	 */
92
	private $_plotVisibleOnly = true;
93
 
94
	/**
95
	 * Display Blanks as
96
	 *
97
	 * @var string
98
	 */
99
	private $_displayBlanksAs = '0';
100
 
101
 
102
	/**
103
	 * Top-Left Cell Position
104
	 *
105
	 * @var string
106
	 */
107
	private $_topLeftCellRef = 'A1';
108
 
109
 
110
	/**
111
	 * Top-Left X-Offset
112
	 *
113
	 * @var integer
114
	 */
115
	private $_topLeftXOffset = 0;
116
 
117
 
118
	/**
119
	 * Top-Left Y-Offset
120
	 *
121
	 * @var integer
122
	 */
123
	private $_topLeftYOffset = 0;
124
 
125
 
126
	/**
127
	 * Bottom-Right Cell Position
128
	 *
129
	 * @var string
130
	 */
131
	private $_bottomRightCellRef = 'A1';
132
 
133
 
134
	/**
135
	 * Bottom-Right X-Offset
136
	 *
137
	 * @var integer
138
	 */
139
	private $_bottomRightXOffset = 10;
140
 
141
 
142
	/**
143
	 * Bottom-Right Y-Offset
144
	 *
145
	 * @var integer
146
	 */
147
	private $_bottomRightYOffset = 10;
148
 
149
 
150
	/**
151
	 * Create a new PHPExcel_Chart
152
	 */
153
	public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null)
154
	{
155
		$this->_name = $name;
156
		$this->_title = $title;
157
		$this->_legend = $legend;
158
		$this->_xAxisLabel = $xAxisLabel;
159
		$this->_yAxisLabel = $yAxisLabel;
160
		$this->_plotArea = $plotArea;
161
		$this->_plotVisibleOnly = $plotVisibleOnly;
162
		$this->_displayBlanksAs = $displayBlanksAs;
163
	}
164
 
165
	/**
166
	 * Get Name
167
	 *
168
	 * @return string
169
	 */
170
	public function getName() {
171
		return $this->_name;
172
	}
173
 
174
	/**
175
	 * Get Worksheet
176
	 *
177
	 * @return PHPExcel_Worksheet
178
	 */
179
	public function getWorksheet() {
180
		return $this->_worksheet;
181
	}
182
 
183
	/**
184
	 * Set Worksheet
185
	 *
186
	 * @param	PHPExcel_Worksheet	$pValue
187
	 * @throws	PHPExcel_Chart_Exception
188
	 * @return PHPExcel_Chart
189
	 */
190
	public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
191
		$this->_worksheet = $pValue;
192
 
193
		return $this;
194
	}
195
 
196
	/**
197
	 * Get Title
198
	 *
199
	 * @return PHPExcel_Chart_Title
200
	 */
201
	public function getTitle() {
202
		return $this->_title;
203
	}
204
 
205
	/**
206
	 * Set Title
207
	 *
208
	 * @param	PHPExcel_Chart_Title $title
209
	 * @return	PHPExcel_Chart
210
	 */
211
	public function setTitle(PHPExcel_Chart_Title $title) {
212
		$this->_title = $title;
213
 
214
		return $this;
215
	}
216
 
217
	/**
218
	 * Get Legend
219
	 *
220
	 * @return PHPExcel_Chart_Legend
221
	 */
222
	public function getLegend() {
223
		return $this->_legend;
224
	}
225
 
226
	/**
227
	 * Set Legend
228
	 *
229
	 * @param	PHPExcel_Chart_Legend $legend
230
	 * @return	PHPExcel_Chart
231
	 */
232
	public function setLegend(PHPExcel_Chart_Legend $legend) {
233
		$this->_legend = $legend;
234
 
235
		return $this;
236
	}
237
 
238
	/**
239
	 * Get X-Axis Label
240
	 *
241
	 * @return PHPExcel_Chart_Title
242
	 */
243
	public function getXAxisLabel() {
244
		return $this->_xAxisLabel;
245
	}
246
 
247
	/**
248
	 * Set X-Axis Label
249
	 *
250
	 * @param	PHPExcel_Chart_Title $label
251
	 * @return	PHPExcel_Chart
252
	 */
253
	public function setXAxisLabel(PHPExcel_Chart_Title $label) {
254
		$this->_xAxisLabel = $label;
255
 
256
		return $this;
257
	}
258
 
259
	/**
260
	 * Get Y-Axis Label
261
	 *
262
	 * @return PHPExcel_Chart_Title
263
	 */
264
	public function getYAxisLabel() {
265
		return $this->_yAxisLabel;
266
	}
267
 
268
	/**
269
	 * Set Y-Axis Label
270
	 *
271
	 * @param	PHPExcel_Chart_Title $label
272
	 * @return	PHPExcel_Chart
273
	 */
274
	public function setYAxisLabel(PHPExcel_Chart_Title $label) {
275
		$this->_yAxisLabel = $label;
276
 
277
		return $this;
278
	}
279
 
280
	/**
281
	 * Get Plot Area
282
	 *
283
	 * @return PHPExcel_Chart_PlotArea
284
	 */
285
	public function getPlotArea() {
286
		return $this->_plotArea;
287
	}
288
 
289
	/**
290
	 * Get Plot Visible Only
291
	 *
292
	 * @return boolean
293
	 */
294
	public function getPlotVisibleOnly() {
295
		return $this->_plotVisibleOnly;
296
	}
297
 
298
	/**
299
	 * Set Plot Visible Only
300
	 *
301
	 * @param boolean $plotVisibleOnly
302
	 * @return PHPExcel_Chart
303
	 */
304
	public function setPlotVisibleOnly($plotVisibleOnly = true) {
305
		$this->_plotVisibleOnly = $plotVisibleOnly;
306
 
307
		return $this;
308
	}
309
 
310
	/**
311
	 * Get Display Blanks as
312
	 *
313
	 * @return string
314
	 */
315
	public function getDisplayBlanksAs() {
316
		return $this->_displayBlanksAs;
317
	}
318
 
319
	/**
320
	 * Set Display Blanks as
321
	 *
322
	 * @param string $displayBlanksAs
323
	 * @return PHPExcel_Chart
324
	 */
325
	public function setDisplayBlanksAs($displayBlanksAs = '0') {
326
		$this->_displayBlanksAs = $displayBlanksAs;
327
	}
328
 
329
 
330
	/**
331
	 * Set the Top Left position for the chart
332
	 *
333
	 * @param	string	$cell
334
	 * @param	integer	$xOffset
335
	 * @param	integer	$yOffset
336
	 * @return PHPExcel_Chart
337
	 */
338
	public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
339
		$this->_topLeftCellRef = $cell;
340
		if (!is_null($xOffset))
341
			$this->setTopLeftXOffset($xOffset);
342
		if (!is_null($yOffset))
343
			$this->setTopLeftYOffset($yOffset);
344
 
345
		return $this;
346
	}
347
 
348
	/**
349
	 * Get the top left position of the chart
350
	 *
351
	 * @return array	an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
352
	 */
353
	public function getTopLeftPosition() {
354
		return array( 'cell'	=> $this->_topLeftCellRef,
355
					  'xOffset'	=> $this->_topLeftXOffset,
356
					  'yOffset'	=> $this->_topLeftYOffset
357
					);
358
	}
359
 
360
	/**
361
	 * Get the cell address where the top left of the chart is fixed
362
	 *
363
	 * @return string
364
	 */
365
	public function getTopLeftCell() {
366
		return $this->_topLeftCellRef;
367
	}
368
 
369
	/**
370
	 * Set the Top Left cell position for the chart
371
	 *
372
	 * @param	string	$cell
373
	 * @return PHPExcel_Chart
374
	 */
375
	public function setTopLeftCell($cell) {
376
		$this->_topLeftCellRef = $cell;
377
 
378
		return $this;
379
	}
380
 
381
	/**
382
	 * Set the offset position within the Top Left cell for the chart
383
	 *
384
	 * @param	integer	$xOffset
385
	 * @param	integer	$yOffset
386
	 * @return PHPExcel_Chart
387
	 */
388
	public function setTopLeftOffset($xOffset=null,$yOffset=null) {
389
		if (!is_null($xOffset))
390
			$this->setTopLeftXOffset($xOffset);
391
		if (!is_null($yOffset))
392
			$this->setTopLeftYOffset($yOffset);
393
 
394
		return $this;
395
	}
396
 
397
	/**
398
	 * Get the offset position within the Top Left cell for the chart
399
	 *
400
	 * @return integer[]
401
	 */
402
	public function getTopLeftOffset() {
403
		return array( 'X' => $this->_topLeftXOffset,
404
					  'Y' => $this->_topLeftYOffset
405
					);
406
	}
407
 
408
	public function setTopLeftXOffset($xOffset) {
409
		$this->_topLeftXOffset = $xOffset;
410
 
411
		return $this;
412
	}
413
 
414
	public function getTopLeftXOffset() {
415
		return $this->_topLeftXOffset;
416
	}
417
 
418
	public function setTopLeftYOffset($yOffset) {
419
		$this->_topLeftYOffset = $yOffset;
420
 
421
		return $this;
422
	}
423
 
424
	public function getTopLeftYOffset() {
425
		return $this->_topLeftYOffset;
426
	}
427
 
428
	/**
429
	 * Set the Bottom Right position of the chart
430
	 *
431
	 * @param	string	$cell
432
	 * @param	integer	$xOffset
433
	 * @param	integer	$yOffset
434
	 * @return PHPExcel_Chart
435
	 */
436
	public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
437
		$this->_bottomRightCellRef = $cell;
438
		if (!is_null($xOffset))
439
			$this->setBottomRightXOffset($xOffset);
440
		if (!is_null($yOffset))
441
			$this->setBottomRightYOffset($yOffset);
442
 
443
		return $this;
444
	}
445
 
446
	/**
447
	 * Get the bottom right position of the chart
448
	 *
449
	 * @return array	an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
450
	 */
451
	public function getBottomRightPosition() {
452
		return array( 'cell'	=> $this->_bottomRightCellRef,
453
					  'xOffset'	=> $this->_bottomRightXOffset,
454
					  'yOffset'	=> $this->_bottomRightYOffset
455
					);
456
	}
457
 
458
	public function setBottomRightCell($cell) {
459
		$this->_bottomRightCellRef = $cell;
460
 
461
		return $this;
462
	}
463
 
464
	/**
465
	 * Get the cell address where the bottom right of the chart is fixed
466
	 *
467
	 * @return string
468
	 */
469
	public function getBottomRightCell() {
470
		return $this->_bottomRightCellRef;
471
	}
472
 
473
	/**
474
	 * Set the offset position within the Bottom Right cell for the chart
475
	 *
476
	 * @param	integer	$xOffset
477
	 * @param	integer	$yOffset
478
	 * @return PHPExcel_Chart
479
	 */
480
	public function setBottomRightOffset($xOffset=null,$yOffset=null) {
481
		if (!is_null($xOffset))
482
			$this->setBottomRightXOffset($xOffset);
483
		if (!is_null($yOffset))
484
			$this->setBottomRightYOffset($yOffset);
485
 
486
		return $this;
487
	}
488
 
489
	/**
490
	 * Get the offset position within the Bottom Right cell for the chart
491
	 *
492
	 * @return integer[]
493
	 */
494
	public function getBottomRightOffset() {
495
		return array( 'X' => $this->_bottomRightXOffset,
496
					  'Y' => $this->_bottomRightYOffset
497
					);
498
	}
499
 
500
	public function setBottomRightXOffset($xOffset) {
501
		$this->_bottomRightXOffset = $xOffset;
502
 
503
		return $this;
504
	}
505
 
506
	public function getBottomRightXOffset() {
507
		return $this->_bottomRightXOffset;
508
	}
509
 
510
	public function setBottomRightYOffset($yOffset) {
511
		$this->_bottomRightYOffset = $yOffset;
512
 
513
		return $this;
514
	}
515
 
516
	public function getBottomRightYOffset() {
517
		return $this->_bottomRightYOffset;
518
	}
519
 
520
 
521
	public function refresh() {
522
		if ($this->_worksheet !== NULL) {
523
			$this->_plotArea->refresh($this->_worksheet);
524
		}
525
	}
526
 
527
	public function render($outputDestination = null) {
528
		$libraryName = PHPExcel_Settings::getChartRendererName();
529
		if (is_null($libraryName)) {
530
			return false;
531
		}
532
		//	Ensure that data series values are up-to-date before we render
533
		$this->refresh();
534
 
535
		$libraryPath = PHPExcel_Settings::getChartRendererPath();
536
		$includePath = str_replace('\\','/',get_include_path());
537
		$rendererPath = str_replace('\\','/',$libraryPath);
538
		if (strpos($rendererPath,$includePath) === false) {
539
			set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
540
		}
541
 
542
		$rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
543
		$renderer = new $rendererName($this);
544
 
545
		if ($outputDestination == 'php://output') {
546
			$outputDestination = null;
547
		}
548
		return $renderer->render($outputDestination);
549
	}
550
 
551
}