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\DiffColumnChart\DiffColumnChartOptions; |
11
|
|
|
|
12
|
|
|
class DiffColumnChart extends ColumnChart implements DiffChart |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var DiffColumnChartOptions |
16
|
|
|
*/ |
17
|
|
|
protected ChartOptionsInterface $options; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var BarChart|ColumnChart |
21
|
|
|
*/ |
22
|
|
|
private $oldChart; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var BarChart|ColumnChart |
26
|
|
|
*/ |
27
|
|
|
private $newChart; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param BarChart|ColumnChart|object $oldChart |
31
|
|
|
* @param BarChart|ColumnChart|object $newChart |
32
|
|
|
* |
33
|
|
|
* @throws GoogleChartsException |
34
|
|
|
*/ |
35
|
|
|
public function __construct($oldChart, $newChart) |
36
|
|
|
{ |
37
|
|
|
if ((!$oldChart instanceof ColumnChart && !$oldChart instanceof BarChart) |
38
|
|
|
|| (!$newChart instanceof ColumnChart && !$newChart instanceof BarChart)) { |
39
|
|
|
throw new GoogleChartsException('Instance of ColumnChart or BarChart is expected'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
parent::__construct(); |
43
|
|
|
|
44
|
|
|
$this->options = new DiffColumnChartOptions(); |
45
|
|
|
|
46
|
|
|
$this->oldChart = $oldChart; |
47
|
|
|
$this->newChart = $newChart; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getOptions(): DiffColumnChartOptions |
51
|
|
|
{ |
52
|
|
|
return $this->options; |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param DiffColumnChartOptions $options |
57
|
|
|
*/ |
58
|
|
|
public function setOptions(ChartOptionsInterface $options): DiffColumnChart |
59
|
|
|
{ |
60
|
|
|
$this->options = $options; |
|
|
|
|
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return BarChart|ColumnChart |
67
|
|
|
*/ |
68
|
|
|
public function getOldChart(): Chart |
69
|
|
|
{ |
70
|
|
|
return $this->oldChart; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return BarChart|ColumnChart |
75
|
|
|
*/ |
76
|
|
|
public function getNewChart(): Chart |
77
|
|
|
{ |
78
|
|
|
return $this->newChart; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|