Split out data for statistics and for charts.

This commit is contained in:
23rd 2023-09-29 16:32:07 +03:00 committed by John Preston
parent 2638e54181
commit 8ac6aca315
5 changed files with 80 additions and 65 deletions

View File

@ -555,7 +555,6 @@ PRIVATE
data/data_sparse_ids.h
data/data_sponsored_messages.cpp
data/data_sponsored_messages.h
data/data_statistics.cpp
data/data_statistics.h
data/data_stories.cpp
data/data_stories.h
@ -1292,8 +1291,6 @@ PRIVATE
statistics/chart_widget.h
statistics/point_details_widget.cpp
statistics/point_details_widget.h
statistics/segment_tree.cpp
statistics/segment_tree.h
statistics/statistics_box.cpp
statistics/statistics_box.h
statistics/statistics_common.h

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "statistics/segment_tree.h"
#include "data/data_statistics_chart.h"
namespace Data {
@ -35,64 +35,6 @@ struct StatisticsInviterInfo final {
int addedMemberCount = 0;
};
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;
[[nodiscard]] int findStartIndex(float v) const;
[[nodiscard]] int findEndIndex(int left, float v) const;
[[nodiscard]] int findIndex(int left, int right, float v) const;
struct Line final {
std::vector<int> y;
Statistic::SegmentTree segmentTree;
int id = 0;
QString idString;
QString name;
int maxValue = 0;
int minValue = std::numeric_limits<int>::max();
QString colorKey;
QColor color;
QColor colorDark;
};
std::vector<float64> x;
std::vector<float64> xPercentage;
std::vector<QString> daysLookup;
std::vector<Line> lines;
struct {
float64 min = 0.;
float64 max = 0.;
} defaultZoomXIndex;
int maxValue = 0;
int minValue = std::numeric_limits<int>::max();
float64 oneDayPercentage = 0.;
float64 timeStep = 0.;
};
struct StatisticalGraph final {
StatisticalChart chart;
QString zoomToken;
QString error;
};
struct StatisticalValue final {
float64 value = 0.;
float64 previousValue = 0.;

View File

@ -5,11 +5,11 @@ 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
*/
#include "data/data_statistics.h"
#include "data/data_statistics_chart.h"
#include <QtCore/QDateTime>
namespace Data {
namespace {
} // namespace
void StatisticalChart::measure() {
if (x.empty()) {

View File

@ -0,0 +1,72 @@
/*
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;
[[nodiscard]] int findStartIndex(float v) const;
[[nodiscard]] int findEndIndex(int left, float v) const;
[[nodiscard]] int findIndex(int left, int right, float v) const;
struct Line final {
std::vector<int> y;
Statistic::SegmentTree segmentTree;
int id = 0;
QString idString;
QString name;
int maxValue = 0;
int minValue = std::numeric_limits<int>::max();
QString colorKey;
QColor color;
QColor colorDark;
};
std::vector<float64> x;
std::vector<float64> xPercentage;
std::vector<QString> daysLookup;
std::vector<Line> lines;
struct {
float64 min = 0.;
float64 max = 0.;
} defaultZoomXIndex;
int maxValue = 0;
int minValue = std::numeric_limits<int>::max();
float64 oneDayPercentage = 0.;
float64 timeStep = 0.;
};
struct StatisticalGraph final {
StatisticalChart chart;
QString zoomToken;
QString error;
};
} // namespace Data

View File

@ -69,6 +69,8 @@ PRIVATE
countries/countries_instance.cpp
countries/countries_instance.h
data/data_statistics_chart.cpp
data/data_statistics_chart.h
data/data_subscription_option.h
dialogs/dialogs_three_state_icon.h
@ -161,6 +163,8 @@ PRIVATE
statistics/chart_lines_filter_widget.cpp
statistics/chart_lines_filter_widget.h
statistics/segment_tree.cpp
statistics/segment_tree.h
ui/boxes/auto_delete_settings.cpp
ui/boxes/auto_delete_settings.h