LCOV - code coverage report
Current view: top level - lib/charts - forecast_chart.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 26 0.0 %
Date: 2024-10-04 11:09:33 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2023 The terCAD team. All rights reserved.
       2             : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3             : 
       4             : import 'package:app_finance/_ext/build_context_ext.dart';
       5             : import 'package:app_finance/charts/interface/chart_data.dart';
       6             : import 'package:app_finance/charts/painter/forecast_chart_painter.dart';
       7             : import 'package:app_finance/charts/painter/foreground_chart_painter.dart';
       8             : import 'package:app_finance/design/generic/empty_widget.dart';
       9             : import 'package:flutter/material.dart';
      10             : 
      11             : class ForecastChart extends StatelessWidget {
      12             :   final double width;
      13             :   final double height;
      14             :   final double indent;
      15             :   final String tooltip;
      16             :   final List<ChartData> data;
      17             :   final double yMax;
      18             : 
      19           0 :   const ForecastChart({
      20             :     super.key,
      21             :     required this.data,
      22             :     required this.yMax,
      23             :     required this.width,
      24             :     required this.height,
      25             :     this.indent = 0.0,
      26             :     this.tooltip = '',
      27             :   });
      28             : 
      29           0 :   @override
      30             :   Widget build(BuildContext context) {
      31           0 :     if (data.isEmpty || data.first.data.isEmpty) {
      32             :       return const EmptyWidget();
      33             :     }
      34           0 :     final now = DateTime.now();
      35           0 :     final size = Size(width, height);
      36           0 :     final bgColor = context.colorScheme.onSurface;
      37           0 :     final xMin = DateTime(now.year, now.month);
      38           0 :     final xMax = DateTime(now.year, now.month + 1);
      39           0 :     final bg = ForegroundChartPainter(
      40             :       size: size,
      41             :       color: bgColor,
      42             :       lineColor: bgColor,
      43           0 :       background: bgColor.withOpacity(0.1),
      44             :       yMin: 0.0,
      45             :       yMax: 140,
      46           0 :       yArea: [80, 120],
      47             :       xType: DateTime,
      48             :       yType: Percentage,
      49           0 :       xMin: xMin.millisecondsSinceEpoch.toDouble(),
      50           0 :       xMax: xMax.millisecondsSinceEpoch.toDouble(),
      51             :     );
      52           0 :     return SizedBox(
      53           0 :       height: size.height,
      54           0 :       width: size.width,
      55           0 :       child: CustomPaint(
      56             :         size: size,
      57           0 :         painter: ForecastChartPainter(
      58           0 :           indent: bg.shift,
      59             :           size: size,
      60           0 :           data: data,
      61           0 :           yMax: yMax * bg.yMax / 100,
      62           0 :           xMin: xMin.millisecondsSinceEpoch.toDouble(),
      63           0 :           xMax: xMax.millisecondsSinceEpoch.toDouble(),
      64             :         ),
      65             :         foregroundPainter: bg,
      66             :         willChange: false,
      67           0 :         child: Padding(
      68           0 :           padding: EdgeInsets.only(top: indent / 4),
      69           0 :           child: Text(tooltip),
      70             :         ),
      71             :       ),
      72             :     );
      73             :   }
      74             : }

Generated by: LCOV version 1.14