2 require_once 'Properties.php';
6 * User: Wiktor Trzonkowski
11 class PHPExcel_Chart_Axis
extends
21 $_axis_number = array(
22 'format' => self
::FORMAT_CODE_GENERAL
,
32 private $_axis_options = array(
37 'orientation' => self
::ORIENTATION_NORMAL
,
38 'minor_tick_mark' => self
::TICK_MARK_NONE
,
39 'major_tick_mark' => self
::TICK_MARK_NONE
,
40 'axis_labels' => self
::AXIS_LABELS_NEXT_TO
,
41 'horizontal_crosses' => self
::HORIZONTAL_CROSSES_AUTOZERO
,
42 'horizontal_crosses_value' => NULL
51 private $_fill_properties = array(
52 'type' => self
::EXCEL_COLOR_TYPE_ARGB
,
63 private $_line_properties = array(
64 'type' => self
::EXCEL_COLOR_TYPE_ARGB
,
70 * Line Style Properties
75 private $_line_style_properties = array(
77 'compound' => self
::LINE_STYLE_COMPOUND_SIMPLE
,
78 'dash' => self
::LINE_STYLE_DASH_SOLID
,
79 'cap' => self
::LINE_STYLE_CAP_FLAT
,
80 'join' => self
::LINE_STYLE_JOIN_BEVEL
,
83 'type' => self
::LINE_STYLE_ARROW_TYPE_NOARROW
,
84 'size' => self
::LINE_STYLE_ARROW_SIZE_5
87 'type' => self
::LINE_STYLE_ARROW_TYPE_NOARROW
,
88 'size' => self
::LINE_STYLE_ARROW_SIZE_8
99 private $_shadow_properties = array(
100 'presets' => self
::SHADOW_PRESETS_NOSHADOW
,
103 'type' => self
::EXCEL_COLOR_TYPE_STANDARD
,
116 'rotWithShape' => NULL
122 * @var array of mixed
125 private $_glow_properties = array(
128 'type' => self
::EXCEL_COLOR_TYPE_STANDARD
,
135 * Soft Edge Properties
137 * @var array of mixed
140 private $_soft_edges = array(
145 * Get Series Data Type
150 public function setAxisNumberProperties($format_code) {
151 $this->_axis_number
['format'] = (string) $format_code;
152 $this->_axis_number
['source_linked'] = 0;
156 * Get Axis Number Format Data Type
161 public function getAxisNumberFormat() {
162 return $this->_axis_number
['format'];
166 * Get Axis Number Source Linked
171 public function getAxisNumberSourceLinked() {
172 return (string) $this->_axis_number
['source_linked'];
176 * Set Axis Options Properties
178 * @param string $axis_labels
179 * @param string $horizontal_crosses_value
180 * @param string $horizontal_crosses
181 * @param string $axis_orientation
182 * @param string $major_tmt
183 * @param string $minor_tmt
184 * @param string $minimum
185 * @param string $maximum
186 * @param string $major_unit
187 * @param string $minor_unit
191 public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = NULL,
192 $axis_orientation = NULL, $major_tmt = NULL, $minor_tmt = NULL, $minimum = NULL, $maximum = NULL, $major_unit = NULL,
193 $minor_unit = NULL) {
195 $this->_axis_options
['axis_labels'] = (string) $axis_labels;
196 ($horizontal_crosses_value !== NULL)
197 ?
$this->_axis_options
['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL;
198 ($horizontal_crosses !== NULL) ?
$this->_axis_options
['horizontal_crosses'] = (string) $horizontal_crosses : NULL;
199 ($axis_orientation !== NULL) ?
$this->_axis_options
['orientation'] = (string) $axis_orientation : NULL;
200 ($major_tmt !== NULL) ?
$this->_axis_options
['major_tick_mark'] = (string) $major_tmt : NULL;
201 ($minor_tmt !== NULL) ?
$this->_axis_options
['minor_tick_mark'] = (string) $minor_tmt : NULL;
202 ($minor_tmt !== NULL) ?
$this->_axis_options
['minor_tick_mark'] = (string) $minor_tmt : NULL;
203 ($minimum !== NULL) ?
$this->_axis_options
['minimum'] = (string) $minimum : NULL;
204 ($maximum !== NULL) ?
$this->_axis_options
['maximum'] = (string) $maximum : NULL;
205 ($major_unit !== NULL) ?
$this->_axis_options
['major_unit'] = (string) $major_unit : NULL;
206 ($minor_unit !== NULL) ?
$this->_axis_options
['minor_unit'] = (string) $minor_unit : NULL;
210 * Get Axis Options Property
212 * @param string $property
217 public function getAxisOptionsProperty($property) {
218 return $this->_axis_options
[$property];
222 * Set Axis Orientation Property
224 * @param string $orientation
228 public function setAxisOrientation($orientation) {
229 $this->orientation
= (string) $orientation;
235 * @param string $color
237 * @param string $type
241 public function setFillParameters($color, $alpha = 0, $type = self
::EXCEL_COLOR_TYPE_ARGB
) {
242 $this->_fill_properties
= $this->setColorProperties($color, $alpha, $type);
248 * @param string $color
250 * @param string $type
254 public function setLineParameters($color, $alpha = 0, $type = self
::EXCEL_COLOR_TYPE_ARGB
) {
255 $this->_line_properties
= $this->setColorProperties($color, $alpha, $type);
261 * @param string $property
266 public function getFillProperty($property) {
267 return $this->_fill_properties
[$property];
273 * @param string $property
278 public function getLineProperty($property) {
279 return $this->_line_properties
[$property];
283 * Set Line Style Properties
285 * @param float $line_width
286 * @param string $compound_type
287 * @param string $dash_type
288 * @param string $cap_type
289 * @param string $join_type
290 * @param string $head_arrow_type
291 * @param string $head_arrow_size
292 * @param string $end_arrow_type
293 * @param string $end_arrow_size
297 public function setLineStyleProperties($line_width = NULL, $compound_type = NULL,
298 $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL,
299 $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
301 (!is_null($line_width)) ?
$this->_line_style_properties
['width'] = $this->getExcelPointsWidth((float) $line_width)
303 (!is_null($compound_type)) ?
$this->_line_style_properties
['compound'] = (string) $compound_type : NULL;
304 (!is_null($dash_type)) ?
$this->_line_style_properties
['dash'] = (string) $dash_type : NULL;
305 (!is_null($cap_type)) ?
$this->_line_style_properties
['cap'] = (string) $cap_type : NULL;
306 (!is_null($join_type)) ?
$this->_line_style_properties
['join'] = (string) $join_type : NULL;
307 (!is_null($head_arrow_type)) ?
$this->_line_style_properties
['arrow']['head']['type'] = (string) $head_arrow_type
309 (!is_null($head_arrow_size)) ?
$this->_line_style_properties
['arrow']['head']['size'] = (string) $head_arrow_size
311 (!is_null($end_arrow_type)) ?
$this->_line_style_properties
['arrow']['end']['type'] = (string) $end_arrow_type
313 (!is_null($end_arrow_size)) ?
$this->_line_style_properties
['arrow']['end']['size'] = (string) $end_arrow_size
318 * Get Line Style Property
320 * @param array|string $elements
325 public function getLineStyleProperty($elements) {
326 return $this->getArrayElementsValue($this->_line_style_properties
, $elements);
330 * Get Line Style Arrow Excel Width
332 * @param string $arrow
337 public function getLineStyleArrowWidth($arrow) {
338 return $this->getLineStyleArrowSize($this->_line_style_properties
['arrow'][$arrow]['size'], 'w');
342 * Get Line Style Arrow Excel Length
344 * @param string $arrow
349 public function getLineStyleArrowLength($arrow) {
350 return $this->getLineStyleArrowSize($this->_line_style_properties
['arrow'][$arrow]['size'], 'len');
354 * Set Shadow Properties
356 * @param int $shadow_presets
357 * @param string $sh_color_value
358 * @param string $sh_color_type
359 * @param string $sh_color_alpha
360 * @param float $sh_blur
361 * @param int $sh_angle
362 * @param float $sh_distance
366 public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
368 ->_setShadowPresetsProperties((int) $sh_presets)
370 is_null($sh_color_value) ?
$this->_shadow_properties
['color']['value'] : $sh_color_value
371 , is_null($sh_color_alpha) ?
(int) $this->_shadow_properties
['color']['alpha'] : $sh_color_alpha
372 , is_null($sh_color_type) ?
$this->_shadow_properties
['color']['type'] : $sh_color_type)
373 ->_setShadowBlur($sh_blur)
374 ->_setShadowAngle($sh_angle)
375 ->_setShadowDistance($sh_distance);
381 * @param int $shadow_presets
383 * @return PHPExcel_Chart_Axis
386 private function _setShadowPresetsProperties($shadow_presets) {
387 $this->_shadow_properties
['presets'] = $shadow_presets;
388 $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
394 * Set Shadow Properties from Maped Values
396 * @param array $properties_map
397 * @param * $reference
399 * @return PHPExcel_Chart_Axis
402 private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
403 $base_reference = $reference;
404 foreach ($properties_map as $property_key => $property_val) {
405 if (is_array($property_val)) {
406 if ($reference === NULL) {
407 $reference = & $this->_shadow_properties
[$property_key];
409 $reference = & $reference[$property_key];
411 $this->_setShadowProperiesMapValues($property_val, $reference);
413 if ($base_reference === NULL) {
414 $this->_shadow_properties
[$property_key] = $property_val;
416 $reference[$property_key] = $property_val;
427 * @param string $color
429 * @param string $type
431 * @return PHPExcel_Chart_Axis
434 private function _setShadowColor($color, $alpha, $type) {
435 $this->_shadow_properties
['color'] = $this->setColorProperties($color, $alpha, $type);
445 * @return PHPExcel_Chart_Axis
448 private function _setShadowBlur($blur) {
449 if ($blur !== NULL) {
450 $this->_shadow_properties
['blur'] = (string) $this->getExcelPointsWidth($blur);
461 * @return PHPExcel_Chart_Axis
464 private function _setShadowAngle($angle) {
465 if ($angle !== NULL) {
466 $this->_shadow_properties
['direction'] = (string) $this->getExcelPointsAngle($angle);
473 * Set Shadow Distance
475 * @param float $distance
477 * @return PHPExcel_Chart_Axis
480 private function _setShadowDistance($distance) {
481 if ($distance !== NULL) {
482 $this->_shadow_properties
['distance'] = (string) $this->getExcelPointsWidth($distance);
492 * @param string $color_value
493 * @param int $color_alpha
494 * @param string $color_type
497 public function getShadowProperty($elements) {
498 return $this->getArrayElementsValue($this->_shadow_properties
, $elements);
502 * Set Glow Properties
505 * @param string $color_value
506 * @param int $color_alpha
507 * @param string $color_type
510 public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
512 ->_setGlowSize($size)
514 is_null($color_value) ?
$this->_glow_properties
['color']['value'] : $color_value
515 , is_null($color_alpha) ?
(int) $this->_glow_properties
['color']['alpha'] : $color_alpha
516 , is_null($color_type) ?
$this->_glow_properties
['color']['type'] : $color_type);
522 * @param array|string $property
527 public function getGlowProperty($property) {
528 return $this->getArrayElementsValue($this->_glow_properties
, $property);
536 * @return PHPExcel_Chart_Axis
539 private function _setGlowSize($size) {
540 if (!is_null($size)) {
541 $this->_glow_properties
['size'] = $this->getExcelPointsWidth($size);
550 * @param string $color
552 * @param string $type
554 * @return PHPExcel_Chart_Axis
557 private function _setGlowColor($color, $alpha, $type) {
558 $this->_glow_properties
['color'] = $this->setColorProperties($color, $alpha, $type);
564 * Set Soft Edges Size
569 public function setSoftEdges($size) {
570 if (!is_null($size)) {
571 $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
576 * Get Soft Edges Size
581 public function getSoftEdgesSize() {
582 return $this->_soft_edges
['size'];