mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Improved display of different inner currencies in statistical charts.
This commit is contained in:
parent
049cde48ee
commit
811d75e383
2 changed files with 29 additions and 2 deletions
|
@ -11,6 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Data {
|
||||
|
||||
enum class StatisticalCurrency {
|
||||
None,
|
||||
Ton,
|
||||
Credits,
|
||||
};
|
||||
|
||||
struct StatisticalChart {
|
||||
StatisticalChart() = default;
|
||||
|
||||
|
@ -67,6 +73,8 @@ struct StatisticalChart {
|
|||
bool isFooterHidden = false;
|
||||
bool hasPercentages = false;
|
||||
bool weekFormat = false;
|
||||
|
||||
StatisticalCurrency currency = StatisticalCurrency::None;
|
||||
float64 currencyRate = 0.;
|
||||
|
||||
// View data.
|
||||
|
|
|
@ -8,8 +8,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "statistics/statistics_data_deserialize.h"
|
||||
|
||||
#include "base/debug_log.h"
|
||||
#include "data/data_channel_earn.h" // kEarnMultiplier.
|
||||
#include "data/data_statistics_chart.h"
|
||||
#include "statistics/statistics_types.h"
|
||||
#include "ui/text/format_values.h" // kCreditsCurrency.
|
||||
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
@ -40,6 +42,18 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
|||
}) | ranges::to_vector;
|
||||
|
||||
auto result = Data::StatisticalChart();
|
||||
|
||||
{
|
||||
const auto tickFormatIt = root.constFind(u"yTickFormatter"_q);
|
||||
if (tickFormatIt != root.constEnd()) {
|
||||
const auto tickFormat = tickFormatIt->toString();
|
||||
if (tickFormat.contains(u"TON"_q)) {
|
||||
result.currency = Data::StatisticalCurrency::Ton;
|
||||
} else if (tickFormat.contains(Ui::kCreditsCurrency)) {
|
||||
result.currency = Data::StatisticalCurrency::Credits;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto columnIdCount = 0;
|
||||
for (const auto &column : columns) {
|
||||
const auto array = column.toArray();
|
||||
|
@ -62,8 +76,13 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
|||
line.isHiddenOnStart = ranges::contains(hiddenLines, columnId);
|
||||
line.y.resize(length);
|
||||
for (auto i = 0; i < length; i++) {
|
||||
const auto value = ChartValue(base::SafeRound(
|
||||
array.at(i + 1).toDouble()));
|
||||
using Currency = Data::StatisticalCurrency;
|
||||
const auto multiplier = (result.currency == Currency::Credits)
|
||||
? Data::kEarnMultiplier
|
||||
: 1;
|
||||
const auto value = ChartValue(
|
||||
base::SafeRound(array.at(i + 1).toDouble()))
|
||||
* multiplier;
|
||||
line.y[i] = value;
|
||||
if (value > line.maxValue) {
|
||||
line.maxValue = value;
|
||||
|
|
Loading…
Add table
Reference in a new issue