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)
|
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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user