|
@@
-1,895
+1,931
|
|
1
|
/****************************************************************************
|
|
1
|
/****************************************************************************
|
|
2
|
**
|
|
2
|
**
|
|
3
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
3
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
4
|
** Contact: https://www.qt.io/licensing/
|
|
4
|
** Contact: https://www.qt.io/licensing/
|
|
5
|
**
|
|
5
|
**
|
|
6
|
** This file is part of the Qt Charts module of the Qt Toolkit.
|
|
6
|
** This file is part of the Qt Charts module of the Qt Toolkit.
|
|
7
|
**
|
|
7
|
**
|
|
8
|
** $QT_BEGIN_LICENSE:GPL$
|
|
8
|
** $QT_BEGIN_LICENSE:GPL$
|
|
9
|
** Commercial License Usage
|
|
9
|
** Commercial License Usage
|
|
10
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
10
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
11
|
** accordance with the commercial license agreement provided with the
|
|
11
|
** accordance with the 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 The Qt Company. For licensing terms
|
|
13
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
14
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
14
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
15
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
15
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
16
|
**
|
|
16
|
**
|
|
17
|
** GNU General Public License Usage
|
|
17
|
** GNU General Public License Usage
|
|
18
|
** Alternatively, this file may be used under the terms of the GNU
|
|
18
|
** Alternatively, this file may be used under the terms of the GNU
|
|
19
|
** General Public License version 3 or (at your option) any later version
|
|
19
|
** General Public License version 3 or (at your option) any later version
|
|
20
|
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
|
20
|
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
|
21
|
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
|
21
|
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
|
22
|
** included in the packaging of this file. Please review the following
|
|
22
|
** included in the packaging of this file. Please review the following
|
|
23
|
** information to ensure the GNU General Public License requirements will
|
|
23
|
** information to ensure the GNU General Public License requirements will
|
|
24
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
24
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
25
|
**
|
|
25
|
**
|
|
26
|
** $QT_END_LICENSE$
|
|
26
|
** $QT_END_LICENSE$
|
|
27
|
**
|
|
27
|
**
|
|
28
|
****************************************************************************/
|
|
28
|
****************************************************************************/
|
|
29
|
|
|
29
|
|
|
30
|
#include <QtCharts/QChart>
|
|
30
|
#include <QtCharts/QChart>
|
|
31
|
#include <private/qchart_p.h>
|
|
31
|
#include <private/qchart_p.h>
|
|
32
|
#include <private/legendscroller_p.h>
|
|
32
|
#include <private/legendscroller_p.h>
|
|
33
|
#include <private/qlegend_p.h>
|
|
33
|
#include <private/qlegend_p.h>
|
|
34
|
#include <private/chartbackground_p.h>
|
|
34
|
#include <private/chartbackground_p.h>
|
|
35
|
#include <QtCharts/QAbstractAxis>
|
|
35
|
#include <QtCharts/QAbstractAxis>
|
|
36
|
#include <private/abstractchartlayout_p.h>
|
|
36
|
#include <private/abstractchartlayout_p.h>
|
|
37
|
#include <private/charttheme_p.h>
|
|
37
|
#include <private/charttheme_p.h>
|
|
38
|
#include <private/chartpresenter_p.h>
|
|
38
|
#include <private/chartpresenter_p.h>
|
|
39
|
#include <private/chartdataset_p.h>
|
|
39
|
#include <private/chartdataset_p.h>
|
|
40
|
#include <QtWidgets/QGraphicsScene>
|
|
40
|
#include <QtWidgets/QGraphicsScene>
|
|
41
|
#include <QGraphicsSceneResizeEvent>
|
|
41
|
#include <QGraphicsSceneResizeEvent>
|
|
42
|
|
|
42
|
|
|
43
|
QT_CHARTS_BEGIN_NAMESPACE
|
|
43
|
QT_CHARTS_BEGIN_NAMESPACE
|
|
44
|
|
|
44
|
|
|
45
|
/*!
|
|
45
|
/*!
|
|
46
|
\enum QChart::ChartTheme
|
|
46
|
\enum QChart::ChartTheme
|
|
47
|
|
|
47
|
|
|
48
|
This enum describes the theme used by the chart.
|
|
48
|
This enum describes the theme used by the chart.
|
|
49
|
|
|
49
|
|
|
50
|
\value ChartThemeLight The default theme
|
|
50
|
\value ChartThemeLight The default theme
|
|
51
|
\value ChartThemeBlueCerulean
|
|
51
|
\value ChartThemeBlueCerulean
|
|
52
|
\value ChartThemeDark
|
|
52
|
\value ChartThemeDark
|
|
53
|
\value ChartThemeBrownSand
|
|
53
|
\value ChartThemeBrownSand
|
|
54
|
\value ChartThemeBlueNcs
|
|
54
|
\value ChartThemeBlueNcs
|
|
55
|
\value ChartThemeHighContrast
|
|
55
|
\value ChartThemeHighContrast
|
|
56
|
\value ChartThemeBlueIcy
|
|
56
|
\value ChartThemeBlueIcy
|
|
57
|
\value ChartThemeQt
|
|
57
|
\value ChartThemeQt
|
|
58
|
*/
|
|
58
|
*/
|
|
59
|
|
|
59
|
|
|
60
|
/*!
|
|
60
|
/*!
|
|
61
|
\enum QChart::AnimationOption
|
|
61
|
\enum QChart::AnimationOption
|
|
62
|
|
|
62
|
|
|
63
|
For enabling/disabling animations. Defaults to NoAnimation.
|
|
63
|
For enabling/disabling animations. Defaults to NoAnimation.
|
|
64
|
|
|
64
|
|
|
65
|
\value NoAnimation
|
|
65
|
\value NoAnimation
|
|
66
|
\value GridAxisAnimations
|
|
66
|
\value GridAxisAnimations
|
|
67
|
\value SeriesAnimations
|
|
67
|
\value SeriesAnimations
|
|
68
|
\value AllAnimations
|
|
68
|
\value AllAnimations
|
|
69
|
*/
|
|
69
|
*/
|
|
70
|
|
|
70
|
|
|
71
|
/*!
|
|
71
|
/*!
|
|
72
|
\enum QChart::ChartType
|
|
72
|
\enum QChart::ChartType
|
|
73
|
|
|
73
|
|
|
74
|
This enum describes the chart type.
|
|
74
|
This enum describes the chart type.
|
|
75
|
|
|
75
|
|
|
76
|
\value ChartTypeUndefined
|
|
76
|
\value ChartTypeUndefined
|
|
77
|
\value ChartTypeCartesian
|
|
77
|
\value ChartTypeCartesian
|
|
78
|
\value ChartTypePolar
|
|
78
|
\value ChartTypePolar
|
|
79
|
*/
|
|
79
|
*/
|
|
80
|
|
|
80
|
|
|
81
|
/*!
|
|
81
|
/*!
|
|
82
|
\class QChart
|
|
82
|
\class QChart
|
|
83
|
\inmodule Qt Charts
|
|
83
|
\inmodule Qt Charts
|
|
84
|
\brief Main chart API for Qt Charts.
|
|
84
|
\brief Main chart API for Qt Charts.
|
|
85
|
|
|
85
|
|
|
86
|
QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
|
|
86
|
QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
|
|
87
|
representation of different types of series and other chart related objects like legend and
|
|
87
|
representation of different types of series and other chart related objects like legend and
|
|
88
|
axes. If you simply want to show a chart in a layout, you can use the
|
|
88
|
axes. If you simply want to show a chart in a layout, you can use the
|
|
89
|
convenience class QChartView instead of QChart.
|
|
89
|
convenience class QChartView instead of QChart.
|
|
90
|
\sa QChartView, QPolarChart
|
|
90
|
\sa QChartView, QPolarChart
|
|
91
|
*/
|
|
91
|
*/
|
|
92
|
|
|
92
|
|
|
93
|
/*!
|
|
93
|
/*!
|
|
94
|
\property QChart::animationOptions
|
|
94
|
\property QChart::animationOptions
|
|
95
|
The animation \a options for the chart. Animations are enabled/disabled based on this setting.
|
|
95
|
The animation \a options for the chart. Animations are enabled/disabled based on this setting.
|
|
96
|
*/
|
|
96
|
*/
|
|
97
|
|
|
97
|
|
|
98
|
/*!
|
|
98
|
/*!
|
|
99
|
\property QChart::animationDuration
|
|
99
|
\property QChart::animationDuration
|
|
100
|
The duration of the animation for the chart.
|
|
100
|
The duration of the animation for the chart.
|
|
101
|
*/
|
|
101
|
*/
|
|
102
|
|
|
102
|
|
|
103
|
/*!
|
|
103
|
/*!
|
|
104
|
\property QChart::animationEasingCurve
|
|
104
|
\property QChart::animationEasingCurve
|
|
105
|
The easing curve of the animation for the chart.
|
|
105
|
The easing curve of the animation for the chart.
|
|
106
|
*/
|
|
106
|
*/
|
|
107
|
|
|
107
|
|
|
108
|
/*!
|
|
108
|
/*!
|
|
109
|
\property QChart::backgroundVisible
|
|
109
|
\property QChart::backgroundVisible
|
|
110
|
Specifies whether the chart background is visible or not.
|
|
110
|
Specifies whether the chart background is visible or not.
|
|
111
|
\sa setBackgroundBrush(), setBackgroundPen(), plotAreaBackgroundVisible
|
|
111
|
\sa setBackgroundBrush(), setBackgroundPen(), plotAreaBackgroundVisible
|
|
112
|
*/
|
|
112
|
*/
|
|
113
|
|
|
113
|
|
|
114
|
/*!
|
|
114
|
/*!
|
|
115
|
\property QChart::dropShadowEnabled
|
|
115
|
\property QChart::dropShadowEnabled
|
|
116
|
If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
|
|
116
|
If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
|
|
117
|
shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
|
|
117
|
shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
|
|
118
|
*/
|
|
118
|
*/
|
|
119
|
|
|
119
|
|
|
120
|
/*!
|
|
120
|
/*!
|
|
121
|
\property QChart::backgroundRoundness
|
|
121
|
\property QChart::backgroundRoundness
|
|
122
|
The diameter of the rounding circle at the corners of the chart background.
|
|
122
|
The diameter of the rounding circle at the corners of the chart background.
|
|
123
|
*/
|
|
123
|
*/
|
|
124
|
|
|
124
|
|
|
125
|
/*!
|
|
125
|
/*!
|
|
126
|
\property QChart::margins
|
|
126
|
\property QChart::margins
|
|
127
|
Margins between the plot area (axes) and the edge of the chart widget.
|
|
127
|
Margins between the plot area (axes) and the edge of the chart widget.
|
|
128
|
*/
|
|
128
|
*/
|
|
129
|
|
|
129
|
|
|
130
|
/*!
|
|
130
|
/*!
|
|
131
|
\property QChart::theme
|
|
131
|
\property QChart::theme
|
|
132
|
Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
|
|
132
|
Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
|
|
133
|
pens, brushes, and fonts of series, axes, title, and legend. \l {Chart themes example} shows an example with a few
|
|
133
|
pens, brushes, and fonts of series, axes, title, and legend. \l {Chart themes example} shows an example with a few
|
|
134
|
different themes.
|
|
134
|
different themes.
|
|
135
|
\note Changing the theme will overwrite all customizations previously applied to the series.
|
|
135
|
\note Changing the theme will overwrite all customizations previously applied to the series.
|
|
136
|
*/
|
|
136
|
*/
|
|
137
|
|
|
137
|
|
|
138
|
/*!
|
|
138
|
/*!
|
|
139
|
\property QChart::title
|
|
139
|
\property QChart::title
|
|
140
|
Title is the name (label) of a chart. It is shown as a headline on top of the chart. Chart title supports html formatting.
|
|
140
|
Title is the name (label) of a chart. It is shown as a headline on top of the chart. Chart title supports html formatting.
|
|
141
|
*/
|
|
141
|
*/
|
|
142
|
|
|
142
|
|
|
143
|
/*!
|
|
143
|
/*!
|
|
144
|
\property QChart::chartType
|
|
144
|
\property QChart::chartType
|
|
145
|
Chart type indicates if the chart is a cartesian chart or a polar chart.
|
|
145
|
Chart type indicates if the chart is a cartesian chart or a polar chart.
|
|
146
|
This property is set internally and it is read only.
|
|
146
|
This property is set internally and it is read only.
|
|
147
|
\sa QPolarChart
|
|
147
|
\sa QPolarChart
|
|
148
|
*/
|
|
148
|
*/
|
|
149
|
|
|
149
|
|
|
150
|
/*!
|
|
150
|
/*!
|
|
151
|
\property QChart::plotAreaBackgroundVisible
|
|
151
|
\property QChart::plotAreaBackgroundVisible
|
|
152
|
Specifies whether the chart plot area background is visible or not.
|
|
152
|
Specifies whether the chart plot area background is visible or not.
|
|
153
|
\note By default the plot area background is not visible and the plot area uses
|
|
153
|
\note By default the plot area background is not visible and the plot area uses
|
|
154
|
the general chart background.
|
|
154
|
the general chart background.
|
|
155
|
\sa setPlotAreaBackgroundBrush(), setPlotAreaBackgroundPen(), backgroundVisible
|
|
155
|
\sa setPlotAreaBackgroundBrush(), setPlotAreaBackgroundPen(), backgroundVisible
|
|
156
|
*/
|
|
156
|
*/
|
|
157
|
|
|
157
|
|
|
158
|
/*!
|
|
158
|
/*!
|
|
159
|
\property QChart::localizeNumbers
|
|
159
|
\property QChart::localizeNumbers
|
|
160
|
\since QtCharts 2.0
|
|
160
|
\since QtCharts 2.0
|
|
161
|
When \c{true}, all generated numbers appearing in various series and axis labels will be
|
|
161
|
When \c{true}, all generated numbers appearing in various series and axis labels will be
|
|
162
|
localized using the QLocale set with the locale property.
|
|
162
|
localized using the QLocale set with the locale property.
|
|
163
|
When \c{false}, the "C" locale is always used.
|
|
163
|
When \c{false}, the "C" locale is always used.
|
|
164
|
Defaults to \c{false}.
|
|
164
|
Defaults to \c{false}.
|
|
165
|
\note This property doesn't affect QDateTimeAxis labels, which always use the QLocale set with
|
|
165
|
\note This property doesn't affect QDateTimeAxis labels, which always use the QLocale set with
|
|
166
|
the locale property.
|
|
166
|
the locale property.
|
|
167
|
|
|
167
|
|
|
168
|
\sa locale
|
|
168
|
\sa locale
|
|
169
|
*/
|
|
169
|
*/
|
|
170
|
|
|
170
|
|
|
171
|
/*!
|
|
171
|
/*!
|
|
172
|
\property QChart::locale
|
|
172
|
\property QChart::locale
|
|
173
|
\since QtCharts 2.0
|
|
173
|
\since QtCharts 2.0
|
|
174
|
Sets the locale used to format various chart labels when localizeNumbers is \c{true}.
|
|
174
|
Sets the locale used to format various chart labels when localizeNumbers is \c{true}.
|
|
175
|
This also determines the locale used to format QDateTimeAxis labels regardless of
|
|
175
|
This also determines the locale used to format QDateTimeAxis labels regardless of
|
|
176
|
localizeNumbers property.
|
|
176
|
localizeNumbers property.
|
|
177
|
Defaults to application default locale at the time the chart is constructed.
|
|
177
|
Defaults to application default locale at the time the chart is constructed.
|
|
178
|
|
|
178
|
|
|
179
|
\sa localizeNumbers
|
|
179
|
\sa localizeNumbers
|
|
180
|
*/
|
|
180
|
*/
|
|
181
|
|
|
181
|
|
|
182
|
/*!
|
|
182
|
/*!
|
|
183
|
\property QChart::plotArea
|
|
183
|
\property QChart::plotArea
|
|
184
|
Holds the rectangle within which the drawing of the chart is done.
|
|
184
|
Holds the rectangle within which the drawing of the chart is done.
|
|
185
|
It does not include the area defined by margins.
|
|
185
|
It does not include the area defined by margins.
|
|
186
|
*/
|
|
186
|
*/
|
|
187
|
|
|
187
|
|
|
188
|
/*!
|
|
188
|
/*!
|
|
189
|
\internal
|
|
189
|
\internal
|
|
190
|
Constructs a chart object of \a type which is a child of a \a parent.
|
|
190
|
Constructs a chart object of \a type which is a child of a \a parent.
|
|
191
|
Parameter \a wFlags is passed to the QGraphicsWidget constructor.
|
|
191
|
Parameter \a wFlags is passed to the QGraphicsWidget constructor.
|
|
192
|
This constructor is called only by subclasses.
|
|
192
|
This constructor is called only by subclasses.
|
|
193
|
*/
|
|
193
|
*/
|
|
194
|
QChart::QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
|
194
|
QChart::QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
|
195
|
: QGraphicsWidget(parent, wFlags),
|
|
195
|
: QGraphicsWidget(parent, wFlags),
|
|
196
|
d_ptr(new QChartPrivate(this, type))
|
|
196
|
d_ptr(new QChartPrivate(this, type))
|
|
197
|
{
|
|
197
|
{
|
|
198
|
d_ptr->init();
|
|
198
|
d_ptr->init();
|
|
199
|
}
|
|
199
|
}
|
|
200
|
|
|
200
|
|
|
201
|
/*!
|
|
201
|
/*!
|
|
202
|
Constructs a chart object which is a child of a \a parent.
|
|
202
|
Constructs a chart object which is a child of a \a parent.
|
|
203
|
Parameter \a wFlags is passed to the QGraphicsWidget constructor.
|
|
203
|
Parameter \a wFlags is passed to the QGraphicsWidget constructor.
|
|
204
|
*/
|
|
204
|
*/
|
|
205
|
QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
|
205
|
QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
|
206
|
: QGraphicsWidget(parent, wFlags),
|
|
206
|
: QGraphicsWidget(parent, wFlags),
|
|
207
|
d_ptr(new QChartPrivate(this, ChartTypeCartesian))
|
|
207
|
d_ptr(new QChartPrivate(this, ChartTypeCartesian))
|
|
208
|
{
|
|
208
|
{
|
|
209
|
d_ptr->init();
|
|
209
|
d_ptr->init();
|
|
210
|
}
|
|
210
|
}
|
|
211
|
|
|
211
|
|
|
212
|
/*!
|
|
212
|
/*!
|
|
213
|
Destroys the chart object and its children, like series and axis objects added to it.
|
|
213
|
Destroys the chart object and its children, like series and axis objects added to it.
|
|
214
|
*/
|
|
214
|
*/
|
|
215
|
QChart::~QChart()
|
|
215
|
QChart::~QChart()
|
|
216
|
{
|
|
216
|
{
|
|
217
|
//start by deleting dataset, it will remove all series and axes
|
|
217
|
//start by deleting dataset, it will remove all series and axes
|
|
218
|
delete d_ptr->m_dataset;
|
|
218
|
delete d_ptr->m_dataset;
|
|
219
|
d_ptr->m_dataset = 0;
|
|
219
|
d_ptr->m_dataset = 0;
|
|
220
|
}
|
|
220
|
}
|
|
221
|
|
|
221
|
|
|
222
|
/*!
|
|
222
|
/*!
|
|
223
|
Adds the \a series onto the chart and takes the ownership of it.
|
|
223
|
Adds the \a series onto the chart and takes the ownership of it.
|
|
224
|
|
|
224
|
|
|
225
|
\note A newly added series is attached to no axes by default, including any axes that were created for the chart
|
|
225
|
\note A newly added series is attached to no axes by default, including any axes that were created for the chart
|
|
226
|
using createDefaultAxes() before the series was added to the chart. If no axes are attached to
|
|
226
|
using createDefaultAxes() before the series was added to the chart. If no axes are attached to
|
|
227
|
the newly added series before the chart is shown, the series will get drawn as if it had axes with ranges
|
|
227
|
the newly added series before the chart is shown, the series will get drawn as if it had axes with ranges
|
|
228
|
that exactly fit the series to the plot area of the chart. This can be confusing if the same chart also displays other
|
|
228
|
that exactly fit the series to the plot area of the chart. This can be confusing if the same chart also displays other
|
|
229
|
series that have properly attached axes, so always make sure you either call createDefaultAxes() after
|
|
229
|
series that have properly attached axes, so always make sure you either call createDefaultAxes() after
|
|
230
|
a series has been added or explicitly attach axes for the series.
|
|
230
|
a series has been added or explicitly attach axes for the series.
|
|
231
|
|
|
231
|
|
|
232
|
\sa removeSeries(), removeAllSeries(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
232
|
\sa removeSeries(), removeAllSeries(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
233
|
*/
|
|
233
|
*/
|
|
234
|
void QChart::addSeries(QAbstractSeries *series)
|
|
234
|
void QChart::addSeries(QAbstractSeries *series)
|
|
235
|
{
|
|
235
|
{
|
|
236
|
Q_ASSERT(series);
|
|
236
|
Q_ASSERT(series);
|
|
237
|
d_ptr->m_dataset->addSeries(series);
|
|
237
|
d_ptr->m_dataset->addSeries(series);
|
|
238
|
}
|
|
238
|
}
|
|
239
|
|
|
239
|
|
|
240
|
/*!
|
|
240
|
/*!
|
|
241
|
Removes the \a series from the chart.
|
|
241
|
Removes the \a series from the chart.
|
|
242
|
The chart releases its ownership of the specified \a series object.
|
|
242
|
The chart releases its ownership of the specified \a series object.
|
|
243
|
|
|
243
|
|
|
244
|
\sa addSeries(), removeAllSeries()
|
|
244
|
\sa addSeries(), removeAllSeries()
|
|
245
|
*/
|
|
245
|
*/
|
|
246
|
void QChart::removeSeries(QAbstractSeries *series)
|
|
246
|
void QChart::removeSeries(QAbstractSeries *series)
|
|
247
|
{
|
|
247
|
{
|
|
248
|
Q_ASSERT(series);
|
|
248
|
Q_ASSERT(series);
|
|
249
|
d_ptr->m_dataset->removeSeries(series);
|
|
249
|
d_ptr->m_dataset->removeSeries(series);
|
|
250
|
}
|
|
250
|
}
|
|
251
|
|
|
251
|
|
|
252
|
/*!
|
|
252
|
/*!
|
|
253
|
Removes and deletes all series objects that have been added to the chart.
|
|
253
|
Removes and deletes all series objects that have been added to the chart.
|
|
254
|
|
|
254
|
|
|
255
|
\sa addSeries(), removeSeries()
|
|
255
|
\sa addSeries(), removeSeries()
|
|
256
|
*/
|
|
256
|
*/
|
|
257
|
void QChart::removeAllSeries()
|
|
257
|
void QChart::removeAllSeries()
|
|
258
|
{
|
|
258
|
{
|
|
259
|
foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
|
|
259
|
foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
|
|
260
|
removeSeries(s);
|
|
260
|
removeSeries(s);
|
|
261
|
delete s;
|
|
261
|
delete s;
|
|
262
|
}
|
|
262
|
}
|
|
263
|
}
|
|
263
|
}
|
|
264
|
|
|
264
|
|
|
265
|
/*!
|
|
265
|
/*!
|
|
266
|
Sets the \a brush that is used for painting the background of the chart area.
|
|
266
|
Sets the \a brush that is used for painting the background of the chart area.
|
|
267
|
*/
|
|
267
|
*/
|
|
268
|
void QChart::setBackgroundBrush(const QBrush &brush)
|
|
268
|
void QChart::setBackgroundBrush(const QBrush &brush)
|
|
269
|
{
|
|
269
|
{
|
|
270
|
d_ptr->m_presenter->setBackgroundBrush(brush);
|
|
270
|
d_ptr->m_presenter->setBackgroundBrush(brush);
|
|
271
|
}
|
|
271
|
}
|
|
272
|
|
|
272
|
|
|
273
|
/*!
|
|
273
|
/*!
|
|
274
|
Gets the brush that is used for painting the background of the chart area.
|
|
274
|
Gets the brush that is used for painting the background of the chart area.
|
|
275
|
*/
|
|
275
|
*/
|
|
276
|
QBrush QChart::backgroundBrush() const
|
|
276
|
QBrush QChart::backgroundBrush() const
|
|
277
|
{
|
|
277
|
{
|
|
278
|
return d_ptr->m_presenter->backgroundBrush();
|
|
278
|
return d_ptr->m_presenter->backgroundBrush();
|
|
279
|
}
|
|
279
|
}
|
|
280
|
|
|
280
|
|
|
281
|
/*!
|
|
281
|
/*!
|
|
282
|
Sets the \a pen that is used for painting the background of the chart area.
|
|
282
|
Sets the \a pen that is used for painting the background of the chart area.
|
|
283
|
*/
|
|
283
|
*/
|
|
284
|
void QChart::setBackgroundPen(const QPen &pen)
|
|
284
|
void QChart::setBackgroundPen(const QPen &pen)
|
|
285
|
{
|
|
285
|
{
|
|
286
|
d_ptr->m_presenter->setBackgroundPen(pen);
|
|
286
|
d_ptr->m_presenter->setBackgroundPen(pen);
|
|
287
|
}
|
|
287
|
}
|
|
288
|
|
|
288
|
|
|
289
|
/*!
|
|
289
|
/*!
|
|
290
|
Gets the pen that is used for painting the background of the chart area.
|
|
290
|
Gets the pen that is used for painting the background of the chart area.
|
|
291
|
*/
|
|
291
|
*/
|
|
292
|
QPen QChart::backgroundPen() const
|
|
292
|
QPen QChart::backgroundPen() const
|
|
293
|
{
|
|
293
|
{
|
|
294
|
return d_ptr->m_presenter->backgroundPen();
|
|
294
|
return d_ptr->m_presenter->backgroundPen();
|
|
295
|
}
|
|
295
|
}
|
|
296
|
|
|
296
|
|
|
297
|
void QChart::setTitle(const QString &title)
|
|
297
|
void QChart::setTitle(const QString &title)
|
|
298
|
{
|
|
298
|
{
|
|
299
|
d_ptr->m_presenter->setTitle(title);
|
|
299
|
d_ptr->m_presenter->setTitle(title);
|
|
300
|
}
|
|
300
|
}
|
|
301
|
|
|
301
|
|
|
302
|
QString QChart::title() const
|
|
302
|
QString QChart::title() const
|
|
303
|
{
|
|
303
|
{
|
|
304
|
return d_ptr->m_presenter->title();
|
|
304
|
return d_ptr->m_presenter->title();
|
|
305
|
}
|
|
305
|
}
|
|
306
|
|
|
306
|
|
|
307
|
/*!
|
|
307
|
/*!
|
|
308
|
Sets the \a font that is used for drawing the chart title.
|
|
308
|
Sets the \a font that is used for drawing the chart title.
|
|
309
|
*/
|
|
309
|
*/
|
|
310
|
void QChart::setTitleFont(const QFont &font)
|
|
310
|
void QChart::setTitleFont(const QFont &font)
|
|
311
|
{
|
|
311
|
{
|
|
312
|
d_ptr->m_presenter->setTitleFont(font);
|
|
312
|
d_ptr->m_presenter->setTitleFont(font);
|
|
313
|
}
|
|
313
|
}
|
|
314
|
|
|
314
|
|
|
315
|
/*!
|
|
315
|
/*!
|
|
316
|
Gets the font that is used for drawing the chart title.
|
|
316
|
Gets the font that is used for drawing the chart title.
|
|
317
|
*/
|
|
317
|
*/
|
|
318
|
QFont QChart::titleFont() const
|
|
318
|
QFont QChart::titleFont() const
|
|
319
|
{
|
|
319
|
{
|
|
320
|
return d_ptr->m_presenter->titleFont();
|
|
320
|
return d_ptr->m_presenter->titleFont();
|
|
321
|
}
|
|
321
|
}
|
|
322
|
|
|
322
|
|
|
323
|
/*!
|
|
323
|
/*!
|
|
324
|
Sets the \a brush used for drawing the title text.
|
|
324
|
Sets the \a brush used for drawing the title text.
|
|
325
|
*/
|
|
325
|
*/
|
|
326
|
void QChart::setTitleBrush(const QBrush &brush)
|
|
326
|
void QChart::setTitleBrush(const QBrush &brush)
|
|
327
|
{
|
|
327
|
{
|
|
328
|
d_ptr->m_presenter->setTitleBrush(brush);
|
|
328
|
d_ptr->m_presenter->setTitleBrush(brush);
|
|
329
|
}
|
|
329
|
}
|
|
330
|
|
|
330
|
|
|
331
|
/*!
|
|
331
|
/*!
|
|
332
|
Returns the brush used for drawing the title text.
|
|
332
|
Returns the brush used for drawing the title text.
|
|
333
|
*/
|
|
333
|
*/
|
|
334
|
QBrush QChart::titleBrush() const
|
|
334
|
QBrush QChart::titleBrush() const
|
|
335
|
{
|
|
335
|
{
|
|
336
|
return d_ptr->m_presenter->titleBrush();
|
|
336
|
return d_ptr->m_presenter->titleBrush();
|
|
337
|
}
|
|
337
|
}
|
|
338
|
|
|
338
|
|
|
339
|
void QChart::setTheme(QChart::ChartTheme theme)
|
|
339
|
void QChart::setTheme(QChart::ChartTheme theme)
|
|
340
|
{
|
|
340
|
{
|
|
341
|
d_ptr->m_themeManager->setTheme(theme);
|
|
341
|
d_ptr->m_themeManager->setTheme(theme);
|
|
342
|
}
|
|
342
|
}
|
|
343
|
|
|
343
|
|
|
344
|
QChart::ChartTheme QChart::theme() const
|
|
344
|
QChart::ChartTheme QChart::theme() const
|
|
345
|
{
|
|
345
|
{
|
|
346
|
return d_ptr->m_themeManager->theme()->id();
|
|
346
|
return d_ptr->m_themeManager->theme()->id();
|
|
347
|
}
|
|
347
|
}
|
|
348
|
|
|
348
|
|
|
349
|
/*!
|
|
349
|
/*!
|
|
350
|
Zooms in the view by a factor of two.
|
|
350
|
Zooms in the view by a factor of two.
|
|
351
|
*/
|
|
351
|
*/
|
|
352
|
void QChart::zoomIn()
|
|
352
|
void QChart::zoomIn()
|
|
353
|
{
|
|
353
|
{
|
|
354
|
d_ptr->zoomIn(2.0);
|
|
354
|
d_ptr->zoomIn(2.0);
|
|
355
|
}
|
|
355
|
}
|
|
356
|
|
|
356
|
|
|
|
|
|
357
|
void QChart::zoomIn2(double factor)
|
|
|
|
|
358
|
{
|
|
|
|
|
359
|
d_ptr->zoomIn2(factor);
|
|
|
|
|
360
|
}
|
|
|
|
|
361
|
|
|
357
|
/*!
|
|
362
|
/*!
|
|
358
|
Zooms in the view to a maximum level at which \a rect is still fully visible.
|
|
363
|
Zooms in the view to a maximum level at which \a rect is still fully visible.
|
|
359
|
\note This is not supported for polar charts.
|
|
364
|
\note This is not supported for polar charts.
|
|
360
|
*/
|
|
365
|
*/
|
|
361
|
void QChart::zoomIn(const QRectF &rect)
|
|
366
|
void QChart::zoomIn(const QRectF &rect)
|
|
362
|
{
|
|
367
|
{
|
|
363
|
if (d_ptr->m_type == QChart::ChartTypePolar)
|
|
368
|
if (d_ptr->m_type == QChart::ChartTypePolar)
|
|
364
|
return;
|
|
369
|
return;
|
|
365
|
d_ptr->zoomIn(rect);
|
|
370
|
d_ptr->zoomIn(rect);
|
|
366
|
}
|
|
371
|
}
|
|
367
|
|
|
372
|
|
|
368
|
/*!
|
|
373
|
/*!
|
|
369
|
Zooms out the view by a factor of two.
|
|
374
|
Zooms out the view by a factor of two.
|
|
370
|
*/
|
|
375
|
*/
|
|
371
|
void QChart::zoomOut()
|
|
376
|
void QChart::zoomOut()
|
|
372
|
{
|
|
377
|
{
|
|
373
|
d_ptr->zoomOut(2.0);
|
|
378
|
d_ptr->zoomOut(2.0);
|
|
374
|
}
|
|
379
|
}
|
|
375
|
|
|
380
|
|
|
|
|
|
381
|
void QChart::zoomOut2(double factor)
|
|
|
|
|
382
|
{
|
|
|
|
|
383
|
d_ptr->zoomOut2(factor);
|
|
|
|
|
384
|
}
|
|
|
|
|
385
|
|
|
376
|
/*!
|
|
386
|
/*!
|
|
377
|
Zooms in the view by a custom \a factor.
|
|
387
|
Zooms in the view by a custom \a factor.
|
|
378
|
|
|
388
|
|
|
379
|
A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
|
|
389
|
A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
|
|
380
|
*/
|
|
390
|
*/
|
|
381
|
void QChart::zoom(qreal factor)
|
|
391
|
void QChart::zoom(qreal factor)
|
|
382
|
{
|
|
392
|
{
|
|
383
|
if (qFuzzyCompare(factor, 0))
|
|
393
|
if (qFuzzyCompare(factor, 0))
|
|
384
|
return;
|
|
394
|
return;
|
|
385
|
|
|
395
|
|
|
386
|
if (qFuzzyCompare(factor, (qreal)1.0))
|
|
396
|
if (qFuzzyCompare(factor, (qreal)1.0))
|
|
387
|
return;
|
|
397
|
return;
|
|
388
|
|
|
398
|
|
|
389
|
if (factor < 0)
|
|
399
|
if (factor < 0)
|
|
390
|
return;
|
|
400
|
return;
|
|
391
|
|
|
401
|
|
|
392
|
if (factor > 1.0)
|
|
402
|
if (factor > 1.0)
|
|
393
|
d_ptr->zoomIn(factor);
|
|
403
|
d_ptr->zoomIn(factor);
|
|
394
|
else
|
|
404
|
else
|
|
395
|
d_ptr->zoomOut(1.0 / factor);
|
|
405
|
d_ptr->zoomOut(1.0 / factor);
|
|
396
|
}
|
|
406
|
}
|
|
397
|
|
|
407
|
|
|
398
|
|
|
408
|
|
|
399
|
/*!
|
|
409
|
/*!
|
|
400
|
Resets the series domains to what they were before any zoom method was called.
|
|
410
|
Resets the series domains to what they were before any zoom method was called.
|
|
401
|
Note that this will also reset any scrolls and explicit axis range settings done between
|
|
411
|
Note that this will also reset any scrolls and explicit axis range settings done between
|
|
402
|
the first zoom operation and calling this method. If no zoom operation has been
|
|
412
|
the first zoom operation and calling this method. If no zoom operation has been
|
|
403
|
done, this method does nothing.
|
|
413
|
done, this method does nothing.
|
|
404
|
*/
|
|
414
|
*/
|
|
405
|
void QChart::zoomReset()
|
|
415
|
void QChart::zoomReset()
|
|
406
|
{
|
|
416
|
{
|
|
407
|
d_ptr->zoomReset();
|
|
417
|
d_ptr->zoomReset();
|
|
408
|
}
|
|
418
|
}
|
|
409
|
|
|
419
|
|
|
410
|
/*!
|
|
420
|
/*!
|
|
411
|
Returns true if any series has a zoomed domain.
|
|
421
|
Returns true if any series has a zoomed domain.
|
|
412
|
*/
|
|
422
|
*/
|
|
413
|
bool QChart::isZoomed()
|
|
423
|
bool QChart::isZoomed()
|
|
414
|
{
|
|
424
|
{
|
|
415
|
return d_ptr->isZoomed();
|
|
425
|
return d_ptr->isZoomed();
|
|
416
|
}
|
|
426
|
}
|
|
417
|
|
|
427
|
|
|
418
|
/*!
|
|
428
|
/*!
|
|
419
|
Returns a pointer to the horizontal axis attached to the specified \a series.
|
|
429
|
Returns a pointer to the horizontal axis attached to the specified \a series.
|
|
420
|
If no \a series is specified, the first horizontal axis added to the chart is returned.
|
|
430
|
If no \a series is specified, the first horizontal axis added to the chart is returned.
|
|
421
|
|
|
431
|
|
|
422
|
\sa addAxis(), QAbstractSeries::attachAxis()
|
|
432
|
\sa addAxis(), QAbstractSeries::attachAxis()
|
|
423
|
*/
|
|
433
|
*/
|
|
424
|
QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
|
|
434
|
QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
|
|
425
|
{
|
|
435
|
{
|
|
426
|
QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series);
|
|
436
|
QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series);
|
|
427
|
if (axisList.count())
|
|
437
|
if (axisList.count())
|
|
428
|
return axisList[0];
|
|
438
|
return axisList[0];
|
|
429
|
return 0;
|
|
439
|
return 0;
|
|
430
|
}
|
|
440
|
}
|
|
431
|
|
|
441
|
|
|
432
|
/*!
|
|
442
|
/*!
|
|
433
|
Returns a pointer to the vertical axis attached to the specified \a series.
|
|
443
|
Returns a pointer to the vertical axis attached to the specified \a series.
|
|
434
|
If no \a series is specified, the first vertical axis added to the chart is returned.
|
|
444
|
If no \a series is specified, the first vertical axis added to the chart is returned.
|
|
435
|
|
|
445
|
|
|
436
|
\sa addAxis(), QAbstractSeries::attachAxis()
|
|
446
|
\sa addAxis(), QAbstractSeries::attachAxis()
|
|
437
|
*/
|
|
447
|
*/
|
|
438
|
QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
|
|
448
|
QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
|
|
439
|
{
|
|
449
|
{
|
|
440
|
QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series);
|
|
450
|
QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series);
|
|
441
|
if (axisList.count())
|
|
451
|
if (axisList.count())
|
|
442
|
return axisList[0];
|
|
452
|
return axisList[0];
|
|
443
|
return 0;
|
|
453
|
return 0;
|
|
444
|
}
|
|
454
|
}
|
|
445
|
|
|
455
|
|
|
446
|
/*!
|
|
456
|
/*!
|
|
447
|
Returns the axes attached to the \a series with \a orientation. If no \a series is provided,
|
|
457
|
Returns the axes attached to the \a series with \a orientation. If no \a series is provided,
|
|
448
|
then all axes added to the chart with the specified orientation are returned.
|
|
458
|
then all axes added to the chart with the specified orientation are returned.
|
|
449
|
\sa addAxis(), createDefaultAxes()
|
|
459
|
\sa addAxis(), createDefaultAxes()
|
|
450
|
*/
|
|
460
|
*/
|
|
451
|
QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
|
|
461
|
QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
|
|
452
|
{
|
|
462
|
{
|
|
453
|
QList<QAbstractAxis *> result ;
|
|
463
|
QList<QAbstractAxis *> result ;
|
|
454
|
|
|
464
|
|
|
455
|
if (series) {
|
|
465
|
if (series) {
|
|
456
|
foreach (QAbstractAxis *axis, series->attachedAxes()){
|
|
466
|
foreach (QAbstractAxis *axis, series->attachedAxes()){
|
|
457
|
if (orientation.testFlag(axis->orientation()))
|
|
467
|
if (orientation.testFlag(axis->orientation()))
|
|
458
|
result << axis;
|
|
468
|
result << axis;
|
|
459
|
}
|
|
469
|
}
|
|
460
|
} else {
|
|
470
|
} else {
|
|
461
|
foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){
|
|
471
|
foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){
|
|
462
|
if (orientation.testFlag(axis->orientation()) && !result.contains(axis))
|
|
472
|
if (orientation.testFlag(axis->orientation()) && !result.contains(axis))
|
|
463
|
result << axis;
|
|
473
|
result << axis;
|
|
464
|
}
|
|
474
|
}
|
|
465
|
}
|
|
475
|
}
|
|
466
|
|
|
476
|
|
|
467
|
return result;
|
|
477
|
return result;
|
|
468
|
}
|
|
478
|
}
|
|
469
|
|
|
479
|
|
|
470
|
/*!
|
|
480
|
/*!
|
|
471
|
Creates axes for the chart based on the series that have already been added to the chart. Any axes previously added to
|
|
481
|
Creates axes for the chart based on the series that have already been added to the chart. Any axes previously added to
|
|
472
|
the chart will be deleted.
|
|
482
|
the chart will be deleted.
|
|
473
|
|
|
483
|
|
|
474
|
\note This function has to be called after all series have been added to the chart. The axes created by this function
|
|
484
|
\note This function has to be called after all series have been added to the chart. The axes created by this function
|
|
475
|
will NOT get automatically attached to any series added to the chart after this function has been called.
|
|
485
|
will NOT get automatically attached to any series added to the chart after this function has been called.
|
|
476
|
A series with no axes attached will by default scale to utilize the entire plot area of the chart, which can be confusing
|
|
486
|
A series with no axes attached will by default scale to utilize the entire plot area of the chart, which can be confusing
|
|
477
|
if there are other series with properly attached axes also present.
|
|
487
|
if there are other series with properly attached axes also present.
|
|
478
|
|
|
488
|
|
|
479
|
\table
|
|
489
|
\table
|
|
480
|
\header
|
|
490
|
\header
|
|
481
|
\li Series type
|
|
491
|
\li Series type
|
|
482
|
\li X-axis
|
|
492
|
\li X-axis
|
|
483
|
\li Y-axis
|
|
493
|
\li Y-axis
|
|
484
|
\row
|
|
494
|
\row
|
|
485
|
\li QXYSeries
|
|
495
|
\li QXYSeries
|
|
486
|
\li QValueAxis
|
|
496
|
\li QValueAxis
|
|
487
|
\li QValueAxis
|
|
497
|
\li QValueAxis
|
|
488
|
\row
|
|
498
|
\row
|
|
489
|
\li QBarSeries
|
|
499
|
\li QBarSeries
|
|
490
|
\li QBarCategoryAxis
|
|
500
|
\li QBarCategoryAxis
|
|
491
|
\li QValueAxis
|
|
501
|
\li QValueAxis
|
|
492
|
\row
|
|
502
|
\row
|
|
493
|
\li QPieSeries
|
|
503
|
\li QPieSeries
|
|
494
|
\li None
|
|
504
|
\li None
|
|
495
|
\li None
|
|
505
|
\li None
|
|
496
|
\endtable
|
|
506
|
\endtable
|
|
497
|
|
|
507
|
|
|
498
|
If there are several QXYSeries derived series added to the chart and no series of other types have been added, then only one pair of axes is created.
|
|
508
|
If there are several QXYSeries derived series added to the chart and no series of other types have been added, then only one pair of axes is created.
|
|
499
|
If there are several series of different types added to the chart, then each series gets its own axes pair.
|
|
509
|
If there are several series of different types added to the chart, then each series gets its own axes pair.
|
|
500
|
|
|
510
|
|
|
501
|
The axes specific to the series can be later obtained from the chart by providing the series as the parameter for axes() function call.
|
|
511
|
The axes specific to the series can be later obtained from the chart by providing the series as the parameter for axes() function call.
|
|
502
|
QPieSeries does not create any axes.
|
|
512
|
QPieSeries does not create any axes.
|
|
503
|
|
|
513
|
|
|
504
|
\sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis()
|
|
514
|
\sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis()
|
|
505
|
*/
|
|
515
|
*/
|
|
506
|
void QChart::createDefaultAxes()
|
|
516
|
void QChart::createDefaultAxes()
|
|
507
|
{
|
|
517
|
{
|
|
508
|
d_ptr->m_dataset->createDefaultAxes();
|
|
518
|
d_ptr->m_dataset->createDefaultAxes();
|
|
509
|
}
|
|
519
|
}
|
|
510
|
|
|
520
|
|
|
511
|
/*!
|
|
521
|
/*!
|
|
512
|
Returns the legend object of the chart. Ownership stays with the chart.
|
|
522
|
Returns the legend object of the chart. Ownership stays with the chart.
|
|
513
|
*/
|
|
523
|
*/
|
|
514
|
QLegend *QChart::legend() const
|
|
524
|
QLegend *QChart::legend() const
|
|
515
|
{
|
|
525
|
{
|
|
516
|
return d_ptr->m_legend;
|
|
526
|
return d_ptr->m_legend;
|
|
517
|
}
|
|
527
|
}
|
|
518
|
|
|
528
|
|
|
519
|
void QChart::setMargins(const QMargins &margins)
|
|
529
|
void QChart::setMargins(const QMargins &margins)
|
|
520
|
{
|
|
530
|
{
|
|
521
|
d_ptr->m_presenter->layout()->setMargins(margins);
|
|
531
|
d_ptr->m_presenter->layout()->setMargins(margins);
|
|
522
|
}
|
|
532
|
}
|
|
523
|
|
|
533
|
|
|
524
|
QMargins QChart::margins() const
|
|
534
|
QMargins QChart::margins() const
|
|
525
|
{
|
|
535
|
{
|
|
526
|
return d_ptr->m_presenter->layout()->margins();
|
|
536
|
return d_ptr->m_presenter->layout()->margins();
|
|
527
|
}
|
|
537
|
}
|
|
528
|
|
|
538
|
|
|
529
|
QChart::ChartType QChart::chartType() const
|
|
539
|
QChart::ChartType QChart::chartType() const
|
|
530
|
{
|
|
540
|
{
|
|
531
|
return d_ptr->m_type;
|
|
541
|
return d_ptr->m_type;
|
|
532
|
}
|
|
542
|
}
|
|
533
|
|
|
543
|
|
|
534
|
QRectF QChart::plotArea() const
|
|
544
|
QRectF QChart::plotArea() const
|
|
535
|
{
|
|
545
|
{
|
|
536
|
return d_ptr->m_presenter->geometry();
|
|
546
|
return d_ptr->m_presenter->geometry();
|
|
537
|
}
|
|
547
|
}
|
|
538
|
|
|
548
|
|
|
539
|
/*!
|
|
549
|
/*!
|
|
540
|
Sets the \a brush for the background of the plot area of the chart.
|
|
550
|
Sets the \a brush for the background of the plot area of the chart.
|
|
541
|
|
|
551
|
|
|
542
|
\sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen(), plotAreaBackgroundBrush()
|
|
552
|
\sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen(), plotAreaBackgroundBrush()
|
|
543
|
*/
|
|
553
|
*/
|
|
544
|
void QChart::setPlotAreaBackgroundBrush(const QBrush &brush)
|
|
554
|
void QChart::setPlotAreaBackgroundBrush(const QBrush &brush)
|
|
545
|
{
|
|
555
|
{
|
|
546
|
d_ptr->m_presenter->setPlotAreaBackgroundBrush(brush);
|
|
556
|
d_ptr->m_presenter->setPlotAreaBackgroundBrush(brush);
|
|
547
|
}
|
|
557
|
}
|
|
548
|
|
|
558
|
|
|
549
|
/*!
|
|
559
|
/*!
|
|
550
|
Returns the brush for the background of the plot area of the chart.
|
|
560
|
Returns the brush for the background of the plot area of the chart.
|
|
551
|
|
|
561
|
|
|
552
|
\sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen(), setPlotAreaBackgroundBrush()
|
|
562
|
\sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen(), setPlotAreaBackgroundBrush()
|
|
553
|
*/
|
|
563
|
*/
|
|
554
|
QBrush QChart::plotAreaBackgroundBrush() const
|
|
564
|
QBrush QChart::plotAreaBackgroundBrush() const
|
|
555
|
{
|
|
565
|
{
|
|
556
|
return d_ptr->m_presenter->plotAreaBackgroundBrush();
|
|
566
|
return d_ptr->m_presenter->plotAreaBackgroundBrush();
|
|
557
|
}
|
|
567
|
}
|
|
558
|
|
|
568
|
|
|
559
|
/*!
|
|
569
|
/*!
|
|
560
|
Sets the \a pen for the background of the plot area of the chart.
|
|
570
|
Sets the \a pen for the background of the plot area of the chart.
|
|
561
|
|
|
571
|
|
|
562
|
\sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush(), plotAreaBackgroundPen()
|
|
572
|
\sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush(), plotAreaBackgroundPen()
|
|
563
|
*/
|
|
573
|
*/
|
|
564
|
void QChart::setPlotAreaBackgroundPen(const QPen &pen)
|
|
574
|
void QChart::setPlotAreaBackgroundPen(const QPen &pen)
|
|
565
|
{
|
|
575
|
{
|
|
566
|
d_ptr->m_presenter->setPlotAreaBackgroundPen(pen);
|
|
576
|
d_ptr->m_presenter->setPlotAreaBackgroundPen(pen);
|
|
567
|
}
|
|
577
|
}
|
|
568
|
|
|
578
|
|
|
569
|
/*!
|
|
579
|
/*!
|
|
570
|
Returns the pen for the background of the plot area of the chart.
|
|
580
|
Returns the pen for the background of the plot area of the chart.
|
|
571
|
|
|
581
|
|
|
572
|
\sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush(), setPlotAreaBackgroundPen()
|
|
582
|
\sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush(), setPlotAreaBackgroundPen()
|
|
573
|
*/
|
|
583
|
*/
|
|
574
|
QPen QChart::plotAreaBackgroundPen() const
|
|
584
|
QPen QChart::plotAreaBackgroundPen() const
|
|
575
|
{
|
|
585
|
{
|
|
576
|
return d_ptr->m_presenter->plotAreaBackgroundPen();
|
|
586
|
return d_ptr->m_presenter->plotAreaBackgroundPen();
|
|
577
|
}
|
|
587
|
}
|
|
578
|
|
|
588
|
|
|
579
|
void QChart::setPlotAreaBackgroundVisible(bool visible)
|
|
589
|
void QChart::setPlotAreaBackgroundVisible(bool visible)
|
|
580
|
{
|
|
590
|
{
|
|
581
|
d_ptr->m_presenter->setPlotAreaBackgroundVisible(visible);
|
|
591
|
d_ptr->m_presenter->setPlotAreaBackgroundVisible(visible);
|
|
582
|
}
|
|
592
|
}
|
|
583
|
|
|
593
|
|
|
584
|
bool QChart::isPlotAreaBackgroundVisible() const
|
|
594
|
bool QChart::isPlotAreaBackgroundVisible() const
|
|
585
|
{
|
|
595
|
{
|
|
586
|
return d_ptr->m_presenter->isPlotAreaBackgroundVisible();
|
|
596
|
return d_ptr->m_presenter->isPlotAreaBackgroundVisible();
|
|
587
|
}
|
|
597
|
}
|
|
588
|
|
|
598
|
|
|
589
|
void QChart::setLocalizeNumbers(bool localize)
|
|
599
|
void QChart::setLocalizeNumbers(bool localize)
|
|
590
|
{
|
|
600
|
{
|
|
591
|
d_ptr->m_presenter->setLocalizeNumbers(localize);
|
|
601
|
d_ptr->m_presenter->setLocalizeNumbers(localize);
|
|
592
|
}
|
|
602
|
}
|
|
593
|
|
|
603
|
|
|
594
|
bool QChart::localizeNumbers() const
|
|
604
|
bool QChart::localizeNumbers() const
|
|
595
|
{
|
|
605
|
{
|
|
596
|
return d_ptr->m_presenter->localizeNumbers();
|
|
606
|
return d_ptr->m_presenter->localizeNumbers();
|
|
597
|
}
|
|
607
|
}
|
|
598
|
|
|
608
|
|
|
599
|
void QChart::setLocale(const QLocale &locale)
|
|
609
|
void QChart::setLocale(const QLocale &locale)
|
|
600
|
{
|
|
610
|
{
|
|
601
|
d_ptr->m_presenter->setLocale(locale);
|
|
611
|
d_ptr->m_presenter->setLocale(locale);
|
|
602
|
}
|
|
612
|
}
|
|
603
|
|
|
613
|
|
|
604
|
QLocale QChart::locale() const
|
|
614
|
QLocale QChart::locale() const
|
|
605
|
{
|
|
615
|
{
|
|
606
|
return d_ptr->m_presenter->locale();
|
|
616
|
return d_ptr->m_presenter->locale();
|
|
607
|
}
|
|
617
|
}
|
|
608
|
|
|
618
|
|
|
609
|
void QChart::setAnimationOptions(AnimationOptions options)
|
|
619
|
void QChart::setAnimationOptions(AnimationOptions options)
|
|
610
|
{
|
|
620
|
{
|
|
611
|
d_ptr->m_presenter->setAnimationOptions(options);
|
|
621
|
d_ptr->m_presenter->setAnimationOptions(options);
|
|
612
|
}
|
|
622
|
}
|
|
613
|
|
|
623
|
|
|
614
|
QChart::AnimationOptions QChart::animationOptions() const
|
|
624
|
QChart::AnimationOptions QChart::animationOptions() const
|
|
615
|
{
|
|
625
|
{
|
|
616
|
return d_ptr->m_presenter->animationOptions();
|
|
626
|
return d_ptr->m_presenter->animationOptions();
|
|
617
|
}
|
|
627
|
}
|
|
618
|
|
|
628
|
|
|
619
|
void QChart::setAnimationDuration(int msecs)
|
|
629
|
void QChart::setAnimationDuration(int msecs)
|
|
620
|
{
|
|
630
|
{
|
|
621
|
d_ptr->m_presenter->setAnimationDuration(msecs);
|
|
631
|
d_ptr->m_presenter->setAnimationDuration(msecs);
|
|
622
|
}
|
|
632
|
}
|
|
623
|
|
|
633
|
|
|
624
|
int QChart::animationDuration() const
|
|
634
|
int QChart::animationDuration() const
|
|
625
|
{
|
|
635
|
{
|
|
626
|
return d_ptr->m_presenter->animationDuration();
|
|
636
|
return d_ptr->m_presenter->animationDuration();
|
|
627
|
}
|
|
637
|
}
|
|
628
|
|
|
638
|
|
|
629
|
void QChart::setAnimationEasingCurve(const QEasingCurve &curve)
|
|
639
|
void QChart::setAnimationEasingCurve(const QEasingCurve &curve)
|
|
630
|
{
|
|
640
|
{
|
|
631
|
d_ptr->m_presenter->setAnimationEasingCurve(curve);
|
|
641
|
d_ptr->m_presenter->setAnimationEasingCurve(curve);
|
|
632
|
}
|
|
642
|
}
|
|
633
|
|
|
643
|
|
|
634
|
QEasingCurve QChart::animationEasingCurve() const
|
|
644
|
QEasingCurve QChart::animationEasingCurve() const
|
|
635
|
{
|
|
645
|
{
|
|
636
|
return d_ptr->m_presenter->animationEasingCurve();
|
|
646
|
return d_ptr->m_presenter->animationEasingCurve();
|
|
637
|
}
|
|
647
|
}
|
|
638
|
|
|
648
|
|
|
639
|
/*!
|
|
649
|
/*!
|
|
640
|
Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
|
|
650
|
Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
|
|
641
|
|
|
651
|
|
|
642
|
For polar charts, \a dx indicates the angle along angular axis instead of distance.
|
|
652
|
For polar charts, \a dx indicates the angle along angular axis instead of distance.
|
|
643
|
*/
|
|
653
|
*/
|
|
644
|
void QChart::scroll(qreal dx, qreal dy)
|
|
654
|
void QChart::scroll(qreal dx, qreal dy)
|
|
645
|
{
|
|
655
|
{
|
|
646
|
d_ptr->scroll(dx,dy);
|
|
656
|
d_ptr->scroll(dx,dy);
|
|
647
|
}
|
|
657
|
}
|
|
648
|
|
|
658
|
|
|
649
|
void QChart::setBackgroundVisible(bool visible)
|
|
659
|
void QChart::setBackgroundVisible(bool visible)
|
|
650
|
{
|
|
660
|
{
|
|
651
|
d_ptr->m_presenter->setBackgroundVisible(visible);
|
|
661
|
d_ptr->m_presenter->setBackgroundVisible(visible);
|
|
652
|
}
|
|
662
|
}
|
|
653
|
|
|
663
|
|
|
654
|
bool QChart::isBackgroundVisible() const
|
|
664
|
bool QChart::isBackgroundVisible() const
|
|
655
|
{
|
|
665
|
{
|
|
656
|
return d_ptr->m_presenter->isBackgroundVisible();
|
|
666
|
return d_ptr->m_presenter->isBackgroundVisible();
|
|
657
|
}
|
|
667
|
}
|
|
658
|
|
|
668
|
|
|
659
|
void QChart::setDropShadowEnabled(bool enabled)
|
|
669
|
void QChart::setDropShadowEnabled(bool enabled)
|
|
660
|
{
|
|
670
|
{
|
|
661
|
d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
|
|
671
|
d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
|
|
662
|
}
|
|
672
|
}
|
|
663
|
|
|
673
|
|
|
664
|
bool QChart::isDropShadowEnabled() const
|
|
674
|
bool QChart::isDropShadowEnabled() const
|
|
665
|
{
|
|
675
|
{
|
|
666
|
return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
|
|
676
|
return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
|
|
667
|
}
|
|
677
|
}
|
|
668
|
|
|
678
|
|
|
669
|
void QChart::setBackgroundRoundness(qreal diameter)
|
|
679
|
void QChart::setBackgroundRoundness(qreal diameter)
|
|
670
|
{
|
|
680
|
{
|
|
671
|
d_ptr->m_presenter->setBackgroundRoundness(diameter);
|
|
681
|
d_ptr->m_presenter->setBackgroundRoundness(diameter);
|
|
672
|
}
|
|
682
|
}
|
|
673
|
|
|
683
|
|
|
674
|
qreal QChart::backgroundRoundness() const
|
|
684
|
qreal QChart::backgroundRoundness() const
|
|
675
|
{
|
|
685
|
{
|
|
676
|
return d_ptr->m_presenter->backgroundRoundness();
|
|
686
|
return d_ptr->m_presenter->backgroundRoundness();
|
|
677
|
}
|
|
687
|
}
|
|
678
|
|
|
688
|
|
|
679
|
/*!
|
|
689
|
/*!
|
|
680
|
Returns all series that are added to the chart.
|
|
690
|
Returns all series that are added to the chart.
|
|
681
|
|
|
691
|
|
|
682
|
\sa addSeries(), removeSeries(), removeAllSeries()
|
|
692
|
\sa addSeries(), removeSeries(), removeAllSeries()
|
|
683
|
*/
|
|
693
|
*/
|
|
684
|
QList<QAbstractSeries *> QChart::series() const
|
|
694
|
QList<QAbstractSeries *> QChart::series() const
|
|
685
|
{
|
|
695
|
{
|
|
686
|
return d_ptr->m_dataset->series();
|
|
696
|
return d_ptr->m_dataset->series();
|
|
687
|
}
|
|
697
|
}
|
|
688
|
|
|
698
|
|
|
689
|
/*!
|
|
699
|
/*!
|
|
690
|
Adds the \a axis to the chart and attaches it to the \a series as a bottom-aligned horizontal axis.
|
|
700
|
Adds the \a axis to the chart and attaches it to the \a series as a bottom-aligned horizontal axis.
|
|
691
|
The chart takes ownership of both the \a axis and the \a series.
|
|
701
|
The chart takes ownership of both the \a axis and the \a series.
|
|
692
|
Any horizontal axes previously attached to the \a series are deleted.
|
|
702
|
Any horizontal axes previously attached to the \a series are deleted.
|
|
693
|
|
|
703
|
|
|
694
|
\sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
704
|
\sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
695
|
*/
|
|
705
|
*/
|
|
696
|
void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series)
|
|
706
|
void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series)
|
|
697
|
{
|
|
707
|
{
|
|
698
|
QList<QAbstractAxis*> list = axes(Qt::Horizontal, series);
|
|
708
|
QList<QAbstractAxis*> list = axes(Qt::Horizontal, series);
|
|
699
|
|
|
709
|
|
|
700
|
foreach (QAbstractAxis* a, list) {
|
|
710
|
foreach (QAbstractAxis* a, list) {
|
|
701
|
d_ptr->m_dataset->removeAxis(a);
|
|
711
|
d_ptr->m_dataset->removeAxis(a);
|
|
702
|
delete a;
|
|
712
|
delete a;
|
|
703
|
}
|
|
713
|
}
|
|
704
|
|
|
714
|
|
|
705
|
if (!d_ptr->m_dataset->axes().contains(axis))
|
|
715
|
if (!d_ptr->m_dataset->axes().contains(axis))
|
|
706
|
d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom);
|
|
716
|
d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom);
|
|
707
|
d_ptr->m_dataset->attachAxis(series, axis);
|
|
717
|
d_ptr->m_dataset->attachAxis(series, axis);
|
|
708
|
}
|
|
718
|
}
|
|
709
|
|
|
719
|
|
|
710
|
/*!
|
|
720
|
/*!
|
|
711
|
Adds the \a axis to the chart and attaches it to the \a series as a left-aligned vertical axis.
|
|
721
|
Adds the \a axis to the chart and attaches it to the \a series as a left-aligned vertical axis.
|
|
712
|
The chart takes ownership of both the \a axis and the \a series.
|
|
722
|
The chart takes ownership of both the \a axis and the \a series.
|
|
713
|
Any vertical axes previously attached to the \a series are deleted.
|
|
723
|
Any vertical axes previously attached to the \a series are deleted.
|
|
714
|
|
|
724
|
|
|
715
|
\sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
725
|
\sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
716
|
*/
|
|
726
|
*/
|
|
717
|
void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series)
|
|
727
|
void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series)
|
|
718
|
{
|
|
728
|
{
|
|
719
|
QList<QAbstractAxis*> list = axes(Qt::Vertical, series);
|
|
729
|
QList<QAbstractAxis*> list = axes(Qt::Vertical, series);
|
|
720
|
|
|
730
|
|
|
721
|
foreach (QAbstractAxis* a, list) {
|
|
731
|
foreach (QAbstractAxis* a, list) {
|
|
722
|
d_ptr->m_dataset->removeAxis(a);
|
|
732
|
d_ptr->m_dataset->removeAxis(a);
|
|
723
|
delete a;
|
|
733
|
delete a;
|
|
724
|
}
|
|
734
|
}
|
|
725
|
|
|
735
|
|
|
726
|
if (!d_ptr->m_dataset->axes().contains(axis))
|
|
736
|
if (!d_ptr->m_dataset->axes().contains(axis))
|
|
727
|
d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft);
|
|
737
|
d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft);
|
|
728
|
d_ptr->m_dataset->attachAxis(series, axis);
|
|
738
|
d_ptr->m_dataset->attachAxis(series, axis);
|
|
729
|
}
|
|
739
|
}
|
|
730
|
|
|
740
|
|
|
731
|
/*!
|
|
741
|
/*!
|
|
732
|
Adds the \a axis to the chart with \a alignment. The chart takes the ownership of the axis.
|
|
742
|
Adds the \a axis to the chart with \a alignment. The chart takes the ownership of the axis.
|
|
733
|
|
|
743
|
|
|
734
|
\sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
744
|
\sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis()
|
|
735
|
*/
|
|
745
|
*/
|
|
736
|
void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
|
|
746
|
void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
|
|
737
|
{
|
|
747
|
{
|
|
738
|
d_ptr->m_dataset->addAxis(axis, alignment);
|
|
748
|
d_ptr->m_dataset->addAxis(axis, alignment);
|
|
739
|
}
|
|
749
|
}
|
|
740
|
|
|
750
|
|
|
741
|
/*!
|
|
751
|
/*!
|
|
742
|
Removes the \a axis from the chart.
|
|
752
|
Removes the \a axis from the chart.
|
|
743
|
The chart releases its ownership of the specified \a axis object.
|
|
753
|
The chart releases its ownership of the specified \a axis object.
|
|
744
|
|
|
754
|
|
|
745
|
\sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis()
|
|
755
|
\sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis()
|
|
746
|
*/
|
|
756
|
*/
|
|
747
|
void QChart::removeAxis(QAbstractAxis *axis)
|
|
757
|
void QChart::removeAxis(QAbstractAxis *axis)
|
|
748
|
{
|
|
758
|
{
|
|
749
|
d_ptr->m_dataset->removeAxis(axis);
|
|
759
|
d_ptr->m_dataset->removeAxis(axis);
|
|
750
|
}
|
|
760
|
}
|
|
751
|
|
|
761
|
|
|
752
|
/*!
|
|
762
|
/*!
|
|
753
|
Returns the value in the \a series domain that corresponds to the \a position relative to chart widget.
|
|
763
|
Returns the value in the \a series domain that corresponds to the \a position relative to chart widget.
|
|
754
|
*/
|
|
764
|
*/
|
|
755
|
QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series)
|
|
765
|
QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series)
|
|
756
|
{
|
|
766
|
{
|
|
757
|
return d_ptr->m_dataset->mapToValue(position, series);
|
|
767
|
return d_ptr->m_dataset->mapToValue(position, series);
|
|
758
|
}
|
|
768
|
}
|
|
759
|
|
|
769
|
|
|
760
|
/*!
|
|
770
|
/*!
|
|
761
|
Returns the position on the chart widget that corresponds to the \a value in the \a series domain.
|
|
771
|
Returns the position on the chart widget that corresponds to the \a value in the \a series domain.
|
|
762
|
*/
|
|
772
|
*/
|
|
763
|
QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series)
|
|
773
|
QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series)
|
|
764
|
{
|
|
774
|
{
|
|
765
|
return d_ptr->m_dataset->mapToPosition(value, series);
|
|
775
|
return d_ptr->m_dataset->mapToPosition(value, series);
|
|
766
|
}
|
|
776
|
}
|
|
767
|
|
|
777
|
|
|
768
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
778
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
769
|
|
|
779
|
|
|
770
|
QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
|
|
780
|
QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
|
|
771
|
q_ptr(q),
|
|
781
|
q_ptr(q),
|
|
772
|
m_legend(0),
|
|
782
|
m_legend(0),
|
|
773
|
m_dataset(new ChartDataSet(q)),
|
|
783
|
m_dataset(new ChartDataSet(q)),
|
|
774
|
m_presenter(new ChartPresenter(q, type)),
|
|
784
|
m_presenter(new ChartPresenter(q, type)),
|
|
775
|
m_themeManager(new ChartThemeManager(q)),
|
|
785
|
m_themeManager(new ChartThemeManager(q)),
|
|
776
|
m_type(type)
|
|
786
|
m_type(type)
|
|
777
|
{
|
|
787
|
{
|
|
778
|
QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
|
|
788
|
QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
|
|
779
|
QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
|
|
789
|
QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
|
|
780
|
QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
|
|
790
|
QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
|
|
781
|
QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
|
|
791
|
QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
|
|
782
|
QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
|
|
792
|
QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
|
|
783
|
QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
|
|
793
|
QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
|
|
784
|
QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
|
|
794
|
QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
|
|
785
|
QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
|
|
795
|
QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
|
|
786
|
QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged);
|
|
796
|
QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged);
|
|
787
|
}
|
|
797
|
}
|
|
788
|
|
|
798
|
|
|
789
|
QChartPrivate::~QChartPrivate()
|
|
799
|
QChartPrivate::~QChartPrivate()
|
|
790
|
{
|
|
800
|
{
|
|
791
|
delete m_themeManager;
|
|
801
|
delete m_themeManager;
|
|
792
|
}
|
|
802
|
}
|
|
793
|
|
|
803
|
|
|
794
|
// Hackish solution to the problem of explicitly assigning the default pen/brush/font
|
|
804
|
// Hackish solution to the problem of explicitly assigning the default pen/brush/font
|
|
795
|
// to a series or axis and having theme override it:
|
|
805
|
// to a series or axis and having theme override it:
|
|
796
|
// Initialize pens, brushes, and fonts to something nobody is likely to ever use,
|
|
806
|
// Initialize pens, brushes, and fonts to something nobody is likely to ever use,
|
|
797
|
// so that default theme initialization will always set these properly.
|
|
807
|
// so that default theme initialization will always set these properly.
|
|
798
|
QPen &QChartPrivate::defaultPen()
|
|
808
|
QPen &QChartPrivate::defaultPen()
|
|
799
|
{
|
|
809
|
{
|
|
800
|
static QPen defaultPen(QColor(1, 2, 0), 0.93247536);
|
|
810
|
static QPen defaultPen(QColor(1, 2, 0), 0.93247536);
|
|
801
|
return defaultPen;
|
|
811
|
return defaultPen;
|
|
802
|
}
|
|
812
|
}
|
|
803
|
|
|
813
|
|
|
804
|
QBrush &QChartPrivate::defaultBrush()
|
|
814
|
QBrush &QChartPrivate::defaultBrush()
|
|
805
|
{
|
|
815
|
{
|
|
806
|
static QBrush defaultBrush(QColor(1, 2, 0), Qt::Dense7Pattern);
|
|
816
|
static QBrush defaultBrush(QColor(1, 2, 0), Qt::Dense7Pattern);
|
|
807
|
return defaultBrush;
|
|
817
|
return defaultBrush;
|
|
808
|
}
|
|
818
|
}
|
|
809
|
|
|
819
|
|
|
810
|
QFont &QChartPrivate::defaultFont()
|
|
820
|
QFont &QChartPrivate::defaultFont()
|
|
811
|
{
|
|
821
|
{
|
|
812
|
static bool defaultFontInitialized(false);
|
|
822
|
static bool defaultFontInitialized(false);
|
|
813
|
static QFont defaultFont;
|
|
823
|
static QFont defaultFont;
|
|
814
|
if (!defaultFontInitialized) {
|
|
824
|
if (!defaultFontInitialized) {
|
|
815
|
defaultFont.setPointSizeF(8.34563465);
|
|
825
|
defaultFont.setPointSizeF(8.34563465);
|
|
816
|
defaultFontInitialized = true;
|
|
826
|
defaultFontInitialized = true;
|
|
817
|
}
|
|
827
|
}
|
|
818
|
return defaultFont;
|
|
828
|
return defaultFont;
|
|
819
|
}
|
|
829
|
}
|
|
820
|
|
|
830
|
|
|
821
|
void QChartPrivate::init()
|
|
831
|
void QChartPrivate::init()
|
|
822
|
{
|
|
832
|
{
|
|
823
|
m_legend = new LegendScroller(q_ptr);
|
|
833
|
m_legend = new LegendScroller(q_ptr);
|
|
824
|
q_ptr->setTheme(QChart::ChartThemeLight);
|
|
834
|
q_ptr->setTheme(QChart::ChartThemeLight);
|
|
825
|
q_ptr->setLayout(m_presenter->layout());
|
|
835
|
q_ptr->setLayout(m_presenter->layout());
|
|
826
|
}
|
|
836
|
}
|
|
827
|
|
|
837
|
|
|
828
|
void QChartPrivate::zoomIn(qreal factor)
|
|
838
|
void QChartPrivate::zoomIn(qreal factor)
|
|
829
|
{
|
|
839
|
{
|
|
830
|
QRectF rect = m_presenter->geometry();
|
|
840
|
QRectF rect = m_presenter->geometry();
|
|
831
|
rect.setWidth(rect.width() / factor);
|
|
841
|
rect.setWidth(rect.width() / factor);
|
|
832
|
rect.setHeight(rect.height() / factor);
|
|
842
|
rect.setHeight(rect.height() / factor);
|
|
833
|
rect.moveCenter(m_presenter->geometry().center());
|
|
843
|
rect.moveCenter(m_presenter->geometry().center());
|
|
834
|
zoomIn(rect);
|
|
844
|
zoomIn(rect);
|
|
835
|
}
|
|
845
|
}
|
|
836
|
|
|
846
|
|
|
|
|
|
847
|
void QChartPrivate::zoomIn2(qreal factor)
|
|
|
|
|
848
|
{
|
|
|
|
|
849
|
QRectF rect = m_presenter->geometry();
|
|
|
|
|
850
|
rect.setWidth(rect.width() / factor);
|
|
|
|
|
851
|
rect.moveCenter(m_presenter->geometry().center());
|
|
|
|
|
852
|
zoomIn(rect);
|
|
|
|
|
853
|
}
|
|
|
|
|
854
|
|
|
837
|
void QChartPrivate::zoomIn(const QRectF &rect)
|
|
855
|
void QChartPrivate::zoomIn(const QRectF &rect)
|
|
838
|
{
|
|
856
|
{
|
|
839
|
if (!rect.isValid())
|
|
857
|
if (!rect.isValid())
|
|
840
|
return;
|
|
858
|
return;
|
|
841
|
|
|
859
|
|
|
842
|
QRectF r = rect.normalized();
|
|
860
|
QRectF r = rect.normalized();
|
|
843
|
const QRectF geometry = m_presenter->geometry();
|
|
861
|
const QRectF geometry = m_presenter->geometry();
|
|
844
|
r.translate(-geometry.topLeft());
|
|
862
|
r.translate(-geometry.topLeft());
|
|
845
|
|
|
863
|
|
|
846
|
if (!r.isValid())
|
|
864
|
if (!r.isValid())
|
|
847
|
return;
|
|
865
|
return;
|
|
848
|
|
|
866
|
|
|
849
|
QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
|
|
867
|
QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
|
|
850
|
m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
|
|
868
|
m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
|
|
851
|
m_dataset->zoomInDomain(r);
|
|
869
|
m_dataset->zoomInDomain(r);
|
|
852
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
870
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
853
|
|
|
871
|
|
|
854
|
}
|
|
872
|
}
|
|
855
|
|
|
873
|
|
|
856
|
void QChartPrivate::zoomReset()
|
|
874
|
void QChartPrivate::zoomReset()
|
|
857
|
{
|
|
875
|
{
|
|
858
|
m_dataset->zoomResetDomain();
|
|
876
|
m_dataset->zoomResetDomain();
|
|
859
|
}
|
|
877
|
}
|
|
860
|
|
|
878
|
|
|
861
|
bool QChartPrivate::isZoomed()
|
|
879
|
bool QChartPrivate::isZoomed()
|
|
862
|
{
|
|
880
|
{
|
|
863
|
return m_dataset->isZoomedDomain();
|
|
881
|
return m_dataset->isZoomedDomain();
|
|
864
|
}
|
|
882
|
}
|
|
865
|
|
|
883
|
|
|
866
|
void QChartPrivate::zoomOut(qreal factor)
|
|
884
|
void QChartPrivate::zoomOut(qreal factor)
|
|
867
|
{
|
|
885
|
{
|
|
868
|
const QRectF geometry = m_presenter->geometry();
|
|
886
|
const QRectF geometry = m_presenter->geometry();
|
|
869
|
|
|
887
|
|
|
870
|
QRectF r;
|
|
888
|
QRectF r;
|
|
871
|
r.setSize(geometry.size() / factor);
|
|
889
|
r.setSize(geometry.size() / factor);
|
|
872
|
r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
|
|
890
|
r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
|
|
873
|
if (!r.isValid())
|
|
891
|
if (!r.isValid())
|
|
874
|
return;
|
|
892
|
return;
|
|
875
|
|
|
893
|
|
|
876
|
QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
|
|
894
|
QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
|
|
877
|
m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
|
|
895
|
m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
|
|
878
|
m_dataset->zoomOutDomain(r);
|
|
896
|
m_dataset->zoomOutDomain(r);
|
|
879
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
897
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
880
|
}
|
|
898
|
}
|
|
881
|
|
|
899
|
|
|
|
|
|
900
|
void QChartPrivate::zoomOut2(qreal factor)
|
|
|
|
|
901
|
{
|
|
|
|
|
902
|
const QRectF geometry = m_presenter->geometry();
|
|
|
|
|
903
|
|
|
|
|
|
904
|
QRectF r;
|
|
|
|
|
905
|
QSizeF size = geometry.size();
|
|
|
|
|
906
|
size.setWidth(size.width()/factor);
|
|
|
|
|
907
|
r.setSize(size);
|
|
|
|
|
908
|
r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
|
|
|
|
|
909
|
if (!r.isValid())
|
|
|
|
|
910
|
return;
|
|
|
|
|
911
|
|
|
|
|
|
912
|
QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
|
|
|
|
|
913
|
m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
|
|
|
|
|
914
|
m_dataset->zoomOutDomain(r);
|
|
|
|
|
915
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
|
|
|
916
|
}
|
|
|
|
|
917
|
|
|
882
|
void QChartPrivate::scroll(qreal dx, qreal dy)
|
|
918
|
void QChartPrivate::scroll(qreal dx, qreal dy)
|
|
883
|
{
|
|
919
|
{
|
|
884
|
if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
|
|
920
|
if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
|
|
885
|
if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
|
|
921
|
if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
|
|
886
|
if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
|
|
922
|
if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
|
|
887
|
if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
|
|
923
|
if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
|
|
888
|
|
|
924
|
|
|
889
|
m_dataset->scrollDomain(dx, dy);
|
|
925
|
m_dataset->scrollDomain(dx, dy);
|
|
890
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
926
|
m_presenter->setState(ChartPresenter::ShowState,QPointF());
|
|
891
|
}
|
|
927
|
}
|
|
892
|
|
|
928
|
|
|
893
|
#include "moc_qchart.cpp"
|
|
929
|
#include "moc_qchart.cpp"
|
|
894
|
|
|
930
|
|
|
895
|
QT_CHARTS_END_NAMESPACE
|
|
931
|
QT_CHARTS_END_NAMESPACE
|