summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-10-14 11:57:03 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-10-25 10:55:25 +0200
commitd42651120f5e4c60144a8aad21ec900115fe5e50 (patch)
tree2b3486057292787b9eeb9cfcc4f18cef82091ee1 /src
parent5edc1c9063ed6a954c8a4d9c269462dc09c9f493 (diff)
Divide by logBase in the right place to save messy computations
All logs used in computing layout should be to the axis's base; natural logs should only be used to compute those. This incidentally saves the "need" to raise the base to a power in order to then take the log of the result (which would, in any case, have been better done by just multiplying logBase by the power involved). The finally computed values do in fact come out the same, as the factors of logBase are merely moved around and end up cancelling in computing the extra tick values, but using logs to the right base makes the code easier to understand. Change-Id: I6c6921f08ea8359d8236db15ef16eb8ddedb3d29 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/charts/axis/verticalaxis.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/charts/axis/verticalaxis.cpp b/src/charts/axis/verticalaxis.cpp
index 627b3654..05c05cbf 100644
--- a/src/charts/axis/verticalaxis.cpp
+++ b/src/charts/axis/verticalaxis.cpp
@@ -452,10 +452,10 @@ void VerticalAxis::updateMinorTickGeometry()
layout.prepend(layout.at(0) + tickSpacing);
layout.append(layout.at(layout.size() - 1) - tickSpacing);
} else {
- const qreal logMax = qLn(logValueAxis->max());
- const qreal logMin = qLn(logValueAxis->min());
- const qreal logExtraMaxTick = qLn(qPow(base, qFloor(logMax / logBase) + 1.0));
- const qreal logExtraMinTick = qLn(qPow(base, qCeil(logMin / logBase) - 1.0));
+ const qreal logMax = qLn(logValueAxis->max()) / logBase;
+ const qreal logMin = qLn(logValueAxis->min()) / logBase;
+ const qreal logExtraMaxTick = qFloor(logMax) + 1.0;
+ const qreal logExtraMinTick = qCeil(logMin) - 1.0;
const qreal edge = gridGeometry().bottom();
const qreal delta = gridGeometry().height() / qAbs(logMax - logMin);
const qreal extraMaxTick = edge - (logExtraMaxTick - qMin(logMin, logMax)) * delta;