-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathInlineBarGraph.php
69 lines (54 loc) · 1.57 KB
/
InlineBarGraph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Crm\ApplicationModule\Components\Graphs\InlineBarGraph;
use Crm\ApplicationModule\Components\Graphs\BaseGraphControl;
/**
* Inline bar graph
*
* Component for rendering very simple inline bar graphs.
*
* @package Crm\ApplicationModule\Components\Graphs
*/
class InlineBarGraph extends BaseGraphControl
{
private $view = 'inline_bar_graph';
private $yLabel = '[Y label]';
private $xAxis = [];
private $graphTitle = '[Názov grafu]';
private $graphHelp = 'help';
private $height = 300;
public function setYLabel($ylabel)
{
$this->yLabel = $ylabel;
return $this;
}
public function setGraphTitle($graphTitle)
{
$this->graphTitle = $graphTitle;
return $this;
}
public function setGraphHelp($graphHelp)
{
$this->graphHelp = $graphHelp;
return $this;
}
public function addSerie($data)
{
$this->series['data'] = $data;
if (!$this->xAxis) {
$this->xAxis = array_keys($data);
}
return $this;
}
public function render()
{
$this->template->graphId = $this->generateGraphId();
$this->template->graphTitle = $this->graphTitle;
$this->template->graphHelp = $this->graphHelp;
$this->template->xAxis = $this->xAxis;
$this->template->yLabel = $this->yLabel;
$this->template->series = $this->series;
$this->template->height = $this->height;
$this->template->setFile(__DIR__ . '/' . $this->view . '.latte');
$this->template->render();
}
}