summaryrefslogtreecommitdiff
path: root/includes/helper/graph_helper.php
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-01-02 03:57:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-01-02 03:57:23 +0100
commit7313e15ce8236e19331fb6639a3a5b97c8f06ecd (patch)
tree399e5eaa403d6dd5993ca8fb6f2162319d2ed2e1 /includes/helper/graph_helper.php
parentb839e401062b294292fdcbd7e30b79bc149fab6f (diff)
PSR-2 formatting
Diffstat (limited to 'includes/helper/graph_helper.php')
-rw-r--r--includes/helper/graph_helper.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php
index 42a6c07a..c2d0f8a2 100644
--- a/includes/helper/graph_helper.php
+++ b/includes/helper/graph_helper.php
@@ -7,35 +7,34 @@
* @param unknown $colors colors for the data rows
* @param unknown $data the data
*/
-function bargraph($dom_id, $key, $row_names, $colors, $data) {
- $labels = [];
- foreach ($data as $dataset) {
- $labels[] = $dataset[$key];
- }
-
- $datasets = [];
- foreach ($row_names as $row_key => $name) {
- $values = [];
+function bargraph($dom_id, $key, $row_names, $colors, $data)
+{
+ $labels = [];
foreach ($data as $dataset) {
- $values[] = $dataset[$row_key];
+ $labels[] = $dataset[$key];
}
- $datasets[] = [
+
+ $datasets = [];
+ foreach ($row_names as $row_key => $name) {
+ $values = [];
+ foreach ($data as $dataset) {
+ $values[] = $dataset[$row_key];
+ }
+ $datasets[] = [
'label' => $name,
'fillColor' => $colors[$row_key],
- 'data' => $values
+ 'data' => $values
];
- }
+ }
- return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
+ return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
<script type="text/javascript">
$(function(){
var ctx = $("#' . $dom_id . '").get(0).getContext("2d");
var chart = new Chart(ctx).Bar(' . json_encode([
'labels' => $labels,
- 'datasets' => $datasets
+ 'datasets' => $datasets
]) . ');
});
</script>';
}
-
-?> \ No newline at end of file