Skip to content

Commit

Permalink
Merge pull request #509 from lyskouski/NF-506
Browse files Browse the repository at this point in the history
[#505] [NF] Calendar Start Day. Fix forecast chart
  • Loading branch information
lyskouski authored Oct 18, 2024
2 parents f5f8e87 + c8243e3 commit 561a0d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lib/charts/forecast_chart.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2023 The terCAD team. All rights reserved.
// Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.

import 'package:app_finance/_classes/herald/app_start_of_month.dart';
import 'package:app_finance/_ext/build_context_ext.dart';
import 'package:app_finance/_ext/date_time_ext.dart';
import 'package:app_finance/charts/interface/chart_data.dart';
import 'package:app_finance/charts/painter/forecast_chart_painter.dart';
import 'package:app_finance/charts/painter/foreground_chart_painter.dart';
Expand Down Expand Up @@ -34,8 +36,9 @@ class ForecastChart extends StatelessWidget {
final now = DateTime.now();
final size = Size(width, height);
final bgColor = context.colorScheme.onSurface;
final xMin = DateTime(now.year, now.month);
final xMax = DateTime(now.year, now.month + 1);
final startingDay = AppStartOfMonth.get();
final xMin = now.getStartingDay(startingDay).millisecondsSinceEpoch.toDouble();
final xMax = DateTime(now.year, now.month + 1).getStartingDay(startingDay).millisecondsSinceEpoch.toDouble();
final bg = ForegroundChartPainter(
size: size,
color: bgColor,
Expand All @@ -46,8 +49,8 @@ class ForecastChart extends StatelessWidget {
yArea: [80, 120],
xType: DateTime,
yType: Percentage,
xMin: xMin.millisecondsSinceEpoch.toDouble(),
xMax: xMax.millisecondsSinceEpoch.toDouble(),
xMin: xMin,
xMax: xMax,
);
return SizedBox(
height: size.height,
Expand All @@ -59,8 +62,8 @@ class ForecastChart extends StatelessWidget {
size: size,
data: data,
yMax: yMax * bg.yMax / 100,
xMin: xMin.millisecondsSinceEpoch.toDouble(),
xMax: xMax.millisecondsSinceEpoch.toDouble(),
xMin: xMin,
xMax: xMax,
),
foregroundPainter: bg,
willChange: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/account/account_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class AccountViewPageState extends AbstractPageState<AccountViewPage> {
bills: billList.fold(0.0, (v, e) => v + exchange.reform(e.details ?? 0.0, e.currency, account.currency)),
);
increment++;
curr = DateTime(now.year, now.month - increment, startingDay);
curr = DateTime(now.year, now.month - increment).getStartingDay(startingDay);
}
return IteratorController(data, transform: (v) => v);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/budget/budget_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class BudgetViewPageState extends AbstractPageState<BudgetViewPage> with TickerP
break;
}
iteration++;
curr = DateTime(now.year, now.month - iteration, startingDay);
curr = DateTime(now.year, now.month - iteration).getStartingDay(startingDay);
summary.details = 0.0;
summary.color = null;
summary.title = DateFormat.MMMM().format(curr);
Expand Down

0 comments on commit 561a0d1

Please sign in to comment.