Skip to content

Commit

Permalink
[#146] [RF] Improve Forecast Chart. Fix height
Browse files Browse the repository at this point in the history
  • Loading branch information
lyskouski committed Aug 20, 2023
1 parent e6ae9fe commit 210b63a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- Simple grouping via `/` (in name) for the main page
- Bills, Transfers, Incomes
- Exchange rates, Default Currency for Summary
- Metrics: Budget Forecast
- Metrics: Budget Forecast (with Monte Carlo simulation)
- Goals Definition
- Recovery via WebDav
- Import from `.csv`-files
Expand Down
4 changes: 3 additions & 1 deletion lib/charts/forecast_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ForecastData {

class ForecastChart extends StatefulWidget {
final double width;
final double height;
final double indent;
final String tooltip;
final List<ForecastData> data;
Expand All @@ -24,6 +25,7 @@ class ForecastChart extends StatefulWidget {
required this.data,
required this.yMax,
required this.width,
required this.height,
this.indent = 0.0,
this.tooltip = '',
});
Expand All @@ -36,7 +38,7 @@ class ForecastChartState extends State<ForecastChart> {
@override
Widget build(BuildContext context) {
final now = DateTime.now();
final size = Size(widget.width, widget.width / 1.9);
final size = Size(widget.width, widget.height);
final bgColor = Theme.of(context).colorScheme.onBackground;
final xMin = DateTime(now.year, now.month);
final xMax = DateTime(now.year, now.month + 1);
Expand Down
4 changes: 2 additions & 2 deletions lib/charts/painter/foreground_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class ForegroundChartPainter extends CustomPainter {
}) {
_setTextArea();
shift = textArea * 1.2;
yDiv = 12 * size!.width ~/ 640;
xDiv = 12 * size!.height ~/ 240;
yDiv = 12 * size!.height ~/ 400;
xDiv = 12 * size!.width ~/ 640;
}

void _setTextArea() {
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"accountType": "Account Type",
"acknowledgeTooltip": "Acknowledge",
"activate": "Activate",
"actualData": "Historical Data",
"addAccountTooltip": "Add Account",
"addBudgetTooltip": "Add new Budget Category",
"addGoalTooltip": "Add new Goal",
Expand Down Expand Up @@ -118,6 +119,7 @@
"expenseDateTime": "Billed At",
"expenseHeadline": "Expense",
"expenseTransfer": "Amount of Transfer",
"forecastData": "Forecast",
"from": "from",
"goNextTooltip": "Go Next",
"goalHeadline": "Goals",
Expand Down
14 changes: 14 additions & 0 deletions lib/widgets/metrics/budget_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BudgetTab extends StatelessWidget {
),
ForecastChart(
width: ThemeHelper.getWidth(context, 4),
height: 200,
indent: indent,
data: [
ForecastData(DataHandler.getAmountGroupedByDate(
Expand All @@ -48,6 +49,19 @@ class BudgetTab extends StatelessWidget {
exchange: exchange,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocale.labels.actualData,
style: textTheme.bodySmall!.copyWith(color: Colors.red),
),
Text(
AppLocale.labels.forecastData,
style: textTheme.bodySmall!.copyWith(color: Colors.red.withBlue(200)),
),
],
)
],
),
),
Expand Down

0 comments on commit 210b63a

Please sign in to comment.