LCOV - code coverage report
Current view: top level - lib/charts - column_chart.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 28 0
Test Date: 2026-11-14 15:04:37 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/_classes/herald/app_locale.dart';
       5              : import 'package:app_finance/_ext/build_context_ext.dart';
       6              : import 'package:app_finance/charts/interface/chart_data.dart';
       7              : import 'package:app_finance/charts/painter/column_chart_painter.dart';
       8              : import 'package:app_finance/charts/painter/foreground_chart_painter.dart';
       9              : import 'package:app_finance/design/generic/empty_widget.dart';
      10              : import 'package:material_ui/material_ui.dart';
      11              : import 'package:intl/intl.dart';
      12              : 
      13              : class ColumnChart extends StatelessWidget {
      14              :   final double width;
      15              :   final double height;
      16              :   final double indent;
      17              :   final String tooltip;
      18              :   final List<ChartData> data;
      19              :   final double yMax;
      20              : 
      21            0 :   const ColumnChart({
      22              :     super.key,
      23              :     required this.data,
      24              :     required this.yMax,
      25              :     required this.width,
      26              :     required this.height,
      27              :     this.indent = 0.0,
      28              :     this.tooltip = '',
      29              :   });
      30              : 
      31            0 :   @override
      32              :   Widget build(BuildContext context) {
      33            0 :     if (data.isEmpty || data.last.data.isEmpty) {
      34              :       return const EmptyWidget();
      35              :     }
      36            0 :     final now = DateTime.now();
      37            0 :     final size = Size(width, height);
      38            0 :     final bgColor = context.colorScheme.onSurface;
      39            0 :     final xMin = DateTime(now.year);
      40            0 :     final xMax = DateTime(now.year + 1);
      41            0 :     final bg = ForegroundChartPainter(
      42              :       size: size,
      43              :       color: bgColor,
      44              :       lineColor: bgColor,
      45            0 :       background: bgColor.withValues(alpha: 0.1),
      46              :       yMin: 0.0,
      47            0 :       yMax: yMax,
      48            0 :       yTpl: NumberFormat.compact(locale: AppLocale.code),
      49              :       xType: DateTime,
      50            0 :       xMin: xMin.millisecondsSinceEpoch.toDouble(),
      51            0 :       xMax: xMax.millisecondsSinceEpoch.toDouble(),
      52            0 :       xTpl: DateFormat.MMM(AppLocale.code),
      53              :     );
      54            0 :     return SizedBox(
      55            0 :       height: size.height,
      56            0 :       width: size.width,
      57            0 :       child: CustomPaint(
      58              :         size: size,
      59            0 :         painter: ColumnChartPainter(
      60            0 :           indent: bg.shift,
      61              :           size: size,
      62            0 :           data: data,
      63            0 :           yMax: yMax,
      64            0 :           xMin: bg.xMin,
      65            0 :           xMax: bg.xMax,
      66              :         ),
      67              :         foregroundPainter: bg,
      68              :         willChange: false,
      69            0 :         child: Padding(
      70            0 :           padding: EdgeInsets.only(top: indent / 4),
      71            0 :           child: Text(tooltip),
      72              :         ),
      73              :       ),
      74              :     );
      75              :   }
      76              : }
        

Generated by: LCOV version 2.0-1