fix(app): подписи осей и легенда графика стоимости

Крайние подписи оси Y (414.6K поверх 400K) скрыты, числа в русской краткой форме, подписи оси X не обрезаются справа. Добавлена легенда: сплошная линия — стоимость, пунктир — вложено нетто.
This commit is contained in:
Dmitry
2026-09-20 10:46:35 +03:00
parent 617682351b
commit 6891028074
2 changed files with 94 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
/// «12,3 тыс», «1,2 млн» — for axis labels and cells too narrow for a full amount.
///
/// fl_chart's own short form («414.6K») is English and rounds a step of 50 000 to the same
/// label twice; this one keeps the Russian suffixes and one decimal below a hundred.
String compactNumber(double value) {
final n = value.abs();
String scaled(double x, String suffix) {
final s = x >= 100
? x.round().toString()
: x.toStringAsFixed(1).replaceAll(RegExp(r'\.0$'), '');
return '${s.replaceAll('.', ',')} $suffix';
}
final sign = value < 0 ? '' : '';
if (n >= 1e6) return '$sign${scaled(n / 1e6, 'млн')}';
if (n >= 1e3) return '$sign${scaled(n / 1e3, 'тыс')}';
return '$sign${n.round()}';
}