0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Fix diagram size when legend is showed

This commit is contained in:
Emil Sawicki 2022-02-15 17:39:14 +01:00
parent b14f0be7bc
commit f03ccdd23b
2 changed files with 5 additions and 9 deletions

View File

@ -91,7 +91,6 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
{
// TODO_ES Fix bottom legend when axis is at the bottom
prepareLegendToPaint(legendRect, painter);
int indicatorSize = painter->fontMetrics().height()/2;

View File

@ -197,28 +197,25 @@ void ChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
const QRectF titleRect = QRectF(borderMargin,borderMargin,rect().width()-borderMargin*2,titleOffset);
QRectF legendRect = QRectF(0, 0, 0, 0);
QRectF diagramRect = QRectF(0, 0, 0, 0);
QRectF diagramRect = rect().adjusted(borderMargin, titleOffset + borderMargin,
-(borderMargin * 2), -borderMargin);
if (m_showLegend) {
legendRect = m_chart->calcChartLegendRect(painter->font(), rect(), false, borderMargin, titleOffset);
switch(legendAlign()) {
case LegendAlignRightTop:
case LegendAlignRightBottom:
case LegendAlignRightCenter:
diagramRect = rect().adjusted(borderMargin, titleOffset + borderMargin,
-(legendRect.width() + borderMargin * 2), -borderMargin);
diagramRect.adjust(0, 0, -legendRect.width(), 0);
break;
case LegendAlignBottomLeft:
case LegendAlignBottomCenter:
case LegendAlignBottomRight:
diagramRect = rect().adjusted(borderMargin, titleOffset + borderMargin,
(borderMargin * 2), -legendRect.height());
diagramRect.adjust(0, 0, 0, -(legendRect.height() + borderMargin * 2));
break;
}
} else {
diagramRect = rect().adjusted(borderMargin, titleOffset + borderMargin,
-(borderMargin * 2), -borderMargin);
}
painter->fillRect(diagramRect, Qt::yellow);
paintChartTitle(painter, titleRect);
if (m_showLegend)
m_chart->paintChartLegend(painter,legendRect);