feat: Format numerical values with comma separators in attendance and project progress charts
This commit is contained in:
parent
a0f3475c5e
commit
c27b226b58
@ -319,10 +319,13 @@ class _AttendanceChart extends StatelessWidget {
|
||||
primaryXAxis: CategoryAxis(labelRotation: 45),
|
||||
primaryYAxis: NumericAxis(minimum: 0, interval: 1),
|
||||
series: rolesWithData.map((role) {
|
||||
final seriesData = filteredDates.map((date) {
|
||||
final key = '${role}_$date';
|
||||
return {'date': date, 'present': formattedMap[key] ?? 0};
|
||||
}).where((d) => (d['present'] ?? 0) > 0).toList(); // ✅ remove 0 bars
|
||||
final seriesData = filteredDates
|
||||
.map((date) {
|
||||
final key = '${role}_$date';
|
||||
return {'date': date, 'present': formattedMap[key] ?? 0};
|
||||
})
|
||||
.where((d) => (d['present'] ?? 0) > 0)
|
||||
.toList(); // ✅ remove 0 bars
|
||||
|
||||
return StackedColumnSeries<Map<String, dynamic>, String>(
|
||||
dataSource: seriesData,
|
||||
@ -334,8 +337,10 @@ class _AttendanceChart extends StatelessWidget {
|
||||
isVisible: true,
|
||||
builder: (dynamic data, _, __, ___, ____) {
|
||||
return (data['present'] ?? 0) > 0
|
||||
? Text('${data['present']}',
|
||||
style: const TextStyle(fontSize: 11))
|
||||
? Text(
|
||||
NumberFormat.decimalPattern().format(data['present']),
|
||||
style: const TextStyle(fontSize: 11),
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
@ -426,8 +431,13 @@ class _AttendanceTable extends StatelessWidget {
|
||||
DataCell(_RolePill(role: role, color: getRoleColor(role))),
|
||||
...filteredDates.map((date) {
|
||||
final key = '${role}_$date';
|
||||
return DataCell(Text('${formattedMap[key] ?? 0}',
|
||||
style: const TextStyle(fontSize: 13)));
|
||||
return DataCell(
|
||||
Text(
|
||||
NumberFormat.decimalPattern()
|
||||
.format(formattedMap[key] ?? 0),
|
||||
style: const TextStyle(fontSize: 13),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
|
@ -5,6 +5,7 @@ import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||
import 'package:marco/controller/dashboard/dashboard_controller.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
import 'package:marco/helpers/widgets/my_text.dart'; // import MyText
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DashboardOverviewWidgets {
|
||||
static final DashboardController dashboardController =
|
||||
@ -32,6 +33,7 @@ class DashboardOverviewWidgets {
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
);
|
||||
static final NumberFormat _commaFormatter = NumberFormat.decimalPattern();
|
||||
|
||||
/// Teams Overview Card without chart, labels & values in rows
|
||||
static Widget teamsOverview() {
|
||||
@ -79,8 +81,9 @@ class DashboardOverviewWidgets {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyText(total.toString(), style: _infoNumberTextStyle),
|
||||
MyText(inToday.toString(),
|
||||
MyText(_commaFormatter.format(total),
|
||||
style: _infoNumberTextStyle),
|
||||
MyText(_commaFormatter.format(inToday),
|
||||
style: _infoNumberGreenTextStyle.copyWith(
|
||||
color: Colors.green[700])),
|
||||
],
|
||||
@ -209,11 +212,11 @@ class DashboardOverviewWidgets {
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
MyText(value.toString(),
|
||||
MyText(_commaFormatter.format(value),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white, // text in white for contrast
|
||||
color: Colors.white,
|
||||
)),
|
||||
MySpacing.height(2),
|
||||
MyText(label,
|
||||
|
@ -48,6 +48,7 @@ class ProjectProgressChart extends StatelessWidget {
|
||||
Color(0xFFFFB74D),
|
||||
Color(0xFF64B5F6),
|
||||
];
|
||||
static final NumberFormat _commaFormatter = NumberFormat.decimalPattern();
|
||||
|
||||
static final Map<String, Color> _taskColorMap = {};
|
||||
|
||||
@ -228,9 +229,17 @@ class ProjectProgressChart extends StatelessWidget {
|
||||
xValueMapper: (d, _) => DateFormat('MMM d').format(d.date),
|
||||
yValueMapper: (d, _) => d.planned,
|
||||
color: _getTaskColor('Planned'),
|
||||
dataLabelSettings: const DataLabelSettings(
|
||||
dataLabelSettings: DataLabelSettings(
|
||||
isVisible: true,
|
||||
textStyle: TextStyle(fontSize: 11),
|
||||
builder: (data, point, series, pointIndex, seriesIndex) {
|
||||
final value = seriesIndex == 0
|
||||
? (data as ChartTaskData).planned
|
||||
: (data as ChartTaskData).completed;
|
||||
return Text(
|
||||
_commaFormatter.format(value),
|
||||
style: const TextStyle(fontSize: 11),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
ColumnSeries<ChartTaskData, String>(
|
||||
@ -239,9 +248,17 @@ class ProjectProgressChart extends StatelessWidget {
|
||||
xValueMapper: (d, _) => DateFormat('MMM d').format(d.date),
|
||||
yValueMapper: (d, _) => d.completed,
|
||||
color: _getTaskColor('Completed'),
|
||||
dataLabelSettings: const DataLabelSettings(
|
||||
dataLabelSettings: DataLabelSettings(
|
||||
isVisible: true,
|
||||
textStyle: TextStyle(fontSize: 11),
|
||||
builder: (data, point, series, pointIndex, seriesIndex) {
|
||||
final value = seriesIndex == 0
|
||||
? (data as ChartTaskData).planned
|
||||
: (data as ChartTaskData).completed;
|
||||
return Text(
|
||||
_commaFormatter.format(value),
|
||||
style: const TextStyle(fontSize: 11),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user