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)
];
static final Map<String, Color> _roleColorMap = {};
Color _getRoleColor(String role) {
return _roleColorMap.putIfAbsent(
role,
() => _flatColors[_roleColorMap.length % _flatColors.length],
);
final index = role.hashCode.abs() % _flatColors.length;
return _flatColors[index];
}
@override

View File

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