1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: Mischa <[email protected]> |
5
|
|
|
* Date: 24/10/2016 |
6
|
|
|
* Time: 9:55 AM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace CarlosIO\Geckoboard\Widgets; |
10
|
|
|
|
11
|
|
|
use CarlosIO\Geckoboard\Data\LineChartV2\Series; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class LineChartV2 |
15
|
|
|
* |
16
|
|
|
* @package CarlosIO\Geckoboard\Widgets |
17
|
|
|
*/ |
18
|
|
|
class LineChartV2 extends Widget |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
CONST DIMENSION_X = 'x'; |
22
|
|
|
CONST DIMENSION_Y = 'y'; |
23
|
|
|
CONST DEFAULT_COLOUR = "ff9900"; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string $name Line Chart Name |
27
|
|
|
*/ |
28
|
|
|
protected $name; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var array $data Line Chart Data |
32
|
|
|
*/ |
33
|
|
|
protected $data; |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $series = array(); |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $axis; |
45
|
|
|
|
46
|
|
|
public function addSeries($series) { |
47
|
|
|
$this->series[] = $series; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Set the elements to appear evenly spread along dimension |
53
|
|
|
* |
54
|
|
|
* @param string $dimension The dimension where labels will be displayed |
55
|
|
|
* @param array $labels Labels displayed in this axis |
|
|
|
|
56
|
|
|
* @return $this |
57
|
|
|
*/ |
58
|
|
|
public function setAxis($dimension, $axis) { |
59
|
|
|
$this->axis[$dimension] = $axis; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Add a new label to an specific axis |
66
|
|
|
* |
67
|
|
|
* @param string $dimension The dimension where labels will be displayed |
68
|
|
|
* @param mix $label Label displayed in this axis |
69
|
|
|
*/ |
70
|
|
View Code Duplication |
protected function addLabel($dimension, $label) { |
|
|
|
|
71
|
|
|
if (!in_array($dimension, array(self::DIMENSION_X, self::DIMENSION_Y))) { |
72
|
|
|
throw new \InvalidArgumentException(sprintf("Value '%s' is not a valid dimension", $dimension)); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$this->axis[$dimension][] = $label; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Return axises in a 2D array |
80
|
|
|
*/ |
81
|
|
|
public function getAxis() { |
82
|
|
|
if (null === $this->axis) { |
83
|
|
|
$this->axis[self::DIMENSION_X] = new Axis(self::DIMENSION_X); |
84
|
|
|
$this->axis[self::DIMENSION_Y] = new Axis(self::DIMENSION_Y); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return $this->axis; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get data in array format. |
92
|
|
|
* |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
public function getData() { |
96
|
|
|
$result = array(); |
97
|
|
|
|
98
|
|
|
if (!empty($this->axis[self::DIMENSION_X])) { |
99
|
|
|
$result['x_axis'] = $this->axis[self::DIMENSION_X]->toArray(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if (!empty($this->axis[self::DIMENSION_Y])) { |
103
|
|
|
$result['y_axis'] = $this->axis[self::DIMENSION_Y]->toArray(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
foreach ($this->series as $series) { |
107
|
|
|
$result['series'][] = $series; |
108
|
|
|
} |
109
|
|
|
return $result; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param string $name |
115
|
|
|
*/ |
116
|
|
|
public function setName($name) |
117
|
|
|
{ |
118
|
|
|
$this->name = $name; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function getName() |
125
|
|
|
{ |
126
|
|
|
return $this->name; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.