2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Fixed bug of display for y-axis captions with instant delivered data.

This commit is contained in:
23rd
2023-07-14 21:09:55 +03:00
committed by John Preston
parent 64bb818fe9
commit b1ed8cd1b1
2 changed files with 17 additions and 12 deletions

View File

@@ -816,7 +816,9 @@ ChartWidget::ChartWidget(not_null<Ui::RpWidget*> parent)
}
}) {
sizeValue(
) | rpl::start_with_next([=](const QSize &s) {
) | rpl::filter([](const QSize &s) {
return !s.isNull();
}) | rpl::start_with_next([=](const QSize &s) {
const auto filtersHeight = _filterButtons
? _filterButtons->height()
: 0;
@@ -840,6 +842,11 @@ ChartWidget::ChartWidget(not_null<Ui::RpWidget*> parent)
- st::statisticsChartFooterHeight
- filtersHeight
- st::statisticsChartFooterSkip);
{
updateChartFullWidth(s.width());
updateBottomDates();
}
}, lifetime());
setupChartArea();
@@ -857,6 +864,11 @@ void ChartWidget::resizeHeight() {
+ (_filterButtons ? _filterButtons->height() : 0));
}
void ChartWidget::updateChartFullWidth(int w) {
const auto finalXLimits = _animationController.finalXLimits();
_bottomLine.chartFullWidth = w / (finalXLimits.max - finalXLimits.min);
}
QRect ChartWidget::chartAreaRect() const {
return _chartArea->rect()
- QMargins(
@@ -971,7 +983,7 @@ void ChartWidget::setupChartArea() {
}
void ChartWidget::updateBottomDates() {
if (!_chartData) {
if (!_chartData || !_bottomLine.chartFullWidth) {
return;
}
const auto d = _bottomLine.chartFullWidth * _chartData.oneDayPercentage;
@@ -1079,11 +1091,7 @@ void ChartWidget::setupFooter() {
xPercentageLimits,
_animatedChartLines,
now);
{
const auto finalXLimits = _animationController.finalXLimits();
_bottomLine.chartFullWidth = _chartArea->width()
/ (finalXLimits.max - finalXLimits.min);
}
updateChartFullWidth(_chartArea->width());
updateBottomDates();
if ((now - _lastHeightLimitsChanged) < kHeightLimitsUpdateTimeout) {
return;
@@ -1221,11 +1229,7 @@ void ChartWidget::setChartData(Data::StatisticalChart chartData) {
{ _chartData.xPercentage.front(), _chartData.xPercentage.back() },
_animatedChartLines,
0);
{
const auto finalXLimits = _animationController.finalXLimits();
_bottomLine.chartFullWidth = _chartArea->width()
/ (finalXLimits.max - finalXLimits.min);
}
updateChartFullWidth(_chartArea->width());
updateBottomDates();
_animationController.finish();
addHorizontalLine(_animationController.finalHeightLimits(), false);