diff options
author | Bot <bot@myigel.name> | 2017-01-02 15:43:36 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-01-02 15:49:53 +0100 |
commit | d71e7bbfad2f07f82df0c515608996d250fd4182 (patch) | |
tree | 5083a17b218c08b3a699a0bf15bec926cc2dd185 /includes/helper/graph_helper.php | |
parent | 7313e15ce8236e19331fb6639a3a5b97c8f06ecd (diff) |
Formatting
Diffstat (limited to 'includes/helper/graph_helper.php')
-rw-r--r-- | includes/helper/graph_helper.php | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php index c2d0f8a2..d844213c 100644 --- a/includes/helper/graph_helper.php +++ b/includes/helper/graph_helper.php @@ -2,10 +2,11 @@ /** * Renders a bargraph - * @param string $key keyname of the x-axis - * @param array $row_names keynames for the data rows - * @param unknown $colors colors for the data rows - * @param unknown $data the data + * + * @param string $key keyname of the x-axis + * @param array $row_names keynames for the data rows + * @param unknown $colors colors for the data rows + * @param unknown $data the data */ function bargraph($dom_id, $key, $row_names, $colors, $data) { @@ -13,7 +14,7 @@ function bargraph($dom_id, $key, $row_names, $colors, $data) foreach ($data as $dataset) { $labels[] = $dataset[$key]; } - + $datasets = []; foreach ($row_names as $row_key => $name) { $values = []; @@ -21,20 +22,20 @@ function bargraph($dom_id, $key, $row_names, $colors, $data) $values[] = $dataset[$row_key]; } $datasets[] = [ - 'label' => $name, - 'fillColor' => $colors[$row_key], - 'data' => $values - ]; + 'label' => $name, + 'fillColor' => $colors[$row_key], + 'data' => $values + ]; } - + 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 - ]) . '); + 'labels' => $labels, + 'datasets' => $datasets + ]) . '); }); </script>'; } |