Skip to content

Commit

Permalink
Fix bottom ticks for large intervals by including year and larger str…
Browse files Browse the repository at this point in the history
…iding.
  • Loading branch information
braniii committed Oct 25, 2023
1 parent 276a0a1 commit 6358974
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions app/lib/widget/linechart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,26 @@ class _CustomLineChartState extends State<CustomLineChart> {
final int interval = (
max<double>(maxX - minX, 1) / (24 * 3600 * 1000) ~/ 6
).toInt();
if (date.day == 1) {
if (date.day == 1 && date.month == 1) {
return DateFormat(
'yy',
Localizations.localeOf(context).languageCode
).format(date);
} else if (date.day == 1) {
// if tick interval of more than 45 days show only every second tick
// starting from the first date of shown range.
if (
interval > 45 &&
(
DateTime.fromMillisecondsSinceEpoch(minX.toInt()).month % 2 ==
date.month % 2
)
(interval <= 45) ||
(interval > 45 && interval < 75 && date.month % 2 == 1) ||
(interval >= 75 && interval < 120 && date.month % 3 == 1) ||
(interval >= 120 && date.month % 6 == 1)
) {
return '';
return DateFormat(
'MMM',
Localizations.localeOf(context).languageCode
).format(date);
}
return DateFormat(
'MMM',
Localizations.localeOf(context).languageCode
).format(date);
return '';
} else if (
date.month != date.add(Duration(days: interval ~/ 1.5)).month ||
(
Expand Down

0 comments on commit 6358974

Please sign in to comment.