refactor: Simplify color assignment logic in AttendanceDashboardChart and ProjectProgressChart
This commit is contained in:
parent
68cfdf54d6
commit
4cb60138c0
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user