Properties.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Chart;
  3. /**
  4. * Created by PhpStorm.
  5. * User: nhw2h8s
  6. * Date: 7/2/14
  7. * Time: 5:45 PM.
  8. */
  9. abstract class Properties
  10. {
  11. const
  12. EXCEL_COLOR_TYPE_STANDARD = 'prstClr';
  13. const EXCEL_COLOR_TYPE_SCHEME = 'schemeClr';
  14. const EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
  15. const
  16. AXIS_LABELS_LOW = 'low';
  17. const AXIS_LABELS_HIGH = 'high';
  18. const AXIS_LABELS_NEXT_TO = 'nextTo';
  19. const AXIS_LABELS_NONE = 'none';
  20. const
  21. TICK_MARK_NONE = 'none';
  22. const TICK_MARK_INSIDE = 'in';
  23. const TICK_MARK_OUTSIDE = 'out';
  24. const TICK_MARK_CROSS = 'cross';
  25. const
  26. HORIZONTAL_CROSSES_AUTOZERO = 'autoZero';
  27. const HORIZONTAL_CROSSES_MAXIMUM = 'max';
  28. const
  29. FORMAT_CODE_GENERAL = 'General';
  30. const FORMAT_CODE_NUMBER = '#,##0.00';
  31. const FORMAT_CODE_CURRENCY = '$#,##0.00';
  32. const FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)';
  33. const FORMAT_CODE_DATE = 'm/d/yyyy';
  34. const FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM';
  35. const FORMAT_CODE_PERCENTAGE = '0.00%';
  36. const FORMAT_CODE_FRACTION = '# ?/?';
  37. const FORMAT_CODE_SCIENTIFIC = '0.00E+00';
  38. const FORMAT_CODE_TEXT = '@';
  39. const FORMAT_CODE_SPECIAL = '00000';
  40. const
  41. ORIENTATION_NORMAL = 'minMax';
  42. const ORIENTATION_REVERSED = 'maxMin';
  43. const
  44. LINE_STYLE_COMPOUND_SIMPLE = 'sng';
  45. const LINE_STYLE_COMPOUND_DOUBLE = 'dbl';
  46. const LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin';
  47. const LINE_STYLE_COMPOUND_THINTHICK = 'thinThick';
  48. const LINE_STYLE_COMPOUND_TRIPLE = 'tri';
  49. const LINE_STYLE_DASH_SOLID = 'solid';
  50. const LINE_STYLE_DASH_ROUND_DOT = 'sysDot';
  51. const LINE_STYLE_DASH_SQUERE_DOT = 'sysDash';
  52. const LINE_STYPE_DASH_DASH = 'dash';
  53. const LINE_STYLE_DASH_DASH_DOT = 'dashDot';
  54. const LINE_STYLE_DASH_LONG_DASH = 'lgDash';
  55. const LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot';
  56. const LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot';
  57. const LINE_STYLE_CAP_SQUARE = 'sq';
  58. const LINE_STYLE_CAP_ROUND = 'rnd';
  59. const LINE_STYLE_CAP_FLAT = 'flat';
  60. const LINE_STYLE_JOIN_ROUND = 'bevel';
  61. const LINE_STYLE_JOIN_MITER = 'miter';
  62. const LINE_STYLE_JOIN_BEVEL = 'bevel';
  63. const LINE_STYLE_ARROW_TYPE_NOARROW = null;
  64. const LINE_STYLE_ARROW_TYPE_ARROW = 'triangle';
  65. const LINE_STYLE_ARROW_TYPE_OPEN = 'arrow';
  66. const LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth';
  67. const LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond';
  68. const LINE_STYLE_ARROW_TYPE_OVAL = 'oval';
  69. const LINE_STYLE_ARROW_SIZE_1 = 1;
  70. const LINE_STYLE_ARROW_SIZE_2 = 2;
  71. const LINE_STYLE_ARROW_SIZE_3 = 3;
  72. const LINE_STYLE_ARROW_SIZE_4 = 4;
  73. const LINE_STYLE_ARROW_SIZE_5 = 5;
  74. const LINE_STYLE_ARROW_SIZE_6 = 6;
  75. const LINE_STYLE_ARROW_SIZE_7 = 7;
  76. const LINE_STYLE_ARROW_SIZE_8 = 8;
  77. const LINE_STYLE_ARROW_SIZE_9 = 9;
  78. const
  79. SHADOW_PRESETS_NOSHADOW = null;
  80. const SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1;
  81. const SHADOW_PRESETS_OUTER_BOTTOM = 2;
  82. const SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3;
  83. const SHADOW_PRESETS_OUTER_RIGHT = 4;
  84. const SHADOW_PRESETS_OUTER_CENTER = 5;
  85. const SHADOW_PRESETS_OUTER_LEFT = 6;
  86. const SHADOW_PRESETS_OUTER_TOP_RIGHT = 7;
  87. const SHADOW_PRESETS_OUTER_TOP = 8;
  88. const SHADOW_PRESETS_OUTER_TOP_LEFT = 9;
  89. const SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10;
  90. const SHADOW_PRESETS_INNER_BOTTOM = 11;
  91. const SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12;
  92. const SHADOW_PRESETS_INNER_RIGHT = 13;
  93. const SHADOW_PRESETS_INNER_CENTER = 14;
  94. const SHADOW_PRESETS_INNER_LEFT = 15;
  95. const SHADOW_PRESETS_INNER_TOP_RIGHT = 16;
  96. const SHADOW_PRESETS_INNER_TOP = 17;
  97. const SHADOW_PRESETS_INNER_TOP_LEFT = 18;
  98. const SHADOW_PRESETS_PERSPECTIVE_BELOW = 19;
  99. const SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20;
  100. const SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21;
  101. const SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22;
  102. const SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
  103. /**
  104. * @param float $width
  105. *
  106. * @return float
  107. */
  108. protected function getExcelPointsWidth($width)
  109. {
  110. return $width * 12700;
  111. }
  112. /**
  113. * @param float $angle
  114. *
  115. * @return float
  116. */
  117. protected function getExcelPointsAngle($angle)
  118. {
  119. return $angle * 60000;
  120. }
  121. protected function getTrueAlpha($alpha)
  122. {
  123. return (string) 100 - $alpha . '000';
  124. }
  125. protected function setColorProperties($color, $alpha, $type)
  126. {
  127. return [
  128. 'type' => (string) $type,
  129. 'value' => (string) $color,
  130. 'alpha' => (string) $this->getTrueAlpha($alpha),
  131. ];
  132. }
  133. protected function getLineStyleArrowSize($array_selector, $array_kay_selector)
  134. {
  135. $sizes = [
  136. 1 => ['w' => 'sm', 'len' => 'sm'],
  137. 2 => ['w' => 'sm', 'len' => 'med'],
  138. 3 => ['w' => 'sm', 'len' => 'lg'],
  139. 4 => ['w' => 'med', 'len' => 'sm'],
  140. 5 => ['w' => 'med', 'len' => 'med'],
  141. 6 => ['w' => 'med', 'len' => 'lg'],
  142. 7 => ['w' => 'lg', 'len' => 'sm'],
  143. 8 => ['w' => 'lg', 'len' => 'med'],
  144. 9 => ['w' => 'lg', 'len' => 'lg'],
  145. ];
  146. return $sizes[$array_selector][$array_kay_selector];
  147. }
  148. protected function getShadowPresetsMap($shadow_presets_option)
  149. {
  150. $presets_options = [
  151. //OUTER
  152. 1 => [
  153. 'effect' => 'outerShdw',
  154. 'blur' => '50800',
  155. 'distance' => '38100',
  156. 'direction' => '2700000',
  157. 'algn' => 'tl',
  158. 'rotWithShape' => '0',
  159. ],
  160. 2 => [
  161. 'effect' => 'outerShdw',
  162. 'blur' => '50800',
  163. 'distance' => '38100',
  164. 'direction' => '5400000',
  165. 'algn' => 't',
  166. 'rotWithShape' => '0',
  167. ],
  168. 3 => [
  169. 'effect' => 'outerShdw',
  170. 'blur' => '50800',
  171. 'distance' => '38100',
  172. 'direction' => '8100000',
  173. 'algn' => 'tr',
  174. 'rotWithShape' => '0',
  175. ],
  176. 4 => [
  177. 'effect' => 'outerShdw',
  178. 'blur' => '50800',
  179. 'distance' => '38100',
  180. 'algn' => 'l',
  181. 'rotWithShape' => '0',
  182. ],
  183. 5 => [
  184. 'effect' => 'outerShdw',
  185. 'size' => [
  186. 'sx' => '102000',
  187. 'sy' => '102000',
  188. ],
  189. 'blur' => '63500',
  190. 'distance' => '38100',
  191. 'algn' => 'ctr',
  192. 'rotWithShape' => '0',
  193. ],
  194. 6 => [
  195. 'effect' => 'outerShdw',
  196. 'blur' => '50800',
  197. 'distance' => '38100',
  198. 'direction' => '10800000',
  199. 'algn' => 'r',
  200. 'rotWithShape' => '0',
  201. ],
  202. 7 => [
  203. 'effect' => 'outerShdw',
  204. 'blur' => '50800',
  205. 'distance' => '38100',
  206. 'direction' => '18900000',
  207. 'algn' => 'bl',
  208. 'rotWithShape' => '0',
  209. ],
  210. 8 => [
  211. 'effect' => 'outerShdw',
  212. 'blur' => '50800',
  213. 'distance' => '38100',
  214. 'direction' => '16200000',
  215. 'rotWithShape' => '0',
  216. ],
  217. 9 => [
  218. 'effect' => 'outerShdw',
  219. 'blur' => '50800',
  220. 'distance' => '38100',
  221. 'direction' => '13500000',
  222. 'algn' => 'br',
  223. 'rotWithShape' => '0',
  224. ],
  225. //INNER
  226. 10 => [
  227. 'effect' => 'innerShdw',
  228. 'blur' => '63500',
  229. 'distance' => '50800',
  230. 'direction' => '2700000',
  231. ],
  232. 11 => [
  233. 'effect' => 'innerShdw',
  234. 'blur' => '63500',
  235. 'distance' => '50800',
  236. 'direction' => '5400000',
  237. ],
  238. 12 => [
  239. 'effect' => 'innerShdw',
  240. 'blur' => '63500',
  241. 'distance' => '50800',
  242. 'direction' => '8100000',
  243. ],
  244. 13 => [
  245. 'effect' => 'innerShdw',
  246. 'blur' => '63500',
  247. 'distance' => '50800',
  248. ],
  249. 14 => [
  250. 'effect' => 'innerShdw',
  251. 'blur' => '114300',
  252. ],
  253. 15 => [
  254. 'effect' => 'innerShdw',
  255. 'blur' => '63500',
  256. 'distance' => '50800',
  257. 'direction' => '10800000',
  258. ],
  259. 16 => [
  260. 'effect' => 'innerShdw',
  261. 'blur' => '63500',
  262. 'distance' => '50800',
  263. 'direction' => '18900000',
  264. ],
  265. 17 => [
  266. 'effect' => 'innerShdw',
  267. 'blur' => '63500',
  268. 'distance' => '50800',
  269. 'direction' => '16200000',
  270. ],
  271. 18 => [
  272. 'effect' => 'innerShdw',
  273. 'blur' => '63500',
  274. 'distance' => '50800',
  275. 'direction' => '13500000',
  276. ],
  277. //perspective
  278. 19 => [
  279. 'effect' => 'outerShdw',
  280. 'blur' => '152400',
  281. 'distance' => '317500',
  282. 'size' => [
  283. 'sx' => '90000',
  284. 'sy' => '-19000',
  285. ],
  286. 'direction' => '5400000',
  287. 'rotWithShape' => '0',
  288. ],
  289. 20 => [
  290. 'effect' => 'outerShdw',
  291. 'blur' => '76200',
  292. 'direction' => '18900000',
  293. 'size' => [
  294. 'sy' => '23000',
  295. 'kx' => '-1200000',
  296. ],
  297. 'algn' => 'bl',
  298. 'rotWithShape' => '0',
  299. ],
  300. 21 => [
  301. 'effect' => 'outerShdw',
  302. 'blur' => '76200',
  303. 'direction' => '13500000',
  304. 'size' => [
  305. 'sy' => '23000',
  306. 'kx' => '1200000',
  307. ],
  308. 'algn' => 'br',
  309. 'rotWithShape' => '0',
  310. ],
  311. 22 => [
  312. 'effect' => 'outerShdw',
  313. 'blur' => '76200',
  314. 'distance' => '12700',
  315. 'direction' => '2700000',
  316. 'size' => [
  317. 'sy' => '-23000',
  318. 'kx' => '-800400',
  319. ],
  320. 'algn' => 'bl',
  321. 'rotWithShape' => '0',
  322. ],
  323. 23 => [
  324. 'effect' => 'outerShdw',
  325. 'blur' => '76200',
  326. 'distance' => '12700',
  327. 'direction' => '8100000',
  328. 'size' => [
  329. 'sy' => '-23000',
  330. 'kx' => '800400',
  331. ],
  332. 'algn' => 'br',
  333. 'rotWithShape' => '0',
  334. ],
  335. ];
  336. return $presets_options[$shadow_presets_option];
  337. }
  338. protected function getArrayElementsValue($properties, $elements)
  339. {
  340. $reference = &$properties;
  341. if (!is_array($elements)) {
  342. return $reference[$elements];
  343. }
  344. foreach ($elements as $keys) {
  345. $reference = &$reference[$keys];
  346. }
  347. return $reference;
  348. }
  349. }