Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

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