1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Muspelheim\C3ChartsBundle\C3; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class C3js |
7
|
|
|
* @package Muspelheim\C3ChartsBundle\C3 |
8
|
|
|
*/ |
9
|
|
|
class C3js extends AbstractChart implements ChartInterface |
10
|
|
|
{ |
11
|
|
|
public function __construct() |
12
|
|
|
{ |
13
|
|
|
parent::__construct(); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
|
|
public function render(): string |
20
|
|
|
{ |
21
|
|
|
$chartJS = "new c3.generate({"; |
22
|
|
|
$chartJS .= $this->renderBindTo(); |
23
|
|
|
$chartJS .= $this->renderArea(); |
24
|
|
|
$chartJS .= $this->renderSize(); |
25
|
|
|
$chartJS .= $this->renderPadding(); |
26
|
|
|
$chartJS .= $this->renderColor(); |
27
|
|
|
$chartJS .= $this->renderInteraction(); |
28
|
|
|
$chartJS .= $this->renderTransition(); |
29
|
|
|
$chartJS .= $this->renderData(); |
30
|
|
|
$chartJS .= $this->renderAxis(); |
31
|
|
|
$chartJS .= $this->renderGrid(); |
32
|
|
|
$chartJS .= $this->renderRegion(); |
33
|
|
|
$chartJS .= $this->renderLegend(); |
34
|
|
|
$chartJS .= $this->renderTooltip(); |
35
|
|
|
$chartJS .= $this->renderSubchart(); |
36
|
|
|
$chartJS .= $this->renderZoom(); |
37
|
|
|
$chartJS .= $this->renderPoint(); |
38
|
|
|
$chartJS .= $this->renderLine(); |
39
|
|
|
$chartJS .= $this->renderBar(); |
40
|
|
|
$chartJS .= $this->renderPie(); |
41
|
|
|
$chartJS .= $this->renderDonut(); |
42
|
|
|
$chartJS .= $this->renderGauge(); |
43
|
|
|
$chartJS .= $this->renderTitle(); |
44
|
|
|
$chartJS .= "})"; |
45
|
|
|
|
46
|
|
|
$onload = <<<ONLOAD |
47
|
|
|
;(function () { |
48
|
|
|
var setup = function () { $chartJS } |
49
|
|
|
if (document.readyState !== 'loading') { |
50
|
|
|
setup() |
51
|
|
|
} else { |
52
|
|
|
document.addEventListener('DOMContentLoaded', setup) |
53
|
|
|
} |
54
|
|
|
})(); |
55
|
|
|
ONLOAD; |
56
|
|
|
|
57
|
|
|
return trim($onload); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|