3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 19:15:50 +00:00

Fixed dashboard chart

This commit is contained in:
snipe
2017-01-13 03:19:39 -08:00
parent 06d66f6e94
commit bc5fcf8736
4 changed files with 99 additions and 67 deletions

View File

@ -37,43 +37,6 @@ class StatuslabelsController extends Controller
}
/**
* Show a count of assets by status label
*
* @return array
*/
public function getAssetCountByStatuslabel()
{
$statusLabels = Statuslabel::with('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;
}
}
}
$labels[]='Deployed';
$points[]=Asset::whereNotNull('assigned_to')->count();
$colors_array = array_merge($colors, Helper::chartColors());
$result= [
"labels" => $labels,
"datasets" => [ [
"data" => $points,
"backgroundColor" => $colors_array,
"hoverBackgroundColor" => $colors_array
]]
];
return $result;
}
/**