Skip to content

A free open source IT asset/license management system

Dashbpoard pie fixes

sniped36e8cfbd25a
diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php
index 9860beea20..5bc65d0205 100644
--- a/app/Http/Controllers/Api/StatuslabelsController.php
+++ b/app/Http/Controllers/Api/StatuslabelsController.php
@@ -161,19 +161,22 @@ class StatuslabelsController extends Controller
public function getAssetCountByStatuslabel()
{
- $statusLabels = Statuslabel::get();
+ $statuslabels = Statuslabel::with('assets')->groupBy('id')->withCount('assets')->get();
+
$labels=[];
$points=[];
$colors=[];
- foreach ($statusLabels as $statusLabel) {
- if ($statusLabel->assets()->count() > 0) {
- $labels[]=$statusLabel->name;
- $points[]=$statusLabel->assets()->whereNull('assigned_to')->count();
- if ($statusLabel->color!='') {
- $colors[]=$statusLabel->color;
+ foreach ($statuslabels as $statuslabel) {
+ if ($statuslabel->assets_count > 0) {
+
+ $labels[]=$statuslabel->name. ' ('.number_format($statuslabel->assets_count).')';
+ $points[]=$statuslabel->assets_count;
+ if ($statuslabel->color!='') {
+ $colors[]=$statuslabel->color;
}
}
}
+
$colors_array = array_merge($colors, Helper::chartColors());