Merge pull request #11894 from uberbrady/improve_piechart_labels_legends

Added counts to Dashboard Pie Chart legends and tooltips
This commit is contained in:
snipe 2022-09-29 13:27:28 -07:00 committed by GitHub
commit 78580136f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -3,7 +3,8 @@
namespace App\Http\Transformers; namespace App\Http\Transformers;
use App\Helpers\Helper;/** use App\Helpers\Helper;
/**
* Class PieChartTransformer * Class PieChartTransformer
* *
* This handles the standardized formatting of the API response we need to provide for * This handles the standardized formatting of the API response we need to provide for
@ -27,7 +28,7 @@ class PieChartTransformer
if ($total['count'] > 0) { if ($total['count'] > 0) {
$labels[] = $total['label']; $labels[] = $total['label']." (".$total['count'].")";
$counts[] = $total['count']; $counts[] = $total['count'];
if (isset($total['color'])) { if (isset($total['color'])) {

View file

@ -427,6 +427,13 @@
position: 'top', position: 'top',
responsive: true, responsive: true,
maintainAspectRatio: true, maintainAspectRatio: true,
},
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
return data.labels[tooltipItem.datasetIndex] || '';
}
}
} }
}; };