forked from remp2020/crm-application-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleSankeyGraphGroup.php
66 lines (48 loc) · 1.58 KB
/
GoogleSankeyGraphGroup.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
<?php
namespace Crm\ApplicationModule\Components\Graphs;
use Nette\Utils\Json;
class GoogleSankeyGraphGroup extends BaseGraphControl
{
private $view = 'google_sankey_graph_group';
private $graphTitle = '';
private $graphHelp = '';
private $height = 300;
private $firstColumnName = '';
private $secondColumnName = '';
private $countColumnName = '';
private $rows = [];
public function setGraphTitle($graphTitle)
{
$this->graphTitle = $graphTitle;
return $this;
}
public function setGraphHelp($graphHelp)
{
$this->graphHelp = $graphHelp;
return $this;
}
public function setColumnNames($first, $second, $count)
{
$this->firstColumnName = $first;
$this->secondColumnName = $second;
$this->countColumnName = $count;
}
public function setRows($rows)
{
$this->rows = $rows;
}
public function render()
{
$this->template->graphId = $this->generateGraphId();
$this->template->graphTitle = $this->graphTitle;
$this->template->graphHelp = $this->graphHelp;
$this->template->height = $this->height;
$this->template->firstColumnName = $this->firstColumnName;
$this->template->secondColumnName = $this->secondColumnName;
$this->template->countColumnName = $this->countColumnName;
$this->template->empty = empty($this->rows);
$this->template->rows = Json::encode($this->rows);
$this->template->setFile(__DIR__ . '/' . $this->view . '.latte');
$this->template->render();
}
}