mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +03:00
Fix vertical axis labels padding
This commit is contained in:
parent
74c0f52369
commit
df0e4d8393
@ -9,15 +9,19 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
|||||||
const qreal vPadding = this->vPadding(chartRect);
|
const qreal vPadding = this->vPadding(chartRect);
|
||||||
|
|
||||||
const qreal valuesVMargin = this->valuesVMargin(painter);
|
const qreal valuesVMargin = this->valuesVMargin(painter);
|
||||||
const qreal topOffset = painter->fontMetrics().height();
|
|
||||||
|
|
||||||
QRectF gridRect = chartRect.adjusted(
|
QRectF gridRect = chartRect.adjusted(
|
||||||
hPadding,
|
hPadding,
|
||||||
vPadding + valuesVMargin + topOffset,
|
vPadding + valuesVMargin * 2,
|
||||||
-hPadding * 3,
|
-hPadding * 3,
|
||||||
-vPadding
|
-vPadding * 3
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!m_chartItem->horizontalAxisOnTop()) {
|
||||||
|
// If horizontal axis is on the bottom, move grid a little up
|
||||||
|
gridRect.adjust(0, -valuesVMargin, 0 , -valuesVMargin);
|
||||||
|
}
|
||||||
|
|
||||||
// Adapt font for horizontal axis
|
// Adapt font for horizontal axis
|
||||||
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter)) / xAxisData().segmentCount() * 0.8,
|
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter)) / xAxisData().segmentCount() * 0.8,
|
||||||
painter->font(),
|
painter->font(),
|
||||||
@ -25,23 +29,8 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
|||||||
|
|
||||||
const qreal valuesHMargin = this->valuesHMargin(painter);
|
const qreal valuesHMargin = this->valuesHMargin(painter);
|
||||||
|
|
||||||
QRectF calcRect = horizontalLabelsRect(
|
// Adjust vertical axis labels padding
|
||||||
painter,
|
gridRect.adjust(valuesHMargin * 0.2, 0, 0, 0);
|
||||||
chartRect.adjusted(
|
|
||||||
hPadding * 2 + valuesHMargin,
|
|
||||||
chartRect.height() - (painter->fontMetrics().height() + vPadding*2),
|
|
||||||
-(hPadding * 2),
|
|
||||||
-vPadding
|
|
||||||
)
|
|
||||||
);
|
|
||||||
gridRect.adjust(0, 0, 0, -calcRect.height());
|
|
||||||
|
|
||||||
if (!m_chartItem->horizontalAxisOnTop()) {
|
|
||||||
// Draw labels above the grid
|
|
||||||
const qreal height = calcRect.height();
|
|
||||||
calcRect.setBottom(gridRect.top());
|
|
||||||
calcRect.setTop(calcRect.bottom() - height);
|
|
||||||
}
|
|
||||||
|
|
||||||
paintGrid(painter, gridRect);
|
paintGrid(painter, gridRect);
|
||||||
|
|
||||||
@ -49,7 +38,6 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
|||||||
painter,
|
painter,
|
||||||
gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0)
|
gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0)
|
||||||
);
|
);
|
||||||
paintHorizontalLabels(painter, calcRect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||||
|
@ -844,7 +844,7 @@ void AbstractSeriesChart::paintGrid(QPainter *painter, QRectF gridRect)
|
|||||||
const qreal valuesHMargin = this->valuesHMargin(painter);
|
const qreal valuesHMargin = this->valuesHMargin(painter);
|
||||||
const qreal vStep = gridRect.height() / yAxisSegmentCount;
|
const qreal vStep = gridRect.height() / yAxisSegmentCount;
|
||||||
const qreal hStep = (gridRect.width() - valuesHMargin - gridOffset.width()) / xAxisSegmentCount;
|
const qreal hStep = (gridRect.width() - valuesHMargin - gridOffset.width()) / xAxisSegmentCount;
|
||||||
const qreal textPositionHOffset = valuesHMargin * 0.2;
|
const qreal textPositionHOffset = valuesHMargin * 0.1;
|
||||||
|
|
||||||
// Vertical axis lines
|
// Vertical axis lines
|
||||||
const QTextOption verticalTextOption(Qt::AlignRight);
|
const QTextOption verticalTextOption(Qt::AlignRight);
|
||||||
|
Loading…
Reference in New Issue
Block a user