ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Legend.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Legend
6 {
8  const XL_LEGEND_POSITION_BOTTOM = -4107; // Below the chart.
9  const XL_LEGEND_POSITION_CORNER = 2; // In the upper right-hand corner of the chart border.
10  const XL_LEGEND_POSITION_CUSTOM = -4161; // A custom position.
11  const XL_LEGEND_POSITION_LEFT = -4131; // Left of the chart.
12  const XL_LEGEND_POSITION_RIGHT = -4152; // Right of the chart.
13  const XL_LEGEND_POSITION_TOP = -4160; // Above the chart.
14 
15  const POSITION_RIGHT = 'r';
16  const POSITION_LEFT = 'l';
17  const POSITION_BOTTOM = 'b';
18  const POSITION_TOP = 't';
19  const POSITION_TOPRIGHT = 'tr';
20 
21  private static $positionXLref = [
22  self::XL_LEGEND_POSITION_BOTTOM => self::POSITION_BOTTOM,
23  self::XL_LEGEND_POSITION_CORNER => self::POSITION_TOPRIGHT,
24  self::XL_LEGEND_POSITION_CUSTOM => '??',
25  self::XL_LEGEND_POSITION_LEFT => self::POSITION_LEFT,
26  self::XL_LEGEND_POSITION_RIGHT => self::POSITION_RIGHT,
27  self::XL_LEGEND_POSITION_TOP => self::POSITION_TOP,
28  ];
29 
35  private $position = self::POSITION_RIGHT;
36 
42  private $overlay = true;
43 
49  private $layout;
50 
57  public function __construct($position = self::POSITION_RIGHT, ?Layout $layout = null, $overlay = false)
58  {
59  $this->setPosition($position);
60  $this->layout = $layout;
61  $this->setOverlay($overlay);
62  }
63 
69  public function getPosition()
70  {
71  return $this->position;
72  }
73 
81  public function setPosition($position)
82  {
83  if (!in_array($position, self::$positionXLref)) {
84  return false;
85  }
86 
87  $this->position = $position;
88 
89  return true;
90  }
91 
97  public function getPositionXL()
98  {
99  return array_search($this->position, self::$positionXLref);
100  }
101 
109  public function setPositionXL($positionXL)
110  {
111  if (!isset(self::$positionXLref[$positionXL])) {
112  return false;
113  }
114 
115  $this->position = self::$positionXLref[$positionXL];
116 
117  return true;
118  }
119 
125  public function getOverlay()
126  {
127  return $this->overlay;
128  }
129 
135  public function setOverlay($overlay): void
136  {
137  $this->overlay = $overlay;
138  }
139 
145  public function getLayout()
146  {
147  return $this->layout;
148  }
149 }
__construct($position=self::POSITION_RIGHT, ?Layout $layout=null, $overlay=false)
Create a new Legend.
Definition: Legend.php:57
setPosition($position)
Get legend position using an excel string value.
Definition: Legend.php:81
getPositionXL()
Get legend position as an Excel internal numeric value.
Definition: Legend.php:97
getOverlay()
Get allow overlay of other elements?
Definition: Legend.php:125
setOverlay($overlay)
Set allow overlay of other elements?
Definition: Legend.php:135
const XL_LEGEND_POSITION_BOTTOM
Legend positions.
Definition: Legend.php:8
setPositionXL($positionXL)
Set legend position using an Excel internal numeric value.
Definition: Legend.php:109
getPosition()
Get legend position as an excel string value.
Definition: Legend.php:69