/
LineChart.php
39 lines (29 loc) · 1005 Bytes
/
LineChart.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
<?php
/**
* MIT licence
* Version 1.1.0
* Sjaak Priester, Amsterdam 29-10-2015... 17-09-2017.
*
* Google Charts widget for Yii 2.0 framework
* @link https://developers.google.com/chart/
*/
namespace sjaakp\gcharts;
class LineChart extends Chart {
public function init() {
parent::init();
$dataTable = $this->dataTable();
$jOpts = self::encode($this->options);
$id = $this->getId();
if ($this->mode == 'classic') {
$package = 'corechart';
$call = "var $id=new google.visualization.LineChart(document.getElementById('$id'));$id.draw($dataTable,$jOpts);";
}
else {
$package = 'line';
if ($this->mode == 'transition') $jOpts = "google.charts.Line.convertOptions($jOpts)";
$call = "var $id=new google.charts.Line(document.getElementById('$id'));$id.draw($dataTable,$jOpts);";
}
$this->loadPackages($package);
$this->drawChart($call);
}
}