2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Slightly improved display of numbers approaching zero in stats charts.

This commit is contained in:
23rd
2025-05-20 23:56:40 +03:00
parent a532067a93
commit b0125e8165
2 changed files with 6 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ constexpr auto kStep = 5.;
}
[[nodiscard]] QString Format(ChartValue absoluteValue) {
constexpr auto kTooMuch = ChartValue(10'000);
static constexpr auto kTooMuch = ChartValue(10'000);
return (absoluteValue >= kTooMuch)
? Lang::FormatCountToShort(absoluteValue).string
: QString::number(absoluteValue);

View File

@@ -20,8 +20,11 @@ namespace Statistic {
namespace {
[[nodiscard]] QString FormatF(float64 absoluteValue) {
constexpr auto kTooMuch = int(10'000);
return (absoluteValue >= kTooMuch)
static constexpr auto kTooMuch = int(10'000);
static constexpr auto kTooSmall = 1e-9;
return (std::abs(absoluteValue) <= kTooSmall)
? u"0"_q
: (absoluteValue >= kTooMuch)
? Lang::FormatCountToShort(absoluteValue).string
: QString::number(absoluteValue);
}