From 6a9743cf43975d4689b48503321c1e7a9a437457 2012-12-10 14:07:11 From: Marek Rosa Date: 2012-12-10 14:07:11 Subject: [PATCH] QLogValueAxis number of labels calculation fixed --- diff --git a/src/axis/logvalueaxis/chartlogvalueaxisx.cpp b/src/axis/logvalueaxis/chartlogvalueaxisx.cpp index 376884f..de9dc3c 100644 --- a/src/axis/logvalueaxis/chartlogvalueaxisx.cpp +++ b/src/axis/logvalueaxis/chartlogvalueaxisx.cpp @@ -95,9 +95,7 @@ QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint QStringList ticksList; qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); - int tickCount = qAbs(qRound(logMax - logMin)); - tickCount++; - + int tickCount = qAbs(ceil(logMax) - ceil(logMin)); if (m_axis->max() > m_axis->min() && tickCount > 1) ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); else diff --git a/src/axis/logvalueaxis/chartlogvalueaxisy.cpp b/src/axis/logvalueaxis/chartlogvalueaxisy.cpp index b3072fd..25d51c0 100644 --- a/src/axis/logvalueaxis/chartlogvalueaxisy.cpp +++ b/src/axis/logvalueaxis/chartlogvalueaxisy.cpp @@ -25,6 +25,7 @@ #include #include #include +#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -94,12 +95,13 @@ QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint QStringList ticksList; qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); - int tickCount = qAbs(qRound(logMax - logMin)); - tickCount++; + int tickCount = qAbs(ceil(logMax) - ceil(logMin)); if (m_axis->max() > m_axis->min() && tickCount > 1) ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); else ticksList.append(QString(" ")); + qDebug() << ticksList; + qDebug() << tickCount; qreal width = 0; qreal height = 0; @@ -113,7 +115,7 @@ QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint break; } case Qt::PreferredSize: { - int count = qMax(ticksList.first().count() , ticksList.last().count()); + int count = qMax(ticksList.first().count(), ticksList.last().count()); width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance width += base.width(); height = fn.height() * ticksList.count();