Skip to content

A free open source IT asset/license management system

Added counts to Dashboard Pie Chart legends and tooltips

Brady Wetherington420c216973b2
diff --git a/app/Http/Transformers/PieChartTransformer.php b/app/Http/Transformers/PieChartTransformer.php
index 855a125113..e5f48644a5 100644
--- a/app/Http/Transformers/PieChartTransformer.php
+++ b/app/Http/Transformers/PieChartTransformer.php
@@ -3,14 +3,15 @@
namespace App\Http\Transformers;
-use App\Helpers\Helper;/**
+use App\Helpers\Helper;
+/**
* Class PieChartTransformer
*
* This handles the standardized formatting of the API response we need to provide for
* the pie charts
*
* @return \Illuminate\Http\Response
- *@since [v6.0.11]
+ * @since [v6.0.11]
* @author [A. Gianotto] [<[email protected]>]
*/
class PieChartTransformer
@@ -27,7 +28,7 @@ class PieChartTransformer
if ($total['count'] > 0) {
- $labels[] = $total['label'];
+ $labels[] = $total['label']." (".$total['count'].")";
$counts[] = $total['count'];
if (isset($total['color'])) {
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php
index fe6f2ac0dd..7f07b549d8 100755
--- a/resources/views/dashboard.blade.php
+++ b/resources/views/dashboard.blade.php
@@ -427,6 +427,13 @@
position: 'top',
responsive: true,
maintainAspectRatio: true,
+ },
+ tooltips: {
+ callbacks: {
+ label: function(tooltipItem, data) {
+ return data.labels[tooltipItem.datasetIndex] || '';
+ }
+ }
}
};