mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
shows tooltip with data.
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/models/air_quality_data_model.dart';
|
import 'package:syncrow_web/pages/analytics/models/air_quality_data_model.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -171,28 +172,64 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
tooltipPadding: const EdgeInsets.all(8),
|
tooltipPadding: const EdgeInsets.all(8),
|
||||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
||||||
final data = chartData[group.x.toInt()];
|
final data = chartData[group.x.toInt()];
|
||||||
final stackItems = rod.rodStackItems;
|
|
||||||
|
final List<TextSpan> children = [];
|
||||||
|
|
||||||
|
final textStyle = context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
fontSize: 12,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.good != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nGOOD: ${data.good!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.moderate != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nMODERATE: ${data.moderate!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.poor != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nPOOR: ${data.poor!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.unhealthy != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nUNHEALTHY: ${data.unhealthy!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.severe != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nSEVERE: ${data.severe!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.hazardous != null) {
|
||||||
|
children.add(TextSpan(
|
||||||
|
text: '\nHAZARDOUS: ${data.hazardous!.toStringAsFixed(1)}%',
|
||||||
|
style: textStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return BarTooltipItem(
|
return BarTooltipItem(
|
||||||
'${data.date.day}/${data.date.month}\n',
|
DateFormat('dd/MM/yyyy').format(data.date),
|
||||||
context.textTheme.bodyMedium!.copyWith(
|
context.textTheme.bodyMedium!.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontSize: 14,
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
children: stackItems.map((item) {
|
children: children,
|
||||||
final metricName = AirQualityDataModel.metricColors.entries
|
|
||||||
.firstWhere((entry) => entry.value == item.color)
|
|
||||||
.key
|
|
||||||
.toLowerCase();
|
|
||||||
return TextSpan(
|
|
||||||
text:
|
|
||||||
'$metricName: ${(item.toY - item.fromY).toStringAsFixed(1)}%\n',
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user