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