LineChartData bottomTitles max value is not equal to TitleMeta max value
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
I use the X-axis as the timeline and want to display the min and max times, but the max value of getTitlesWidget(1698797425.999999) is not equal to the max of TitleMeta(1698797426.0), so the tail end cannot be displayed.
If I set the interval of bottomTitles to 1, it can be improved, but when the difference between my min and max values is too large, it will cause ANR. #438
**To Reproduce**
```dart=
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
void main() {
runApp(const ProviderScope(child: MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: _Body(),
);
}
}
class _Body extends StatelessWidget {
_Body({super.key});
final hourMinute = DateFormat('HH:mm:ss');
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
height: 200,
width: double.infinity,
padding: const EdgeInsets.all(16),
child: LineChart(
LineChartData(
minX: 1698797425,
maxX: 1698797426,
minY: 0,
maxY: 10,
titlesData: FlTitlesData(
topTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
),
rightTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (double value, TitleMeta meta) {
print('bottomTitles: $value');
final date = DateTime.fromMillisecondsSinceEpoch(value.toInt());
/// only show min & max title
return value == meta.min || value == meta.max
? SideTitleWidget(
axisSide: meta.axisSide,
space: 10,
child: Text(hourMinute.format(date)),
)
: const SizedBox();
}),
),
),
lineBarsData: [
LineChartBarData(
spots: [
const FlSpot(1698797425, 0),
const FlSpot(1698797426, 10),
],
),
],
),
duration: Duration.zero,
),
);
}
}
```
**Screenshots**

**Versions**
- Flutter:3.13.9
- FlChart:0.64.0
Contributor guide
Research direction
Start with the bottomTitles getTitlesWidget callback and the TitleMeta min/max values described in the reproduction. Run the provided Flutter example with the 1698797425–1698797426 range, then verify behavior with a much larger range related to #438. Done means the maximum title can be identified reliably without requiring interval 1 or causing an ANR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100