From 0eb8e085745917d3c7321bf0587c8525e6c9dac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedek=20L=C3=A1szl=C3=B3?= Date: Sun, 19 May 2024 17:11:57 +0200 Subject: [PATCH] y axis text rotation --- src/graph/server/gui/chart/chart.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/graph/server/gui/chart/chart.cpp b/src/graph/server/gui/chart/chart.cpp index fdbce14..1714be2 100644 --- a/src/graph/server/gui/chart/chart.cpp +++ b/src/graph/server/gui/chart/chart.cpp @@ -145,16 +145,22 @@ void ChartWidget::paintEvent(QPaintEvent* e) { // limits // y max-mid-min - painter.drawText(QRect(marginX / 2, marginY, marginX / 2, marginY), Qt::AlignCenter, QString::number(spec.axis.y.max)); - painter.drawText(QRect(marginX / 2, height() / 2 - marginY / 2, marginX / 2, marginY), Qt::AlignCenter, - QString::number((spec.axis.y.max + spec.axis.y.min) / 2)); - painter.drawText(QRect(marginX / 2, height() - marginY * 2, marginX / 2, marginY), Qt::AlignCenter, QString::number(spec.axis.y.min)); + painter.save(); + painter.rotate(-90); + painter.translate(-height(), 0); + + painter.drawText(QRect(marginY, marginX / 2, marginY, marginX / 2), Qt::AlignCenter, QString::number(spec.axis.y.min, 'f', 2)); + painter.drawText(QRect(height() / 2 - marginY / 2, marginX / 2, marginY, marginX / 2), Qt::AlignCenter, + QString::number((spec.axis.y.min + spec.axis.y.max) / 2, 'f', 2)); + painter.drawText(QRect(height() - marginY * 2, marginX / 2, marginY, marginX / 2), Qt::AlignCenter, QString::number(spec.axis.y.max, 'f', 2)); + + painter.restore(); // x min-mid-max - painter.drawText(QRect(marginX, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, QString::number(spec.axis.x.min)); + painter.drawText(QRect(marginX, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, QString::number(spec.axis.x.min, 'f', 2)); painter.drawText(QRect(width() / 2 - marginX / 2, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, - QString::number((spec.axis.x.min + spec.axis.x.max) / 2)); - painter.drawText(QRect(width() - marginX * 2, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, QString::number(spec.axis.x.max)); + QString::number((spec.axis.x.min + spec.axis.x.max) / 2, 'f', 2)); + painter.drawText(QRect(width() - marginX * 2, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, QString::number(spec.axis.x.max, 'f', 2)); // axis labels painter.drawText(QRect(0, height() - marginY / 2, width(), marginY / 2), Qt::AlignCenter, spec.axis.x.label);