| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function render($value) { |
||
| 23 | $data = $value->data(); |
||
| 24 | |||
| 25 | if (!$data) { |
||
| 26 | return '[no data]'; |
||
| 27 | } |
||
| 28 | |||
| 29 | $data = json_encode($data); |
||
| 30 | $options = json_encode($value->options()); |
||
| 31 | |||
| 32 | $type = $value->chartType(); |
||
| 33 | $id = uniqid("$type-chart-"); |
||
| 34 | return (string)new Element('div', [], [ |
||
| 35 | new Element('canvas', ['id' => $id]), |
||
| 36 | new Element('script', [], [" |
||
| 37 | var ctx = document.getElementById('$id').getContext('2d'); |
||
| 38 | new Chart(ctx).$type($data, $options); |
||
| 39 | "]) |
||
| 40 | ]); |
||
| 41 | } |
||
| 42 | |||
| 52 | } |