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