1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CMEN\GoogleChartsBundle\GoogleCharts\Charts\Diff; |
4
|
|
|
|
5
|
|
|
use CMEN\GoogleChartsBundle\Exception\GoogleChartsException; |
6
|
|
|
use CMEN\GoogleChartsBundle\GoogleCharts\Chart; |
7
|
|
|
use CMEN\GoogleChartsBundle\GoogleCharts\Charts\BarChart; |
8
|
|
|
use CMEN\GoogleChartsBundle\GoogleCharts\Charts\ColumnChart; |
9
|
|
|
use CMEN\GoogleChartsBundle\GoogleCharts\Options\ChartOptionsInterface; |
10
|
|
|
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Diff\DiffBarChart\DiffBarChartOptions; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @author Christophe Meneses |
14
|
|
|
*/ |
15
|
|
|
class DiffBarChart extends BarChart implements DiffChart |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var DiffBarChartOptions |
19
|
|
|
*/ |
20
|
|
|
protected ChartOptionsInterface $options; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var BarChart|ColumnChart |
24
|
|
|
*/ |
25
|
|
|
private $oldChart; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var BarChart|ColumnChart |
29
|
|
|
*/ |
30
|
|
|
private $newChart; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param BarChart|ColumnChart|object $oldChart |
34
|
|
|
* @param BarChart|ColumnChart|object $newChart |
35
|
|
|
* |
36
|
|
|
* @throws GoogleChartsException |
37
|
|
|
*/ |
38
|
|
|
public function __construct($oldChart, $newChart) |
39
|
|
|
{ |
40
|
|
|
if ((!$oldChart instanceof ColumnChart && !$oldChart instanceof BarChart) |
41
|
|
|
|| (!$newChart instanceof ColumnChart && !$newChart instanceof BarChart)) { |
42
|
|
|
throw new GoogleChartsException('Instance of ColumnChart or BarChart is expected'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
parent::__construct(); |
46
|
|
|
|
47
|
|
|
$this->options = new DiffBarChartOptions(); |
48
|
|
|
|
49
|
|
|
$this->oldChart = $oldChart; |
50
|
|
|
$this->newChart = $newChart; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getOptions(): DiffBarChartOptions |
54
|
|
|
{ |
55
|
|
|
return $this->options; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param DiffBarChartOptions $options |
60
|
|
|
*/ |
61
|
|
|
public function setOptions(ChartOptionsInterface $options): DiffBarChart |
62
|
|
|
{ |
63
|
|
|
$this->options = $options; |
|
|
|
|
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return BarChart|ColumnChart |
70
|
|
|
*/ |
71
|
|
|
public function getOldChart(): Chart |
72
|
|
|
{ |
73
|
|
|
return $this->oldChart; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return BarChart|ColumnChart |
78
|
|
|
*/ |
79
|
|
|
public function getNewChart(): Chart |
80
|
|
|
{ |
81
|
|
|
return $this->newChart; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|