##// END OF EJS Templates
Remove QML LogValueAxis documentation as it is not implemented...
Miikka Heikkinen -
r2438:df26734569cc
parent child
Show More
@@ -1,96 +1,95
1 /*!
1 /*!
2 \page qml.html
2 \page qml.html
3 \title QtCommercial Charts QML API
3 \title QtCommercial Charts QML API
4 \keyword Charts QML API
4 \keyword Charts QML API
5
5
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
7 applications.
7 applications.
8
8
9 \table
9 \table
10 \row
10 \row
11 \o \br
11 \o \br
12 Use the following QML to create a simple pie chart:
12 Use the following QML to create a simple pie chart:
13 \br
13 \br
14 \br
14 \br
15 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
15 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
16 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
16 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
17 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
17 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
18 \o \inlineimage examples_qmlpiechart.png
18 \o \inlineimage examples_qmlpiechart.png
19 \endtable
19 \endtable
20
20
21 \raw HTML
21 \raw HTML
22 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
22 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
23 <tr>
23 <tr>
24 <th class="titleheader" width="25%"> ChartView and it's properties </th>
24 <th class="titleheader" width="25%"> ChartView and it's properties </th>
25 </tr>
25 </tr>
26 <tr>
26 <tr>
27 <td valign="top">
27 <td valign="top">
28 <ul>
28 <ul>
29 <li><a href="qml-chartview.html">ChartView</a></li>
29 <li><a href="qml-chartview.html">ChartView</a></li>
30 <li><a href="qml-abstractaxis.html">AbstractAxis</a></li>
30 <li><a href="qml-abstractaxis.html">AbstractAxis</a></li>
31 <li><a href="qml-valueaxis.html">ValueAxis</a></li>
31 <li><a href="qml-valueaxis.html">ValueAxis</a></li>
32 <li><a href="qml-logvaluesaxis.html">LogValueAxis</a></li>
33 <li><a href="qml-categoryaxis.html">CategoryAxis</a></li>
32 <li><a href="qml-categoryaxis.html">CategoryAxis</a></li>
34 <li><a href="qml-categoryrange.html">CategoryRange</a></li>
33 <li><a href="qml-categoryrange.html">CategoryRange</a></li>
35 <li><a href="qml-barcategoryaxis.html">BarCategoryAxis</a></li>
34 <li><a href="qml-barcategoryaxis.html">BarCategoryAxis</a></li>
36 <li><a href="qml-datetimeaxis.html">DateTimeAxis</a></li>
35 <li><a href="qml-datetimeaxis.html">DateTimeAxis</a></li>
37 <li><a href="qml-legend.html">Legend</a></li>
36 <li><a href="qml-legend.html">Legend</a></li>
38 <li><a href="qml-abstractseries.html">AbstractSeries</a></li>
37 <li><a href="qml-abstractseries.html">AbstractSeries</a></li>
39 </ul>
38 </ul>
40 </td>
39 </td>
41 </tr>
40 </tr>
42 </table>
41 </table>
43 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
42 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
44 <tr>
43 <tr>
45 <th class="titleheader" width="25%"> XY chart </th>
44 <th class="titleheader" width="25%"> XY chart </th>
46 </tr>
45 </tr>
47 <tr>
46 <tr>
48 <td valign="top">
47 <td valign="top">
49 <ul>
48 <ul>
50 <li><a href="qml-xyseries.html">XYSeries</a></li>
49 <li><a href="qml-xyseries.html">XYSeries</a></li>
51 <li><a href="qml-lineseries.html">LineSeries</a></li>
50 <li><a href="qml-lineseries.html">LineSeries</a></li>
52 <li><a href="qml-areaseries.html">AreaSeries</a></li>
51 <li><a href="qml-areaseries.html">AreaSeries</a></li>
53 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
52 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
54 <li><a href="qml-splineseries.html">SplineSeries</a></li>
53 <li><a href="qml-splineseries.html">SplineSeries</a></li>
55 <li><a href="qml-xypoint.html">XYPoint</a></li>
54 <li><a href="qml-xypoint.html">XYPoint</a></li>
56 <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li>
55 <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li>
57 <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li>
56 <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li>
58 </ul>
57 </ul>
59 </td>
58 </td>
60 </tr>
59 </tr>
61 </table>
60 </table>
62 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
61 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
63 <tr>
62 <tr>
64 <th class="titleheader" width="25%"> Pie chart </th>
63 <th class="titleheader" width="25%"> Pie chart </th>
65 <tr>
64 <tr>
66 <td valign="top">
65 <td valign="top">
67 <ul>
66 <ul>
68 <li><a href="qml-pieseries.html">PieSeries</a></li>
67 <li><a href="qml-pieseries.html">PieSeries</a></li>
69 <li><a href="qml-pieslice.html">PieSlice</a></li>
68 <li><a href="qml-pieslice.html">PieSlice</a></li>
70 <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li>
69 <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li>
71 <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li>
70 <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li>
72 </ul>
71 </ul>
73 </td>
72 </td>
74 </tr>
73 </tr>
75 </table>
74 </table>
76 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
75 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
77 <tr>
76 <tr>
78 <th class="titleheader" width="25%"> Bar chart </th>
77 <th class="titleheader" width="25%"> Bar chart </th>
79 <tr>
78 <tr>
80 <td valign="top">
79 <td valign="top">
81 <ul>
80 <ul>
82 <li><a href="qml-barseries.html">BarSeries</a></li>
81 <li><a href="qml-barseries.html">BarSeries</a></li>
83 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
82 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
84 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
83 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
85 <li><a href="qml-horizontalbarseries.html">HorizontalBarSeries</a></li>
84 <li><a href="qml-horizontalbarseries.html">HorizontalBarSeries</a></li>
86 <li><a href="qml-horizontalstackedbarseries.html">HorizontalStackedBarSeries</a></li>
85 <li><a href="qml-horizontalstackedbarseries.html">HorizontalStackedBarSeries</a></li>
87 <li><a href="qml-horizontalpercentbarseries.html">HorizontalPercentBarSeries</a></li>
86 <li><a href="qml-horizontalpercentbarseries.html">HorizontalPercentBarSeries</a></li>
88 <li><a href="qml-barset.html">BarSet</a></li>
87 <li><a href="qml-barset.html">BarSet</a></li>
89 <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li>
88 <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li>
90 <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li>
89 <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li>
91 </ul>
90 </ul>
92 </td>
91 </td>
93 </tr>
92 </tr>
94 </table>
93 </table>
95 \endraw
94 \endraw
96 */
95 */
@@ -1,384 +1,333
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qlogvalueaxis.h"
21 #include "qlogvalueaxis.h"
22 #include "qlogvalueaxis_p.h"
22 #include "qlogvalueaxis_p.h"
23 #include "chartlogvalueaxisx_p.h"
23 #include "chartlogvalueaxisx_p.h"
24 #include "chartlogvalueaxisy_p.h"
24 #include "chartlogvalueaxisy_p.h"
25 #include "abstractdomain_p.h"
25 #include "abstractdomain_p.h"
26 #include <float.h>
26 #include <float.h>
27 #include <cmath>
27 #include <cmath>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 /*!
30 /*!
31 \class QLogValueAxis
31 \class QLogValueAxis
32 \brief The QLogValueAxis class is used for manipulating chart's axis.
32 \brief The QLogValueAxis class is used for manipulating chart's axis.
33 \mainclass
33 \mainclass
34
34
35 \note If a QLogValueAxis is attached to a series with one or more points with
35 \note If a QLogValueAxis is attached to a series with one or more points with
36 negative or zero values on the associated dimension, the series will not be
36 negative or zero values on the associated dimension, the series will not be
37 plotted at all. This is particularly relevant when XYModelMappers are used,
37 plotted at all. This is particularly relevant when XYModelMappers are used,
38 since empty cells in models typically contain zero values.
38 since empty cells in models typically contain zero values.
39 */
39 */
40
40
41 /*!
41 /*!
42 \qmlclass LogValuesAxis QLogValueAxis
43 \brief The LogValueAxis element is used for manipulating chart's axes
44 \inherits AbstractAxis
45
46 \note If a LogValueAxis is attached to a series with one or more points with
47 negative or zero values on the associated dimension, the series will not be
48 plotted at all. This is particularly relevant when XYModelMappers are used,
49 since empty cells in models typically contain zero values.
50 */
51
52 /*!
53 \property QLogValueAxis::min
42 \property QLogValueAxis::min
54 Defines the minimum value on the axis.
43 Defines the minimum value on the axis.
55 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
44 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
56 Value has to be greater then 0.
45 Value has to be greater then 0.
57 */
46 */
58 /*!
59 \qmlproperty real LogValuesAxis::min
60 Defines the minimum value on the axis.
61 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
62 Value has to be greater then 0.
63 */
64
47
65 /*!
48 /*!
66 \property QLogValueAxis::max
49 \property QLogValueAxis::max
67 Defines the maximum value on the axis.
50 Defines the maximum value on the axis.
68 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
51 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
69 Value has to be greater then 0.
52 Value has to be greater then 0.
70 */
53 */
71 /*!
72 \qmlproperty real LogValuesAxis::max
73 Defines the maximum value on the axis.
74 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
75 Value has to be greater then 0.
76 */
77
54
78 /*!
55 /*!
79 \property QLogValueAxis::base
56 \property QLogValueAxis::base
80 Defines the base of the logarithm.
57 Defines the base of the logarithm.
81 Value has to be greater then 0 and not equal 1
58 Value has to be greater then 0 and not equal 1
82 */
59 */
83 /*!
84 \qmlproperty real LogValuesAxis::base
85 Defines the maximum value on the axis.
86 Defines the base of the logarithm.
87 Value has to be greater then 0 and not equal 1
88 */
89
60
90 /*!
61 /*!
91 \property QLogValueAxis::labelFormat
62 \property QLogValueAxis::labelFormat
92 Defines the label format of the axis.
63 Defines the label format of the axis.
93 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c
64 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c
94 See QString::sprintf() for additional details.
65 See QString::sprintf() for additional details.
95 */
66 */
96 /*!
97 \qmlproperty real LogValuesAxis::labelFormat
98 Defines the label format of the axis.
99 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c
100 See QString::sprintf() for additional details.
101 */
102
67
103 /*!
68 /*!
104 \fn void QLogValueAxis::minChanged(qreal min)
69 \fn void QLogValueAxis::minChanged(qreal min)
105 Axis emits signal when \a min of axis has changed.
70 Axis emits signal when \a min of axis has changed.
106 */
71 */
107 /*!
108 \qmlsignal LogValuesAxis::onMinChanged(qreal min)
109 Axis emits signal when \a min of axis has changed.
110 */
111
72
112 /*!
73 /*!
113 \fn void QLogValueAxis::maxChanged(qreal max)
74 \fn void QLogValueAxis::maxChanged(qreal max)
114 Axis emits signal when \a max of axis has changed.
75 Axis emits signal when \a max of axis has changed.
115 */
76 */
116 /*!
117 \qmlsignal LogValuesAxis::onMaxChanged(qreal max)
118 Axis emits signal when \a max of axis has changed.
119 */
120
77
121 /*!
78 /*!
122 \fn void QLogValueAxis::rangeChanged(qreal min, qreal max)
79 \fn void QLogValueAxis::rangeChanged(qreal min, qreal max)
123 Axis emits signal when \a min or \a max of axis has changed.
80 Axis emits signal when \a min or \a max of axis has changed.
124 */
81 */
125
82
126 /*!
83 /*!
127 \fn void QLogValueAxis::labelFormatChanged(const QString &format)
84 \fn void QLogValueAxis::labelFormatChanged(const QString &format)
128 Axis emits signal when \a format of axis labels has changed.
85 Axis emits signal when \a format of axis labels has changed.
129 */
86 */
130 /*!
131 \qmlsignal LogValueAxis::labelFormatChanged(const QString &format)
132 Axis emits signal when \a format of axis labels has changed.
133 */
134
87
135 /*!
88 /*!
136 \fn void QLogValueAxis::baseChanged(qreal base)
89 \fn void QLogValueAxis::baseChanged(qreal base)
137 Axis emits signal when \a base of logarithm of the axis has changed.
90 Axis emits signal when \a base of logarithm of the axis has changed.
138 */
91 */
139 /*!
140 \qmlsignal LogValuesAxis::baseChanged(qreal base)
141 Axis emits signal when \a base of logarithm of the axis has changed.
142 */
143
92
144 /*!
93 /*!
145 Constructs an axis object which is a child of \a parent.
94 Constructs an axis object which is a child of \a parent.
146 */
95 */
147 QLogValueAxis::QLogValueAxis(QObject *parent) :
96 QLogValueAxis::QLogValueAxis(QObject *parent) :
148 QAbstractAxis(*new QLogValueAxisPrivate(this), parent)
97 QAbstractAxis(*new QLogValueAxisPrivate(this), parent)
149 {
98 {
150
99
151 }
100 }
152
101
153 /*!
102 /*!
154 \internal
103 \internal
155 */
104 */
156 QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent)
105 QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent)
157 {
106 {
158
107
159 }
108 }
160
109
161 /*!
110 /*!
162 Destroys the object
111 Destroys the object
163 */
112 */
164 QLogValueAxis::~QLogValueAxis()
113 QLogValueAxis::~QLogValueAxis()
165 {
114 {
166 Q_D(QLogValueAxis);
115 Q_D(QLogValueAxis);
167 if (d->m_chart)
116 if (d->m_chart)
168 d->m_chart->removeAxis(this);
117 d->m_chart->removeAxis(this);
169 }
118 }
170
119
171 void QLogValueAxis::setMin(qreal min)
120 void QLogValueAxis::setMin(qreal min)
172 {
121 {
173 Q_D(QLogValueAxis);
122 Q_D(QLogValueAxis);
174 setRange(min, qMax(d->m_max, min));
123 setRange(min, qMax(d->m_max, min));
175 }
124 }
176
125
177 qreal QLogValueAxis::min() const
126 qreal QLogValueAxis::min() const
178 {
127 {
179 Q_D(const QLogValueAxis);
128 Q_D(const QLogValueAxis);
180 return d->m_min;
129 return d->m_min;
181 }
130 }
182
131
183 void QLogValueAxis::setMax(qreal max)
132 void QLogValueAxis::setMax(qreal max)
184 {
133 {
185 Q_D(QLogValueAxis);
134 Q_D(QLogValueAxis);
186 setRange(qMin(d->m_min, max), max);
135 setRange(qMin(d->m_min, max), max);
187 }
136 }
188
137
189 qreal QLogValueAxis::max() const
138 qreal QLogValueAxis::max() const
190 {
139 {
191 Q_D(const QLogValueAxis);
140 Q_D(const QLogValueAxis);
192 return d->m_max;
141 return d->m_max;
193 }
142 }
194
143
195 /*!
144 /*!
196 Sets range from \a min to \a max on the axis.
145 Sets range from \a min to \a max on the axis.
197 If min is greater than max then this function returns without making any changes.
146 If min is greater than max then this function returns without making any changes.
198 */
147 */
199 void QLogValueAxis::setRange(qreal min, qreal max)
148 void QLogValueAxis::setRange(qreal min, qreal max)
200 {
149 {
201 Q_D(QLogValueAxis);
150 Q_D(QLogValueAxis);
202 bool changed = false;
151 bool changed = false;
203
152
204 if (min > max)
153 if (min > max)
205 return;
154 return;
206
155
207 if (min > 0) {
156 if (min > 0) {
208 if (!qFuzzyCompare(d->m_min, min)) {
157 if (!qFuzzyCompare(d->m_min, min)) {
209 d->m_min = min;
158 d->m_min = min;
210 changed = true;
159 changed = true;
211 emit minChanged(min);
160 emit minChanged(min);
212 }
161 }
213
162
214 if (!qFuzzyCompare(d->m_max, max)) {
163 if (!qFuzzyCompare(d->m_max, max)) {
215 d->m_max = max;
164 d->m_max = max;
216 changed = true;
165 changed = true;
217 emit maxChanged(max);
166 emit maxChanged(max);
218 }
167 }
219
168
220 if (changed) {
169 if (changed) {
221 emit rangeChanged(min, max);
170 emit rangeChanged(min, max);
222 emit d->rangeChanged(min,max);
171 emit d->rangeChanged(min,max);
223 }
172 }
224 }
173 }
225 }
174 }
226
175
227 void QLogValueAxis::setLabelFormat(const QString &format)
176 void QLogValueAxis::setLabelFormat(const QString &format)
228 {
177 {
229 Q_D(QLogValueAxis);
178 Q_D(QLogValueAxis);
230 d->m_format = format;
179 d->m_format = format;
231 emit labelFormatChanged(format);
180 emit labelFormatChanged(format);
232 }
181 }
233
182
234 QString QLogValueAxis::labelFormat() const
183 QString QLogValueAxis::labelFormat() const
235 {
184 {
236 Q_D(const QLogValueAxis);
185 Q_D(const QLogValueAxis);
237 return d->m_format;
186 return d->m_format;
238 }
187 }
239
188
240 void QLogValueAxis::setBase(qreal base)
189 void QLogValueAxis::setBase(qreal base)
241 {
190 {
242 // check if base is correct
191 // check if base is correct
243 if (qFuzzyCompare(base, 1))
192 if (qFuzzyCompare(base, 1))
244 return;
193 return;
245
194
246 if (base > 0) {
195 if (base > 0) {
247 Q_D(QLogValueAxis);
196 Q_D(QLogValueAxis);
248 d->m_base = base;
197 d->m_base = base;
249 emit baseChanged(base);
198 emit baseChanged(base);
250 }
199 }
251 }
200 }
252
201
253 qreal QLogValueAxis::base() const
202 qreal QLogValueAxis::base() const
254 {
203 {
255 Q_D(const QLogValueAxis);
204 Q_D(const QLogValueAxis);
256 return d->m_base;
205 return d->m_base;
257 }
206 }
258
207
259 /*!
208 /*!
260 Returns the type of the axis
209 Returns the type of the axis
261 */
210 */
262 QAbstractAxis::AxisType QLogValueAxis::type() const
211 QAbstractAxis::AxisType QLogValueAxis::type() const
263 {
212 {
264 return AxisTypeLogValue;
213 return AxisTypeLogValue;
265 }
214 }
266
215
267 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
216 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
268
217
269 QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q)
218 QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q)
270 : QAbstractAxisPrivate(q),
219 : QAbstractAxisPrivate(q),
271 m_min(1),
220 m_min(1),
272 m_max(1),
221 m_max(1),
273 m_base(10),
222 m_base(10),
274 m_format(QString::null)
223 m_format(QString::null)
275 {
224 {
276 }
225 }
277
226
278 QLogValueAxisPrivate::~QLogValueAxisPrivate()
227 QLogValueAxisPrivate::~QLogValueAxisPrivate()
279 {
228 {
280
229
281 }
230 }
282
231
283 void QLogValueAxisPrivate::setMin(const QVariant &min)
232 void QLogValueAxisPrivate::setMin(const QVariant &min)
284 {
233 {
285 Q_Q(QLogValueAxis);
234 Q_Q(QLogValueAxis);
286 bool ok;
235 bool ok;
287 qreal value = min.toReal(&ok);
236 qreal value = min.toReal(&ok);
288 if (ok)
237 if (ok)
289 q->setMin(value);
238 q->setMin(value);
290 }
239 }
291
240
292 void QLogValueAxisPrivate::setMax(const QVariant &max)
241 void QLogValueAxisPrivate::setMax(const QVariant &max)
293 {
242 {
294
243
295 Q_Q(QLogValueAxis);
244 Q_Q(QLogValueAxis);
296 bool ok;
245 bool ok;
297 qreal value = max.toReal(&ok);
246 qreal value = max.toReal(&ok);
298 if (ok)
247 if (ok)
299 q->setMax(value);
248 q->setMax(value);
300 }
249 }
301
250
302 void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max)
251 void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max)
303 {
252 {
304 Q_Q(QLogValueAxis);
253 Q_Q(QLogValueAxis);
305 bool ok1;
254 bool ok1;
306 bool ok2;
255 bool ok2;
307 qreal value1 = min.toReal(&ok1);
256 qreal value1 = min.toReal(&ok1);
308 qreal value2 = max.toReal(&ok2);
257 qreal value2 = max.toReal(&ok2);
309 if (ok1 && ok2)
258 if (ok1 && ok2)
310 q->setRange(value1, value2);
259 q->setRange(value1, value2);
311 }
260 }
312
261
313 void QLogValueAxisPrivate::setRange(qreal min, qreal max)
262 void QLogValueAxisPrivate::setRange(qreal min, qreal max)
314 {
263 {
315 Q_Q(QLogValueAxis);
264 Q_Q(QLogValueAxis);
316 bool changed = false;
265 bool changed = false;
317
266
318 if (min > max)
267 if (min > max)
319 return;
268 return;
320
269
321 if (min > 0) {
270 if (min > 0) {
322 if (!qFuzzyCompare(m_min, min)) {
271 if (!qFuzzyCompare(m_min, min)) {
323 m_min = min;
272 m_min = min;
324 changed = true;
273 changed = true;
325 emit q->minChanged(min);
274 emit q->minChanged(min);
326 }
275 }
327
276
328 if (!qFuzzyCompare(m_max, max)) {
277 if (!qFuzzyCompare(m_max, max)) {
329 m_max = max;
278 m_max = max;
330 changed = true;
279 changed = true;
331 emit q->maxChanged(max);
280 emit q->maxChanged(max);
332 }
281 }
333
282
334 if (changed) {
283 if (changed) {
335 emit rangeChanged(min,max);
284 emit rangeChanged(min,max);
336 emit q->rangeChanged(min, max);
285 emit q->rangeChanged(min, max);
337 }
286 }
338 }
287 }
339 }
288 }
340
289
341 void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem* parent)
290 void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem* parent)
342 {
291 {
343 Q_Q(QLogValueAxis);
292 Q_Q(QLogValueAxis);
344 ChartAxis* axis(0);
293 ChartAxis* axis(0);
345 if (orientation() == Qt::Vertical)
294 if (orientation() == Qt::Vertical)
346 axis = new ChartLogValueAxisY(q,parent);
295 axis = new ChartLogValueAxisY(q,parent);
347 if (orientation() == Qt::Horizontal)
296 if (orientation() == Qt::Horizontal)
348 axis = new ChartLogValueAxisX(q,parent);
297 axis = new ChartLogValueAxisX(q,parent);
349
298
350 m_item.reset(axis);
299 m_item.reset(axis);
351 QAbstractAxisPrivate::initializeGraphics(parent);
300 QAbstractAxisPrivate::initializeGraphics(parent);
352 }
301 }
353
302
354
303
355 void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain)
304 void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain)
356 {
305 {
357 if (orientation() == Qt::Vertical) {
306 if (orientation() == Qt::Vertical) {
358 if(!qFuzzyCompare(m_max, m_min)) {
307 if(!qFuzzyCompare(m_max, m_min)) {
359 domain->setRangeY(m_min, m_max);
308 domain->setRangeY(m_min, m_max);
360 } else if ( domain->minY() > 0) {
309 } else if ( domain->minY() > 0) {
361 setRange(domain->minY(), domain->maxY());
310 setRange(domain->minY(), domain->maxY());
362 } else if (domain->maxY() > 0) {
311 } else if (domain->maxY() > 0) {
363 domain->setRangeY(m_min, domain->maxY());
312 domain->setRangeY(m_min, domain->maxY());
364 } else {
313 } else {
365 domain->setRangeY(1, 10);
314 domain->setRangeY(1, 10);
366 }
315 }
367 }
316 }
368 if (orientation() == Qt::Horizontal) {
317 if (orientation() == Qt::Horizontal) {
369 if(!qFuzzyCompare(m_max, m_min)) {
318 if(!qFuzzyCompare(m_max, m_min)) {
370 domain->setRangeX(m_min, m_max);
319 domain->setRangeX(m_min, m_max);
371 } else if (domain->minX() > 0){
320 } else if (domain->minX() > 0){
372 setRange(domain->minX(), domain->maxX());
321 setRange(domain->minX(), domain->maxX());
373 } else if (domain->maxX() > 0) {
322 } else if (domain->maxX() > 0) {
374 domain->setRangeX(m_min, domain->maxX());
323 domain->setRangeX(m_min, domain->maxX());
375 } else {
324 } else {
376 domain->setRangeX(1, 10);
325 domain->setRangeX(1, 10);
377 }
326 }
378 }
327 }
379 }
328 }
380
329
381 #include "moc_qlogvalueaxis.cpp"
330 #include "moc_qlogvalueaxis.cpp"
382 #include "moc_qlogvalueaxis_p.cpp"
331 #include "moc_qlogvalueaxis_p.cpp"
383
332
384 QTCOMMERCIALCHART_END_NAMESPACE
333 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now