y axis text rotation
This commit is contained in:
parent
590b302016
commit
0eb8e08574
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user