feat: Enhance attendance dashboard by filtering roles with data and improving chart series mapping
This commit is contained in:
parent
25a1331878
commit
9e4c0378c6
@ -36,6 +36,11 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
List<String> get filteredRoles =>
|
||||
filteredData.map((e) => e['role'] as String).toSet().toList();
|
||||
|
||||
List<String> get rolesWithData => filteredRoles.where((role) {
|
||||
return filteredData.any(
|
||||
(entry) => entry['role'] == role && (entry['present'] ?? 0) > 0);
|
||||
}).toList();
|
||||
|
||||
final Map<String, Color> _roleColorMap = {};
|
||||
final List<Color> flatColors = [
|
||||
const Color(0xFFE57373),
|
||||
@ -52,7 +57,6 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
|
||||
Color _getRoleColor(String role) {
|
||||
if (_roleColorMap.containsKey(role)) return _roleColorMap[role]!;
|
||||
|
||||
final index = _roleColorMap.length % flatColors.length;
|
||||
final color = flatColors[index];
|
||||
_roleColorMap[role] = color;
|
||||
@ -62,7 +66,6 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() {
|
||||
// Now this observes `controller.roleWiseData`, `isLoading`, `isChartView`, etc.
|
||||
final isChartView = controller.isChartView.value;
|
||||
final selectedRange = controller.selectedRange.value;
|
||||
final isLoading = controller.isLoading.value;
|
||||
@ -78,8 +81,7 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
child: Card(
|
||||
color: Colors.white,
|
||||
elevation: 6,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
shadowColor: Colors.black12,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
@ -116,10 +118,7 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
MyText.bodyMedium('Attendance Overview', fontWeight: 600),
|
||||
MyText.bodySmall(
|
||||
'Role-wise present count',
|
||||
color: Colors.grey,
|
||||
),
|
||||
MyText.bodySmall('Role-wise present count', color: Colors.grey),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -213,7 +212,7 @@ class AttendanceDashboardChart extends StatelessWidget {
|
||||
interval: 1,
|
||||
majorGridLines: const MajorGridLines(width: 0),
|
||||
),
|
||||
series: filteredRoles.map((role) {
|
||||
series: rolesWithData.map((role) {
|
||||
final data = filteredDates.map((formattedDate) {
|
||||
final key = '${role}_$formattedDate';
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user