1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Halfpastfour\PHPChartJS\Options\Elements; |
4
|
|
|
|
5
|
|
|
use Halfpastfour\PHPChartJS\ArraySerializableInterface; |
6
|
|
|
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; |
7
|
|
|
use Zend\Json\Json; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Rectangle |
11
|
|
|
* @package Halfpastfour\PHPChartJS\Options\Elements |
12
|
|
|
*/ |
13
|
|
|
class Rectangle implements ArraySerializableInterface, \JsonSerializable |
14
|
|
|
{ |
15
|
|
|
use ArraySerializable; |
16
|
|
|
|
17
|
|
|
const BORDER_SKIPPED_BOTTOM = 'bottom'; |
18
|
|
|
const BORDER_SKIPPED_LEFT = 'left'; |
19
|
|
|
const BORDER_SKIPPED_TOP = 'top'; |
20
|
|
|
const BORDER_SKIPPED_RIGHT = 'right'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Bar fill color. |
24
|
|
|
* @default 'rgba(0,0,0,0.1)' |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $backgroundColor; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Bar stroke width. |
31
|
|
|
* @default 0 |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
private $borderWidth; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Bar stroke color. |
38
|
|
|
* @default 'rgba(0,0,0,0.1)' |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $borderColor; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Skipped (excluded) border: 'bottom', 'left', 'top' or 'right'. |
45
|
|
|
* @default self::BORDER_SKIPPED_BOTTOM |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $borderSkipped; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function getBackgroundColor() |
54
|
|
|
{ |
55
|
|
|
return $this->backgroundColor; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $backgroundColor |
60
|
|
|
* @return Rectangle |
61
|
|
|
*/ |
62
|
|
|
public function setBackgroundColor($backgroundColor) |
63
|
|
|
{ |
64
|
|
|
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor); |
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return int |
70
|
|
|
*/ |
71
|
|
|
public function getBorderWidth() |
72
|
|
|
{ |
73
|
|
|
return $this->borderWidth; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param int $borderWidth |
78
|
|
|
* @return Rectangle |
79
|
|
|
*/ |
80
|
|
|
public function setBorderWidth($borderWidth) |
81
|
|
|
{ |
82
|
|
|
$this->borderWidth = intval($borderWidth); |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getBorderColor() |
90
|
|
|
{ |
91
|
|
|
return $this->borderColor; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $borderColor |
96
|
|
|
* @return Rectangle |
97
|
|
|
*/ |
98
|
|
|
public function setBorderColor($borderColor) |
99
|
|
|
{ |
100
|
|
|
$this->borderColor = is_null($borderColor) ? null : strval($borderColor); |
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function getBorderSkipped() |
108
|
|
|
{ |
109
|
|
|
return $this->borderSkipped; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string $borderSkipped |
114
|
|
|
* @return Rectangle |
115
|
|
|
*/ |
116
|
|
|
public function setBorderSkipped($borderSkipped) |
117
|
|
|
{ |
118
|
|
|
$this->borderSkipped = is_null($borderSkipped) ? null : strval($borderSkipped); |
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string |
126
|
|
|
* @throws \ReflectionException |
127
|
|
|
* @throws \Zend_Reflection_Exception |
128
|
|
|
*/ |
129
|
|
|
public function jsonSerialize() |
130
|
|
|
{ |
131
|
|
|
return Json::encode($this->getArrayCopy()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
} |