refactor: Simplify color assignment logic in AttendanceDashboardChart and ProjectProgressChart

This commit is contained in:
Vaibhav Surve 2025-09-22 17:15:57 +05:30
parent 68cfdf54d6
commit 4cb60138c0
2 changed files with 4 additions and 12 deletions

View File

@ -46,13 +46,9 @@ class AttendanceDashboardChart extends StatelessWidget {
Color(0xFF64B5F6), // Blue 300 (repeat) Color(0xFF64B5F6), // Blue 300 (repeat)
]; ];
static final Map<String, Color> _roleColorMap = {};
Color _getRoleColor(String role) { Color _getRoleColor(String role) {
return _roleColorMap.putIfAbsent( final index = role.hashCode.abs() % _flatColors.length;
role, return _flatColors[index];
() => _flatColors[_roleColorMap.length % _flatColors.length],
);
} }
@override @override

View File

@ -50,13 +50,9 @@ class ProjectProgressChart extends StatelessWidget {
]; ];
static final NumberFormat _commaFormatter = NumberFormat.decimalPattern(); static final NumberFormat _commaFormatter = NumberFormat.decimalPattern();
static final Map<String, Color> _taskColorMap = {};
Color _getTaskColor(String taskName) { Color _getTaskColor(String taskName) {
return _taskColorMap.putIfAbsent( final index = taskName.hashCode % _flatColors.length;
taskName, return _flatColors[index];
() => _flatColors[_taskColorMap.length % _flatColors.length],
);
} }
@override @override