mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: consider overhang of horizontal axes
The old code didn't consider that labels can peak out of horizontal axes if labels are under ticks. This commit takes this into account. However, it must be noted that this is only heuristics: Before setting the size of the axes, the actual minimum and maximum label are not known, because we round to "nice" numbers. But the size of the axis can only be set after knowing the overhang, leading to a circular dependency. Therefore, the code currently simply uses the minimum and maximum value of the data, hoping that the "nice" values will not format to something significantly larger. We could do a multi-pass scheme, but let's not for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0ff1145fd8
commit
bdecd98ef5
3 changed files with 63 additions and 11 deletions
|
@ -97,15 +97,21 @@ void StatsView::plotAreaChanged(const QSizeF &s)
|
|||
if (title)
|
||||
top += title->boundingRect().height() + titleBorder;
|
||||
// Currently, we only have either none, or an x- and a y-axis
|
||||
if (xAxis)
|
||||
std::pair<double,double> horizontalSpace{ 0.0, 0.0 };
|
||||
if (xAxis) {
|
||||
bottom -= xAxis->height();
|
||||
horizontalSpace = xAxis->horizontalOverhang();
|
||||
}
|
||||
if (bottom - top < minSize)
|
||||
return;
|
||||
if (yAxis) {
|
||||
yAxis->setSize(bottom - top);
|
||||
left += yAxis->width();
|
||||
yAxis->setPos(QPointF(left, bottom));
|
||||
horizontalSpace.first = std::max(horizontalSpace.first, yAxis->width());
|
||||
}
|
||||
left += horizontalSpace.first;
|
||||
right -= horizontalSpace.second;
|
||||
if (yAxis)
|
||||
yAxis->setPos(QPointF(left, bottom));
|
||||
if (right - left < minSize)
|
||||
return;
|
||||
if (xAxis) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue