2023-09-29 16:32:07 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "statistics/segment_tree.h"
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
struct StatisticalChart {
|
|
|
|
StatisticalChart() = default;
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
return lines.empty();
|
|
|
|
}
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void measure();
|
|
|
|
|
|
|
|
[[nodiscard]] QString getDayString(int i) const;
|
|
|
|
|
2023-10-02 16:43:11 +03:00
|
|
|
[[nodiscard]] int findStartIndex(float64 v) const;
|
|
|
|
[[nodiscard]] int findEndIndex(int left, float64 v) const;
|
|
|
|
[[nodiscard]] int findIndex(int left, int right, float64 v) const;
|
2023-09-29 16:32:07 +03:00
|
|
|
|
|
|
|
struct Line final {
|
2024-04-11 17:37:54 +03:00
|
|
|
std::vector<Statistic::ChartValue> y;
|
2023-09-29 16:32:07 +03:00
|
|
|
|
|
|
|
Statistic::SegmentTree segmentTree;
|
|
|
|
int id = 0;
|
|
|
|
QString idString;
|
|
|
|
QString name;
|
2024-04-11 17:37:54 +03:00
|
|
|
Statistic::ChartValue maxValue = 0;
|
2024-04-11 18:56:11 +03:00
|
|
|
Statistic::ChartValue minValue
|
|
|
|
= std::numeric_limits<Statistic::ChartValue>::max();
|
2023-09-29 16:32:07 +03:00
|
|
|
QString colorKey;
|
|
|
|
QColor color;
|
|
|
|
QColor colorDark;
|
2023-10-04 05:06:58 +03:00
|
|
|
bool isHiddenOnStart = false;
|
2023-09-29 16:32:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<float64> x;
|
|
|
|
std::vector<float64> xPercentage;
|
|
|
|
std::vector<QString> daysLookup;
|
|
|
|
|
|
|
|
std::vector<Line> lines;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
float64 min = 0.;
|
|
|
|
float64 max = 0.;
|
|
|
|
} defaultZoomXIndex;
|
|
|
|
|
2024-04-11 17:37:54 +03:00
|
|
|
Statistic::ChartValue maxValue = 0;
|
2024-04-11 18:56:11 +03:00
|
|
|
Statistic::ChartValue minValue
|
|
|
|
= std::numeric_limits<Statistic::ChartValue>::max();
|
2023-09-29 16:32:07 +03:00
|
|
|
|
|
|
|
float64 oneDayPercentage = 0.;
|
|
|
|
|
|
|
|
float64 timeStep = 0.;
|
|
|
|
|
2023-10-04 03:35:38 +03:00
|
|
|
bool isFooterHidden = false;
|
2023-10-05 18:45:48 +03:00
|
|
|
bool hasPercentages = false;
|
2023-10-11 07:03:49 +03:00
|
|
|
bool weekFormat = false;
|
2024-03-28 06:40:16 +03:00
|
|
|
float64 currencyRate = 0.;
|
2023-10-04 03:35:38 +03:00
|
|
|
|
2023-12-06 22:28:57 +03:00
|
|
|
// View data.
|
|
|
|
int dayStringMaxWidth = 0;
|
|
|
|
|
2023-09-29 16:32:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct StatisticalGraph final {
|
|
|
|
StatisticalChart chart;
|
|
|
|
QString zoomToken;
|
|
|
|
QString error;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|