1 | <?php |
||
12 | class GoogleChartsExtension extends \Twig_Extension |
||
13 | { |
||
14 | /** @var ChartOutputInterface */ |
||
15 | private $chartOutput; |
||
16 | |||
17 | /** |
||
18 | * GoogleChartsExtension constructor. |
||
19 | * |
||
20 | * @param ChartOutputInterface $chartOutput |
||
21 | */ |
||
22 | public function __construct(ChartOutputInterface $chartOutput) |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | public function getFunctions() |
||
40 | |||
41 | /** |
||
42 | * Returns the Javascript for the beginning of one or more charts. |
||
43 | * |
||
44 | * @param Chart|Chart[] $charts Chart instance or array of Chart instance |
||
45 | * @param string|string[]|null $elementsID HTML element ID or array of HTML elements IDs. Can be null |
||
46 | * |
||
47 | * @return string |
||
48 | * |
||
49 | * @throws GoogleChartsException |
||
50 | */ |
||
51 | public function gcStart($charts, $elementsID = null) |
||
55 | |||
56 | /** |
||
57 | * Returns the Javascript for the end of one or more charts. |
||
58 | * |
||
59 | * @param Chart|Chart[] $charts Chart instance or array of Chart instance |
||
60 | * |
||
61 | * @return string |
||
62 | * |
||
63 | * @throws GoogleChartsException |
||
64 | */ |
||
65 | public function gcEnd($charts) |
||
69 | |||
70 | /** |
||
71 | * Returns the full Javascript to draw one or more charts. |
||
72 | * |
||
73 | * @param Chart|Chart[] $charts Chart instance or array of Chart instance |
||
74 | * @param string|string[]|null $elementsID HTML element ID or array of HTML elements IDs. Can be null |
||
75 | * |
||
76 | * @return string |
||
77 | * |
||
78 | * @throws GoogleChartsException |
||
79 | */ |
||
80 | public function gcDraw($charts, $elementsID = null) |
||
84 | |||
85 | /** |
||
86 | * Add an event to a chart. |
||
87 | * |
||
88 | * @param Chart $chart A Chart instance |
||
89 | * @param string $type Type of event |
||
90 | * @param string $functionName Name of Javascript function |
||
91 | */ |
||
92 | public function gcEvent(Chart $chart, $type, $functionName) |
||
96 | |||
97 | /** |
||
98 | * Set the locale. Must be called before drawing charts. |
||
99 | * |
||
100 | * @see https://developers.google.com/chart/interactive/docs/basic_load_libs#loadwithlocale |
||
101 | * |
||
102 | * @param string $language Locale, for example : "fr" |
||
103 | */ |
||
104 | public function gcLanguage($language) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getName() |
||
116 | } |
||
117 |