|
@@
-1,870
+1,883
|
|
1
|
/****************************************************************************
|
|
1
|
/****************************************************************************
|
|
2
|
**
|
|
2
|
**
|
|
3
|
** Copyright (C) 2015 The Qt Company Ltd
|
|
3
|
** Copyright (C) 2015 The Qt Company Ltd
|
|
4
|
** All rights reserved.
|
|
4
|
** All rights reserved.
|
|
5
|
** For any questions to The Qt Company, please use contact form at http://qt.io
|
|
5
|
** For any questions to The Qt Company, please use contact form at http://qt.io
|
|
6
|
**
|
|
6
|
**
|
|
7
|
** This file is part of the Qt Charts module.
|
|
7
|
** This file is part of the Qt Charts module.
|
|
8
|
**
|
|
8
|
**
|
|
9
|
** Licensees holding valid commercial license for Qt may use this file in
|
|
9
|
** Licensees holding valid commercial license for Qt may use this file in
|
|
10
|
** accordance with the Qt License Agreement provided with the Software
|
|
10
|
** accordance with the Qt License Agreement provided with the Software
|
|
11
|
** or, alternatively, in accordance with the terms contained in a written
|
|
11
|
** or, alternatively, in accordance with the terms contained in a written
|
|
12
|
** agreement between you and The Qt Company.
|
|
12
|
** agreement between you and The Qt Company.
|
|
13
|
**
|
|
13
|
**
|
|
14
|
** If you have questions regarding the use of this file, please use
|
|
14
|
** If you have questions regarding the use of this file, please use
|
|
15
|
** contact form at http://qt.io
|
|
15
|
** contact form at http://qt.io
|
|
16
|
**
|
|
16
|
**
|
|
17
|
****************************************************************************/
|
|
17
|
****************************************************************************/
|
|
18
|
|
|
18
|
|
|
19
|
#include <QtCharts/QXYSeries>
|
|
19
|
#include <QtCharts/QXYSeries>
|
|
20
|
#include <private/qxyseries_p.h>
|
|
20
|
#include <private/qxyseries_p.h>
|
|
21
|
#include <private/abstractdomain_p.h>
|
|
21
|
#include <private/abstractdomain_p.h>
|
|
22
|
#include <QtCharts/QValueAxis>
|
|
22
|
#include <QtCharts/QValueAxis>
|
|
23
|
#include <private/xychart_p.h>
|
|
23
|
#include <private/xychart_p.h>
|
|
24
|
#include <QtCharts/QXYLegendMarker>
|
|
24
|
#include <QtCharts/QXYLegendMarker>
|
|
25
|
#include <private/charthelpers_p.h>
|
|
25
|
#include <private/charthelpers_p.h>
|
|
26
|
#include <private/qchart_p.h>
|
|
26
|
#include <private/qchart_p.h>
|
|
27
|
#include <QtGui/QPainter>
|
|
27
|
#include <QtGui/QPainter>
|
|
28
|
|
|
28
|
|
|
29
|
QT_CHARTS_BEGIN_NAMESPACE
|
|
29
|
QT_CHARTS_BEGIN_NAMESPACE
|
|
30
|
|
|
30
|
|
|
31
|
/*!
|
|
31
|
/*!
|
|
32
|
\class QXYSeries
|
|
32
|
\class QXYSeries
|
|
33
|
\inmodule Qt Charts
|
|
33
|
\inmodule Qt Charts
|
|
34
|
\brief The QXYSeries class is a base class for line, spline and scatter series.
|
|
34
|
\brief The QXYSeries class is a base class for line, spline and scatter series.
|
|
35
|
*/
|
|
35
|
*/
|
|
36
|
/*!
|
|
36
|
/*!
|
|
37
|
\qmltype XYSeries
|
|
37
|
\qmltype XYSeries
|
|
38
|
\instantiates QXYSeries
|
|
38
|
\instantiates QXYSeries
|
|
39
|
\inqmlmodule QtCharts
|
|
39
|
\inqmlmodule QtCharts
|
|
40
|
|
|
40
|
|
|
41
|
\inherits AbstractSeries
|
|
41
|
\inherits AbstractSeries
|
|
42
|
|
|
42
|
|
|
43
|
\brief The XYSeries type is a base type for line, spline and scatter series.
|
|
43
|
\brief The XYSeries type is a base type for line, spline and scatter series.
|
|
44
|
|
|
44
|
|
|
45
|
The XYSeries class is a base class for line, spline and scatter series.
|
|
45
|
The XYSeries class is a base class for line, spline and scatter series.
|
|
46
|
The class cannot be instantiated directly.
|
|
46
|
The class cannot be instantiated directly.
|
|
47
|
*/
|
|
47
|
*/
|
|
48
|
|
|
48
|
|
|
49
|
/*!
|
|
49
|
/*!
|
|
50
|
\qmlproperty AbstractAxis XYSeries::axisX
|
|
50
|
\qmlproperty AbstractAxis XYSeries::axisX
|
|
51
|
The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for
|
|
51
|
The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for
|
|
52
|
the series.
|
|
52
|
the series.
|
|
53
|
\sa axisXTop
|
|
53
|
\sa axisXTop
|
|
54
|
*/
|
|
54
|
*/
|
|
55
|
|
|
55
|
|
|
56
|
/*!
|
|
56
|
/*!
|
|
57
|
\qmlproperty AbstractAxis XYSeries::axisY
|
|
57
|
\qmlproperty AbstractAxis XYSeries::axisY
|
|
58
|
The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for
|
|
58
|
The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for
|
|
59
|
the series.
|
|
59
|
the series.
|
|
60
|
\sa axisYRight
|
|
60
|
\sa axisYRight
|
|
61
|
*/
|
|
61
|
*/
|
|
62
|
|
|
62
|
|
|
63
|
/*!
|
|
63
|
/*!
|
|
64
|
\qmlproperty AbstractAxis XYSeries::axisXTop
|
|
64
|
\qmlproperty AbstractAxis XYSeries::axisXTop
|
|
65
|
The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or
|
|
65
|
The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or
|
|
66
|
axisXTop, but not both.
|
|
66
|
axisXTop, but not both.
|
|
67
|
\sa axisX
|
|
67
|
\sa axisX
|
|
68
|
*/
|
|
68
|
*/
|
|
69
|
|
|
69
|
|
|
70
|
/*!
|
|
70
|
/*!
|
|
71
|
\qmlproperty AbstractAxis XYSeries::axisYRight
|
|
71
|
\qmlproperty AbstractAxis XYSeries::axisYRight
|
|
72
|
The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY
|
|
72
|
The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY
|
|
73
|
or axisYRight, but not both.
|
|
73
|
or axisYRight, but not both.
|
|
74
|
\sa axisY
|
|
74
|
\sa axisY
|
|
75
|
*/
|
|
75
|
*/
|
|
76
|
|
|
76
|
|
|
77
|
/*!
|
|
77
|
/*!
|
|
78
|
\qmlproperty AbstractAxis XYSeries::axisAngular
|
|
78
|
\qmlproperty AbstractAxis XYSeries::axisAngular
|
|
79
|
The angular axis used for the series, drawn around the polar chart view.
|
|
79
|
The angular axis used for the series, drawn around the polar chart view.
|
|
80
|
\sa axisX
|
|
80
|
\sa axisX
|
|
81
|
*/
|
|
81
|
*/
|
|
82
|
|
|
82
|
|
|
83
|
/*!
|
|
83
|
/*!
|
|
84
|
\qmlproperty AbstractAxis XYSeries::axisRadial
|
|
84
|
\qmlproperty AbstractAxis XYSeries::axisRadial
|
|
85
|
The radial axis used for the series, drawn inside the polar chart view.
|
|
85
|
The radial axis used for the series, drawn inside the polar chart view.
|
|
86
|
\sa axisY
|
|
86
|
\sa axisY
|
|
87
|
*/
|
|
87
|
*/
|
|
88
|
|
|
88
|
|
|
89
|
/*!
|
|
89
|
/*!
|
|
90
|
\property QXYSeries::pointsVisible
|
|
90
|
\property QXYSeries::pointsVisible
|
|
91
|
Controls if the data points are visible and should be drawn.
|
|
91
|
Controls if the data points are visible and should be drawn.
|
|
92
|
*/
|
|
92
|
*/
|
|
93
|
/*!
|
|
93
|
/*!
|
|
94
|
\qmlproperty bool XYSeries::pointsVisible
|
|
94
|
\qmlproperty bool XYSeries::pointsVisible
|
|
95
|
Controls if the data points are visible and should be drawn.
|
|
95
|
Controls if the data points are visible and should be drawn.
|
|
96
|
*/
|
|
96
|
*/
|
|
97
|
|
|
97
|
|
|
98
|
/*!
|
|
98
|
/*!
|
|
99
|
\fn QPen QXYSeries::pen() const
|
|
99
|
\fn QPen QXYSeries::pen() const
|
|
100
|
\brief Returns pen used to draw points for series.
|
|
100
|
\brief Returns pen used to draw points for series.
|
|
101
|
\sa setPen()
|
|
101
|
\sa setPen()
|
|
102
|
*/
|
|
102
|
*/
|
|
103
|
|
|
103
|
|
|
104
|
/*!
|
|
104
|
/*!
|
|
105
|
\fn QBrush QXYSeries::brush() const
|
|
105
|
\fn QBrush QXYSeries::brush() const
|
|
106
|
\brief Returns brush used to draw points for series.
|
|
106
|
\brief Returns brush used to draw points for series.
|
|
107
|
\sa setBrush()
|
|
107
|
\sa setBrush()
|
|
108
|
*/
|
|
108
|
*/
|
|
109
|
|
|
109
|
|
|
110
|
/*!
|
|
110
|
/*!
|
|
111
|
\property QXYSeries::color
|
|
111
|
\property QXYSeries::color
|
|
112
|
The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
|
|
112
|
The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
|
|
113
|
fill (brush) color in case of QScatterSeries or QAreaSeries.
|
|
113
|
fill (brush) color in case of QScatterSeries or QAreaSeries.
|
|
114
|
\sa QXYSeries::pen(), QXYSeries::brush()
|
|
114
|
\sa QXYSeries::pen(), QXYSeries::brush()
|
|
115
|
*/
|
|
115
|
*/
|
|
116
|
/*!
|
|
116
|
/*!
|
|
117
|
\qmlproperty color XYSeries::color
|
|
117
|
\qmlproperty color XYSeries::color
|
|
118
|
The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
|
|
118
|
The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
|
|
119
|
fill (brush) color in case of ScatterSeries or AreaSeries.
|
|
119
|
fill (brush) color in case of ScatterSeries or AreaSeries.
|
|
120
|
*/
|
|
120
|
*/
|
|
121
|
|
|
121
|
|
|
122
|
/*!
|
|
122
|
/*!
|
|
123
|
\property QXYSeries::pointLabelsFormat
|
|
123
|
\property QXYSeries::pointLabelsFormat
|
|
124
|
The \a format used for showing labels with series points.
|
|
124
|
The \a format used for showing labels with series points.
|
|
125
|
|
|
125
|
|
|
126
|
QXYSeries supports the following format tags:
|
|
126
|
QXYSeries supports the following format tags:
|
|
127
|
\table
|
|
127
|
\table
|
|
128
|
\row
|
|
128
|
\row
|
|
129
|
\li @xPoint \li The x value of the data point
|
|
129
|
\li @xPoint \li The x value of the data point
|
|
130
|
\row
|
|
130
|
\row
|
|
131
|
\li @yPoint \li The y value of the data point
|
|
131
|
\li @yPoint \li The y value of the data point
|
|
132
|
\endtable
|
|
132
|
\endtable
|
|
133
|
|
|
133
|
|
|
134
|
For example, the following usage of the format tags would produce labels that have the data
|
|
134
|
For example, the following usage of the format tags would produce labels that have the data
|
|
135
|
point (x, y) shown inside brackets separated by a comma:
|
|
135
|
point (x, y) shown inside brackets separated by a comma:
|
|
136
|
\code
|
|
136
|
\code
|
|
137
|
series->setPointLabelsFormat("(@xPoint, @yPoint)");
|
|
137
|
series->setPointLabelsFormat("(@xPoint, @yPoint)");
|
|
138
|
\endcode
|
|
138
|
\endcode
|
|
139
|
|
|
139
|
|
|
140
|
By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot
|
|
140
|
By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot
|
|
141
|
area, labels on the edge of the plot area are cut. If the points are close to each other the
|
|
141
|
area, labels on the edge of the plot area are cut. If the points are close to each other the
|
|
142
|
labels may overlap.
|
|
142
|
labels may overlap.
|
|
143
|
|
|
143
|
|
|
144
|
\sa QXYSeries::pointLabelsVisible, QXYSeries::pointLabelsFont, QXYSeries::pointLabelsColor
|
|
144
|
\sa QXYSeries::pointLabelsVisible, QXYSeries::pointLabelsFont, QXYSeries::pointLabelsColor
|
|
145
|
*/
|
|
145
|
*/
|
|
146
|
/*!
|
|
146
|
/*!
|
|
147
|
\qmlproperty string XYSeries::pointLabelsFormat
|
|
147
|
\qmlproperty string XYSeries::pointLabelsFormat
|
|
148
|
The \a format used for showing labels with series points.
|
|
148
|
The \a format used for showing labels with series points.
|
|
149
|
|
|
149
|
|
|
150
|
\sa QXYSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
|
|
150
|
\sa QXYSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
|
|
151
|
*/
|
|
151
|
*/
|
|
152
|
/*!
|
|
152
|
/*!
|
|
153
|
\fn void QXYSeries::pointLabelsFormatChanged(const QString &format)
|
|
153
|
\fn void QXYSeries::pointLabelsFormatChanged(const QString &format)
|
|
154
|
Signal is emitted when the \a format of data point labels is changed.
|
|
154
|
Signal is emitted when the \a format of data point labels is changed.
|
|
155
|
*/
|
|
155
|
*/
|
|
156
|
/*!
|
|
156
|
/*!
|
|
157
|
\qmlsignal XYSeries::onPointLabelsFormatChanged(string format)
|
|
157
|
\qmlsignal XYSeries::onPointLabelsFormatChanged(string format)
|
|
158
|
Signal is emitted when the \a format of data point labels is changed.
|
|
158
|
Signal is emitted when the \a format of data point labels is changed.
|
|
159
|
*/
|
|
159
|
*/
|
|
160
|
|
|
160
|
|
|
161
|
/*!
|
|
161
|
/*!
|
|
162
|
\property QXYSeries::pointLabelsVisible
|
|
162
|
\property QXYSeries::pointLabelsVisible
|
|
163
|
Defines the visibility for data point labels. False by default.
|
|
163
|
Defines the visibility for data point labels. False by default.
|
|
164
|
|
|
164
|
|
|
165
|
\sa QXYSeries::pointLabelsFormat
|
|
165
|
\sa QXYSeries::pointLabelsFormat
|
|
166
|
*/
|
|
166
|
*/
|
|
167
|
/*!
|
|
167
|
/*!
|
|
168
|
\qmlproperty bool XYSeries::pointLabelsVisible
|
|
168
|
\qmlproperty bool XYSeries::pointLabelsVisible
|
|
169
|
Defines the visibility for data point labels.
|
|
169
|
Defines the visibility for data point labels.
|
|
170
|
|
|
170
|
|
|
171
|
\sa pointLabelsFormat
|
|
171
|
\sa pointLabelsFormat
|
|
172
|
*/
|
|
172
|
*/
|
|
173
|
/*!
|
|
173
|
/*!
|
|
174
|
\fn void QXYSeries::pointLabelsVisibilityChanged(bool visible)
|
|
174
|
\fn void QXYSeries::pointLabelsVisibilityChanged(bool visible)
|
|
175
|
The visibility of the data point labels is changed to \a visible.
|
|
175
|
The visibility of the data point labels is changed to \a visible.
|
|
176
|
*/
|
|
176
|
*/
|
|
177
|
/*!
|
|
177
|
/*!
|
|
178
|
\qmlsignal XYSeries::onPointLabelsVisibilityChanged(bool visible)
|
|
178
|
\qmlsignal XYSeries::onPointLabelsVisibilityChanged(bool visible)
|
|
179
|
The visibility of the data point labels is changed to \a visible.
|
|
179
|
The visibility of the data point labels is changed to \a visible.
|
|
180
|
*/
|
|
180
|
*/
|
|
181
|
|
|
181
|
|
|
182
|
/*!
|
|
182
|
/*!
|
|
183
|
\property QXYSeries::pointLabelsFont
|
|
183
|
\property QXYSeries::pointLabelsFont
|
|
184
|
Defines the font used for data point labels.
|
|
184
|
Defines the font used for data point labels.
|
|
185
|
|
|
185
|
|
|
186
|
\sa QXYSeries::pointLabelsFormat
|
|
186
|
\sa QXYSeries::pointLabelsFormat
|
|
187
|
*/
|
|
187
|
*/
|
|
188
|
/*!
|
|
188
|
/*!
|
|
189
|
\qmlproperty font XYSeries::pointLabelsFont
|
|
189
|
\qmlproperty font XYSeries::pointLabelsFont
|
|
190
|
Defines the font used for data point labels.
|
|
190
|
Defines the font used for data point labels.
|
|
191
|
|
|
191
|
|
|
192
|
\sa pointLabelsFormat
|
|
192
|
\sa pointLabelsFormat
|
|
193
|
*/
|
|
193
|
*/
|
|
194
|
/*!
|
|
194
|
/*!
|
|
195
|
\fn void QXYSeries::pointLabelsFontChanged(const QFont &font);
|
|
195
|
\fn void QXYSeries::pointLabelsFontChanged(const QFont &font);
|
|
196
|
The font used for data point labels is changed to \a font.
|
|
196
|
The font used for data point labels is changed to \a font.
|
|
197
|
*/
|
|
197
|
*/
|
|
198
|
/*!
|
|
198
|
/*!
|
|
199
|
\qmlsignal XYSeries::onPointLabelsFontChanged(Font font)
|
|
199
|
\qmlsignal XYSeries::onPointLabelsFontChanged(Font font)
|
|
200
|
The font used for data point labels is changed to \a font.
|
|
200
|
The font used for data point labels is changed to \a font.
|
|
201
|
*/
|
|
201
|
*/
|
|
202
|
|
|
202
|
|
|
203
|
/*!
|
|
203
|
/*!
|
|
204
|
\property QXYSeries::pointLabelsColor
|
|
204
|
\property QXYSeries::pointLabelsColor
|
|
205
|
Defines the color used for data point labels. By default, the color is the color of the brush
|
|
205
|
Defines the color used for data point labels. By default, the color is the color of the brush
|
|
206
|
defined in theme for labels.
|
|
206
|
defined in theme for labels.
|
|
207
|
|
|
207
|
|
|
208
|
\sa QXYSeries::pointLabelsFormat
|
|
208
|
\sa QXYSeries::pointLabelsFormat
|
|
209
|
*/
|
|
209
|
*/
|
|
210
|
/*!
|
|
210
|
/*!
|
|
211
|
\qmlproperty font XYSeries::pointLabelsColor
|
|
211
|
\qmlproperty font XYSeries::pointLabelsColor
|
|
212
|
Defines the color used for data point labels. By default, the color is the color of the brush
|
|
212
|
Defines the color used for data point labels. By default, the color is the color of the brush
|
|
213
|
defined in theme for labels.
|
|
213
|
defined in theme for labels.
|
|
214
|
|
|
214
|
|
|
215
|
\sa pointLabelsFormat
|
|
215
|
\sa pointLabelsFormat
|
|
216
|
*/
|
|
216
|
*/
|
|
217
|
/*!
|
|
217
|
/*!
|
|
218
|
\fn void QXYSeries::pointLabelsColorChanged(const QColor &color);
|
|
218
|
\fn void QXYSeries::pointLabelsColorChanged(const QColor &color);
|
|
219
|
The color used for data point labels is changed to \a color.
|
|
219
|
The color used for data point labels is changed to \a color.
|
|
220
|
*/
|
|
220
|
*/
|
|
221
|
/*!
|
|
221
|
/*!
|
|
222
|
\qmlsignal XYSeries::onPointLabelsColorChanged(Color color)
|
|
222
|
\qmlsignal XYSeries::onPointLabelsColorChanged(Color color)
|
|
223
|
The color used for data point labels is changed to \a color.
|
|
223
|
The color used for data point labels is changed to \a color.
|
|
224
|
*/
|
|
224
|
*/
|
|
225
|
|
|
225
|
|
|
226
|
/*!
|
|
226
|
/*!
|
|
227
|
\fn void QXYSeries::clicked(const QPointF& point)
|
|
227
|
\fn void QXYSeries::clicked(const QPointF& point)
|
|
228
|
\brief Signal is emitted when user clicks the \a point on chart. The \a point is the point
|
|
228
|
\brief Signal is emitted when user clicks the \a point on chart. The \a point is the point
|
|
229
|
where the press was triggered.
|
|
229
|
where the press was triggered.
|
|
230
|
\sa pressed, released, doubleClicked
|
|
230
|
\sa pressed, released, doubleClicked
|
|
231
|
*/
|
|
231
|
*/
|
|
232
|
/*!
|
|
232
|
/*!
|
|
233
|
\qmlsignal XYSeries::onClicked(QPointF point)
|
|
233
|
\qmlsignal XYSeries::onClicked(QPointF point)
|
|
234
|
Signal is emitted when user clicks the \a point on chart. The \a point is the point where the
|
|
234
|
Signal is emitted when user clicks the \a point on chart. The \a point is the point where the
|
|
235
|
press was triggered. For example:
|
|
235
|
press was triggered. For example:
|
|
236
|
\code
|
|
236
|
\code
|
|
237
|
LineSeries {
|
|
237
|
LineSeries {
|
|
238
|
XYPoint { x: 0; y: 0 }
|
|
238
|
XYPoint { x: 0; y: 0 }
|
|
239
|
XYPoint { x: 1.1; y: 2.1 }
|
|
239
|
XYPoint { x: 1.1; y: 2.1 }
|
|
240
|
onClicked: console.log("onClicked: " + point.x + ", " + point.y);
|
|
240
|
onClicked: console.log("onClicked: " + point.x + ", " + point.y);
|
|
241
|
}
|
|
241
|
}
|
|
242
|
\endcode
|
|
242
|
\endcode
|
|
243
|
\sa onPressed, onReleased, onDoubleClicked
|
|
243
|
\sa onPressed, onReleased, onDoubleClicked
|
|
244
|
*/
|
|
244
|
*/
|
|
245
|
|
|
245
|
|
|
246
|
/*!
|
|
246
|
/*!
|
|
247
|
\fn void QXYSeries::hovered(const QPointF &point, bool state)
|
|
247
|
\fn void QXYSeries::hovered(const QPointF &point, bool state)
|
|
248
|
This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
|
|
248
|
This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
|
|
249
|
of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
|
|
249
|
of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
|
|
250
|
the series.
|
|
250
|
the series.
|
|
251
|
*/
|
|
251
|
*/
|
|
252
|
/*!
|
|
252
|
/*!
|
|
253
|
\qmlsignal XYSeries::onHovered(point point, bool state)
|
|
253
|
\qmlsignal XYSeries::onHovered(point point, bool state)
|
|
254
|
This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
|
|
254
|
This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
|
|
255
|
of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
|
|
255
|
of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
|
|
256
|
the series.
|
|
256
|
the series.
|
|
257
|
*/
|
|
257
|
*/
|
|
258
|
|
|
258
|
|
|
259
|
/*!
|
|
259
|
/*!
|
|
260
|
\fn void QXYSeries::pressed(const QPointF& point)
|
|
260
|
\fn void QXYSeries::pressed(const QPointF& point)
|
|
261
|
\brief Signal is emitted when user presses the \a point on chart.
|
|
261
|
\brief Signal is emitted when user presses the \a point on chart.
|
|
262
|
\sa clicked, released, doubleClicked
|
|
262
|
\sa clicked, released, doubleClicked
|
|
263
|
*/
|
|
263
|
*/
|
|
264
|
/*!
|
|
264
|
/*!
|
|
265
|
\qmlsignal XYSeries::onPressed(QPointF point)
|
|
265
|
\qmlsignal XYSeries::onPressed(QPointF point)
|
|
266
|
Signal is emitted when user presses the \a point on chart. For example:
|
|
266
|
Signal is emitted when user presses the \a point on chart. For example:
|
|
267
|
\code
|
|
267
|
\code
|
|
268
|
LineSeries {
|
|
268
|
LineSeries {
|
|
269
|
XYPoint { x: 0; y: 0 }
|
|
269
|
XYPoint { x: 0; y: 0 }
|
|
270
|
XYPoint { x: 1.1; y: 2.1 }
|
|
270
|
XYPoint { x: 1.1; y: 2.1 }
|
|
271
|
onPressed: console.log("onPressed: " + point.x + ", " + point.y);
|
|
271
|
onPressed: console.log("onPressed: " + point.x + ", " + point.y);
|
|
272
|
}
|
|
272
|
}
|
|
273
|
\endcode
|
|
273
|
\endcode
|
|
274
|
\sa onClicked, onReleased, onDoubleClicked
|
|
274
|
\sa onClicked, onReleased, onDoubleClicked
|
|
275
|
*/
|
|
275
|
*/
|
|
276
|
|
|
276
|
|
|
277
|
/*!
|
|
277
|
/*!
|
|
278
|
\fn void QXYSeries::released(const QPointF& point)
|
|
278
|
\fn void QXYSeries::released(const QPointF& point)
|
|
279
|
\brief Signal is emitted when user releases a press that was triggered on a \a point on chart.
|
|
279
|
\brief Signal is emitted when user releases a press that was triggered on a \a point on chart.
|
|
280
|
\sa pressed, clicked, doubleClicked
|
|
280
|
\sa pressed, clicked, doubleClicked
|
|
281
|
*/
|
|
281
|
*/
|
|
282
|
/*!
|
|
282
|
/*!
|
|
283
|
\qmlsignal XYSeries::onReleased(QPointF point)
|
|
283
|
\qmlsignal XYSeries::onReleased(QPointF point)
|
|
284
|
Signal is emitted when user releases a press that was triggered on a \a point on chart.
|
|
284
|
Signal is emitted when user releases a press that was triggered on a \a point on chart.
|
|
285
|
For example:
|
|
285
|
For example:
|
|
286
|
\code
|
|
286
|
\code
|
|
287
|
LineSeries {
|
|
287
|
LineSeries {
|
|
288
|
XYPoint { x: 0; y: 0 }
|
|
288
|
XYPoint { x: 0; y: 0 }
|
|
289
|
XYPoint { x: 1.1; y: 2.1 }
|
|
289
|
XYPoint { x: 1.1; y: 2.1 }
|
|
290
|
onReleased: console.log("onReleased: " + point.x + ", " + point.y);
|
|
290
|
onReleased: console.log("onReleased: " + point.x + ", " + point.y);
|
|
291
|
}
|
|
291
|
}
|
|
292
|
\endcode
|
|
292
|
\endcode
|
|
293
|
\sa onPressed, onClicked, onDoubleClicked
|
|
293
|
\sa onPressed, onClicked, onDoubleClicked
|
|
294
|
*/
|
|
294
|
*/
|
|
295
|
|
|
295
|
|
|
296
|
/*!
|
|
296
|
/*!
|
|
297
|
\fn void QXYSeries::doubleClicked(const QPointF& point)
|
|
297
|
\fn void QXYSeries::doubleClicked(const QPointF& point)
|
|
298
|
\brief Signal is emitted when user doubleclicks the \a point on chart. The \a point is the
|
|
298
|
\brief Signal is emitted when user doubleclicks the \a point on chart. The \a point is the
|
|
299
|
point where the first press was triggered.
|
|
299
|
point where the first press was triggered.
|
|
300
|
\sa pressed, released, clicked
|
|
300
|
\sa pressed, released, clicked
|
|
301
|
*/
|
|
301
|
*/
|
|
302
|
/*!
|
|
302
|
/*!
|
|
303
|
\qmlsignal XYSeries::onDoubleClicked(QPointF point)
|
|
303
|
\qmlsignal XYSeries::onDoubleClicked(QPointF point)
|
|
304
|
Signal is emitted when user doubleclicks the \a point on chart. The \a point is the point where
|
|
304
|
Signal is emitted when user doubleclicks the \a point on chart. The \a point is the point where
|
|
305
|
the first press was triggered. For example:
|
|
305
|
the first press was triggered. For example:
|
|
306
|
\code
|
|
306
|
\code
|
|
307
|
LineSeries {
|
|
307
|
LineSeries {
|
|
308
|
XYPoint { x: 0; y: 0 }
|
|
308
|
XYPoint { x: 0; y: 0 }
|
|
309
|
XYPoint { x: 1.1; y: 2.1 }
|
|
309
|
XYPoint { x: 1.1; y: 2.1 }
|
|
310
|
onDoubleClicked: console.log("onDoubleClicked: " + point.x + ", " + point.y);
|
|
310
|
onDoubleClicked: console.log("onDoubleClicked: " + point.x + ", " + point.y);
|
|
311
|
}
|
|
311
|
}
|
|
312
|
\endcode
|
|
312
|
\endcode
|
|
313
|
\sa onPressed, onReleased, onClicked
|
|
313
|
\sa onPressed, onReleased, onClicked
|
|
314
|
*/
|
|
314
|
*/
|
|
315
|
|
|
315
|
|
|
316
|
/*!
|
|
316
|
/*!
|
|
317
|
\fn void QXYSeries::pointReplaced(int index)
|
|
317
|
\fn void QXYSeries::pointReplaced(int index)
|
|
318
|
Signal is emitted when a point has been replaced at \a index.
|
|
318
|
Signal is emitted when a point has been replaced at \a index.
|
|
319
|
\sa replace()
|
|
319
|
\sa replace()
|
|
320
|
*/
|
|
320
|
*/
|
|
321
|
/*!
|
|
321
|
/*!
|
|
322
|
\qmlsignal XYSeries::onPointReplaced(int index)
|
|
322
|
\qmlsignal XYSeries::onPointReplaced(int index)
|
|
323
|
Signal is emitted when a point has been replaced at \a index.
|
|
323
|
Signal is emitted when a point has been replaced at \a index.
|
|
324
|
*/
|
|
324
|
*/
|
|
325
|
|
|
325
|
|
|
326
|
/*!
|
|
326
|
/*!
|
|
327
|
\fn void QXYSeries::pointsReplaced()
|
|
327
|
\fn void QXYSeries::pointsReplaced()
|
|
328
|
Signal is emitted when all points have been replaced with other points.
|
|
328
|
Signal is emitted when all points have been replaced with other points.
|
|
329
|
\sa replace()
|
|
329
|
\sa replace()
|
|
330
|
*/
|
|
330
|
*/
|
|
331
|
/*!
|
|
331
|
/*!
|
|
332
|
\qmlsignal XYSeries::onPointsReplaced()
|
|
332
|
\qmlsignal XYSeries::onPointsReplaced()
|
|
333
|
Signal is emitted when all points have been replaced with other points.
|
|
333
|
Signal is emitted when all points have been replaced with other points.
|
|
334
|
*/
|
|
334
|
*/
|
|
335
|
|
|
335
|
|
|
336
|
/*!
|
|
336
|
/*!
|
|
337
|
\fn void QXYSeries::pointAdded(int index)
|
|
337
|
\fn void QXYSeries::pointAdded(int index)
|
|
338
|
Signal is emitted when a point has been added at \a index.
|
|
338
|
Signal is emitted when a point has been added at \a index.
|
|
339
|
\sa append(), insert()
|
|
339
|
\sa append(), insert()
|
|
340
|
*/
|
|
340
|
*/
|
|
341
|
/*!
|
|
341
|
/*!
|
|
342
|
\qmlsignal XYSeries::onPointAdded(int index)
|
|
342
|
\qmlsignal XYSeries::onPointAdded(int index)
|
|
343
|
Signal is emitted when a point has been added at \a index.
|
|
343
|
Signal is emitted when a point has been added at \a index.
|
|
344
|
*/
|
|
344
|
*/
|
|
345
|
|
|
345
|
|
|
346
|
/*!
|
|
346
|
/*!
|
|
347
|
\fn void QXYSeries::pointRemoved(int index)
|
|
347
|
\fn void QXYSeries::pointRemoved(int index)
|
|
348
|
Signal is emitted when a point has been removed from \a index.
|
|
348
|
Signal is emitted when a point has been removed from \a index.
|
|
349
|
\sa remove()
|
|
349
|
\sa remove()
|
|
350
|
*/
|
|
350
|
*/
|
|
351
|
|
|
351
|
|
|
352
|
/*!
|
|
352
|
/*!
|
|
353
|
\qmlsignal XYSeries::onPointRemoved(int index)
|
|
353
|
\qmlsignal XYSeries::onPointRemoved(int index)
|
|
354
|
Signal is emitted when a point has been removed from \a index.
|
|
354
|
Signal is emitted when a point has been removed from \a index.
|
|
355
|
*/
|
|
355
|
*/
|
|
356
|
|
|
356
|
|
|
357
|
/*!
|
|
357
|
/*!
|
|
358
|
\fn void QXYSeries::colorChanged(QColor color)
|
|
358
|
\fn void QXYSeries::colorChanged(QColor color)
|
|
359
|
\brief Signal is emitted when the line (pen) color has changed to \a color.
|
|
359
|
\brief Signal is emitted when the line (pen) color has changed to \a color.
|
|
360
|
*/
|
|
360
|
*/
|
|
361
|
/*!
|
|
361
|
/*!
|
|
362
|
\qmlsignal XYSeries::onColorChanged(color color)
|
|
362
|
\qmlsignal XYSeries::onColorChanged(color color)
|
|
363
|
Signal is emitted when the line (pen) color has changed to \a color.
|
|
363
|
Signal is emitted when the line (pen) color has changed to \a color.
|
|
364
|
*/
|
|
364
|
*/
|
|
365
|
|
|
365
|
|
|
366
|
/*!
|
|
366
|
/*!
|
|
367
|
\fn void QXYSeriesPrivate::updated()
|
|
367
|
\fn void QXYSeriesPrivate::updated()
|
|
368
|
\brief \internal
|
|
368
|
\brief \internal
|
|
369
|
*/
|
|
369
|
*/
|
|
370
|
|
|
370
|
|
|
371
|
/*!
|
|
371
|
/*!
|
|
372
|
\qmlmethod XYSeries::append(real x, real y)
|
|
372
|
\qmlmethod XYSeries::append(real x, real y)
|
|
373
|
Append point (\a x, \a y) to the series
|
|
373
|
Append point (\a x, \a y) to the series
|
|
374
|
*/
|
|
374
|
*/
|
|
375
|
|
|
375
|
|
|
376
|
/*!
|
|
376
|
/*!
|
|
377
|
\qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY)
|
|
377
|
\qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY)
|
|
378
|
Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not
|
|
378
|
Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not
|
|
379
|
exist.
|
|
379
|
exist.
|
|
380
|
*/
|
|
380
|
*/
|
|
381
|
|
|
381
|
|
|
382
|
/*!
|
|
382
|
/*!
|
|
383
|
\qmlmethod XYSeries::remove(real x, real y)
|
|
383
|
\qmlmethod XYSeries::remove(real x, real y)
|
|
384
|
Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist.
|
|
384
|
Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist.
|
|
385
|
*/
|
|
385
|
*/
|
|
386
|
|
|
386
|
|
|
387
|
/*!
|
|
387
|
/*!
|
|
388
|
\qmlmethod XYSeries::insert(int index, real x, real y)
|
|
388
|
\qmlmethod XYSeries::insert(int index, real x, real y)
|
|
389
|
Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of
|
|
389
|
Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of
|
|
390
|
points. If index is the same as or bigger than count, the point is appended to the list of points.
|
|
390
|
points. If index is the same as or bigger than count, the point is appended to the list of points.
|
|
391
|
*/
|
|
391
|
*/
|
|
392
|
|
|
392
|
|
|
393
|
/*!
|
|
393
|
/*!
|
|
394
|
\qmlmethod QPointF XYSeries::at(int index)
|
|
394
|
\qmlmethod QPointF XYSeries::at(int index)
|
|
395
|
Returns point at \a index. Returns (0, 0) if the index is not valid.
|
|
395
|
Returns point at \a index. Returns (0, 0) if the index is not valid.
|
|
396
|
*/
|
|
396
|
*/
|
|
397
|
|
|
397
|
|
|
398
|
/*!
|
|
398
|
/*!
|
|
399
|
\internal
|
|
399
|
\internal
|
|
400
|
|
|
400
|
|
|
401
|
Constructs empty series object which is a child of \a parent.
|
|
401
|
Constructs empty series object which is a child of \a parent.
|
|
402
|
When series object is added to QChart instance ownerships is transferred.
|
|
402
|
When series object is added to QChart instance ownerships is transferred.
|
|
403
|
*/
|
|
403
|
*/
|
|
404
|
QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent)
|
|
404
|
QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent)
|
|
405
|
: QAbstractSeries(d, parent)
|
|
405
|
: QAbstractSeries(d, parent)
|
|
406
|
{
|
|
406
|
{
|
|
407
|
}
|
|
407
|
}
|
|
408
|
|
|
408
|
|
|
409
|
/*!
|
|
409
|
/*!
|
|
410
|
Destroys the object. Series added to QChart instances are owned by those,
|
|
410
|
Destroys the object. Series added to QChart instances are owned by those,
|
|
411
|
and are destroyed when QChart instances are destroyed.
|
|
411
|
and are destroyed when QChart instances are destroyed.
|
|
412
|
*/
|
|
412
|
*/
|
|
413
|
QXYSeries::~QXYSeries()
|
|
413
|
QXYSeries::~QXYSeries()
|
|
414
|
{
|
|
414
|
{
|
|
415
|
}
|
|
415
|
}
|
|
416
|
|
|
416
|
|
|
417
|
/*!
|
|
417
|
/*!
|
|
418
|
Adds data point (\a x, \a y) to the series.
|
|
418
|
Adds data point (\a x, \a y) to the series.
|
|
419
|
*/
|
|
419
|
*/
|
|
420
|
void QXYSeries::append(qreal x, qreal y)
|
|
420
|
void QXYSeries::append(qreal x, qreal y)
|
|
421
|
{
|
|
421
|
{
|
|
422
|
append(QPointF(x, y));
|
|
422
|
append(QPointF(x, y));
|
|
423
|
}
|
|
423
|
}
|
|
424
|
|
|
424
|
|
|
425
|
/*!
|
|
425
|
/*!
|
|
426
|
This is an overloaded function.
|
|
426
|
This is an overloaded function.
|
|
427
|
Adds data \a point to the series.
|
|
427
|
Adds data \a point to the series.
|
|
428
|
*/
|
|
428
|
*/
|
|
429
|
void QXYSeries::append(const QPointF &point)
|
|
429
|
void QXYSeries::append(const QPointF &point)
|
|
430
|
{
|
|
430
|
{
|
|
431
|
Q_D(QXYSeries);
|
|
431
|
Q_D(QXYSeries);
|
|
432
|
|
|
432
|
|
|
433
|
if (isValidValue(point)) {
|
|
433
|
if (isValidValue(point)) {
|
|
434
|
d->m_points << point;
|
|
434
|
d->m_points << point;
|
|
435
|
emit pointAdded(d->m_points.count() - 1);
|
|
435
|
emit pointAdded(d->m_points.count() - 1);
|
|
436
|
}
|
|
436
|
}
|
|
437
|
}
|
|
437
|
}
|
|
438
|
|
|
438
|
|
|
439
|
/*!
|
|
439
|
/*!
|
|
440
|
This is an overloaded function.
|
|
440
|
This is an overloaded function.
|
|
441
|
Adds list of data \a points to the series.
|
|
441
|
Adds list of data \a points to the series.
|
|
442
|
*/
|
|
442
|
*/
|
|
443
|
void QXYSeries::append(const QList<QPointF> &points)
|
|
443
|
void QXYSeries::append(const QList<QPointF> &points)
|
|
444
|
{
|
|
444
|
{
|
|
445
|
foreach (const QPointF &point , points)
|
|
445
|
foreach (const QPointF &point , points)
|
|
446
|
append(point);
|
|
446
|
append(point);
|
|
447
|
}
|
|
447
|
}
|
|
448
|
|
|
448
|
|
|
449
|
/*!
|
|
449
|
/*!
|
|
450
|
Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY).
|
|
450
|
Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY).
|
|
451
|
\sa QXYSeries::pointReplaced()
|
|
451
|
\sa QXYSeries::pointReplaced()
|
|
452
|
*/
|
|
452
|
*/
|
|
453
|
void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
|
|
453
|
void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
|
|
454
|
{
|
|
454
|
{
|
|
455
|
replace(QPointF(oldX, oldY), QPointF(newX, newY));
|
|
455
|
replace(QPointF(oldX, oldY), QPointF(newX, newY));
|
|
456
|
}
|
|
456
|
}
|
|
457
|
|
|
457
|
|
|
458
|
/*!
|
|
458
|
/*!
|
|
459
|
Replaces \a oldPoint with \a newPoint.
|
|
459
|
Replaces \a oldPoint with \a newPoint.
|
|
460
|
\sa QXYSeries::pointReplaced()
|
|
460
|
\sa QXYSeries::pointReplaced()
|
|
461
|
*/
|
|
461
|
*/
|
|
462
|
void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint)
|
|
462
|
void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint)
|
|
463
|
{
|
|
463
|
{
|
|
464
|
Q_D(QXYSeries);
|
|
464
|
Q_D(QXYSeries);
|
|
465
|
int index = d->m_points.indexOf(oldPoint);
|
|
465
|
int index = d->m_points.indexOf(oldPoint);
|
|
466
|
if (index == -1)
|
|
466
|
if (index == -1)
|
|
467
|
return;
|
|
467
|
return;
|
|
468
|
replace(index, newPoint);
|
|
468
|
replace(index, newPoint);
|
|
469
|
}
|
|
469
|
}
|
|
470
|
|
|
470
|
|
|
471
|
/*!
|
|
471
|
/*!
|
|
472
|
Replaces the point at \a index with data point (\a newX, \a newY).
|
|
472
|
Replaces the point at \a index with data point (\a newX, \a newY).
|
|
473
|
\sa QXYSeries::pointReplaced()
|
|
473
|
\sa QXYSeries::pointReplaced()
|
|
474
|
*/
|
|
474
|
*/
|
|
475
|
void QXYSeries::replace(int index, qreal newX, qreal newY)
|
|
475
|
void QXYSeries::replace(int index, qreal newX, qreal newY)
|
|
476
|
{
|
|
476
|
{
|
|
477
|
replace(index, QPointF(newX, newY));
|
|
477
|
replace(index, QPointF(newX, newY));
|
|
478
|
}
|
|
478
|
}
|
|
479
|
|
|
479
|
|
|
480
|
/*!
|
|
480
|
/*!
|
|
481
|
Replaces the point at \a index with \a newPoint.
|
|
481
|
Replaces the point at \a index with \a newPoint.
|
|
482
|
\sa QXYSeries::pointReplaced()
|
|
482
|
\sa QXYSeries::pointReplaced()
|
|
483
|
*/
|
|
483
|
*/
|
|
484
|
void QXYSeries::replace(int index, const QPointF &newPoint)
|
|
484
|
void QXYSeries::replace(int index, const QPointF &newPoint)
|
|
485
|
{
|
|
485
|
{
|
|
486
|
Q_D(QXYSeries);
|
|
486
|
Q_D(QXYSeries);
|
|
487
|
if (isValidValue(newPoint)) {
|
|
487
|
if (isValidValue(newPoint)) {
|
|
488
|
d->m_points[index] = newPoint;
|
|
488
|
d->m_points[index] = newPoint;
|
|
489
|
emit pointReplaced(index);
|
|
489
|
emit pointReplaced(index);
|
|
490
|
}
|
|
490
|
}
|
|
491
|
}
|
|
491
|
}
|
|
492
|
|
|
492
|
|
|
493
|
/*!
|
|
493
|
/*!
|
|
494
|
Replaces the current points with \a points.
|
|
494
|
Replaces the current points with \a points.
|
|
495
|
\note This is much faster than replacing data points one by one,
|
|
495
|
\note This is much faster than replacing data points one by one,
|
|
496
|
or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced()
|
|
496
|
or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced()
|
|
497
|
when the points have been replaced.
|
|
497
|
when the points have been replaced. However, note that using the overload that takes
|
|
|
|
|
498
|
\c{QVector<QPointF>} as parameter is slightly faster than using this overload.
|
|
498
|
\sa QXYSeries::pointsReplaced()
|
|
499
|
\sa QXYSeries::pointsReplaced()
|
|
499
|
*/
|
|
500
|
*/
|
|
500
|
void QXYSeries::replace(QList<QPointF> points)
|
|
501
|
void QXYSeries::replace(QList<QPointF> points)
|
|
501
|
{
|
|
502
|
{
|
|
|
|
|
503
|
replace(points.toVector());
|
|
|
|
|
504
|
}
|
|
|
|
|
505
|
|
|
|
|
|
506
|
/*!
|
|
|
|
|
507
|
Replaces the current points with \a points.
|
|
|
|
|
508
|
\note This is much faster than replacing data points one by one,
|
|
|
|
|
509
|
or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced()
|
|
|
|
|
510
|
when the points have been replaced.
|
|
|
|
|
511
|
\sa QXYSeries::pointsReplaced()
|
|
|
|
|
512
|
*/
|
|
|
|
|
513
|
void QXYSeries::replace(QVector<QPointF> points)
|
|
|
|
|
514
|
{
|
|
502
|
Q_D(QXYSeries);
|
|
515
|
Q_D(QXYSeries);
|
|
503
|
d->m_points = points.toVector();
|
|
516
|
d->m_points = points;
|
|
504
|
emit pointsReplaced();
|
|
517
|
emit pointsReplaced();
|
|
505
|
}
|
|
518
|
}
|
|
506
|
|
|
519
|
|
|
507
|
/*!
|
|
520
|
/*!
|
|
508
|
Removes the point (\a x, \a y) from the series.
|
|
521
|
Removes the point (\a x, \a y) from the series.
|
|
509
|
*/
|
|
522
|
*/
|
|
510
|
void QXYSeries::remove(qreal x, qreal y)
|
|
523
|
void QXYSeries::remove(qreal x, qreal y)
|
|
511
|
{
|
|
524
|
{
|
|
512
|
remove(QPointF(x, y));
|
|
525
|
remove(QPointF(x, y));
|
|
513
|
}
|
|
526
|
}
|
|
514
|
|
|
527
|
|
|
515
|
/*!
|
|
528
|
/*!
|
|
516
|
Removes the \a point from the series.
|
|
529
|
Removes the \a point from the series.
|
|
517
|
*/
|
|
530
|
*/
|
|
518
|
void QXYSeries::remove(const QPointF &point)
|
|
531
|
void QXYSeries::remove(const QPointF &point)
|
|
519
|
{
|
|
532
|
{
|
|
520
|
Q_D(QXYSeries);
|
|
533
|
Q_D(QXYSeries);
|
|
521
|
int index = d->m_points.indexOf(point);
|
|
534
|
int index = d->m_points.indexOf(point);
|
|
522
|
if (index == -1)
|
|
535
|
if (index == -1)
|
|
523
|
return;
|
|
536
|
return;
|
|
524
|
remove(index);
|
|
537
|
remove(index);
|
|
525
|
}
|
|
538
|
}
|
|
526
|
|
|
539
|
|
|
527
|
/*!
|
|
540
|
/*!
|
|
528
|
Removes the point at \a index from the series.
|
|
541
|
Removes the point at \a index from the series.
|
|
529
|
*/
|
|
542
|
*/
|
|
530
|
void QXYSeries::remove(int index)
|
|
543
|
void QXYSeries::remove(int index)
|
|
531
|
{
|
|
544
|
{
|
|
532
|
Q_D(QXYSeries);
|
|
545
|
Q_D(QXYSeries);
|
|
533
|
d->m_points.remove(index);
|
|
546
|
d->m_points.remove(index);
|
|
534
|
emit pointRemoved(index);
|
|
547
|
emit pointRemoved(index);
|
|
535
|
}
|
|
548
|
}
|
|
536
|
|
|
549
|
|
|
537
|
/*!
|
|
550
|
/*!
|
|
538
|
Inserts a \a point in the series at \a index position.
|
|
551
|
Inserts a \a point in the series at \a index position.
|
|
539
|
*/
|
|
552
|
*/
|
|
540
|
void QXYSeries::insert(int index, const QPointF &point)
|
|
553
|
void QXYSeries::insert(int index, const QPointF &point)
|
|
541
|
{
|
|
554
|
{
|
|
542
|
Q_D(QXYSeries);
|
|
555
|
Q_D(QXYSeries);
|
|
543
|
if (isValidValue(point)) {
|
|
556
|
if (isValidValue(point)) {
|
|
544
|
index = qMax(0, qMin(index, d->m_points.size()));
|
|
557
|
index = qMax(0, qMin(index, d->m_points.size()));
|
|
545
|
d->m_points.insert(index, point);
|
|
558
|
d->m_points.insert(index, point);
|
|
546
|
emit pointAdded(index);
|
|
559
|
emit pointAdded(index);
|
|
547
|
}
|
|
560
|
}
|
|
548
|
}
|
|
561
|
}
|
|
549
|
|
|
562
|
|
|
550
|
/*!
|
|
563
|
/*!
|
|
551
|
Removes all points from the series.
|
|
564
|
Removes all points from the series.
|
|
552
|
*/
|
|
565
|
*/
|
|
553
|
void QXYSeries::clear()
|
|
566
|
void QXYSeries::clear()
|
|
554
|
{
|
|
567
|
{
|
|
555
|
Q_D(QXYSeries);
|
|
568
|
Q_D(QXYSeries);
|
|
556
|
for (int i = d->m_points.size() - 1; i >= 0; i--)
|
|
569
|
for (int i = d->m_points.size() - 1; i >= 0; i--)
|
|
557
|
remove(d->m_points.at(i));
|
|
570
|
remove(d->m_points.at(i));
|
|
558
|
}
|
|
571
|
}
|
|
559
|
|
|
572
|
|
|
560
|
/*!
|
|
573
|
/*!
|
|
561
|
Returns list of points in the series.
|
|
574
|
Returns list of points in the series.
|
|
562
|
*/
|
|
575
|
*/
|
|
563
|
QList<QPointF> QXYSeries::points() const
|
|
576
|
QList<QPointF> QXYSeries::points() const
|
|
564
|
{
|
|
577
|
{
|
|
565
|
Q_D(const QXYSeries);
|
|
578
|
Q_D(const QXYSeries);
|
|
566
|
return d->m_points.toList();
|
|
579
|
return d->m_points.toList();
|
|
567
|
}
|
|
580
|
}
|
|
568
|
|
|
581
|
|
|
569
|
/*!
|
|
582
|
/*!
|
|
570
|
Returns point at \a index in internal points vector.
|
|
583
|
Returns point at \a index in internal points vector.
|
|
571
|
*/
|
|
584
|
*/
|
|
572
|
const QPointF &QXYSeries::at(int index) const
|
|
585
|
const QPointF &QXYSeries::at(int index) const
|
|
573
|
{
|
|
586
|
{
|
|
574
|
Q_D(const QXYSeries);
|
|
587
|
Q_D(const QXYSeries);
|
|
575
|
return d->m_points.at(index);
|
|
588
|
return d->m_points.at(index);
|
|
576
|
}
|
|
589
|
}
|
|
577
|
|
|
590
|
|
|
578
|
/*!
|
|
591
|
/*!
|
|
579
|
Returns number of data points within series.
|
|
592
|
Returns number of data points within series.
|
|
580
|
*/
|
|
593
|
*/
|
|
581
|
int QXYSeries::count() const
|
|
594
|
int QXYSeries::count() const
|
|
582
|
{
|
|
595
|
{
|
|
583
|
Q_D(const QXYSeries);
|
|
596
|
Q_D(const QXYSeries);
|
|
584
|
return d->m_points.count();
|
|
597
|
return d->m_points.count();
|
|
585
|
}
|
|
598
|
}
|
|
586
|
|
|
599
|
|
|
587
|
|
|
600
|
|
|
588
|
/*!
|
|
601
|
/*!
|
|
589
|
Sets \a pen used for drawing points on the chart. If the pen is not defined, the
|
|
602
|
Sets \a pen used for drawing points on the chart. If the pen is not defined, the
|
|
590
|
pen from chart theme is used.
|
|
603
|
pen from chart theme is used.
|
|
591
|
\sa QChart::setTheme()
|
|
604
|
\sa QChart::setTheme()
|
|
592
|
*/
|
|
605
|
*/
|
|
593
|
void QXYSeries::setPen(const QPen &pen)
|
|
606
|
void QXYSeries::setPen(const QPen &pen)
|
|
594
|
{
|
|
607
|
{
|
|
595
|
Q_D(QXYSeries);
|
|
608
|
Q_D(QXYSeries);
|
|
596
|
if (d->m_pen != pen) {
|
|
609
|
if (d->m_pen != pen) {
|
|
597
|
bool emitColorChanged = d->m_pen.color() != pen.color();
|
|
610
|
bool emitColorChanged = d->m_pen.color() != pen.color();
|
|
598
|
d->m_pen = pen;
|
|
611
|
d->m_pen = pen;
|
|
599
|
emit d->updated();
|
|
612
|
emit d->updated();
|
|
600
|
if (emitColorChanged)
|
|
613
|
if (emitColorChanged)
|
|
601
|
emit colorChanged(pen.color());
|
|
614
|
emit colorChanged(pen.color());
|
|
602
|
}
|
|
615
|
}
|
|
603
|
}
|
|
616
|
}
|
|
604
|
|
|
617
|
|
|
605
|
QPen QXYSeries::pen() const
|
|
618
|
QPen QXYSeries::pen() const
|
|
606
|
{
|
|
619
|
{
|
|
607
|
Q_D(const QXYSeries);
|
|
620
|
Q_D(const QXYSeries);
|
|
608
|
if (d->m_pen == QChartPrivate::defaultPen())
|
|
621
|
if (d->m_pen == QChartPrivate::defaultPen())
|
|
609
|
return QPen();
|
|
622
|
return QPen();
|
|
610
|
else
|
|
623
|
else
|
|
611
|
return d->m_pen;
|
|
624
|
return d->m_pen;
|
|
612
|
}
|
|
625
|
}
|
|
613
|
|
|
626
|
|
|
614
|
/*!
|
|
627
|
/*!
|
|
615
|
Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
|
|
628
|
Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
|
|
616
|
from chart theme setting is used.
|
|
629
|
from chart theme setting is used.
|
|
617
|
\sa QChart::setTheme()
|
|
630
|
\sa QChart::setTheme()
|
|
618
|
*/
|
|
631
|
*/
|
|
619
|
void QXYSeries::setBrush(const QBrush &brush)
|
|
632
|
void QXYSeries::setBrush(const QBrush &brush)
|
|
620
|
{
|
|
633
|
{
|
|
621
|
Q_D(QXYSeries);
|
|
634
|
Q_D(QXYSeries);
|
|
622
|
if (d->m_brush != brush) {
|
|
635
|
if (d->m_brush != brush) {
|
|
623
|
d->m_brush = brush;
|
|
636
|
d->m_brush = brush;
|
|
624
|
emit d->updated();
|
|
637
|
emit d->updated();
|
|
625
|
}
|
|
638
|
}
|
|
626
|
}
|
|
639
|
}
|
|
627
|
|
|
640
|
|
|
628
|
QBrush QXYSeries::brush() const
|
|
641
|
QBrush QXYSeries::brush() const
|
|
629
|
{
|
|
642
|
{
|
|
630
|
Q_D(const QXYSeries);
|
|
643
|
Q_D(const QXYSeries);
|
|
631
|
if (d->m_brush == QChartPrivate::defaultBrush())
|
|
644
|
if (d->m_brush == QChartPrivate::defaultBrush())
|
|
632
|
return QBrush();
|
|
645
|
return QBrush();
|
|
633
|
else
|
|
646
|
else
|
|
634
|
return d->m_brush;
|
|
647
|
return d->m_brush;
|
|
635
|
}
|
|
648
|
}
|
|
636
|
|
|
649
|
|
|
637
|
void QXYSeries::setColor(const QColor &color)
|
|
650
|
void QXYSeries::setColor(const QColor &color)
|
|
638
|
{
|
|
651
|
{
|
|
639
|
QPen p = pen();
|
|
652
|
QPen p = pen();
|
|
640
|
if (p.color() != color) {
|
|
653
|
if (p.color() != color) {
|
|
641
|
p.setColor(color);
|
|
654
|
p.setColor(color);
|
|
642
|
setPen(p);
|
|
655
|
setPen(p);
|
|
643
|
}
|
|
656
|
}
|
|
644
|
}
|
|
657
|
}
|
|
645
|
|
|
658
|
|
|
646
|
QColor QXYSeries::color() const
|
|
659
|
QColor QXYSeries::color() const
|
|
647
|
{
|
|
660
|
{
|
|
648
|
return pen().color();
|
|
661
|
return pen().color();
|
|
649
|
}
|
|
662
|
}
|
|
650
|
|
|
663
|
|
|
651
|
void QXYSeries::setPointsVisible(bool visible)
|
|
664
|
void QXYSeries::setPointsVisible(bool visible)
|
|
652
|
{
|
|
665
|
{
|
|
653
|
Q_D(QXYSeries);
|
|
666
|
Q_D(QXYSeries);
|
|
654
|
if (d->m_pointsVisible != visible) {
|
|
667
|
if (d->m_pointsVisible != visible) {
|
|
655
|
d->m_pointsVisible = visible;
|
|
668
|
d->m_pointsVisible = visible;
|
|
656
|
emit d->updated();
|
|
669
|
emit d->updated();
|
|
657
|
}
|
|
670
|
}
|
|
658
|
}
|
|
671
|
}
|
|
659
|
|
|
672
|
|
|
660
|
bool QXYSeries::pointsVisible() const
|
|
673
|
bool QXYSeries::pointsVisible() const
|
|
661
|
{
|
|
674
|
{
|
|
662
|
Q_D(const QXYSeries);
|
|
675
|
Q_D(const QXYSeries);
|
|
663
|
return d->m_pointsVisible;
|
|
676
|
return d->m_pointsVisible;
|
|
664
|
}
|
|
677
|
}
|
|
665
|
|
|
678
|
|
|
666
|
void QXYSeries::setPointLabelsFormat(const QString &format)
|
|
679
|
void QXYSeries::setPointLabelsFormat(const QString &format)
|
|
667
|
{
|
|
680
|
{
|
|
668
|
Q_D(QXYSeries);
|
|
681
|
Q_D(QXYSeries);
|
|
669
|
if (d->m_pointLabelsFormat != format) {
|
|
682
|
if (d->m_pointLabelsFormat != format) {
|
|
670
|
d->m_pointLabelsFormat = format;
|
|
683
|
d->m_pointLabelsFormat = format;
|
|
671
|
emit pointLabelsFormatChanged(format);
|
|
684
|
emit pointLabelsFormatChanged(format);
|
|
672
|
}
|
|
685
|
}
|
|
673
|
}
|
|
686
|
}
|
|
674
|
|
|
687
|
|
|
675
|
QString QXYSeries::pointLabelsFormat() const
|
|
688
|
QString QXYSeries::pointLabelsFormat() const
|
|
676
|
{
|
|
689
|
{
|
|
677
|
Q_D(const QXYSeries);
|
|
690
|
Q_D(const QXYSeries);
|
|
678
|
return d->m_pointLabelsFormat;
|
|
691
|
return d->m_pointLabelsFormat;
|
|
679
|
}
|
|
692
|
}
|
|
680
|
|
|
693
|
|
|
681
|
void QXYSeries::setPointLabelsVisible(bool visible)
|
|
694
|
void QXYSeries::setPointLabelsVisible(bool visible)
|
|
682
|
{
|
|
695
|
{
|
|
683
|
Q_D(QXYSeries);
|
|
696
|
Q_D(QXYSeries);
|
|
684
|
if (d->m_pointLabelsVisible != visible) {
|
|
697
|
if (d->m_pointLabelsVisible != visible) {
|
|
685
|
d->m_pointLabelsVisible = visible;
|
|
698
|
d->m_pointLabelsVisible = visible;
|
|
686
|
emit pointLabelsVisibilityChanged(visible);
|
|
699
|
emit pointLabelsVisibilityChanged(visible);
|
|
687
|
}
|
|
700
|
}
|
|
688
|
}
|
|
701
|
}
|
|
689
|
|
|
702
|
|
|
690
|
bool QXYSeries::pointLabelsVisible() const
|
|
703
|
bool QXYSeries::pointLabelsVisible() const
|
|
691
|
{
|
|
704
|
{
|
|
692
|
Q_D(const QXYSeries);
|
|
705
|
Q_D(const QXYSeries);
|
|
693
|
return d->m_pointLabelsVisible;
|
|
706
|
return d->m_pointLabelsVisible;
|
|
694
|
}
|
|
707
|
}
|
|
695
|
|
|
708
|
|
|
696
|
void QXYSeries::setPointLabelsFont(const QFont &font)
|
|
709
|
void QXYSeries::setPointLabelsFont(const QFont &font)
|
|
697
|
{
|
|
710
|
{
|
|
698
|
Q_D(QXYSeries);
|
|
711
|
Q_D(QXYSeries);
|
|
699
|
if (d->m_pointLabelsFont != font) {
|
|
712
|
if (d->m_pointLabelsFont != font) {
|
|
700
|
d->m_pointLabelsFont = font;
|
|
713
|
d->m_pointLabelsFont = font;
|
|
701
|
emit pointLabelsFontChanged(font);
|
|
714
|
emit pointLabelsFontChanged(font);
|
|
702
|
}
|
|
715
|
}
|
|
703
|
}
|
|
716
|
}
|
|
704
|
|
|
717
|
|
|
705
|
QFont QXYSeries::pointLabelsFont() const
|
|
718
|
QFont QXYSeries::pointLabelsFont() const
|
|
706
|
{
|
|
719
|
{
|
|
707
|
Q_D(const QXYSeries);
|
|
720
|
Q_D(const QXYSeries);
|
|
708
|
return d->m_pointLabelsFont;
|
|
721
|
return d->m_pointLabelsFont;
|
|
709
|
}
|
|
722
|
}
|
|
710
|
|
|
723
|
|
|
711
|
void QXYSeries::setPointLabelsColor(const QColor &color)
|
|
724
|
void QXYSeries::setPointLabelsColor(const QColor &color)
|
|
712
|
{
|
|
725
|
{
|
|
713
|
Q_D(QXYSeries);
|
|
726
|
Q_D(QXYSeries);
|
|
714
|
if (d->m_pointLabelsColor != color) {
|
|
727
|
if (d->m_pointLabelsColor != color) {
|
|
715
|
d->m_pointLabelsColor = color;
|
|
728
|
d->m_pointLabelsColor = color;
|
|
716
|
emit pointLabelsColorChanged(color);
|
|
729
|
emit pointLabelsColorChanged(color);
|
|
717
|
}
|
|
730
|
}
|
|
718
|
}
|
|
731
|
}
|
|
719
|
|
|
732
|
|
|
720
|
QColor QXYSeries::pointLabelsColor() const
|
|
733
|
QColor QXYSeries::pointLabelsColor() const
|
|
721
|
{
|
|
734
|
{
|
|
722
|
Q_D(const QXYSeries);
|
|
735
|
Q_D(const QXYSeries);
|
|
723
|
if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
|
|
736
|
if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
|
|
724
|
return QPen().color();
|
|
737
|
return QPen().color();
|
|
725
|
else
|
|
738
|
else
|
|
726
|
return d->m_pointLabelsColor;
|
|
739
|
return d->m_pointLabelsColor;
|
|
727
|
}
|
|
740
|
}
|
|
728
|
|
|
741
|
|
|
729
|
/*!
|
|
742
|
/*!
|
|
730
|
Stream operator for adding a data \a point to the series.
|
|
743
|
Stream operator for adding a data \a point to the series.
|
|
731
|
\sa append()
|
|
744
|
\sa append()
|
|
732
|
*/
|
|
745
|
*/
|
|
733
|
QXYSeries &QXYSeries::operator<< (const QPointF &point)
|
|
746
|
QXYSeries &QXYSeries::operator<< (const QPointF &point)
|
|
734
|
{
|
|
747
|
{
|
|
735
|
append(point);
|
|
748
|
append(point);
|
|
736
|
return *this;
|
|
749
|
return *this;
|
|
737
|
}
|
|
750
|
}
|
|
738
|
|
|
751
|
|
|
739
|
|
|
752
|
|
|
740
|
/*!
|
|
753
|
/*!
|
|
741
|
Stream operator for adding a list of \a points to the series.
|
|
754
|
Stream operator for adding a list of \a points to the series.
|
|
742
|
\sa append()
|
|
755
|
\sa append()
|
|
743
|
*/
|
|
756
|
*/
|
|
744
|
|
|
757
|
|
|
745
|
QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points)
|
|
758
|
QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points)
|
|
746
|
{
|
|
759
|
{
|
|
747
|
append(points);
|
|
760
|
append(points);
|
|
748
|
return *this;
|
|
761
|
return *this;
|
|
749
|
}
|
|
762
|
}
|
|
750
|
|
|
763
|
|
|
751
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
764
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
752
|
|
|
765
|
|
|
753
|
|
|
766
|
|
|
754
|
QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q)
|
|
767
|
QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q)
|
|
755
|
: QAbstractSeriesPrivate(q),
|
|
768
|
: QAbstractSeriesPrivate(q),
|
|
756
|
m_pen(QChartPrivate::defaultPen()),
|
|
769
|
m_pen(QChartPrivate::defaultPen()),
|
|
757
|
m_brush(QChartPrivate::defaultBrush()),
|
|
770
|
m_brush(QChartPrivate::defaultBrush()),
|
|
758
|
m_pointsVisible(false),
|
|
771
|
m_pointsVisible(false),
|
|
759
|
m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
|
|
772
|
m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
|
|
760
|
m_pointLabelsVisible(false),
|
|
773
|
m_pointLabelsVisible(false),
|
|
761
|
m_pointLabelsFont(QChartPrivate::defaultFont()),
|
|
774
|
m_pointLabelsFont(QChartPrivate::defaultFont()),
|
|
762
|
m_pointLabelsColor(QChartPrivate::defaultPen().color())
|
|
775
|
m_pointLabelsColor(QChartPrivate::defaultPen().color())
|
|
763
|
{
|
|
776
|
{
|
|
764
|
}
|
|
777
|
}
|
|
765
|
|
|
778
|
|
|
766
|
void QXYSeriesPrivate::initializeDomain()
|
|
779
|
void QXYSeriesPrivate::initializeDomain()
|
|
767
|
{
|
|
780
|
{
|
|
768
|
qreal minX(0);
|
|
781
|
qreal minX(0);
|
|
769
|
qreal minY(0);
|
|
782
|
qreal minY(0);
|
|
770
|
qreal maxX(1);
|
|
783
|
qreal maxX(1);
|
|
771
|
qreal maxY(1);
|
|
784
|
qreal maxY(1);
|
|
772
|
|
|
785
|
|
|
773
|
Q_Q(QXYSeries);
|
|
786
|
Q_Q(QXYSeries);
|
|
774
|
|
|
787
|
|
|
775
|
const QList<QPointF>& points = q->points();
|
|
788
|
const QList<QPointF>& points = q->points();
|
|
776
|
|
|
789
|
|
|
777
|
if (!points.isEmpty()) {
|
|
790
|
if (!points.isEmpty()) {
|
|
778
|
minX = points[0].x();
|
|
791
|
minX = points[0].x();
|
|
779
|
minY = points[0].y();
|
|
792
|
minY = points[0].y();
|
|
780
|
maxX = minX;
|
|
793
|
maxX = minX;
|
|
781
|
maxY = minY;
|
|
794
|
maxY = minY;
|
|
782
|
|
|
795
|
|
|
783
|
for (int i = 0; i < points.count(); i++) {
|
|
796
|
for (int i = 0; i < points.count(); i++) {
|
|
784
|
qreal x = points[i].x();
|
|
797
|
qreal x = points[i].x();
|
|
785
|
qreal y = points[i].y();
|
|
798
|
qreal y = points[i].y();
|
|
786
|
minX = qMin(minX, x);
|
|
799
|
minX = qMin(minX, x);
|
|
787
|
minY = qMin(minY, y);
|
|
800
|
minY = qMin(minY, y);
|
|
788
|
maxX = qMax(maxX, x);
|
|
801
|
maxX = qMax(maxX, x);
|
|
789
|
maxY = qMax(maxY, y);
|
|
802
|
maxY = qMax(maxY, y);
|
|
790
|
}
|
|
803
|
}
|
|
791
|
}
|
|
804
|
}
|
|
792
|
|
|
805
|
|
|
793
|
domain()->setRange(minX, maxX, minY, maxY);
|
|
806
|
domain()->setRange(minX, maxX, minY, maxY);
|
|
794
|
}
|
|
807
|
}
|
|
795
|
|
|
808
|
|
|
796
|
QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend)
|
|
809
|
QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend)
|
|
797
|
{
|
|
810
|
{
|
|
798
|
Q_Q(QXYSeries);
|
|
811
|
Q_Q(QXYSeries);
|
|
799
|
QList<QLegendMarker*> list;
|
|
812
|
QList<QLegendMarker*> list;
|
|
800
|
return list << new QXYLegendMarker(q,legend);
|
|
813
|
return list << new QXYLegendMarker(q,legend);
|
|
801
|
}
|
|
814
|
}
|
|
802
|
|
|
815
|
|
|
803
|
void QXYSeriesPrivate::initializeAxes()
|
|
816
|
void QXYSeriesPrivate::initializeAxes()
|
|
804
|
{
|
|
817
|
{
|
|
805
|
|
|
818
|
|
|
806
|
}
|
|
819
|
}
|
|
807
|
|
|
820
|
|
|
808
|
QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
|
|
821
|
QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
|
|
809
|
{
|
|
822
|
{
|
|
810
|
Q_UNUSED(orientation);
|
|
823
|
Q_UNUSED(orientation);
|
|
811
|
return QAbstractAxis::AxisTypeValue;
|
|
824
|
return QAbstractAxis::AxisTypeValue;
|
|
812
|
}
|
|
825
|
}
|
|
813
|
|
|
826
|
|
|
814
|
QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const
|
|
827
|
QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const
|
|
815
|
{
|
|
828
|
{
|
|
816
|
Q_UNUSED(orientation);
|
|
829
|
Q_UNUSED(orientation);
|
|
817
|
return new QValueAxis;
|
|
830
|
return new QValueAxis;
|
|
818
|
}
|
|
831
|
}
|
|
819
|
|
|
832
|
|
|
820
|
void QXYSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options)
|
|
833
|
void QXYSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options)
|
|
821
|
{
|
|
834
|
{
|
|
822
|
XYChart *item = static_cast<XYChart *>(m_item.data());
|
|
835
|
XYChart *item = static_cast<XYChart *>(m_item.data());
|
|
823
|
Q_ASSERT(item);
|
|
836
|
Q_ASSERT(item);
|
|
824
|
if (item->animation())
|
|
837
|
if (item->animation())
|
|
825
|
item->animation()->stopAndDestroyLater();
|
|
838
|
item->animation()->stopAndDestroyLater();
|
|
826
|
|
|
839
|
|
|
827
|
if (options.testFlag(QChart::SeriesAnimations))
|
|
840
|
if (options.testFlag(QChart::SeriesAnimations))
|
|
828
|
item->setAnimation(new XYAnimation(item));
|
|
841
|
item->setAnimation(new XYAnimation(item));
|
|
829
|
else
|
|
842
|
else
|
|
830
|
item->setAnimation(0);
|
|
843
|
item->setAnimation(0);
|
|
831
|
QAbstractSeriesPrivate::initializeAnimations(options);
|
|
844
|
QAbstractSeriesPrivate::initializeAnimations(options);
|
|
832
|
}
|
|
845
|
}
|
|
833
|
|
|
846
|
|
|
834
|
void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points,
|
|
847
|
void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points,
|
|
835
|
const int offset)
|
|
848
|
const int offset)
|
|
836
|
{
|
|
849
|
{
|
|
837
|
static const QString xPointTag(QLatin1String("@xPoint"));
|
|
850
|
static const QString xPointTag(QLatin1String("@xPoint"));
|
|
838
|
static const QString yPointTag(QLatin1String("@yPoint"));
|
|
851
|
static const QString yPointTag(QLatin1String("@yPoint"));
|
|
839
|
const int labelOffset = offset + 2;
|
|
852
|
const int labelOffset = offset + 2;
|
|
840
|
|
|
853
|
|
|
841
|
painter->setFont(m_pointLabelsFont);
|
|
854
|
painter->setFont(m_pointLabelsFont);
|
|
842
|
painter->setPen(QPen(m_pointLabelsColor));
|
|
855
|
painter->setPen(QPen(m_pointLabelsColor));
|
|
843
|
QFontMetrics fm(painter->font());
|
|
856
|
QFontMetrics fm(painter->font());
|
|
844
|
// m_points is used for the label here as it has the series point information
|
|
857
|
// m_points is used for the label here as it has the series point information
|
|
845
|
// points variable passed is used for positioning because it has the coordinates
|
|
858
|
// points variable passed is used for positioning because it has the coordinates
|
|
846
|
for (int i(0); i < m_points.size(); i++) {
|
|
859
|
for (int i(0); i < m_points.size(); i++) {
|
|
847
|
QString pointLabel = m_pointLabelsFormat;
|
|
860
|
QString pointLabel = m_pointLabelsFormat;
|
|
848
|
pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x()));
|
|
861
|
pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x()));
|
|
849
|
pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y()));
|
|
862
|
pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y()));
|
|
850
|
|
|
863
|
|
|
851
|
// Position text in relation to the point
|
|
864
|
// Position text in relation to the point
|
|
852
|
int pointLabelWidth = fm.width(pointLabel);
|
|
865
|
int pointLabelWidth = fm.width(pointLabel);
|
|
853
|
QPointF position(points.at(i));
|
|
866
|
QPointF position(points.at(i));
|
|
854
|
if (!reverseXAxis())
|
|
867
|
if (!reverseXAxis())
|
|
855
|
position.setX(position.x() - pointLabelWidth / 2);
|
|
868
|
position.setX(position.x() - pointLabelWidth / 2);
|
|
856
|
else
|
|
869
|
else
|
|
857
|
position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2);
|
|
870
|
position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2);
|
|
858
|
if (!reverseYAxis())
|
|
871
|
if (!reverseYAxis())
|
|
859
|
position.setY(position.y() - labelOffset);
|
|
872
|
position.setY(position.y() - labelOffset);
|
|
860
|
else
|
|
873
|
else
|
|
861
|
position.setY(domain()->size().height() - position.y() - labelOffset);
|
|
874
|
position.setY(domain()->size().height() - position.y() - labelOffset);
|
|
862
|
|
|
875
|
|
|
863
|
painter->drawText(position, pointLabel);
|
|
876
|
painter->drawText(position, pointLabel);
|
|
864
|
}
|
|
877
|
}
|
|
865
|
}
|
|
878
|
}
|
|
866
|
|
|
879
|
|
|
867
|
#include "moc_qxyseries.cpp"
|
|
880
|
#include "moc_qxyseries.cpp"
|
|
868
|
#include "moc_qxyseries_p.cpp"
|
|
881
|
#include "moc_qxyseries_p.cpp"
|
|
869
|
|
|
882
|
|
|
870
|
QT_CHARTS_END_NAMESPACE
|
|
883
|
QT_CHARTS_END_NAMESPACE
|