##// END OF EJS Templates
QLogValueAxis number of labels calculation fixed
Marek Rosa -
r2370:6a9743cf4397
parent child
Show More
@@ -95,9 +95,7 QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
95 95 QStringList ticksList;
96 96 qreal logMax = log10(m_axis->max()) / log10(m_axis->base());
97 97 qreal logMin = log10(m_axis->min()) / log10(m_axis->base());
98 int tickCount = qAbs(qRound(logMax - logMin));
99 tickCount++;
100
98 int tickCount = qAbs(ceil(logMax) - ceil(logMin));
101 99 if (m_axis->max() > m_axis->min() && tickCount > 1)
102 100 ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat());
103 101 else
@@ -25,6 +25,7
25 25 #include <QGraphicsLayout>
26 26 #include <QFontMetrics>
27 27 #include <qmath.h>
28 #include <QDebug>
28 29
29 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 31
@@ -94,12 +95,13 QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
94 95 QStringList ticksList;
95 96 qreal logMax = log10(m_axis->max()) / log10(m_axis->base());
96 97 qreal logMin = log10(m_axis->min()) / log10(m_axis->base());
97 int tickCount = qAbs(qRound(logMax - logMin));
98 tickCount++;
98 int tickCount = qAbs(ceil(logMax) - ceil(logMin));
99 99 if (m_axis->max() > m_axis->min() && tickCount > 1)
100 100 ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat());
101 101 else
102 102 ticksList.append(QString(" "));
103 qDebug() << ticksList;
104 qDebug() << tickCount;
103 105 qreal width = 0;
104 106 qreal height = 0;
105 107
@@ -113,7 +115,7 QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
113 115 break;
114 116 }
115 117 case Qt::PreferredSize: {
116 int count = qMax(ticksList.first().count() , ticksList.last().count());
118 int count = qMax(ticksList.first().count(), ticksList.last().count());
117 119 width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance
118 120 width += base.width();
119 121 height = fn.height() * ticksList.count();
General Comments 0
You need to be logged in to leave comments. Login now