Skip to content

Commit 1a25f0f

Browse files
Dieterberolandgeider
authored andcommitted
tooltip: better background color for contrast + show date
1 parent 555f57d commit 1a25f0f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lib/widgets/measurements/charts.dart

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,24 @@ class _MeasurementChartWidgetFlState extends State<MeasurementChartWidgetFl> {
7070

7171
LineTouchData tooltipData() {
7272
return LineTouchData(
73-
touchTooltipData: LineTouchTooltipData(getTooltipItems: (touchedSpots) {
74-
return touchedSpots.map((touchedSpot) {
75-
return LineTooltipItem(
76-
'${touchedSpot.y.toStringAsFixed(1)} ${widget._unit}',
77-
TextStyle(color: touchedSpot.bar.color, fontWeight: FontWeight.bold),
78-
);
79-
}).toList();
80-
}),
73+
touchTooltipData: LineTouchTooltipData(
74+
getTooltipColor: (touchedSpot) => Theme.of(context).colorScheme.primaryContainer,
75+
getTooltipItems: (touchedSpots) {
76+
return touchedSpots.map((touchedSpot) {
77+
final DateTime date = DateTime.fromMillisecondsSinceEpoch(touchedSpot.x.toInt());
78+
final dateStr =
79+
DateFormat.Md(Localizations.localeOf(context).languageCode).format(date);
80+
81+
return LineTooltipItem(
82+
'$dateStr: ${touchedSpot.y.toStringAsFixed(1)} ${widget._unit}',
83+
TextStyle(
84+
color: touchedSpot.bar.color,
85+
fontWeight: FontWeight.bold,
86+
),
87+
);
88+
}).toList();
89+
},
90+
),
8191
);
8292
}
8393

0 commit comments

Comments
 (0)