@@ -0,0 +1,8 | |||||
|
1 | !include( ../examples.pri ) { | |||
|
2 | error( "Couldn't find the examples.pri file!" ) | |||
|
3 | } | |||
|
4 | ||||
|
5 | TARGET = colormap | |||
|
6 | SOURCES += main.cpp | |||
|
7 | ||||
|
8 | HEADERS += |
@@ -0,0 +1,80 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the ColorMapChart API | |||
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Hugo Winter | |||
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | ||||
|
23 | #include <QtWidgets/QApplication> | |||
|
24 | #include <QtWidgets/QMainWindow> | |||
|
25 | #include <QtCharts/QChartView> | |||
|
26 | #include <QtCharts/QColorMapSeries> | |||
|
27 | #include <QtCharts/colormapdatapart.h> | |||
|
28 | ||||
|
29 | QT_CHARTS_USE_NAMESPACE | |||
|
30 | ||||
|
31 | int main(int argc, char *argv[]) | |||
|
32 | { | |||
|
33 | QApplication a(argc, argv); | |||
|
34 | ||||
|
35 | QVector<double> *xSeries = new QVector<double>(); | |||
|
36 | xSeries->reserve(1028); | |||
|
37 | for(int i=0;i<1028;i++) | |||
|
38 | { | |||
|
39 | xSeries->append(i); | |||
|
40 | } | |||
|
41 | QVector<double> *ySeries = new QVector<double>(); | |||
|
42 | ySeries->reserve(768); | |||
|
43 | for(int i=0;i<768;i++) | |||
|
44 | { | |||
|
45 | ySeries->append(i); | |||
|
46 | } | |||
|
47 | QVector<double> *zSeries = new QVector<double>(); | |||
|
48 | zSeries->reserve(1028*768); | |||
|
49 | for(int i=0;i<1028*768;i++) | |||
|
50 | { | |||
|
51 | zSeries->append(i); | |||
|
52 | } | |||
|
53 | ||||
|
54 | ColorMapDataPart * data = new ColorMapDataPart(xSeries,ySeries,zSeries); | |||
|
55 | ||||
|
56 | QColorMapSeries *series = new QColorMapSeries(); | |||
|
57 | series->append(data); | |||
|
58 | ||||
|
59 | QChart *chart = new QChart(); | |||
|
60 | chart->addSeries(series); | |||
|
61 | ||||
|
62 | chart->createDefaultAxes(); | |||
|
63 | ||||
|
64 | chart->setTitle("Simple Colormap Example"); | |||
|
65 | ||||
|
66 | chart->axisX()->setGridLineVisible(false); | |||
|
67 | chart->axisY()->setGridLineVisible(false); | |||
|
68 | ||||
|
69 | chart->legend()->setVisible(false); | |||
|
70 | ||||
|
71 | QChartView *chartView = new QChartView(chart); | |||
|
72 | chartView->setRenderHint(QPainter::Antialiasing); | |||
|
73 | ||||
|
74 | QMainWindow window; | |||
|
75 | window.setCentralWidget(chartView); | |||
|
76 | window.resize(400, 400); | |||
|
77 | window.show(); | |||
|
78 | ||||
|
79 | return a.exec(); | |||
|
80 | } |
@@ -1,66 +1,67 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | SUBDIRS += areachart \ |
|
2 | SUBDIRS += areachart \ | |
3 | customchart \ |
|
3 | customchart \ | |
4 | linechart \ |
|
4 | linechart \ | |
5 | percentbarchart \ |
|
5 | percentbarchart \ | |
6 | piechart \ |
|
6 | piechart \ | |
7 | piechartdrilldown \ |
|
7 | piechartdrilldown \ | |
8 | scatterchart \ |
|
8 | scatterchart \ | |
9 | scatterinteractions \ |
|
9 | scatterinteractions \ | |
10 | splinechart \ |
|
10 | splinechart \ | |
11 | stackedbarchart \ |
|
11 | stackedbarchart \ | |
12 | stackedbarchartdrilldown \ |
|
12 | stackedbarchartdrilldown \ | |
13 | zoomlinechart \ |
|
13 | zoomlinechart \ | |
14 | modeldata \ |
|
14 | modeldata \ | |
15 | barchart \ |
|
15 | barchart \ | |
16 | boxplotchart \ |
|
16 | boxplotchart \ | |
17 | legend \ |
|
17 | legend \ | |
18 | barmodelmapper \ |
|
18 | barmodelmapper \ | |
19 | lineandbar \ |
|
19 | lineandbar \ | |
20 | horizontalbarchart \ |
|
20 | horizontalbarchart \ | |
21 | horizontalstackedbarchart \ |
|
21 | horizontalstackedbarchart \ | |
22 | horizontalpercentbarchart \ |
|
22 | horizontalpercentbarchart \ | |
23 | donutbreakdown \ |
|
23 | donutbreakdown \ | |
24 | temperaturerecords \ |
|
24 | temperaturerecords \ | |
25 | donutchart \ |
|
25 | donutchart \ | |
26 | multiaxis \ |
|
26 | multiaxis \ | |
27 | legendmarkers \ |
|
27 | legendmarkers \ | |
28 | logvalueaxis \ |
|
28 | logvalueaxis \ | |
29 | polarchart \ |
|
29 | polarchart \ | |
30 | piechartcustomization \ |
|
30 | piechartcustomization \ | |
31 | dynamicspline \ |
|
31 | dynamicspline \ | |
32 | nesteddonuts \ |
|
32 | nesteddonuts \ | |
33 | chartinteractions \ |
|
33 | chartinteractions \ | |
34 | callout \ |
|
34 | callout \ | |
35 | chartthemes |
|
35 | chartthemes \ | |
|
36 | colormap | |||
36 |
|
37 | |||
37 | qtHaveModule(quick) { |
|
38 | qtHaveModule(quick) { | |
38 | SUBDIRS += qmlboxplot \ |
|
39 | SUBDIRS += qmlboxplot \ | |
39 | qmlpiechart \ |
|
40 | qmlpiechart \ | |
40 | qmlweather \ |
|
41 | qmlweather \ | |
41 | qmlf1legends \ |
|
42 | qmlf1legends \ | |
42 | qmlcustomizations \ |
|
43 | qmlcustomizations \ | |
43 | qmlaxes \ |
|
44 | qmlaxes \ | |
44 | qmlcustomlegend \ |
|
45 | qmlcustomlegend \ | |
45 | qmlpolarchart \ |
|
46 | qmlpolarchart \ | |
46 | qmlchart \ |
|
47 | qmlchart \ | |
47 | qmloscilloscope |
|
48 | qmloscilloscope | |
48 | } |
|
49 | } | |
49 |
|
50 | |||
50 | qtHaveModule(multimedia) { |
|
51 | qtHaveModule(multimedia) { | |
51 | SUBDIRS += audio |
|
52 | SUBDIRS += audio | |
52 | } else { |
|
53 | } else { | |
53 | message("QtMultimedia library not available. Some examples are disabled.") |
|
54 | message("QtMultimedia library not available. Some examples are disabled.") | |
54 | } |
|
55 | } | |
55 |
|
56 | |||
56 | contains(QT_CONFIG, opengl) { |
|
57 | contains(QT_CONFIG, opengl) { | |
57 | SUBDIRS += openglseries |
|
58 | SUBDIRS += openglseries | |
58 | } else { |
|
59 | } else { | |
59 | message("OpenGL not available. Some examples are disabled.") |
|
60 | message("OpenGL not available. Some examples are disabled.") | |
60 | } |
|
61 | } | |
61 |
|
62 | |||
62 | !contains(QT_COORD_TYPE, float): { |
|
63 | !contains(QT_COORD_TYPE, float): { | |
63 | SUBDIRS += \ |
|
64 | SUBDIRS += \ | |
64 | datetimeaxis |
|
65 | datetimeaxis | |
65 | } |
|
66 | } | |
66 |
|
67 |
@@ -1,931 +1,937 | |||||
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) |
|
357 | void QChart::zoomIn2(double factor, Qt::Orientation orientation) | |
358 | { |
|
358 | { | |
359 | d_ptr->zoomIn2(factor); |
|
359 | d_ptr->zoomIn2(factor, orientation); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | /*! |
|
362 | /*! | |
363 | 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. | |
364 | \note This is not supported for polar charts. |
|
364 | \note This is not supported for polar charts. | |
365 | */ |
|
365 | */ | |
366 | void QChart::zoomIn(const QRectF &rect) |
|
366 | void QChart::zoomIn(const QRectF &rect) | |
367 | { |
|
367 | { | |
368 | if (d_ptr->m_type == QChart::ChartTypePolar) |
|
368 | if (d_ptr->m_type == QChart::ChartTypePolar) | |
369 | return; |
|
369 | return; | |
370 | d_ptr->zoomIn(rect); |
|
370 | d_ptr->zoomIn(rect); | |
371 | } |
|
371 | } | |
372 |
|
372 | |||
373 | /*! |
|
373 | /*! | |
374 | Zooms out the view by a factor of two. |
|
374 | Zooms out the view by a factor of two. | |
375 | */ |
|
375 | */ | |
376 | void QChart::zoomOut() |
|
376 | void QChart::zoomOut() | |
377 | { |
|
377 | { | |
378 | d_ptr->zoomOut(2.0); |
|
378 | d_ptr->zoomOut(2.0); | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | void QChart::zoomOut2(double factor) |
|
381 | void QChart::zoomOut2(double factor, Qt::Orientation orientation) | |
382 | { |
|
382 | { | |
383 | d_ptr->zoomOut2(factor); |
|
383 | d_ptr->zoomOut2(factor, orientation); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | Zooms in the view by a custom \a factor. |
|
387 | Zooms in the view by a custom \a factor. | |
388 |
|
388 | |||
389 | 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. | |
390 | */ |
|
390 | */ | |
391 | void QChart::zoom(qreal factor) |
|
391 | void QChart::zoom(qreal factor) | |
392 | { |
|
392 | { | |
393 | if (qFuzzyCompare(factor, 0)) |
|
393 | if (qFuzzyCompare(factor, 0)) | |
394 | return; |
|
394 | return; | |
395 |
|
395 | |||
396 | if (qFuzzyCompare(factor, (qreal)1.0)) |
|
396 | if (qFuzzyCompare(factor, (qreal)1.0)) | |
397 | return; |
|
397 | return; | |
398 |
|
398 | |||
399 | if (factor < 0) |
|
399 | if (factor < 0) | |
400 | return; |
|
400 | return; | |
401 |
|
401 | |||
402 | if (factor > 1.0) |
|
402 | if (factor > 1.0) | |
403 | d_ptr->zoomIn(factor); |
|
403 | d_ptr->zoomIn(factor); | |
404 | else |
|
404 | else | |
405 | d_ptr->zoomOut(1.0 / factor); |
|
405 | d_ptr->zoomOut(1.0 / factor); | |
406 | } |
|
406 | } | |
407 |
|
407 | |||
408 |
|
408 | |||
409 | /*! |
|
409 | /*! | |
410 | 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. | |
411 | 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 | |
412 | 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 | |
413 | done, this method does nothing. |
|
413 | done, this method does nothing. | |
414 | */ |
|
414 | */ | |
415 | void QChart::zoomReset() |
|
415 | void QChart::zoomReset() | |
416 | { |
|
416 | { | |
417 | d_ptr->zoomReset(); |
|
417 | d_ptr->zoomReset(); | |
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | /*! |
|
420 | /*! | |
421 | Returns true if any series has a zoomed domain. |
|
421 | Returns true if any series has a zoomed domain. | |
422 | */ |
|
422 | */ | |
423 | bool QChart::isZoomed() |
|
423 | bool QChart::isZoomed() | |
424 | { |
|
424 | { | |
425 | return d_ptr->isZoomed(); |
|
425 | return d_ptr->isZoomed(); | |
426 | } |
|
426 | } | |
427 |
|
427 | |||
428 | /*! |
|
428 | /*! | |
429 | 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. | |
430 | 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. | |
431 |
|
431 | |||
432 | \sa addAxis(), QAbstractSeries::attachAxis() |
|
432 | \sa addAxis(), QAbstractSeries::attachAxis() | |
433 | */ |
|
433 | */ | |
434 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const |
|
434 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const | |
435 | { |
|
435 | { | |
436 | QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series); |
|
436 | QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series); | |
437 | if (axisList.count()) |
|
437 | if (axisList.count()) | |
438 | return axisList[0]; |
|
438 | return axisList[0]; | |
439 | return 0; |
|
439 | return 0; | |
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | /*! |
|
442 | /*! | |
443 | 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. | |
444 | 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. | |
445 |
|
445 | |||
446 | \sa addAxis(), QAbstractSeries::attachAxis() |
|
446 | \sa addAxis(), QAbstractSeries::attachAxis() | |
447 | */ |
|
447 | */ | |
448 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const |
|
448 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const | |
449 | { |
|
449 | { | |
450 | QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series); |
|
450 | QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series); | |
451 | if (axisList.count()) |
|
451 | if (axisList.count()) | |
452 | return axisList[0]; |
|
452 | return axisList[0]; | |
453 | return 0; |
|
453 | return 0; | |
454 | } |
|
454 | } | |
455 |
|
455 | |||
456 | /*! |
|
456 | /*! | |
457 | 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, | |
458 | 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. | |
459 | \sa addAxis(), createDefaultAxes() |
|
459 | \sa addAxis(), createDefaultAxes() | |
460 | */ |
|
460 | */ | |
461 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const |
|
461 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const | |
462 | { |
|
462 | { | |
463 | QList<QAbstractAxis *> result ; |
|
463 | QList<QAbstractAxis *> result ; | |
464 |
|
464 | |||
465 | if (series) { |
|
465 | if (series) { | |
466 | foreach (QAbstractAxis *axis, series->attachedAxes()){ |
|
466 | foreach (QAbstractAxis *axis, series->attachedAxes()){ | |
467 | if (orientation.testFlag(axis->orientation())) |
|
467 | if (orientation.testFlag(axis->orientation())) | |
468 | result << axis; |
|
468 | result << axis; | |
469 | } |
|
469 | } | |
470 | } else { |
|
470 | } else { | |
471 | foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){ |
|
471 | foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){ | |
472 | if (orientation.testFlag(axis->orientation()) && !result.contains(axis)) |
|
472 | if (orientation.testFlag(axis->orientation()) && !result.contains(axis)) | |
473 | result << axis; |
|
473 | result << axis; | |
474 | } |
|
474 | } | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | return result; |
|
477 | return result; | |
478 | } |
|
478 | } | |
479 |
|
479 | |||
480 | /*! |
|
480 | /*! | |
481 | 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 | |
482 | the chart will be deleted. |
|
482 | the chart will be deleted. | |
483 |
|
483 | |||
484 | \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 | |
485 | 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. | |
486 | 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 | |
487 | if there are other series with properly attached axes also present. |
|
487 | if there are other series with properly attached axes also present. | |
488 |
|
488 | |||
489 | \table |
|
489 | \table | |
490 | \header |
|
490 | \header | |
491 | \li Series type |
|
491 | \li Series type | |
492 | \li X-axis |
|
492 | \li X-axis | |
493 | \li Y-axis |
|
493 | \li Y-axis | |
494 | \row |
|
494 | \row | |
495 | \li QXYSeries |
|
495 | \li QXYSeries | |
496 | \li QValueAxis |
|
496 | \li QValueAxis | |
497 | \li QValueAxis |
|
497 | \li QValueAxis | |
498 | \row |
|
498 | \row | |
499 | \li QBarSeries |
|
499 | \li QBarSeries | |
500 | \li QBarCategoryAxis |
|
500 | \li QBarCategoryAxis | |
501 | \li QValueAxis |
|
501 | \li QValueAxis | |
502 | \row |
|
502 | \row | |
503 | \li QPieSeries |
|
503 | \li QPieSeries | |
504 | \li None |
|
504 | \li None | |
505 | \li None |
|
505 | \li None | |
506 | \endtable |
|
506 | \endtable | |
507 |
|
507 | |||
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. |
|
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. | |
509 | 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. | |
510 |
|
510 | |||
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. |
|
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. | |
512 | QPieSeries does not create any axes. |
|
512 | QPieSeries does not create any axes. | |
513 |
|
513 | |||
514 | \sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis() |
|
514 | \sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis() | |
515 | */ |
|
515 | */ | |
516 | void QChart::createDefaultAxes() |
|
516 | void QChart::createDefaultAxes() | |
517 | { |
|
517 | { | |
518 | d_ptr->m_dataset->createDefaultAxes(); |
|
518 | d_ptr->m_dataset->createDefaultAxes(); | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | /*! |
|
521 | /*! | |
522 | 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. | |
523 | */ |
|
523 | */ | |
524 | QLegend *QChart::legend() const |
|
524 | QLegend *QChart::legend() const | |
525 | { |
|
525 | { | |
526 | return d_ptr->m_legend; |
|
526 | return d_ptr->m_legend; | |
527 | } |
|
527 | } | |
528 |
|
528 | |||
529 | void QChart::setMargins(const QMargins &margins) |
|
529 | void QChart::setMargins(const QMargins &margins) | |
530 | { |
|
530 | { | |
531 | d_ptr->m_presenter->layout()->setMargins(margins); |
|
531 | d_ptr->m_presenter->layout()->setMargins(margins); | |
532 | } |
|
532 | } | |
533 |
|
533 | |||
534 | QMargins QChart::margins() const |
|
534 | QMargins QChart::margins() const | |
535 | { |
|
535 | { | |
536 | return d_ptr->m_presenter->layout()->margins(); |
|
536 | return d_ptr->m_presenter->layout()->margins(); | |
537 | } |
|
537 | } | |
538 |
|
538 | |||
539 | QChart::ChartType QChart::chartType() const |
|
539 | QChart::ChartType QChart::chartType() const | |
540 | { |
|
540 | { | |
541 | return d_ptr->m_type; |
|
541 | return d_ptr->m_type; | |
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | QRectF QChart::plotArea() const |
|
544 | QRectF QChart::plotArea() const | |
545 | { |
|
545 | { | |
546 | return d_ptr->m_presenter->geometry(); |
|
546 | return d_ptr->m_presenter->geometry(); | |
547 | } |
|
547 | } | |
548 |
|
548 | |||
549 | /*! |
|
549 | /*! | |
550 | 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. | |
551 |
|
551 | |||
552 | \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen(), plotAreaBackgroundBrush() |
|
552 | \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen(), plotAreaBackgroundBrush() | |
553 | */ |
|
553 | */ | |
554 | void QChart::setPlotAreaBackgroundBrush(const QBrush &brush) |
|
554 | void QChart::setPlotAreaBackgroundBrush(const QBrush &brush) | |
555 | { |
|
555 | { | |
556 | d_ptr->m_presenter->setPlotAreaBackgroundBrush(brush); |
|
556 | d_ptr->m_presenter->setPlotAreaBackgroundBrush(brush); | |
557 | } |
|
557 | } | |
558 |
|
558 | |||
559 | /*! |
|
559 | /*! | |
560 | 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. | |
561 |
|
561 | |||
562 | \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen(), setPlotAreaBackgroundBrush() |
|
562 | \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen(), setPlotAreaBackgroundBrush() | |
563 | */ |
|
563 | */ | |
564 | QBrush QChart::plotAreaBackgroundBrush() const |
|
564 | QBrush QChart::plotAreaBackgroundBrush() const | |
565 | { |
|
565 | { | |
566 | return d_ptr->m_presenter->plotAreaBackgroundBrush(); |
|
566 | return d_ptr->m_presenter->plotAreaBackgroundBrush(); | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | /*! |
|
569 | /*! | |
570 | 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. | |
571 |
|
571 | |||
572 | \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush(), plotAreaBackgroundPen() |
|
572 | \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush(), plotAreaBackgroundPen() | |
573 | */ |
|
573 | */ | |
574 | void QChart::setPlotAreaBackgroundPen(const QPen &pen) |
|
574 | void QChart::setPlotAreaBackgroundPen(const QPen &pen) | |
575 | { |
|
575 | { | |
576 | d_ptr->m_presenter->setPlotAreaBackgroundPen(pen); |
|
576 | d_ptr->m_presenter->setPlotAreaBackgroundPen(pen); | |
577 | } |
|
577 | } | |
578 |
|
578 | |||
579 | /*! |
|
579 | /*! | |
580 | 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. | |
581 |
|
581 | |||
582 | \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush(), setPlotAreaBackgroundPen() |
|
582 | \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush(), setPlotAreaBackgroundPen() | |
583 | */ |
|
583 | */ | |
584 | QPen QChart::plotAreaBackgroundPen() const |
|
584 | QPen QChart::plotAreaBackgroundPen() const | |
585 | { |
|
585 | { | |
586 | return d_ptr->m_presenter->plotAreaBackgroundPen(); |
|
586 | return d_ptr->m_presenter->plotAreaBackgroundPen(); | |
587 | } |
|
587 | } | |
588 |
|
588 | |||
589 | void QChart::setPlotAreaBackgroundVisible(bool visible) |
|
589 | void QChart::setPlotAreaBackgroundVisible(bool visible) | |
590 | { |
|
590 | { | |
591 | d_ptr->m_presenter->setPlotAreaBackgroundVisible(visible); |
|
591 | d_ptr->m_presenter->setPlotAreaBackgroundVisible(visible); | |
592 | } |
|
592 | } | |
593 |
|
593 | |||
594 | bool QChart::isPlotAreaBackgroundVisible() const |
|
594 | bool QChart::isPlotAreaBackgroundVisible() const | |
595 | { |
|
595 | { | |
596 | return d_ptr->m_presenter->isPlotAreaBackgroundVisible(); |
|
596 | return d_ptr->m_presenter->isPlotAreaBackgroundVisible(); | |
597 | } |
|
597 | } | |
598 |
|
598 | |||
599 | void QChart::setLocalizeNumbers(bool localize) |
|
599 | void QChart::setLocalizeNumbers(bool localize) | |
600 | { |
|
600 | { | |
601 | d_ptr->m_presenter->setLocalizeNumbers(localize); |
|
601 | d_ptr->m_presenter->setLocalizeNumbers(localize); | |
602 | } |
|
602 | } | |
603 |
|
603 | |||
604 | bool QChart::localizeNumbers() const |
|
604 | bool QChart::localizeNumbers() const | |
605 | { |
|
605 | { | |
606 | return d_ptr->m_presenter->localizeNumbers(); |
|
606 | return d_ptr->m_presenter->localizeNumbers(); | |
607 | } |
|
607 | } | |
608 |
|
608 | |||
609 | void QChart::setLocale(const QLocale &locale) |
|
609 | void QChart::setLocale(const QLocale &locale) | |
610 | { |
|
610 | { | |
611 | d_ptr->m_presenter->setLocale(locale); |
|
611 | d_ptr->m_presenter->setLocale(locale); | |
612 | } |
|
612 | } | |
613 |
|
613 | |||
614 | QLocale QChart::locale() const |
|
614 | QLocale QChart::locale() const | |
615 | { |
|
615 | { | |
616 | return d_ptr->m_presenter->locale(); |
|
616 | return d_ptr->m_presenter->locale(); | |
617 | } |
|
617 | } | |
618 |
|
618 | |||
619 | void QChart::setAnimationOptions(AnimationOptions options) |
|
619 | void QChart::setAnimationOptions(AnimationOptions options) | |
620 | { |
|
620 | { | |
621 | d_ptr->m_presenter->setAnimationOptions(options); |
|
621 | d_ptr->m_presenter->setAnimationOptions(options); | |
622 | } |
|
622 | } | |
623 |
|
623 | |||
624 | QChart::AnimationOptions QChart::animationOptions() const |
|
624 | QChart::AnimationOptions QChart::animationOptions() const | |
625 | { |
|
625 | { | |
626 | return d_ptr->m_presenter->animationOptions(); |
|
626 | return d_ptr->m_presenter->animationOptions(); | |
627 | } |
|
627 | } | |
628 |
|
628 | |||
629 | void QChart::setAnimationDuration(int msecs) |
|
629 | void QChart::setAnimationDuration(int msecs) | |
630 | { |
|
630 | { | |
631 | d_ptr->m_presenter->setAnimationDuration(msecs); |
|
631 | d_ptr->m_presenter->setAnimationDuration(msecs); | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | int QChart::animationDuration() const |
|
634 | int QChart::animationDuration() const | |
635 | { |
|
635 | { | |
636 | return d_ptr->m_presenter->animationDuration(); |
|
636 | return d_ptr->m_presenter->animationDuration(); | |
637 | } |
|
637 | } | |
638 |
|
638 | |||
639 | void QChart::setAnimationEasingCurve(const QEasingCurve &curve) |
|
639 | void QChart::setAnimationEasingCurve(const QEasingCurve &curve) | |
640 | { |
|
640 | { | |
641 | d_ptr->m_presenter->setAnimationEasingCurve(curve); |
|
641 | d_ptr->m_presenter->setAnimationEasingCurve(curve); | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | QEasingCurve QChart::animationEasingCurve() const |
|
644 | QEasingCurve QChart::animationEasingCurve() const | |
645 | { |
|
645 | { | |
646 | return d_ptr->m_presenter->animationEasingCurve(); |
|
646 | return d_ptr->m_presenter->animationEasingCurve(); | |
647 | } |
|
647 | } | |
648 |
|
648 | |||
649 | /*! |
|
649 | /*! | |
650 | 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. | |
651 |
|
651 | |||
652 | 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. | |
653 | */ |
|
653 | */ | |
654 | void QChart::scroll(qreal dx, qreal dy) |
|
654 | void QChart::scroll(qreal dx, qreal dy) | |
655 | { |
|
655 | { | |
656 | d_ptr->scroll(dx,dy); |
|
656 | d_ptr->scroll(dx,dy); | |
657 | } |
|
657 | } | |
658 |
|
658 | |||
659 | void QChart::setBackgroundVisible(bool visible) |
|
659 | void QChart::setBackgroundVisible(bool visible) | |
660 | { |
|
660 | { | |
661 | d_ptr->m_presenter->setBackgroundVisible(visible); |
|
661 | d_ptr->m_presenter->setBackgroundVisible(visible); | |
662 | } |
|
662 | } | |
663 |
|
663 | |||
664 | bool QChart::isBackgroundVisible() const |
|
664 | bool QChart::isBackgroundVisible() const | |
665 | { |
|
665 | { | |
666 | return d_ptr->m_presenter->isBackgroundVisible(); |
|
666 | return d_ptr->m_presenter->isBackgroundVisible(); | |
667 | } |
|
667 | } | |
668 |
|
668 | |||
669 | void QChart::setDropShadowEnabled(bool enabled) |
|
669 | void QChart::setDropShadowEnabled(bool enabled) | |
670 | { |
|
670 | { | |
671 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); |
|
671 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); | |
672 | } |
|
672 | } | |
673 |
|
673 | |||
674 | bool QChart::isDropShadowEnabled() const |
|
674 | bool QChart::isDropShadowEnabled() const | |
675 | { |
|
675 | { | |
676 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); |
|
676 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); | |
677 | } |
|
677 | } | |
678 |
|
678 | |||
679 | void QChart::setBackgroundRoundness(qreal diameter) |
|
679 | void QChart::setBackgroundRoundness(qreal diameter) | |
680 | { |
|
680 | { | |
681 | d_ptr->m_presenter->setBackgroundRoundness(diameter); |
|
681 | d_ptr->m_presenter->setBackgroundRoundness(diameter); | |
682 | } |
|
682 | } | |
683 |
|
683 | |||
684 | qreal QChart::backgroundRoundness() const |
|
684 | qreal QChart::backgroundRoundness() const | |
685 | { |
|
685 | { | |
686 | return d_ptr->m_presenter->backgroundRoundness(); |
|
686 | return d_ptr->m_presenter->backgroundRoundness(); | |
687 | } |
|
687 | } | |
688 |
|
688 | |||
689 | /*! |
|
689 | /*! | |
690 | Returns all series that are added to the chart. |
|
690 | Returns all series that are added to the chart. | |
691 |
|
691 | |||
692 | \sa addSeries(), removeSeries(), removeAllSeries() |
|
692 | \sa addSeries(), removeSeries(), removeAllSeries() | |
693 | */ |
|
693 | */ | |
694 | QList<QAbstractSeries *> QChart::series() const |
|
694 | QList<QAbstractSeries *> QChart::series() const | |
695 | { |
|
695 | { | |
696 | return d_ptr->m_dataset->series(); |
|
696 | return d_ptr->m_dataset->series(); | |
697 | } |
|
697 | } | |
698 |
|
698 | |||
699 | /*! |
|
699 | /*! | |
700 | 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. | |
701 | 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. | |
702 | Any horizontal axes previously attached to the \a series are deleted. |
|
702 | Any horizontal axes previously attached to the \a series are deleted. | |
703 |
|
703 | |||
704 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis() |
|
704 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis() | |
705 | */ |
|
705 | */ | |
706 | void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series) |
|
706 | void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series) | |
707 | { |
|
707 | { | |
708 | QList<QAbstractAxis*> list = axes(Qt::Horizontal, series); |
|
708 | QList<QAbstractAxis*> list = axes(Qt::Horizontal, series); | |
709 |
|
709 | |||
710 | foreach (QAbstractAxis* a, list) { |
|
710 | foreach (QAbstractAxis* a, list) { | |
711 | d_ptr->m_dataset->removeAxis(a); |
|
711 | d_ptr->m_dataset->removeAxis(a); | |
712 | delete a; |
|
712 | delete a; | |
713 | } |
|
713 | } | |
714 |
|
714 | |||
715 | if (!d_ptr->m_dataset->axes().contains(axis)) |
|
715 | if (!d_ptr->m_dataset->axes().contains(axis)) | |
716 | d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom); |
|
716 | d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom); | |
717 | d_ptr->m_dataset->attachAxis(series, axis); |
|
717 | d_ptr->m_dataset->attachAxis(series, axis); | |
718 | } |
|
718 | } | |
719 |
|
719 | |||
720 | /*! |
|
720 | /*! | |
721 | 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. | |
722 | 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. | |
723 | Any vertical axes previously attached to the \a series are deleted. |
|
723 | Any vertical axes previously attached to the \a series are deleted. | |
724 |
|
724 | |||
725 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis() |
|
725 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis() | |
726 | */ |
|
726 | */ | |
727 | void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series) |
|
727 | void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series) | |
728 | { |
|
728 | { | |
729 | QList<QAbstractAxis*> list = axes(Qt::Vertical, series); |
|
729 | QList<QAbstractAxis*> list = axes(Qt::Vertical, series); | |
730 |
|
730 | |||
731 | foreach (QAbstractAxis* a, list) { |
|
731 | foreach (QAbstractAxis* a, list) { | |
732 | d_ptr->m_dataset->removeAxis(a); |
|
732 | d_ptr->m_dataset->removeAxis(a); | |
733 | delete a; |
|
733 | delete a; | |
734 | } |
|
734 | } | |
735 |
|
735 | |||
736 | if (!d_ptr->m_dataset->axes().contains(axis)) |
|
736 | if (!d_ptr->m_dataset->axes().contains(axis)) | |
737 | d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft); |
|
737 | d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft); | |
738 | d_ptr->m_dataset->attachAxis(series, axis); |
|
738 | d_ptr->m_dataset->attachAxis(series, axis); | |
739 | } |
|
739 | } | |
740 |
|
740 | |||
741 | /*! |
|
741 | /*! | |
742 | 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. | |
743 |
|
743 | |||
744 | \sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis() |
|
744 | \sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis() | |
745 | */ |
|
745 | */ | |
746 | void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment) |
|
746 | void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment) | |
747 | { |
|
747 | { | |
748 | d_ptr->m_dataset->addAxis(axis, alignment); |
|
748 | d_ptr->m_dataset->addAxis(axis, alignment); | |
749 | } |
|
749 | } | |
750 |
|
750 | |||
751 | /*! |
|
751 | /*! | |
752 | Removes the \a axis from the chart. |
|
752 | Removes the \a axis from the chart. | |
753 | The chart releases its ownership of the specified \a axis object. |
|
753 | The chart releases its ownership of the specified \a axis object. | |
754 |
|
754 | |||
755 | \sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis() |
|
755 | \sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis() | |
756 | */ |
|
756 | */ | |
757 | void QChart::removeAxis(QAbstractAxis *axis) |
|
757 | void QChart::removeAxis(QAbstractAxis *axis) | |
758 | { |
|
758 | { | |
759 | d_ptr->m_dataset->removeAxis(axis); |
|
759 | d_ptr->m_dataset->removeAxis(axis); | |
760 | } |
|
760 | } | |
761 |
|
761 | |||
762 | /*! |
|
762 | /*! | |
763 | 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. | |
764 | */ |
|
764 | */ | |
765 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) |
|
765 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) | |
766 | { |
|
766 | { | |
767 | return d_ptr->m_dataset->mapToValue(position, series); |
|
767 | return d_ptr->m_dataset->mapToValue(position, series); | |
768 | } |
|
768 | } | |
769 |
|
769 | |||
770 | /*! |
|
770 | /*! | |
771 | 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. | |
772 | */ |
|
772 | */ | |
773 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) |
|
773 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) | |
774 | { |
|
774 | { | |
775 | return d_ptr->m_dataset->mapToPosition(value, series); |
|
775 | return d_ptr->m_dataset->mapToPosition(value, series); | |
776 | } |
|
776 | } | |
777 |
|
777 | |||
778 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
778 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
779 |
|
779 | |||
780 | QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type): |
|
780 | QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type): | |
781 | q_ptr(q), |
|
781 | q_ptr(q), | |
782 | m_legend(0), |
|
782 | m_legend(0), | |
783 | m_dataset(new ChartDataSet(q)), |
|
783 | m_dataset(new ChartDataSet(q)), | |
784 | m_presenter(new ChartPresenter(q, type)), |
|
784 | m_presenter(new ChartPresenter(q, type)), | |
785 | m_themeManager(new ChartThemeManager(q)), |
|
785 | m_themeManager(new ChartThemeManager(q)), | |
786 | m_type(type) |
|
786 | m_type(type) | |
787 | { |
|
787 | { | |
788 | 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*))); | |
789 | 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*))); | |
790 | 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*))); | |
791 | 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*))); | |
792 | 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*))); | |
793 | 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*))); | |
794 | 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*))); | |
795 | 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*))); | |
796 | QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged); |
|
796 | QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged); | |
797 | } |
|
797 | } | |
798 |
|
798 | |||
799 | QChartPrivate::~QChartPrivate() |
|
799 | QChartPrivate::~QChartPrivate() | |
800 | { |
|
800 | { | |
801 | delete m_themeManager; |
|
801 | delete m_themeManager; | |
802 | } |
|
802 | } | |
803 |
|
803 | |||
804 | // 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 | |
805 | // to a series or axis and having theme override it: |
|
805 | // to a series or axis and having theme override it: | |
806 | // 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, | |
807 | // so that default theme initialization will always set these properly. |
|
807 | // so that default theme initialization will always set these properly. | |
808 | QPen &QChartPrivate::defaultPen() |
|
808 | QPen &QChartPrivate::defaultPen() | |
809 | { |
|
809 | { | |
810 | static QPen defaultPen(QColor(1, 2, 0), 0.93247536); |
|
810 | static QPen defaultPen(QColor(1, 2, 0), 0.93247536); | |
811 | return defaultPen; |
|
811 | return defaultPen; | |
812 | } |
|
812 | } | |
813 |
|
813 | |||
814 | QBrush &QChartPrivate::defaultBrush() |
|
814 | QBrush &QChartPrivate::defaultBrush() | |
815 | { |
|
815 | { | |
816 | static QBrush defaultBrush(QColor(1, 2, 0), Qt::Dense7Pattern); |
|
816 | static QBrush defaultBrush(QColor(1, 2, 0), Qt::Dense7Pattern); | |
817 | return defaultBrush; |
|
817 | return defaultBrush; | |
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | QFont &QChartPrivate::defaultFont() |
|
820 | QFont &QChartPrivate::defaultFont() | |
821 | { |
|
821 | { | |
822 | static bool defaultFontInitialized(false); |
|
822 | static bool defaultFontInitialized(false); | |
823 | static QFont defaultFont; |
|
823 | static QFont defaultFont; | |
824 | if (!defaultFontInitialized) { |
|
824 | if (!defaultFontInitialized) { | |
825 | defaultFont.setPointSizeF(8.34563465); |
|
825 | defaultFont.setPointSizeF(8.34563465); | |
826 | defaultFontInitialized = true; |
|
826 | defaultFontInitialized = true; | |
827 | } |
|
827 | } | |
828 | return defaultFont; |
|
828 | return defaultFont; | |
829 | } |
|
829 | } | |
830 |
|
830 | |||
831 | void QChartPrivate::init() |
|
831 | void QChartPrivate::init() | |
832 | { |
|
832 | { | |
833 | m_legend = new LegendScroller(q_ptr); |
|
833 | m_legend = new LegendScroller(q_ptr); | |
834 | q_ptr->setTheme(QChart::ChartThemeLight); |
|
834 | q_ptr->setTheme(QChart::ChartThemeLight); | |
835 | q_ptr->setLayout(m_presenter->layout()); |
|
835 | q_ptr->setLayout(m_presenter->layout()); | |
836 | } |
|
836 | } | |
837 |
|
837 | |||
838 | void QChartPrivate::zoomIn(qreal factor) |
|
838 | void QChartPrivate::zoomIn(qreal factor) | |
839 | { |
|
839 | { | |
840 | QRectF rect = m_presenter->geometry(); |
|
840 | QRectF rect = m_presenter->geometry(); | |
841 | rect.setWidth(rect.width() / factor); |
|
841 | rect.setWidth(rect.width() / factor); | |
842 | rect.setHeight(rect.height() / factor); |
|
842 | rect.setHeight(rect.height() / factor); | |
843 | rect.moveCenter(m_presenter->geometry().center()); |
|
843 | rect.moveCenter(m_presenter->geometry().center()); | |
844 | zoomIn(rect); |
|
844 | zoomIn(rect); | |
845 | } |
|
845 | } | |
846 |
|
846 | |||
847 | void QChartPrivate::zoomIn2(qreal factor) |
|
847 | void QChartPrivate::zoomIn2(qreal factor, Qt::Orientation orientation) | |
848 | { |
|
848 | { | |
849 | QRectF rect = m_presenter->geometry(); |
|
849 | QRectF rect = m_presenter->geometry(); | |
850 | rect.setWidth(rect.width() / factor); |
|
850 | if(orientation == Qt::Vertical) | |
|
851 | rect.setHeight(rect.height() / factor); | |||
|
852 | else | |||
|
853 | rect.setWidth(rect.width() / factor); | |||
851 | rect.moveCenter(m_presenter->geometry().center()); |
|
854 | rect.moveCenter(m_presenter->geometry().center()); | |
852 | zoomIn(rect); |
|
855 | zoomIn(rect); | |
853 | } |
|
856 | } | |
854 |
|
857 | |||
855 | void QChartPrivate::zoomIn(const QRectF &rect) |
|
858 | void QChartPrivate::zoomIn(const QRectF &rect) | |
856 | { |
|
859 | { | |
857 | if (!rect.isValid()) |
|
860 | if (!rect.isValid()) | |
858 | return; |
|
861 | return; | |
859 |
|
862 | |||
860 | QRectF r = rect.normalized(); |
|
863 | QRectF r = rect.normalized(); | |
861 | const QRectF geometry = m_presenter->geometry(); |
|
864 | const QRectF geometry = m_presenter->geometry(); | |
862 | r.translate(-geometry.topLeft()); |
|
865 | r.translate(-geometry.topLeft()); | |
863 |
|
866 | |||
864 | if (!r.isValid()) |
|
867 | if (!r.isValid()) | |
865 | return; |
|
868 | return; | |
866 |
|
869 | |||
867 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); |
|
870 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); | |
868 | m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint); |
|
871 | m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint); | |
869 | m_dataset->zoomInDomain(r); |
|
872 | m_dataset->zoomInDomain(r); | |
870 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); |
|
873 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); | |
871 |
|
874 | |||
872 | } |
|
875 | } | |
873 |
|
876 | |||
874 | void QChartPrivate::zoomReset() |
|
877 | void QChartPrivate::zoomReset() | |
875 | { |
|
878 | { | |
876 | m_dataset->zoomResetDomain(); |
|
879 | m_dataset->zoomResetDomain(); | |
877 | } |
|
880 | } | |
878 |
|
881 | |||
879 | bool QChartPrivate::isZoomed() |
|
882 | bool QChartPrivate::isZoomed() | |
880 | { |
|
883 | { | |
881 | return m_dataset->isZoomedDomain(); |
|
884 | return m_dataset->isZoomedDomain(); | |
882 | } |
|
885 | } | |
883 |
|
886 | |||
884 | void QChartPrivate::zoomOut(qreal factor) |
|
887 | void QChartPrivate::zoomOut(qreal factor) | |
885 | { |
|
888 | { | |
886 | const QRectF geometry = m_presenter->geometry(); |
|
889 | const QRectF geometry = m_presenter->geometry(); | |
887 |
|
890 | |||
888 | QRectF r; |
|
891 | QRectF r; | |
889 | r.setSize(geometry.size() / factor); |
|
892 | r.setSize(geometry.size() / factor); | |
890 | r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2)); |
|
893 | r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2)); | |
891 | if (!r.isValid()) |
|
894 | if (!r.isValid()) | |
892 | return; |
|
895 | return; | |
893 |
|
896 | |||
894 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); |
|
897 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); | |
895 | m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint); |
|
898 | m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint); | |
896 | m_dataset->zoomOutDomain(r); |
|
899 | m_dataset->zoomOutDomain(r); | |
897 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); |
|
900 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); | |
898 | } |
|
901 | } | |
899 |
|
902 | |||
900 | void QChartPrivate::zoomOut2(qreal factor) |
|
903 | void QChartPrivate::zoomOut2(qreal factor, Qt::Orientation orientation) | |
901 | { |
|
904 | { | |
902 | const QRectF geometry = m_presenter->geometry(); |
|
905 | const QRectF geometry = m_presenter->geometry(); | |
903 |
|
906 | |||
904 | QRectF r; |
|
907 | QRectF r; | |
905 | QSizeF size = geometry.size(); |
|
908 | QSizeF size = geometry.size(); | |
906 | size.setWidth(size.width()/factor); |
|
909 | if(orientation == Qt::Vertical) | |
|
910 | size.setHeight(size.height()/factor); | |||
|
911 | else | |||
|
912 | size.setWidth(size.width()/factor); | |||
907 | r.setSize(size); |
|
913 | r.setSize(size); | |
908 | r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2)); |
|
914 | r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2)); | |
909 | if (!r.isValid()) |
|
915 | if (!r.isValid()) | |
910 | return; |
|
916 | return; | |
911 |
|
917 | |||
912 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); |
|
918 | QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height()); | |
913 | m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint); |
|
919 | m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint); | |
914 | m_dataset->zoomOutDomain(r); |
|
920 | m_dataset->zoomOutDomain(r); | |
915 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); |
|
921 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); | |
916 | } |
|
922 | } | |
917 |
|
923 | |||
918 | void QChartPrivate::scroll(qreal dx, qreal dy) |
|
924 | void QChartPrivate::scroll(qreal dx, qreal dy) | |
919 | { |
|
925 | { | |
920 | if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF()); |
|
926 | if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF()); | |
921 | if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF()); |
|
927 | if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF()); | |
922 | if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF()); |
|
928 | if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF()); | |
923 | if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF()); |
|
929 | if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF()); | |
924 |
|
930 | |||
925 | m_dataset->scrollDomain(dx, dy); |
|
931 | m_dataset->scrollDomain(dx, dy); | |
926 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); |
|
932 | m_presenter->setState(ChartPresenter::ShowState,QPointF()); | |
927 | } |
|
933 | } | |
928 |
|
934 | |||
929 | #include "moc_qchart.cpp" |
|
935 | #include "moc_qchart.cpp" | |
930 |
|
936 | |||
931 | QT_CHARTS_END_NAMESPACE |
|
937 | QT_CHARTS_END_NAMESPACE |
@@ -1,205 +1,205 | |||||
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 | #ifndef QCHART_H |
|
30 | #ifndef QCHART_H | |
31 | #define QCHART_H |
|
31 | #define QCHART_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractSeries> |
|
33 | #include <QtCharts/QAbstractSeries> | |
34 | #include <QtCharts/QLegend> |
|
34 | #include <QtCharts/QLegend> | |
35 | #include <QtWidgets/QGraphicsWidget> |
|
35 | #include <QtWidgets/QGraphicsWidget> | |
36 | #include <QtCore/QMargins> |
|
36 | #include <QtCore/QMargins> | |
37 |
|
37 | |||
38 | QT_BEGIN_NAMESPACE |
|
38 | QT_BEGIN_NAMESPACE | |
39 | class QGraphicsSceneResizeEvent; |
|
39 | class QGraphicsSceneResizeEvent; | |
40 | QT_END_NAMESPACE |
|
40 | QT_END_NAMESPACE | |
41 |
|
41 | |||
42 | QT_CHARTS_BEGIN_NAMESPACE |
|
42 | QT_CHARTS_BEGIN_NAMESPACE | |
43 |
|
43 | |||
44 | class QAbstractSeries; |
|
44 | class QAbstractSeries; | |
45 | class QAbstractAxis; |
|
45 | class QAbstractAxis; | |
46 | class QLegend; |
|
46 | class QLegend; | |
47 | class QChartPrivate; |
|
47 | class QChartPrivate; | |
48 | class QBoxPlotSeries; |
|
48 | class QBoxPlotSeries; | |
49 |
|
49 | |||
50 | class QT_CHARTS_EXPORT QChart : public QGraphicsWidget |
|
50 | class QT_CHARTS_EXPORT QChart : public QGraphicsWidget | |
51 | { |
|
51 | { | |
52 | Q_OBJECT |
|
52 | Q_OBJECT | |
53 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
53 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
54 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
54 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
55 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
55 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
56 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
56 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
57 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness) |
|
57 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness) | |
58 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
58 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
59 | Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) |
|
59 | Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) | |
60 | Q_PROPERTY(QEasingCurve animationEasingCurve READ animationEasingCurve WRITE setAnimationEasingCurve) |
|
60 | Q_PROPERTY(QEasingCurve animationEasingCurve READ animationEasingCurve WRITE setAnimationEasingCurve) | |
61 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
|
61 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) | |
62 | Q_PROPERTY(QChart::ChartType chartType READ chartType) |
|
62 | Q_PROPERTY(QChart::ChartType chartType READ chartType) | |
63 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) |
|
63 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) | |
64 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) |
|
64 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) | |
65 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) |
|
65 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) | |
66 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged) |
|
66 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged) | |
67 | Q_ENUMS(ChartTheme) |
|
67 | Q_ENUMS(ChartTheme) | |
68 | Q_ENUMS(AnimationOption) |
|
68 | Q_ENUMS(AnimationOption) | |
69 | Q_ENUMS(ChartType) |
|
69 | Q_ENUMS(ChartType) | |
70 |
|
70 | |||
71 | public: |
|
71 | public: | |
72 | enum ChartType { |
|
72 | enum ChartType { | |
73 | ChartTypeUndefined = 0, |
|
73 | ChartTypeUndefined = 0, | |
74 | ChartTypeCartesian, |
|
74 | ChartTypeCartesian, | |
75 | ChartTypePolar |
|
75 | ChartTypePolar | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | enum ChartTheme { |
|
78 | enum ChartTheme { | |
79 | ChartThemeLight = 0, |
|
79 | ChartThemeLight = 0, | |
80 | ChartThemeBlueCerulean, |
|
80 | ChartThemeBlueCerulean, | |
81 | ChartThemeDark, |
|
81 | ChartThemeDark, | |
82 | ChartThemeBrownSand, |
|
82 | ChartThemeBrownSand, | |
83 | ChartThemeBlueNcs, |
|
83 | ChartThemeBlueNcs, | |
84 | ChartThemeHighContrast, |
|
84 | ChartThemeHighContrast, | |
85 | ChartThemeBlueIcy, |
|
85 | ChartThemeBlueIcy, | |
86 | ChartThemeQt |
|
86 | ChartThemeQt | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | enum AnimationOption { |
|
89 | enum AnimationOption { | |
90 | NoAnimation = 0x0, |
|
90 | NoAnimation = 0x0, | |
91 | GridAxisAnimations = 0x1, |
|
91 | GridAxisAnimations = 0x1, | |
92 | SeriesAnimations = 0x2, |
|
92 | SeriesAnimations = 0x2, | |
93 | AllAnimations = 0x3 |
|
93 | AllAnimations = 0x3 | |
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
96 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
97 |
|
97 | |||
98 | public: |
|
98 | public: | |
99 | explicit QChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); |
|
99 | explicit QChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); | |
100 | ~QChart(); |
|
100 | ~QChart(); | |
101 |
|
101 | |||
102 | void addSeries(QAbstractSeries *series); |
|
102 | void addSeries(QAbstractSeries *series); | |
103 | void removeSeries(QAbstractSeries *series); |
|
103 | void removeSeries(QAbstractSeries *series); | |
104 | void removeAllSeries(); |
|
104 | void removeAllSeries(); | |
105 | QList<QAbstractSeries *> series() const; |
|
105 | QList<QAbstractSeries *> series() const; | |
106 |
|
106 | |||
107 | // *** deprecated *** |
|
107 | // *** deprecated *** | |
108 | void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); |
|
108 | void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); | |
109 | void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); |
|
109 | void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); | |
110 | QAbstractAxis *axisX(QAbstractSeries *series = Q_NULLPTR) const; |
|
110 | QAbstractAxis *axisX(QAbstractSeries *series = Q_NULLPTR) const; | |
111 | QAbstractAxis *axisY(QAbstractSeries *series = Q_NULLPTR) const; |
|
111 | QAbstractAxis *axisY(QAbstractSeries *series = Q_NULLPTR) const; | |
112 | // ****************** |
|
112 | // ****************** | |
113 |
|
113 | |||
114 | void addAxis(QAbstractAxis *axis, Qt::Alignment alignment); |
|
114 | void addAxis(QAbstractAxis *axis, Qt::Alignment alignment); | |
115 | void removeAxis(QAbstractAxis *axis); |
|
115 | void removeAxis(QAbstractAxis *axis); | |
116 | QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = Q_NULLPTR) const; |
|
116 | QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = Q_NULLPTR) const; | |
117 |
|
117 | |||
118 | void createDefaultAxes(); |
|
118 | void createDefaultAxes(); | |
119 |
|
119 | |||
120 | void setTheme(QChart::ChartTheme theme); |
|
120 | void setTheme(QChart::ChartTheme theme); | |
121 | QChart::ChartTheme theme() const; |
|
121 | QChart::ChartTheme theme() const; | |
122 |
|
122 | |||
123 | void setTitle(const QString &title); |
|
123 | void setTitle(const QString &title); | |
124 | QString title() const; |
|
124 | QString title() const; | |
125 | void setTitleFont(const QFont &font); |
|
125 | void setTitleFont(const QFont &font); | |
126 | QFont titleFont() const; |
|
126 | QFont titleFont() const; | |
127 | void setTitleBrush(const QBrush &brush); |
|
127 | void setTitleBrush(const QBrush &brush); | |
128 | QBrush titleBrush() const; |
|
128 | QBrush titleBrush() const; | |
129 |
|
129 | |||
130 | void setBackgroundBrush(const QBrush &brush); |
|
130 | void setBackgroundBrush(const QBrush &brush); | |
131 | QBrush backgroundBrush() const; |
|
131 | QBrush backgroundBrush() const; | |
132 | void setBackgroundPen(const QPen &pen); |
|
132 | void setBackgroundPen(const QPen &pen); | |
133 | QPen backgroundPen() const; |
|
133 | QPen backgroundPen() const; | |
134 | void setBackgroundVisible(bool visible = true); |
|
134 | void setBackgroundVisible(bool visible = true); | |
135 | bool isBackgroundVisible() const; |
|
135 | bool isBackgroundVisible() const; | |
136 |
|
136 | |||
137 | void setDropShadowEnabled(bool enabled = true); |
|
137 | void setDropShadowEnabled(bool enabled = true); | |
138 | bool isDropShadowEnabled() const; |
|
138 | bool isDropShadowEnabled() const; | |
139 | void setBackgroundRoundness(qreal diameter); |
|
139 | void setBackgroundRoundness(qreal diameter); | |
140 | qreal backgroundRoundness() const; |
|
140 | qreal backgroundRoundness() const; | |
141 |
|
141 | |||
142 | void setAnimationOptions(AnimationOptions options); |
|
142 | void setAnimationOptions(AnimationOptions options); | |
143 | AnimationOptions animationOptions() const; |
|
143 | AnimationOptions animationOptions() const; | |
144 | void setAnimationDuration(int msecs); |
|
144 | void setAnimationDuration(int msecs); | |
145 | int animationDuration() const; |
|
145 | int animationDuration() const; | |
146 | void setAnimationEasingCurve(const QEasingCurve &curve); |
|
146 | void setAnimationEasingCurve(const QEasingCurve &curve); | |
147 | QEasingCurve animationEasingCurve() const; |
|
147 | QEasingCurve animationEasingCurve() const; | |
148 |
|
148 | |||
149 | void zoomIn(); |
|
149 | void zoomIn(); | |
150 | void zoomIn2(double factor); |
|
150 | void zoomIn2(double factor, Qt::Orientation orientation); | |
151 | void zoomOut(); |
|
151 | void zoomOut(); | |
152 | void zoomOut2(double factor); |
|
152 | void zoomOut2(double factor, Qt::Orientation orientation); | |
153 |
|
153 | |||
154 | void zoomIn(const QRectF &rect); |
|
154 | void zoomIn(const QRectF &rect); | |
155 | void zoom(qreal factor); |
|
155 | void zoom(qreal factor); | |
156 | void zoomReset(); |
|
156 | void zoomReset(); | |
157 | bool isZoomed(); |
|
157 | bool isZoomed(); | |
158 |
|
158 | |||
159 | void scroll(qreal dx, qreal dy); |
|
159 | void scroll(qreal dx, qreal dy); | |
160 |
|
160 | |||
161 | QLegend *legend() const; |
|
161 | QLegend *legend() const; | |
162 |
|
162 | |||
163 | void setMargins(const QMargins &margins); |
|
163 | void setMargins(const QMargins &margins); | |
164 | QMargins margins() const; |
|
164 | QMargins margins() const; | |
165 |
|
165 | |||
166 | QRectF plotArea() const; |
|
166 | QRectF plotArea() const; | |
167 | void setPlotAreaBackgroundBrush(const QBrush &brush); |
|
167 | void setPlotAreaBackgroundBrush(const QBrush &brush); | |
168 | QBrush plotAreaBackgroundBrush() const; |
|
168 | QBrush plotAreaBackgroundBrush() const; | |
169 | void setPlotAreaBackgroundPen(const QPen &pen); |
|
169 | void setPlotAreaBackgroundPen(const QPen &pen); | |
170 | QPen plotAreaBackgroundPen() const; |
|
170 | QPen plotAreaBackgroundPen() const; | |
171 | void setPlotAreaBackgroundVisible(bool visible = true); |
|
171 | void setPlotAreaBackgroundVisible(bool visible = true); | |
172 | bool isPlotAreaBackgroundVisible() const; |
|
172 | bool isPlotAreaBackgroundVisible() const; | |
173 | void setLocalizeNumbers(bool localize); |
|
173 | void setLocalizeNumbers(bool localize); | |
174 | bool localizeNumbers() const; |
|
174 | bool localizeNumbers() const; | |
175 | void setLocale(const QLocale &locale); |
|
175 | void setLocale(const QLocale &locale); | |
176 | QLocale locale() const; |
|
176 | QLocale locale() const; | |
177 |
|
177 | |||
178 | QPointF mapToValue(const QPointF &position, QAbstractSeries *series = Q_NULLPTR); |
|
178 | QPointF mapToValue(const QPointF &position, QAbstractSeries *series = Q_NULLPTR); | |
179 | QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = Q_NULLPTR); |
|
179 | QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = Q_NULLPTR); | |
180 |
|
180 | |||
181 | ChartType chartType() const; |
|
181 | ChartType chartType() const; | |
182 |
|
182 | |||
183 | Q_SIGNALS: |
|
183 | Q_SIGNALS: | |
184 | void plotAreaChanged(const QRectF &plotArea); |
|
184 | void plotAreaChanged(const QRectF &plotArea); | |
185 |
|
185 | |||
186 | protected: |
|
186 | protected: | |
187 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); |
|
187 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); | |
188 | QScopedPointer<QChartPrivate> d_ptr; |
|
188 | QScopedPointer<QChartPrivate> d_ptr; | |
189 | friend class QLegend; |
|
189 | friend class QLegend; | |
190 | friend class DeclarativeChart; |
|
190 | friend class DeclarativeChart; | |
191 | friend class ChartDataSet; |
|
191 | friend class ChartDataSet; | |
192 | friend class ChartPresenter; |
|
192 | friend class ChartPresenter; | |
193 | friend class ChartThemeManager; |
|
193 | friend class ChartThemeManager; | |
194 | friend class QAbstractSeries; |
|
194 | friend class QAbstractSeries; | |
195 | friend class QBoxPlotSeriesPrivate; |
|
195 | friend class QBoxPlotSeriesPrivate; | |
196 |
|
196 | |||
197 | private: |
|
197 | private: | |
198 | Q_DISABLE_COPY(QChart) |
|
198 | Q_DISABLE_COPY(QChart) | |
199 | }; |
|
199 | }; | |
200 |
|
200 | |||
201 | QT_CHARTS_END_NAMESPACE |
|
201 | QT_CHARTS_END_NAMESPACE | |
202 |
|
202 | |||
203 | Q_DECLARE_OPERATORS_FOR_FLAGS(QT_CHARTS_NAMESPACE::QChart::AnimationOptions) |
|
203 | Q_DECLARE_OPERATORS_FOR_FLAGS(QT_CHARTS_NAMESPACE::QChart::AnimationOptions) | |
204 |
|
204 | |||
205 | #endif // QCHART_H |
|
205 | #endif // QCHART_H |
@@ -1,81 +1,81 | |||||
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 | // W A R N I N G |
|
30 | // W A R N I N G | |
31 | // ------------- |
|
31 | // ------------- | |
32 | // |
|
32 | // | |
33 | // This file is not part of the Qt Chart API. It exists purely as an |
|
33 | // This file is not part of the Qt Chart API. It exists purely as an | |
34 | // implementation detail. This header file may change from version to |
|
34 | // implementation detail. This header file may change from version to | |
35 | // version without notice, or even be removed. |
|
35 | // version without notice, or even be removed. | |
36 | // |
|
36 | // | |
37 | // We mean it. |
|
37 | // We mean it. | |
38 |
|
38 | |||
39 | #ifndef QCHART_P_H |
|
39 | #ifndef QCHART_P_H | |
40 | #define QCHART_P_H |
|
40 | #define QCHART_P_H | |
41 |
|
41 | |||
42 | #include <QtCharts/QChartGlobal> |
|
42 | #include <QtCharts/QChartGlobal> | |
43 | #include <QtCharts/QChart> |
|
43 | #include <QtCharts/QChart> | |
44 |
|
44 | |||
45 | QT_CHARTS_BEGIN_NAMESPACE |
|
45 | QT_CHARTS_BEGIN_NAMESPACE | |
46 |
|
46 | |||
47 | class ChartThemeManager; |
|
47 | class ChartThemeManager; | |
48 | class ChartPresenter; |
|
48 | class ChartPresenter; | |
49 | class QLegend; |
|
49 | class QLegend; | |
50 | class ChartDataSet; |
|
50 | class ChartDataSet; | |
51 |
|
51 | |||
52 | class QChartPrivate |
|
52 | class QChartPrivate | |
53 | { |
|
53 | { | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | QChartPrivate(QChart *q, QChart::ChartType type); |
|
56 | QChartPrivate(QChart *q, QChart::ChartType type); | |
57 | ~QChartPrivate(); |
|
57 | ~QChartPrivate(); | |
58 | QChart *q_ptr; |
|
58 | QChart *q_ptr; | |
59 | QLegend *m_legend; |
|
59 | QLegend *m_legend; | |
60 | ChartDataSet *m_dataset; |
|
60 | ChartDataSet *m_dataset; | |
61 | ChartPresenter *m_presenter; |
|
61 | ChartPresenter *m_presenter; | |
62 | ChartThemeManager *m_themeManager; |
|
62 | ChartThemeManager *m_themeManager; | |
63 | QChart::ChartType m_type; |
|
63 | QChart::ChartType m_type; | |
64 |
|
64 | |||
65 | static QPen &defaultPen(); |
|
65 | static QPen &defaultPen(); | |
66 | static QBrush &defaultBrush(); |
|
66 | static QBrush &defaultBrush(); | |
67 | static QFont &defaultFont(); |
|
67 | static QFont &defaultFont(); | |
68 |
|
68 | |||
69 | void init(); |
|
69 | void init(); | |
70 | void zoomIn(qreal factor); |
|
70 | void zoomIn(qreal factor); | |
71 | void zoomIn2(qreal factor); |
|
71 | void zoomIn2(qreal factor, Qt::Orientation orientation); | |
72 | void zoomOut(qreal factor); |
|
72 | void zoomOut(qreal factor); | |
73 | void zoomOut2(qreal factor); |
|
73 | void zoomOut2(qreal factor, Qt::Orientation orientation); | |
74 | void zoomIn(const QRectF &rect); |
|
74 | void zoomIn(const QRectF &rect); | |
75 | void zoomReset(); |
|
75 | void zoomReset(); | |
76 | bool isZoomed(); |
|
76 | bool isZoomed(); | |
77 | void scroll(qreal dx, qreal dy); |
|
77 | void scroll(qreal dx, qreal dy); | |
78 | }; |
|
78 | }; | |
79 |
|
79 | |||
80 | QT_CHARTS_END_NAMESPACE |
|
80 | QT_CHARTS_END_NAMESPACE | |
81 | #endif |
|
81 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now