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