Fixed mouse selection of pie chart with single part.

This commit is contained in:
23rd 2023-09-26 04:11:18 +03:00 committed by John Preston
parent b261d23645
commit 6995fcafb5
2 changed files with 5 additions and 1 deletions

View File

@ -180,6 +180,7 @@ auto StackLinearChartView::partsPercentage(
auto minPercDiffIndex = int(-1);
auto roundedPercentagesSum = 0.;
_pieHasSinglePart = false;
for (auto k = 0; k < sums.size(); k++) {
const auto rawPercentage = sums[k] / totalSum;
const auto rounded = 0.01 * std::round(rawPercentage * 100.);
@ -198,6 +199,7 @@ auto StackLinearChartView::partsPercentage(
stackedPercentage += rounded;
result.push_back({ rounded, stackedPercentage * 360. - 180. });
_pieHasSinglePart |= (rounded == 1.);
}
{
const auto index = (roundedPercentagesSum > 1.)
@ -787,7 +789,8 @@ void StackLinearChartView::handleMouseMove(
}
bool StackLinearChartView::skipSelectedTranslation() const {
return (_entries.size() == (_transition.lines.size() - 1));
return _pieHasSinglePart
|| (_entries.size() == (_transition.lines.size() - 1));
}
void StackLinearChartView::paintSelectedXIndex(

View File

@ -148,6 +148,7 @@ private:
};
PiePartController _piePartController;
Ui::Animations::Basic _piePartAnimation;
bool _pieHasSinglePart = false;
};