data_statistics_chart.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "statistics/segment_tree.h"
  9. namespace Data {
  10. enum class StatisticalCurrency {
  11. None,
  12. Ton,
  13. Credits,
  14. };
  15. struct StatisticalChart {
  16. StatisticalChart() = default;
  17. [[nodiscard]] bool empty() const {
  18. return lines.empty();
  19. }
  20. [[nodiscard]] explicit operator bool() const {
  21. return !empty();
  22. }
  23. void measure();
  24. [[nodiscard]] QString getDayString(int i) const;
  25. [[nodiscard]] int findStartIndex(float64 v) const;
  26. [[nodiscard]] int findEndIndex(int left, float64 v) const;
  27. [[nodiscard]] int findIndex(int left, int right, float64 v) const;
  28. struct Line final {
  29. std::vector<Statistic::ChartValue> y;
  30. Statistic::SegmentTree segmentTree;
  31. int id = 0;
  32. QString idString;
  33. QString name;
  34. Statistic::ChartValue maxValue = 0;
  35. Statistic::ChartValue minValue
  36. = std::numeric_limits<Statistic::ChartValue>::max();
  37. QString colorKey;
  38. QColor color;
  39. QColor colorDark;
  40. bool isHiddenOnStart = false;
  41. };
  42. std::vector<float64> x;
  43. std::vector<float64> xPercentage;
  44. std::vector<QString> daysLookup;
  45. std::vector<Line> lines;
  46. struct {
  47. float64 min = 0.;
  48. float64 max = 0.;
  49. } defaultZoomXIndex;
  50. Statistic::ChartValue maxValue = 0;
  51. Statistic::ChartValue minValue
  52. = std::numeric_limits<Statistic::ChartValue>::max();
  53. float64 oneDayPercentage = 0.;
  54. float64 timeStep = 1.;
  55. bool isFooterHidden = false;
  56. bool hasPercentages = false;
  57. bool weekFormat = false;
  58. StatisticalCurrency currency = StatisticalCurrency::None;
  59. float64 currencyRate = 0.;
  60. // View data.
  61. int dayStringMaxWidth = 0;
  62. };
  63. struct StatisticalGraph final {
  64. StatisticalChart chart;
  65. QString zoomToken;
  66. QString error;
  67. };
  68. } // namespace Data