y axis text rotation

This commit is contained in:
Benedek László 2024-05-19 17:11:57 +02:00
parent 590b302016
commit 0eb8e08574

View File

@ -145,16 +145,22 @@ void ChartWidget::paintEvent(QPaintEvent* e) {
// limits // limits
// y max-mid-min // y max-mid-min
painter.drawText(QRect(marginX / 2, marginY, marginX / 2, marginY), Qt::AlignCenter, QString::number(spec.axis.y.max)); painter.save();
painter.drawText(QRect(marginX / 2, height() / 2 - marginY / 2, marginX / 2, marginY), Qt::AlignCenter, painter.rotate(-90);
QString::number((spec.axis.y.max + spec.axis.y.min) / 2)); painter.translate(-height(), 0);
painter.drawText(QRect(marginX / 2, height() - marginY * 2, marginX / 2, marginY), Qt::AlignCenter, QString::number(spec.axis.y.min));
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 // 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, 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)); 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)); painter.drawText(QRect(width() - marginX * 2, height() - marginY, marginX, marginY / 2), Qt::AlignCenter, QString::number(spec.axis.x.max, 'f', 2));
// axis labels // axis labels
painter.drawText(QRect(0, height() - marginY / 2, width(), marginY / 2), Qt::AlignCenter, spec.axis.x.label); painter.drawText(QRect(0, height() - marginY / 2, width(), marginY / 2), Qt::AlignCenter, spec.axis.x.label);