mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Slightly improved code style in PaintLinearChartView.
This commit is contained in:
parent
d603f4de51
commit
9e8d60065b
2 changed files with 9 additions and 16 deletions
|
@ -17,15 +17,12 @@ namespace Statistic {
|
|||
void PaintLinearChartView(
|
||||
QPainter &p,
|
||||
const Data::StatisticalChart &chartData,
|
||||
const Limits &xPercentageLimitsNow,
|
||||
const Limits &xPercentageLimitsNowY,
|
||||
const Limits &xPercentageLimits,
|
||||
const Limits &heightLimits,
|
||||
const QRect &rect) {
|
||||
const auto offset = 0;
|
||||
const auto currentMinHeight = rect.y(); //
|
||||
const auto currentMaxHeight = rect.height() + rect.y(); //
|
||||
|
||||
const auto xPercentageLimits = xPercentageLimitsNow;
|
||||
|
||||
for (const auto &line : chartData.lines) {
|
||||
const auto additionalP = (chartData.xPercentage.size() < 2)
|
||||
? 0.
|
||||
|
@ -46,19 +43,15 @@ void PaintLinearChartView(
|
|||
int(chartData.xPercentage.size() - 1),
|
||||
endXIndex + additionalPoints);
|
||||
|
||||
auto minY = std::numeric_limits<float64>::max();
|
||||
auto maxY = 0.;
|
||||
minY = xPercentageLimitsNowY.min;
|
||||
maxY = xPercentageLimitsNowY.max;
|
||||
|
||||
for (auto i = localStart; i <= localEnd; i++) {
|
||||
if (line.y[i] < 0) {
|
||||
continue;
|
||||
}
|
||||
const auto xPoint = ((chartData.xPercentage[i] - xPercentageLimits.min) / (xPercentageLimits.max - xPercentageLimits.min)) * rect.width()
|
||||
- offset;
|
||||
const auto yPercentage = (line.y[i] - minY)
|
||||
/ float64(maxY - minY);
|
||||
const auto xPoint = rect.width()
|
||||
* ((chartData.xPercentage[i] - xPercentageLimits.min)
|
||||
/ (xPercentageLimits.max - xPercentageLimits.min));
|
||||
const auto yPercentage = (line.y[i] - heightLimits.min)
|
||||
/ float64(heightLimits.max - heightLimits.min);
|
||||
const auto yPoint = rect.y() + (1. - yPercentage) * rect.height();
|
||||
if (first) {
|
||||
first = false;
|
||||
|
|
|
@ -18,8 +18,8 @@ struct Limits;
|
|||
void PaintLinearChartView(
|
||||
QPainter &p,
|
||||
const Data::StatisticalChart &chartData,
|
||||
const Limits &xPercentageLimitsNow,
|
||||
const Limits &xPercentageLimitsNowY,
|
||||
const Limits &xPercentageLimits,
|
||||
const Limits &heightLimits,
|
||||
const QRect &rect);
|
||||
|
||||
} // namespace Statistic
|
||||
|
|
Loading…
Add table
Reference in a new issue