Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Chart; 4 5 class Legend 6 { 7 /** Legend positions */ 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 30 /** 31 * Legend position. 32 * 33 * @var string 34 */ 35 private $position = self::POSITION_RIGHT; 36 37 /** 38 * Allow overlay of other elements? 39 * 40 * @var bool 41 */ 42 private $overlay = true; 43 44 /** 45 * Legend Layout. 46 * 47 * @var Layout 48 */ 49 private $layout; 50 51 /** 52 * Create a new Legend. 53 * 54 * @param string $position 55 * @param bool $overlay 56 */ 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 64 /** 65 * Get legend position as an excel string value. 66 * 67 * @return string 68 */ 69 public function getPosition() 70 { 71 return $this->position; 72 } 73 74 /** 75 * Get legend position using an excel string value. 76 * 77 * @param string $position see self::POSITION_* 78 * 79 * @return bool 80 */ 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 92 /** 93 * Get legend position as an Excel internal numeric value. 94 * 95 * @return int 96 */ 97 public function getPositionXL() 98 { 99 return array_search($this->position, self::$positionXLref); 100 } 101 102 /** 103 * Set legend position using an Excel internal numeric value. 104 * 105 * @param int $positionXL see self::XL_LEGEND_POSITION_* 106 * 107 * @return bool 108 */ 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 120 /** 121 * Get allow overlay of other elements? 122 * 123 * @return bool 124 */ 125 public function getOverlay() 126 { 127 return $this->overlay; 128 } 129 130 /** 131 * Set allow overlay of other elements? 132 * 133 * @param bool $overlay 134 * 135 * @return bool 136 */ 137 public function setOverlay($overlay) 138 { 139 if (!is_bool($overlay)) { 140 return false; 141 } 142 143 $this->overlay = $overlay; 144 145 return true; 146 } 147 148 /** 149 * Get Layout. 150 * 151 * @return Layout 152 */ 153 public function getLayout() 154 { 155 return $this->layout; 156 } 157 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body