@@ -47,7 +47,7 public: | |||||
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | QLogValueAxis *axisX= new QLogValueAxis(); |
|
49 | QLogValueAxis *axisX= new QLogValueAxis(); | |
50 |
axisX->setBase( |
|
50 | axisX->setBase(2); | |
51 | QLogValueAxis *axisY= new QLogValueAxis(); |
|
51 | QLogValueAxis *axisY= new QLogValueAxis(); | |
52 | axisY->setBase(2); |
|
52 | axisY->setBase(2); | |
53 | foreach (QAbstractSeries *series, chart->series()) { |
|
53 | foreach (QAbstractSeries *series, chart->series()) { |
@@ -180,11 +180,14 QString QLogValueAxis::labelFormat() const | |||||
180 | void QLogValueAxis::setBase(qreal base) |
|
180 | void QLogValueAxis::setBase(qreal base) | |
181 | { |
|
181 | { | |
182 | // check if base is correct |
|
182 | // check if base is correct | |
183 |
if ( |
|
183 | if (qFuzzyCompare(base, 1)) | |
184 | return; |
|
184 | return; | |
185 |
|
185 | |||
186 | Q_D(QLogValueAxis); |
|
186 | if (base > 0) { | |
187 | d->m_base = base; |
|
187 | Q_D(QLogValueAxis); | |
|
188 | d->m_base = base; | |||
|
189 | emit d->baseChanged(base); | |||
|
190 | } | |||
188 | } |
|
191 | } | |
189 |
|
192 | |||
190 | qreal QLogValueAxis::base() const |
|
193 | qreal QLogValueAxis::base() const |
@@ -56,6 +56,9 class QLogValueAxisPrivate : public QAbstractAxisPrivate | |||||
56 | void setRange(const QVariant &min, const QVariant &max); |
|
56 | void setRange(const QVariant &min, const QVariant &max); | |
57 | int tickCount() const; |
|
57 | int tickCount() const; | |
58 |
|
58 | |||
|
59 | Q_SIGNALS: | |||
|
60 | void baseChanged(qreal base); | |||
|
61 | ||||
59 | protected: |
|
62 | protected: | |
60 | qreal m_min; |
|
63 | qreal m_min; | |
61 | qreal m_max; |
|
64 | qreal m_max; |
@@ -143,10 +143,12 QVector<QPointF> LogXLogYDomain::calculateGeometryPoints(const QList<QPointF>& v | |||||
143 |
|
143 | |||
144 | QPointF LogXLogYDomain::calculateDomainPoint(const QPointF &point) const |
|
144 | QPointF LogXLogYDomain::calculateDomainPoint(const QPointF &point) const | |
145 | { |
|
145 | { | |
146 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); |
|
146 | const qreal leftEdgeX= m_logMinX < m_logMaxX ? m_logMinX : m_logMaxX; | |
147 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); |
|
147 | const qreal leftEdgeY = m_logMinY < m_logMaxY ? m_logMinY : m_logMaxY; | |
148 | qreal x = point.x() / deltaX + m_minX; |
|
148 | const qreal deltaX = m_size.width() / qAbs(m_logMaxX - m_logMinX); | |
149 | qreal y = (point.y() - m_size.height()) / (-deltaY) + m_minY; |
|
149 | const qreal deltaY = m_size.height() / qAbs(m_logMaxY - m_logMinY); | |
|
150 | qreal x = qPow(m_logBaseX, leftEdgeX + point.x() / deltaX); | |||
|
151 | qreal y = qPow(m_logBaseY, leftEdgeY + (m_size.height() - point.y()) / deltaY); | |||
150 | return QPointF(x, y); |
|
152 | return QPointF(x, y); | |
151 | } |
|
153 | } | |
152 |
|
154 |
@@ -145,9 +145,10 QVector<QPointF> LogXYDomain::calculateGeometryPoints(const QList<QPointF>& vect | |||||
145 |
|
145 | |||
146 | QPointF LogXYDomain::calculateDomainPoint(const QPointF &point) const |
|
146 | QPointF LogXYDomain::calculateDomainPoint(const QPointF &point) const | |
147 | { |
|
147 | { | |
148 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); |
|
148 | const qreal leftEdgeX= m_logMinX < m_logMaxX ? m_logMinX : m_logMaxX; | |
|
149 | const qreal deltaX = m_size.width() / qAbs(m_logMaxX - m_logMinX); | |||
149 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); |
|
150 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); | |
150 |
qreal x = point.x() / deltaX |
|
151 | qreal x = qPow(m_logBaseX, leftEdgeX + point.x() / deltaX); | |
151 | qreal y = (point.y() - m_size.height()) / (-deltaY) + m_minY; |
|
152 | qreal y = (point.y() - m_size.height()) / (-deltaY) + m_minY; | |
152 | return QPointF(x, y); |
|
153 | return QPointF(x, y); | |
153 | } |
|
154 | } |
@@ -146,9 +146,10 QVector<QPointF> XLogYDomain::calculateGeometryPoints(const QList<QPointF>& vect | |||||
146 | QPointF XLogYDomain::calculateDomainPoint(const QPointF &point) const |
|
146 | QPointF XLogYDomain::calculateDomainPoint(const QPointF &point) const | |
147 | { |
|
147 | { | |
148 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); |
|
148 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); | |
149 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); |
|
149 | const qreal leftEdgeY = m_logMinY < m_logMaxY ? m_logMinY : m_logMaxY; | |
|
150 | const qreal deltaY = m_size.height() / qAbs(m_logMaxY - m_logMinY); | |||
150 | qreal x = point.x() / deltaX + m_minX; |
|
151 | qreal x = point.x() / deltaX + m_minX; | |
151 |
qreal y = ( |
|
152 | qreal y = qPow(m_logBaseY, leftEdgeY + (m_size.height() - point.y()) / deltaY); | |
152 | return QPointF(x, y); |
|
153 | return QPointF(x, y); | |
153 | } |
|
154 | } | |
154 |
|
155 |
General Comments 0
You need to be logged in to leave comments.
Login now