mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-03 18:49:30 +00:00
Fixed display of zoomed days in pie chart view.
This commit is contained in:
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "data/data_statistics.h"
|
||||
#include "statistics/statistics_common.h"
|
||||
#include "ui/effects/animation_value_f.h"
|
||||
|
||||
namespace Statistic {
|
||||
|
||||
@@ -30,4 +31,38 @@ LeftStartAndStep ComputeLeftStartAndStep(
|
||||
return { leftStart, w };
|
||||
}
|
||||
|
||||
Limits FindStackXIndicesFromRawXPercentages(
|
||||
const Data::StatisticalChart &chartData,
|
||||
const Limits &rawXPercentageLimits,
|
||||
const Limits &zoomedInLimitXIndices) {
|
||||
const auto zoomLimit = Limits{
|
||||
chartData.xPercentage[zoomedInLimitXIndices.min],
|
||||
chartData.xPercentage[zoomedInLimitXIndices.max],
|
||||
};
|
||||
const auto offset = (zoomLimit.max == 1.) ? 0 : -1;
|
||||
const auto minIt = ranges::upper_bound(
|
||||
chartData.xPercentage,
|
||||
anim::interpolateF(
|
||||
zoomLimit.min,
|
||||
zoomLimit.max,
|
||||
rawXPercentageLimits.min));
|
||||
const auto maxIt = ranges::upper_bound(
|
||||
chartData.xPercentage,
|
||||
anim::interpolateF(
|
||||
zoomLimit.min,
|
||||
zoomLimit.max,
|
||||
rawXPercentageLimits.max));
|
||||
const auto start = begin(chartData.xPercentage);
|
||||
return {
|
||||
.min = std::clamp(
|
||||
float64(std::distance(start, minIt) + offset),
|
||||
zoomedInLimitXIndices.min,
|
||||
zoomedInLimitXIndices.max),
|
||||
.max = std::clamp(
|
||||
float64(std::distance(start, maxIt) + offset),
|
||||
zoomedInLimitXIndices.min,
|
||||
zoomedInLimitXIndices.max),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Statistic
|
||||
|
||||
Reference in New Issue
Block a user