##// END OF EJS Templates
Added ChartView.minimumMargins to QML properties
Tero Ahola -
r1928:6a089ea6fc66
parent child
Show More
@@ -0,0 +1,111
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "declarativemargins.h"
22 #include <QDataStream>
23 #include <QDebug>
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27 /*!
28 \qmlclass Margins
29 Uncreatable type that is used to define top, bottom, left and right margins.
30 */
31
32 /*!
33 \qmlproperty int Margins::top
34 The top margin.
35 */
36
37 /*!
38 \qmlproperty int Margins::bottom
39 The bottom margin.
40 */
41
42 /*!
43 \qmlproperty int Margins::left
44 The left margin.
45 */
46
47 /*!
48 \qmlproperty int Margins::right
49 The right margin.
50 */
51
52 DeclarativeMargins::DeclarativeMargins(QObject *parent) :
53 QObject(parent)
54 {
55 QMargins::setTop(0);
56 QMargins::setBottom(0);
57 QMargins::setLeft(0);
58 QMargins::setRight(0);
59 }
60
61 void DeclarativeMargins::setTop(int top)
62 {
63 if (top < 0) {
64 qWarning() << "Cannot set top margin to a negative value:" << top;
65 } else {
66 if (top != QMargins::top()) {
67 QMargins::setTop(top);
68 emit topChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right());
69 }
70 }
71 }
72
73 void DeclarativeMargins::setBottom(int bottom)
74 {
75 if (bottom < 0) {
76 qWarning() << "Cannot set bottom margin to a negative value:" << bottom;
77 } else {
78 if (bottom != QMargins::bottom()) {
79 QMargins::setBottom(bottom);
80 emit bottomChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right());
81 }
82 }
83 }
84
85 void DeclarativeMargins::setLeft(int left)
86 {
87 if (left < 0) {
88 qWarning() << "Cannot set left margin to a negative value:" << left;
89 } else {
90 if (left != QMargins::left()) {
91 QMargins::setLeft(left);
92 emit leftChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right());
93 }
94 }
95 }
96
97 void DeclarativeMargins::setRight(int right)
98 {
99 if (right < 0) {
100 qWarning() << "Cannot set left margin to a negative value:" << right;
101 } else {
102 if (right != QMargins::right()) {
103 QMargins::setRight(right);
104 emit rightChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right());
105 }
106 }
107 }
108
109 #include "moc_declarativemargins.cpp"
110
111 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,54
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef DECLARATIVE_MARGINS_H
22 #define DECLARATIVE_MARGINS_H
23
24 #include "qchartglobal.h"
25 #include <QObject>
26 #include <QMargins>
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 class DeclarativeMargins : public QObject, public QMargins
31 {
32 Q_OBJECT
33 Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged)
34 Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
35 Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged)
36 Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged)
37
38 public:
39 explicit DeclarativeMargins(QObject *parent = 0);
40 void setTop(int top);
41 void setBottom(int bottom);
42 void setLeft(int left);
43 void setRight(int right);
44
45 Q_SIGNALS:
46 void topChanged(int top, int bottom, int left, int right);
47 void bottomChanged(int top, int bottom, int left, int right);
48 void leftChanged(int top, int bottom, int left, int right);
49 void rightChanged(int top, int bottom, int left, int right);
50 };
51
52 QTCOMMERCIALCHART_END_NAMESPACE
53
54 #endif // DECLARATIVE_MARGINS_H
@@ -1,180 +1,181
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23 import QmlCustomModel 1.0
23 import QmlCustomModel 1.0
24
24
25 Rectangle {
25 Rectangle {
26 anchors.fill: parent
26 anchors.fill: parent
27
27
28 //![1]
28 //![1]
29 ChartView {
29 ChartView {
30 id: chartView
30 id: chartView
31 title: "Top-5 car brand shares in Finland"
31 title: "Top-5 car brand shares in Finland"
32 anchors.fill: parent
32 anchors.fill: parent
33 animationOptions: ChartView.SeriesAnimations
33 animationOptions: ChartView.SeriesAnimations
34
34
35 BarCategoriesAxis {
35 BarCategoriesAxis {
36 id: categoriesAxis
36 id: categoriesAxis
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
38 min: "2007"
38 min: "2007"
39 max: "2014"
39 max: "2014"
40 }
40 }
41
41
42 ValueAxis {
42 ValueAxis {
43 id: valueAxis
43 id: valueAxis
44 min: 0
44 min: 0
45 max: 60
45 max: 60
46 }
46 }
47 // ...
47 // ...
48 //![1]
48 //![1]
49
49
50 //![2]
50 //![2]
51 CustomModel {
51 CustomModel {
52 id: customModel
52 id: customModel
53 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
53 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
54 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
54 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
55 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
55 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
56 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
56 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
57 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
57 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
58 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
58 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
59 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
59 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
60 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
60 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
61 }
61 }
62 //![2]
62 //![2]
63
63
64 //![5]
64 //![5]
65 BarSeries {
65 BarSeries {
66 id: myBarSeries
66 id: myBarSeries
67 name: "Others"
67 name: "Others"
68 axisX: categoriesAxis
68 axisX: categoriesAxis
69 axisY: valueAxis
69 axisY: valueAxis
70 barWidth: 0.9
70 barWidth: 0.9
71 visible: false
71 visible: false
72 HBarModelMapper {
72 HBarModelMapper {
73 model: customModel
73 model: customModel
74 firstBarSetRow: 6
74 firstBarSetRow: 6
75 lastBarSetRow: 6
75 lastBarSetRow: 6
76 firstColumn: 2
76 firstColumn: 2
77 }
77 }
78 }
78 }
79 //![5]
79 //![5]
80
80
81 //![4]
81 //![4]
82 LineSeries {
82 LineSeries {
83 id: lineSeries1
83 id: lineSeries1
84 name: "Volkswagen"
84 name: "Volkswagen"
85 axisX: categoriesAxis
85 axisX: categoriesAxis
86 axisY: valueAxis
86 axisY: valueAxis
87 visible: false
87 visible: false
88 HXYModelMapper {
88 HXYModelMapper {
89 model: customModel
89 model: customModel
90 xRow: 0
90 xRow: 0
91 yRow: 1
91 yRow: 1
92 firstColumn: 2
92 firstColumn: 2
93 }
93 }
94 }
94 }
95 //![4]
95 //![4]
96
96
97 LineSeries {
97 LineSeries {
98 id: lineSeries2
98 id: lineSeries2
99 name: "Toyota"
99 name: "Toyota"
100 axisX: categoriesAxis
100 axisX: categoriesAxis
101 axisY: valueAxis
101 axisY: valueAxis
102 visible: false
102 visible: false
103 HXYModelMapper {
103 HXYModelMapper {
104 model: customModel
104 model: customModel
105 xRow: 0
105 xRow: 0
106 yRow: 2
106 yRow: 2
107 firstColumn: 2
107 firstColumn: 2
108 }
108 }
109 }
109 }
110
110
111 LineSeries {
111 LineSeries {
112 id: lineSeries3
112 id: lineSeries3
113 name: "Ford"
113 name: "Ford"
114 axisX: categoriesAxis
114 axisX: categoriesAxis
115 axisY: valueAxis
115 axisY: valueAxis
116 visible: false
116 visible: false
117 HXYModelMapper {
117 HXYModelMapper {
118 model: customModel
118 model: customModel
119 xRow: 0
119 xRow: 0
120 yRow: 3
120 yRow: 3
121 firstColumn: 2
121 firstColumn: 2
122 }
122 }
123 }
123 }
124
124
125 LineSeries {
125 LineSeries {
126 id: lineSeries4
126 id: lineSeries4
127 name: "Skoda"
127 name: "Skoda"
128 axisX: categoriesAxis
128 axisX: categoriesAxis
129 axisY: valueAxis
129 axisY: valueAxis
130 visible: false
130 visible: false
131 HXYModelMapper {
131 HXYModelMapper {
132 model: customModel
132 model: customModel
133 xRow: 0
133 xRow: 0
134 yRow: 4
134 yRow: 4
135 firstColumn: 2
135 firstColumn: 2
136 }
136 }
137 }
137 }
138
138
139 LineSeries {
139 LineSeries {
140 id: lineSeries5
140 id: lineSeries5
141 name: "Volvo"
141 name: "Volvo"
142 axisX: categoriesAxis
142 axisX: categoriesAxis
143 axisY: valueAxis
143 axisY: valueAxis
144 visible: false
144 visible: false
145 HXYModelMapper {
145 HXYModelMapper {
146 model: customModel
146 model: customModel
147 xRow: 0
147 xRow: 0
148 yRow: 5
148 yRow: 5
149 firstColumn: 2
149 firstColumn: 2
150 }
150 }
151 }
151 }
152
152
153 //![3]
153 //![3]
154 PieSeries {
154 PieSeries {
155 id: pieSeries
155 id: pieSeries
156 size: 0.4
156 size: 0.4
157 horizontalPosition: 0.85
157 horizontalPosition: 0.85
158 verticalPosition: 0.4
158 verticalPosition: 0.4
159 onClicked: {
159 onClicked: {
160 // Show the selection by exploding the slice
160 // Show the selection by exploding the slice
161 slice.exploded = !slice.exploded;
161 slice.exploded = !slice.exploded;
162
162
163 // Update the line series to show the yearly data for this slice
163 // Update the line series to show the yearly data for this slice
164 for (var i = 0; i < chartView.count; i++) {
164 for (var i = 0; i < chartView.count; i++) {
165 if (chartView.series(i).name == slice.label) {
165 if (chartView.series(i).name == slice.label) {
166 chartView.series(i).visible = slice.exploded;
166 chartView.series(i).visible = slice.exploded;
167 }
167 }
168 }
168 }
169 }
169 }
170
170
171 }
171 VPieModelMapper {
172 VPieModelMapper {
172 model: customModel
173 model: customModel
174 series: pieSeries
173 labelsColumn: 1
175 labelsColumn: 1
174 valuesColumn: 2
176 valuesColumn: 2
175 firstRow: 1
177 firstRow: 1
176 }
178 }
177 }
178 //![3]
179 //![3]
179 }
180 }
180 }
181 }
@@ -1,47 +1,49
1 TARGET = qtcommercialchartqml
1 TARGET = qtcommercialchartqml
2 QT += declarative
2 QT += declarative
3
3
4 !include( ../plugins.pri ) {
4 !include( ../plugins.pri ) {
5 error( "Couldn't find the plugins.pri file!" )
5 error( "Couldn't find the plugins.pri file!" )
6 }
6 }
7 INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR
7 INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR
8
8
9 CONFIG(debug, debug|release) {
9 CONFIG(debug, debug|release) {
10 mac: TARGET = $$join(TARGET,,,_debug)
10 mac: TARGET = $$join(TARGET,,,_debug)
11 win32: TARGET = $$join(TARGET,,,d)
11 win32: TARGET = $$join(TARGET,,,d)
12 }
12 }
13
13
14 SOURCES += \
14 SOURCES += \
15 plugin.cpp \
15 plugin.cpp \
16 declarativechart.cpp \
16 declarativechart.cpp \
17 declarativexypoint.cpp \
17 declarativexypoint.cpp \
18 declarativexyseries.cpp \
18 declarativexyseries.cpp \
19 declarativelineseries.cpp \
19 declarativelineseries.cpp \
20 declarativesplineseries.cpp \
20 declarativesplineseries.cpp \
21 declarativeareaseries.cpp \
21 declarativeareaseries.cpp \
22 declarativescatterseries.cpp \
22 declarativescatterseries.cpp \
23 declarativepieseries.cpp \
23 declarativepieseries.cpp \
24 declarativebarseries.cpp \
24 declarativebarseries.cpp \
25 declarativecategoryaxis.cpp
25 declarativecategoryaxis.cpp \
26 declarativemargins.cpp
26
27
27 HEADERS += \
28 HEADERS += \
28 declarativechart.h \
29 declarativechart.h \
29 declarativexypoint.h \
30 declarativexypoint.h \
30 declarativexyseries.h \
31 declarativexyseries.h \
31 declarativelineseries.h \
32 declarativelineseries.h \
32 declarativesplineseries.h \
33 declarativesplineseries.h \
33 declarativeareaseries.h \
34 declarativeareaseries.h \
34 declarativescatterseries.h \
35 declarativescatterseries.h \
35 declarativepieseries.h \
36 declarativepieseries.h \
36 declarativebarseries.h \
37 declarativebarseries.h \
37 declarativecategoryaxis.h
38 declarativecategoryaxis.h \
39 declarativemargins.h
38
40
39 TARGETPATH = QtCommercial/Chart
41 TARGETPATH = QtCommercial/Chart
40 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
42 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
41 qmldir.files += $$PWD/qmldir
43 qmldir.files += $$PWD/qmldir
42 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
44 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
43 INSTALLS += target qmldir
45 INSTALLS += target qmldir
44
46
45 FILE = $$PWD/qmldir
47 FILE = $$PWD/qmldir
46 win32:{FILE = $$replace(FILE, "/","\\")}
48 win32:{FILE = $$replace(FILE, "/","\\")}
47 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
49 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_PLUGIN_DIR
@@ -1,678 +1,677
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativechart.h"
21 #include "declarativechart.h"
22 #include <QPainter>
22 #include <QPainter>
23 #include <QDeclarativeEngine>
23 #include <QDeclarativeEngine>
24 #include "declarativelineseries.h"
24 #include "declarativelineseries.h"
25 #include "declarativeareaseries.h"
25 #include "declarativeareaseries.h"
26 #include "declarativebarseries.h"
26 #include "declarativebarseries.h"
27 #include "declarativepieseries.h"
27 #include "declarativepieseries.h"
28 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
29 #include "declarativescatterseries.h"
29 #include "declarativescatterseries.h"
30 #include "qbarcategoryaxis.h"
30 #include "qbarcategoryaxis.h"
31 #include "qvalueaxis.h"
31 #include "qvalueaxis.h"
32 #include "qcategoryaxis.h"
32 #include "qcategoryaxis.h"
33 #include "qabstractseries_p.h"
33 #include "qabstractseries_p.h"
34 #include "declarativemargins.h"
34
35
35 #ifndef QT_ON_ARM
36 #ifndef QT_ON_ARM
36 #include "qdatetimeaxis.h"
37 #include "qdatetimeaxis.h"
37 #endif
38 #endif
38
39
39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40
41
41 /*!
42 /*!
42 \qmlclass ChartView DeclarativeChart
43 \qmlclass ChartView DeclarativeChart
43
44
44 ChartView element is the parent that is responsible for showing different chart series types.
45 ChartView element is the parent that is responsible for showing different chart series types.
45
46
46 The following QML shows how to create a simple chart with one pie series:
47 The following QML shows how to create a simple chart with one pie series:
47 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
48 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
48 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
49 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
49 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
50 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
50
51
51 \beginfloatleft
52 \beginfloatleft
52 \image examples_qmlpiechart.png
53 \image examples_qmlpiechart.png
53 \endfloat
54 \endfloat
54 \clearfloat
55 \clearfloat
55 */
56 */
56
57
57 /*!
58 /*!
58 \qmlproperty Theme ChartView::theme
59 \qmlproperty Theme ChartView::theme
59 Theme defines the visual appearance of the chart, including for example colors, fonts, line
60 Theme defines the visual appearance of the chart, including for example colors, fonts, line
60 widths and chart background.
61 widths and chart background.
61 */
62 */
62
63
63 /*!
64 /*!
64 \qmlproperty Animation ChartView::animation
65 \qmlproperty Animation ChartView::animation
65 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
66 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
66 ChartView.SeriesAnimations or ChartView.AllAnimations.
67 ChartView.SeriesAnimations or ChartView.AllAnimations.
67 */
68 */
68
69
69 /*!
70 /*!
70 \qmlproperty Font ChartView::titleFont
71 \qmlproperty Font ChartView::titleFont
71 The title font of the chart
72 The title font of the chart
72
73
73 See the \l {Font} {QML Font Element} for detailed documentation.
74 See the \l {Font} {QML Font Element} for detailed documentation.
74 */
75 */
75
76
76 /*!
77 /*!
77 \qmlproperty string ChartView::title
78 \qmlproperty string ChartView::title
78 The title of the chart, shown on top of the chart.
79 The title of the chart, shown on top of the chart.
79 \sa ChartView::titleColor
80 \sa ChartView::titleColor
80 */
81 */
81
82
82 /*!
83 /*!
83 \qmlproperty string ChartView::titleColor
84 \qmlproperty string ChartView::titleColor
84 The color of the title text.
85 The color of the title text.
85 */
86 */
86
87
87 /*!
88 /*!
88 \qmlproperty Axis ChartView::axisX
89 \qmlproperty Axis ChartView::axisX
89 The x-axis of the chart.
90 The x-axis of the chart.
90 */
91 */
91
92
92 /*!
93 /*!
93 \qmlproperty Axis ChartView::axisY
94 \qmlproperty Axis ChartView::axisY
94 The default y-axis of the chart.
95 The default y-axis of the chart.
95 */
96 */
96
97
97 /*!
98 /*!
98 \qmlproperty Legend ChartView::legend
99 \qmlproperty Legend ChartView::legend
99 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
100 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
100 */
101 */
101
102
102 /*!
103 /*!
103 \qmlproperty int ChartView::count
104 \qmlproperty int ChartView::count
104 The count of series added to the chart.
105 The count of series added to the chart.
105 */
106 */
106
107
107 /*!
108 /*!
108 \qmlproperty color ChartView::backgroundColor
109 \qmlproperty color ChartView::backgroundColor
109 The color of the chart's background. By default background color is defined by chart theme.
110 The color of the chart's background. By default background color is defined by chart theme.
110 \sa ChartView::theme
111 \sa ChartView::theme
111 */
112 */
112
113
113 /*!
114 /*!
114 \qmlproperty bool ChartView::dropShadowEnabled
115 \qmlproperty bool ChartView::dropShadowEnabled
115 The chart's border drop shadow. Set to true to enable drop shadow.
116 The chart's border drop shadow. Set to true to enable drop shadow.
116 */
117 */
117
118
118 /*!
119 /*!
119 \qmlproperty real ChartView::topMargin
120 \qmlproperty real ChartView::topMargin
120 The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin
121 Deprecated. Use minimumMargins and plotArea instead.
121 area of the chart view. Top margin area is also used by legend, if aligned to top.
122 */
122 */
123
123
124 /*!
124 /*!
125 \qmlproperty real ChartView::bottomMargin
125 \qmlproperty real ChartView::bottomMargin
126 The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by
126 Deprecated. Use minimumMargins and plotArea instead.
127 legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks.
128 */
127 */
129
128
130 /*!
129 /*!
131 \qmlproperty real ChartView::leftMargin
130 \qmlproperty real ChartView::leftMargin
132 The space between the left side of chart view and the left side of the plot area. The left margin area may be used by
131 Deprecated. Use minimumMargins and plotArea instead.
133 legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks.
134 */
132 */
135
133
136 /*!
134 /*!
137 \qmlproperty real ChartView::rightMargin
135 \qmlproperty real ChartView::rightMargin
138 The space between the right side of chart view and the right side of the plot area. The right margin area may be used
136 Deprecated. Use minimumMargins and plotArea instead.
139 by legend (if aligned to right).
137 */
138
139 /*!
140 \qmlproperty Margins ChartView::minimumMargins
141 The minimum margins allowed between the outer bounds and the plotArea of the ChartView.
140 */
142 */
141
143
142 /*!
144 /*!
143 \qmlmethod AbstractSeries ChartView::series(int index)
145 \qmlmethod AbstractSeries ChartView::series(int index)
144 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
146 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
145 the count property of the chart.
147 the count property of the chart.
146 */
148 */
147
149
148 /*!
150 /*!
149 \qmlmethod AbstractSeries ChartView::series(string name)
151 \qmlmethod AbstractSeries ChartView::series(string name)
150 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
152 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
151 */
153 */
152
154
153 /*!
155 /*!
154 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name)
156 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name)
155 Creates a series object of \a type to the chart. For example:
157 Creates a series object of \a type to the chart. For example:
156 \code
158 \code
157 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series");
159 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series");
158 scatter.markerSize = 22;
160 scatter.markerSize = 22;
159 scatter.append(1.1, 2.0);
161 scatter.append(1.1, 2.0);
160 \endcode
162 \endcode
161 */
163 */
162
164
163 /*!
165 /*!
164 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
166 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
165 The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported.
167 The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported.
166 */
168 */
167
169
168 /*!
170 /*!
169 \qmlmethod ChartView::zoomY(real factor)
171 \qmlmethod ChartView::zoomY(real factor)
170 Zooms in by \a factor on the center of the chart.
172 Zooms in by \a factor on the center of the chart.
171 */
173 */
172
174
173 /*!
175 /*!
174 \qmlmethod ChartView::scrollLeft(real pixels)
176 \qmlmethod ChartView::scrollLeft(real pixels)
175 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
177 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
176 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
178 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
177 */
179 */
178
180
179 /*!
181 /*!
180 \qmlmethod ChartView::scrollRight(real pixels)
182 \qmlmethod ChartView::scrollRight(real pixels)
181 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
183 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
182 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
184 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
183 */
185 */
184
186
185 /*!
187 /*!
186 \qmlmethod ChartView::scrollUp(real pixels)
188 \qmlmethod ChartView::scrollUp(real pixels)
187 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
189 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
188 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
190 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
189 */
191 */
190
192
191 /*!
193 /*!
192 \qmlmethod ChartView::scrollDown(real pixels)
194 \qmlmethod ChartView::scrollDown(real pixels)
193 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
195 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
194 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
196 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
195 */
197 */
196
198
197 /*!
199 /*!
198 \qmlsignal ChartView::onTopMarginChanged(real margin)
200 \qmlsignal ChartView::onTopMarginChanged(real margin)
199 The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size
201 The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size
200 related properties of the legend or chart title.
202 related properties of the legend or chart title.
201 */
203 */
202
204
203 /*!
205 /*!
204 \qmlsignal ChartView::onBottomMarginChanged(real margin)
206 \qmlsignal ChartView::onBottomMarginChanged(real margin)
205 The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size
207 The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size
206 related properties of the legend or chart title.
208 related properties of the legend or chart title.
207 */
209 */
208
210
209 /*!
211 /*!
210 \qmlsignal ChartView::onLeftMarginChanged(real margin)
212 \qmlsignal ChartView::onLeftMarginChanged(real margin)
211 The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size
213 The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size
212 related properties of the legend or chart title.
214 related properties of the legend or chart title.
213 */
215 */
214
216
215 /*!
217 /*!
216 \qmlsignal ChartView::onRightMarginChanged(real margin)
218 \qmlsignal ChartView::onRightMarginChanged(real margin)
217 The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size
219 The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size
218 related properties of the legend or chart title.
220 related properties of the legend or chart title.
219 */
221 */
220
222
221 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
223 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
222 : QDeclarativeItem(parent),
224 : QDeclarativeItem(parent),
223 m_chart(new QChart(this))
225 m_chart(new QChart(this))
224 {
226 {
225 setFlag(QGraphicsItem::ItemHasNoContents, false);
227 setFlag(QGraphicsItem::ItemHasNoContents, false);
226 //TODO: check what should be really here margins or platArea ?!
228 m_minMargins = new DeclarativeMargins(this);
227 m_chartMargins = m_chart->minimumMargins();
229 connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
228 connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF)));
230 connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
231 connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
232 connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
233 // TODO: connect to plotAreaChanged signal from m_chart
229 }
234 }
230
235
231 void DeclarativeChart::handleMarginsChanged(QRectF newMargins)
236 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
232 {
237 {
233 //TODO: check what should be really here margins or platArea ?!
238 m_chart->setMinimumMargins(QMargins(left, top, right, bottom));
234 if (m_chartMargins.top() != newMargins.top())
235 topMarginChanged(m_chart->minimumMargins().top());
236 if (m_chartMargins.bottom() != newMargins.bottom())
237 bottomMarginChanged(m_chart->minimumMargins().bottom());
238 if (m_chartMargins.left() != newMargins.left())
239 leftMarginChanged(m_chart->minimumMargins().left());
240 if (m_chartMargins.right() != newMargins.right())
241 rightMarginChanged(m_chart->minimumMargins().right());
242
243 m_chartMargins = m_chart->minimumMargins();
244 }
239 }
245
240
246 DeclarativeChart::~DeclarativeChart()
241 DeclarativeChart::~DeclarativeChart()
247 {
242 {
248 delete m_chart;
243 delete m_chart;
249 }
244 }
250
245
251 void DeclarativeChart::childEvent(QChildEvent *event)
246 void DeclarativeChart::childEvent(QChildEvent *event)
252 {
247 {
253 if (event->type() == QEvent::ChildAdded) {
248 if (event->type() == QEvent::ChildAdded) {
254 if (qobject_cast<QAbstractSeries *>(event->child())) {
249 if (qobject_cast<QAbstractSeries *>(event->child())) {
255 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
250 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
256 }
251 }
257 }
252 }
258 }
253 }
259
254
260 void DeclarativeChart::componentComplete()
255 void DeclarativeChart::componentComplete()
261 {
256 {
262 foreach(QObject *child, children()) {
257 foreach(QObject *child, children()) {
263 if (qobject_cast<QAbstractSeries *>(child)) {
258 if (qobject_cast<QAbstractSeries *>(child)) {
264 // Add series to the chart
259 // Add series to the chart
265 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
260 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
266 m_chart->addSeries(series);
261 m_chart->addSeries(series);
267
262
268 // Set optional user defined axes and connect axis related signals
263 // Set optional user defined axes and connect axis related signals
269 if (qobject_cast<DeclarativeLineSeries *>(child)) {
264 if (qobject_cast<DeclarativeLineSeries *>(child)) {
270 DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child);
265 DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child);
271 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
266 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
272 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
267 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
273 setAxisX(s->axisX(), s);
268 setAxisX(s->axisX(), s);
274 setAxisY(s->axisY(), s);
269 setAxisY(s->axisY(), s);
275 } else if (qobject_cast<DeclarativeSplineSeries *>(child)) {
270 } else if (qobject_cast<DeclarativeSplineSeries *>(child)) {
276 DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child);
271 DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child);
277 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
272 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
278 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
273 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
279 setAxisX(s->axisX(), s);
274 setAxisX(s->axisX(), s);
280 setAxisY(s->axisY(), s);
275 setAxisY(s->axisY(), s);
281 } else if (qobject_cast<DeclarativeScatterSeries *>(child)) {
276 } else if (qobject_cast<DeclarativeScatterSeries *>(child)) {
282 DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child);
277 DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child);
283 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
278 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
284 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
279 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
285 setAxisX(s->axisX(), s);
280 setAxisX(s->axisX(), s);
286 setAxisY(s->axisY(), s);
281 setAxisY(s->axisY(), s);
287 } else if (qobject_cast<DeclarativeAreaSeries *>(child)) {
282 } else if (qobject_cast<DeclarativeAreaSeries *>(child)) {
288 DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child);
283 DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child);
289 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
284 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
290 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
285 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
291 setAxisX(s->axisX(), s);
286 setAxisX(s->axisX(), s);
292 setAxisY(s->axisY(), s);
287 setAxisY(s->axisY(), s);
293 } else if (qobject_cast<DeclarativeBarSeries *>(child)) {
288 } else if (qobject_cast<DeclarativeBarSeries *>(child)) {
294 DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child);
289 DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child);
295 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
290 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
296 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
291 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
297 setAxisX(s->axisX(), s);
292 setAxisX(s->axisX(), s);
298 setAxisY(s->axisY(), s);
293 setAxisY(s->axisY(), s);
299 } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) {
294 } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) {
300 DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child);
295 DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child);
301 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
296 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
302 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
297 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
303 setAxisX(s->axisX(), s);
298 setAxisX(s->axisX(), s);
304 setAxisY(s->axisY(), s);
299 setAxisY(s->axisY(), s);
305 } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) {
300 } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) {
306 DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child);
301 DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child);
307 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
302 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
308 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
303 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
309 setAxisX(s->axisX(), s);
304 setAxisX(s->axisX(), s);
310 setAxisY(s->axisY(), s);
305 setAxisY(s->axisY(), s);
311 } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) {
306 } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) {
312 DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child);
307 DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child);
313 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
308 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
314 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
309 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
315 setAxisX(s->axisX(), s);
310 setAxisX(s->axisX(), s);
316 setAxisY(s->axisY(), s);
311 setAxisY(s->axisY(), s);
317 } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) {
312 } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) {
318 DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child);
313 DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child);
319 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
314 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
320 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
315 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
321 setAxisX(s->axisX(), s);
316 setAxisX(s->axisX(), s);
322 setAxisY(s->axisY(), s);
317 setAxisY(s->axisY(), s);
323 } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) {
318 } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) {
324 DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child);
319 DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child);
325 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
320 connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *)));
326 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
321 connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *)));
327 setAxisX(s->axisX(), s);
322 setAxisX(s->axisX(), s);
328 setAxisY(s->axisY(), s);
323 setAxisY(s->axisY(), s);
329 }
324 }
330
325
331 // Create the missing axes for the series that cannot be painted without axes
326 // Create the missing axes for the series that cannot be painted without axes
332 createDefaultAxes(series);
327 createDefaultAxes(series);
333 } else if(qobject_cast<QAbstractAxis *>(child)) {
328 } else if(qobject_cast<QAbstractAxis *>(child)) {
334 // Do nothing, axes are set for the chart in the context of series
329 // Do nothing, axes are set for the chart in the context of series
335 }
330 }
336 }
331 }
337
332
338 QDeclarativeItem::componentComplete();
333 QDeclarativeItem::componentComplete();
339 }
334 }
340
335
341 void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis)
336 void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis)
342 {
337 {
343 // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis;
338 // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis;
344 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
339 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
345 m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
340 m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
346 }
341 }
347 }
342 }
348
343
349 void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis)
344 void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis)
350 {
345 {
351 // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis;
346 // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis;
352 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
347 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
353 m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
348 m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
354 }
349 }
355 }
350 }
356
351
357 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
352 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
358 {
353 {
359 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
354 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
360 if (newGeometry.isValid()) {
355 if (newGeometry.isValid()) {
361 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
356 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
362 m_chart->resize(newGeometry.width(), newGeometry.height());
357 m_chart->resize(newGeometry.width(), newGeometry.height());
363 }
358 }
364 }
359 }
365 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
360 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
366 }
361 }
367
362
368 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
363 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
369 {
364 {
370 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
365 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
371 if (chartTheme != m_chart->theme())
366 if (chartTheme != m_chart->theme())
372 m_chart->setTheme(chartTheme);
367 m_chart->setTheme(chartTheme);
373 }
368 }
374
369
375 DeclarativeChart::Theme DeclarativeChart::theme()
370 DeclarativeChart::Theme DeclarativeChart::theme()
376 {
371 {
377 return (DeclarativeChart::Theme) m_chart->theme();
372 return (DeclarativeChart::Theme) m_chart->theme();
378 }
373 }
379
374
380 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
375 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
381 {
376 {
382 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
377 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
383 if (animationOptions != m_chart->animationOptions())
378 if (animationOptions != m_chart->animationOptions())
384 m_chart->setAnimationOptions(animationOptions);
379 m_chart->setAnimationOptions(animationOptions);
385 }
380 }
386
381
387 DeclarativeChart::Animation DeclarativeChart::animationOptions()
382 DeclarativeChart::Animation DeclarativeChart::animationOptions()
388 {
383 {
389 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
384 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
390 return DeclarativeChart::AllAnimations;
385 return DeclarativeChart::AllAnimations;
391 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
386 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
392 return DeclarativeChart::GridAxisAnimations;
387 return DeclarativeChart::GridAxisAnimations;
393 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
388 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
394 return DeclarativeChart::SeriesAnimations;
389 return DeclarativeChart::SeriesAnimations;
395 else
390 else
396 return DeclarativeChart::NoAnimation;
391 return DeclarativeChart::NoAnimation;
397 }
392 }
398
393
399 void DeclarativeChart::setTitle(QString title)
394 void DeclarativeChart::setTitle(QString title)
400 {
395 {
401 if (title != m_chart->title())
396 if (title != m_chart->title())
402 m_chart->setTitle(title);
397 m_chart->setTitle(title);
403 }
398 }
404 QString DeclarativeChart::title()
399 QString DeclarativeChart::title()
405 {
400 {
406 return m_chart->title();
401 return m_chart->title();
407 }
402 }
408
403
409 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
404 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
410 {
405 {
411 return m_chart->axisX(series);
406 return m_chart->axisX(series);
412 }
407 }
413
408
414 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
409 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
415 {
410 {
416 return m_chart->axisY(series);
411 return m_chart->axisY(series);
417 }
412 }
418
413
419 QLegend *DeclarativeChart::legend()
414 QLegend *DeclarativeChart::legend()
420 {
415 {
421 return m_chart->legend();
416 return m_chart->legend();
422 }
417 }
423
418
424 void DeclarativeChart::setTitleColor(QColor color)
419 void DeclarativeChart::setTitleColor(QColor color)
425 {
420 {
426 QBrush b = m_chart->titleBrush();
421 QBrush b = m_chart->titleBrush();
427 if (color != b.color()) {
422 if (color != b.color()) {
428 b.setColor(color);
423 b.setColor(color);
429 m_chart->setTitleBrush(b);
424 m_chart->setTitleBrush(b);
430 emit titleColorChanged(color);
425 emit titleColorChanged(color);
431 }
426 }
432 }
427 }
433
428
434 QFont DeclarativeChart::titleFont() const
429 QFont DeclarativeChart::titleFont() const
435 {
430 {
436 return m_chart->titleFont();
431 return m_chart->titleFont();
437 }
432 }
438
433
439 void DeclarativeChart::setTitleFont(const QFont& font)
434 void DeclarativeChart::setTitleFont(const QFont& font)
440 {
435 {
441 m_chart->setTitleFont(font);
436 m_chart->setTitleFont(font);
442 }
437 }
443
438
444 QColor DeclarativeChart::titleColor()
439 QColor DeclarativeChart::titleColor()
445 {
440 {
446 return m_chart->titleBrush().color();
441 return m_chart->titleBrush().color();
447 }
442 }
448
443
449 void DeclarativeChart::setBackgroundColor(QColor color)
444 void DeclarativeChart::setBackgroundColor(QColor color)
450 {
445 {
451 QBrush b = m_chart->backgroundBrush();
446 QBrush b = m_chart->backgroundBrush();
452 if (b.style() != Qt::SolidPattern || color != b.color()) {
447 if (b.style() != Qt::SolidPattern || color != b.color()) {
453 b.setStyle(Qt::SolidPattern);
448 b.setStyle(Qt::SolidPattern);
454 b.setColor(color);
449 b.setColor(color);
455 m_chart->setBackgroundBrush(b);
450 m_chart->setBackgroundBrush(b);
456 emit backgroundColorChanged();
451 emit backgroundColorChanged();
457 }
452 }
458 }
453 }
459
454
460 QColor DeclarativeChart::backgroundColor()
455 QColor DeclarativeChart::backgroundColor()
461 {
456 {
462 return m_chart->backgroundBrush().color();
457 return m_chart->backgroundBrush().color();
463 }
458 }
464
459
465 int DeclarativeChart::count()
460 int DeclarativeChart::count()
466 {
461 {
467 return m_chart->series().count();
462 return m_chart->series().count();
468 }
463 }
469
464
470 void DeclarativeChart::setDropShadowEnabled(bool enabled)
465 void DeclarativeChart::setDropShadowEnabled(bool enabled)
471 {
466 {
472 if (enabled != m_chart->isDropShadowEnabled()) {
467 if (enabled != m_chart->isDropShadowEnabled()) {
473 m_chart->setDropShadowEnabled(enabled);
468 m_chart->setDropShadowEnabled(enabled);
474 dropShadowEnabledChanged(enabled);
469 dropShadowEnabledChanged(enabled);
475 }
470 }
476 }
471 }
477
472
478 bool DeclarativeChart::dropShadowEnabled()
473 bool DeclarativeChart::dropShadowEnabled()
479 {
474 {
480 return m_chart->isDropShadowEnabled();
475 return m_chart->isDropShadowEnabled();
481 }
476 }
482
477
483 qreal DeclarativeChart::topMargin()
478 qreal DeclarativeChart::topMargin()
484 {
479 {
485 return m_chart->minimumMargins().top();
480 qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead.";
481 return m_chart->plotArea().top();
486 }
482 }
487
483
488 qreal DeclarativeChart::bottomMargin()
484 qreal DeclarativeChart::bottomMargin()
489 {
485 {
490 return m_chart->minimumMargins().bottom();
486 qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead.";
487 return m_chart->plotArea().bottom();
491 }
488 }
492
489
493 qreal DeclarativeChart::leftMargin()
490 qreal DeclarativeChart::leftMargin()
494 {
491 {
495 return m_chart->minimumMargins().left();
492 qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead.";
493 return m_chart->plotArea().left();
496 }
494 }
497
495
498 qreal DeclarativeChart::rightMargin()
496 qreal DeclarativeChart::rightMargin()
499 {
497 {
500 return m_chart->minimumMargins().right();
498 qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead.";
499 return m_chart->plotArea().right();
501 }
500 }
502
501
503 void DeclarativeChart::zoom(qreal factor)
502 void DeclarativeChart::zoom(qreal factor)
504 {
503 {
505 m_chart->zoom(factor);
504 m_chart->zoom(factor);
506 }
505 }
507
506
508 void DeclarativeChart::scrollLeft(qreal pixels)
507 void DeclarativeChart::scrollLeft(qreal pixels)
509 {
508 {
510 m_chart->scroll(pixels, 0);
509 m_chart->scroll(pixels, 0);
511 }
510 }
512
511
513 void DeclarativeChart::scrollRight(qreal pixels)
512 void DeclarativeChart::scrollRight(qreal pixels)
514 {
513 {
515 m_chart->scroll(-pixels, 0);
514 m_chart->scroll(-pixels, 0);
516 }
515 }
517
516
518 void DeclarativeChart::scrollUp(qreal pixels)
517 void DeclarativeChart::scrollUp(qreal pixels)
519 {
518 {
520 m_chart->scroll(0, pixels);
519 m_chart->scroll(0, pixels);
521 }
520 }
522
521
523 void DeclarativeChart::scrollDown(qreal pixels)
522 void DeclarativeChart::scrollDown(qreal pixels)
524 {
523 {
525 m_chart->scroll(0, -pixels);
524 m_chart->scroll(0, -pixels);
526 }
525 }
527
526
528 QAbstractSeries *DeclarativeChart::series(int index)
527 QAbstractSeries *DeclarativeChart::series(int index)
529 {
528 {
530 if (index < m_chart->series().count()) {
529 if (index < m_chart->series().count()) {
531 return m_chart->series().at(index);
530 return m_chart->series().at(index);
532 }
531 }
533 return 0;
532 return 0;
534 }
533 }
535
534
536 QAbstractSeries *DeclarativeChart::series(QString seriesName)
535 QAbstractSeries *DeclarativeChart::series(QString seriesName)
537 {
536 {
538 foreach(QAbstractSeries *series, m_chart->series()) {
537 foreach(QAbstractSeries *series, m_chart->series()) {
539 if (series->name() == seriesName)
538 if (series->name() == seriesName)
540 return series;
539 return series;
541 }
540 }
542 return 0;
541 return 0;
543 }
542 }
544
543
545 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
544 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
546 {
545 {
547 QAbstractSeries *series = 0;
546 QAbstractSeries *series = 0;
548
547
549 switch (type) {
548 switch (type) {
550 case DeclarativeChart::SeriesTypeLine:
549 case DeclarativeChart::SeriesTypeLine:
551 series = new DeclarativeLineSeries();
550 series = new DeclarativeLineSeries();
552 break;
551 break;
553 case DeclarativeChart::SeriesTypeArea:
552 case DeclarativeChart::SeriesTypeArea:
554 series = new DeclarativeAreaSeries();
553 series = new DeclarativeAreaSeries();
555 break;
554 break;
556 case DeclarativeChart::SeriesTypeStackedBar:
555 case DeclarativeChart::SeriesTypeStackedBar:
557 series = new DeclarativeStackedBarSeries();
556 series = new DeclarativeStackedBarSeries();
558 break;
557 break;
559 case DeclarativeChart::SeriesTypePercentBar:
558 case DeclarativeChart::SeriesTypePercentBar:
560 series = new DeclarativePercentBarSeries();
559 series = new DeclarativePercentBarSeries();
561 break;
560 break;
562 case DeclarativeChart::SeriesTypeBar:
561 case DeclarativeChart::SeriesTypeBar:
563 series = new DeclarativeBarSeries();
562 series = new DeclarativeBarSeries();
564 break;
563 break;
565 case DeclarativeChart::SeriesTypeHorizontalBar:
564 case DeclarativeChart::SeriesTypeHorizontalBar:
566 series = new DeclarativeHorizontalBarSeries();
565 series = new DeclarativeHorizontalBarSeries();
567 break;
566 break;
568 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
567 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
569 series = new DeclarativeHorizontalPercentBarSeries();
568 series = new DeclarativeHorizontalPercentBarSeries();
570 break;
569 break;
571 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
570 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
572 series = new DeclarativeHorizontalStackedBarSeries();
571 series = new DeclarativeHorizontalStackedBarSeries();
573 break;
572 break;
574 case DeclarativeChart::SeriesTypePie:
573 case DeclarativeChart::SeriesTypePie:
575 series = new DeclarativePieSeries();
574 series = new DeclarativePieSeries();
576 break;
575 break;
577 case DeclarativeChart::SeriesTypeScatter:
576 case DeclarativeChart::SeriesTypeScatter:
578 series = new DeclarativeScatterSeries();
577 series = new DeclarativeScatterSeries();
579 break;
578 break;
580 case DeclarativeChart::SeriesTypeSpline:
579 case DeclarativeChart::SeriesTypeSpline:
581 series = new DeclarativeSplineSeries();
580 series = new DeclarativeSplineSeries();
582 break;
581 break;
583 default:
582 default:
584 qWarning() << "Illegal series type";
583 qWarning() << "Illegal series type";
585 }
584 }
586
585
587 if (series) {
586 if (series) {
588 series->setName(name);
587 series->setName(name);
589 m_chart->addSeries(series);
588 m_chart->addSeries(series);
590 createDefaultAxes(series);
589 createDefaultAxes(series);
591 }
590 }
592
591
593 return series;
592 return series;
594 }
593 }
595
594
596 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
595 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
597 {
596 {
598 if (axis)
597 if (axis)
599 m_chart->setAxisX(axis, series);
598 m_chart->setAxisX(axis, series);
600 }
599 }
601
600
602 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
601 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
603 {
602 {
604 if (axis)
603 if (axis)
605 m_chart->setAxisY(axis, series);
604 m_chart->setAxisY(axis, series);
606 }
605 }
607
606
608 void DeclarativeChart::createDefaultAxes()
607 void DeclarativeChart::createDefaultAxes()
609 {
608 {
610 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
609 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
611 }
610 }
612
611
613 void DeclarativeChart::createDefaultAxes(QAbstractSeries* series)
612 void DeclarativeChart::createDefaultAxes(QAbstractSeries* series)
614 {
613 {
615 foreach (QAbstractSeries *s, m_chart->series()) {
614 foreach (QAbstractSeries *s, m_chart->series()) {
616 // If there is already an x axis of the correct type, re-use it
615 // If there is already an x axis of the correct type, re-use it
617 if (!m_chart->axisX(series) && s != series && m_chart->axisX(s)
616 if (!m_chart->axisX(series) && s != series && m_chart->axisX(s)
618 && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal))
617 && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal))
619 m_chart->setAxisX(m_chart->axisX(s), series);
618 m_chart->setAxisX(m_chart->axisX(s), series);
620
619
621 // If there is already a y axis of the correct type, re-use it
620 // If there is already a y axis of the correct type, re-use it
622 if (!m_chart->axisY(series) && s != series && m_chart->axisY(s)
621 if (!m_chart->axisY(series) && s != series && m_chart->axisY(s)
623 && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical))
622 && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical))
624 m_chart->setAxisY(m_chart->axisY(s), series);
623 m_chart->setAxisY(m_chart->axisY(s), series);
625 }
624 }
626
625
627 // If no x axis of correct type was found, create a new x axis based of default axis type
626 // If no x axis of correct type was found, create a new x axis based of default axis type
628 if (!m_chart->axisX(series)) {
627 if (!m_chart->axisX(series)) {
629 switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) {
628 switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) {
630 case QAbstractAxis::AxisTypeValue:
629 case QAbstractAxis::AxisTypeValue:
631 m_chart->setAxisX(new QValueAxis(this), series);
630 m_chart->setAxisX(new QValueAxis(this), series);
632 break;
631 break;
633 case QAbstractAxis::AxisTypeBarCategory:
632 case QAbstractAxis::AxisTypeBarCategory:
634 m_chart->setAxisX(new QBarCategoryAxis(this), series);
633 m_chart->setAxisX(new QBarCategoryAxis(this), series);
635 break;
634 break;
636 case QAbstractAxis::AxisTypeCategory:
635 case QAbstractAxis::AxisTypeCategory:
637 m_chart->setAxisX(new QCategoryAxis(this), series);
636 m_chart->setAxisX(new QCategoryAxis(this), series);
638 break;
637 break;
639 #ifndef QT_ON_ARM
638 #ifndef QT_ON_ARM
640 case QAbstractAxis::AxisTypeDateTime:
639 case QAbstractAxis::AxisTypeDateTime:
641 m_chart->setAxisX(new QDateTimeAxis(this), series);
640 m_chart->setAxisX(new QDateTimeAxis(this), series);
642 break;
641 break;
643 #endif
642 #endif
644 default:
643 default:
645 // Do nothing, assume AxisTypeNoAxis
644 // Do nothing, assume AxisTypeNoAxis
646 break;
645 break;
647 }
646 }
648 }
647 }
649
648
650 // If no y axis of correct type was found, create a new y axis based of default axis type
649 // If no y axis of correct type was found, create a new y axis based of default axis type
651 if (!m_chart->axisY(series)) {
650 if (!m_chart->axisY(series)) {
652 switch (series->d_ptr->defaultAxisType(Qt::Vertical)) {
651 switch (series->d_ptr->defaultAxisType(Qt::Vertical)) {
653 case QAbstractAxis::AxisTypeValue:
652 case QAbstractAxis::AxisTypeValue:
654 m_chart->setAxisY(new QValueAxis(this), series);
653 m_chart->setAxisY(new QValueAxis(this), series);
655 break;
654 break;
656 case QAbstractAxis::AxisTypeBarCategory:
655 case QAbstractAxis::AxisTypeBarCategory:
657 m_chart->setAxisY(new QBarCategoryAxis(this), series);
656 m_chart->setAxisY(new QBarCategoryAxis(this), series);
658 break;
657 break;
659 case QAbstractAxis::AxisTypeCategory:
658 case QAbstractAxis::AxisTypeCategory:
660 m_chart->setAxisY(new QCategoryAxis(this), series);
659 m_chart->setAxisY(new QCategoryAxis(this), series);
661 break;
660 break;
662 #ifndef QT_ON_ARM
661 #ifndef QT_ON_ARM
663 case QAbstractAxis::AxisTypeDateTime:
662 case QAbstractAxis::AxisTypeDateTime:
664 m_chart->setAxisY(new QDateTimeAxis(this), series);
663 m_chart->setAxisY(new QDateTimeAxis(this), series);
665 break;
664 break;
666 #endif
665 #endif
667 default:
666 default:
668 // Do nothing, assume AxisTypeNoAxis
667 // Do nothing, assume AxisTypeNoAxis
669 break;
668 break;
670 }
669 }
671 }
670 }
672
671
673 //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series);
672 //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series);
674 }
673 }
675
674
676 #include "moc_declarativechart.cpp"
675 #include "moc_declarativechart.cpp"
677
676
678 QTCOMMERCIALCHART_END_NAMESPACE
677 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,155 +1,161
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVECHART_H
21 #ifndef DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
23
23
24 #include <QtCore/QtGlobal>
24 #include <QtCore/QtGlobal>
25 #include <QDeclarativeItem>
25 #include <QDeclarativeItem>
26 #include "qchart.h"
26 #include "qchart.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class DeclarativeMargins;
31
30 class DeclarativeChart : public QDeclarativeItem
32 class DeclarativeChart : public QDeclarativeItem
31 {
33 {
32 Q_OBJECT
34 Q_OBJECT
33 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
35 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
34 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
36 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
35 Q_PROPERTY(QString title READ title WRITE setTitle)
37 Q_PROPERTY(QString title READ title WRITE setTitle)
36 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
38 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
37 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
39 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
38 Q_PROPERTY(QLegend *legend READ legend)
40 Q_PROPERTY(QLegend *legend READ legend)
39 Q_PROPERTY(int count READ count)
41 Q_PROPERTY(int count READ count)
40 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
42 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
41 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
43 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
42 Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged)
44 Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged)
43 Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged)
45 Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged)
44 Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged)
46 Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged)
45 Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged)
47 Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged)
48 Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins REVISION 1)
46 Q_ENUMS(Animation)
49 Q_ENUMS(Animation)
47 Q_ENUMS(Theme)
50 Q_ENUMS(Theme)
48 Q_ENUMS(SeriesType)
51 Q_ENUMS(SeriesType)
49
52
50 public:
53 public:
51 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
54 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
52 enum Theme {
55 enum Theme {
53 ChartThemeLight = 0,
56 ChartThemeLight = 0,
54 ChartThemeBlueCerulean,
57 ChartThemeBlueCerulean,
55 ChartThemeDark,
58 ChartThemeDark,
56 ChartThemeBrownSand,
59 ChartThemeBrownSand,
57 ChartThemeBlueNcs,
60 ChartThemeBlueNcs,
58 ChartThemeHighContrast,
61 ChartThemeHighContrast,
59 ChartThemeBlueIcy
62 ChartThemeBlueIcy
60 };
63 };
61
64
62 enum Animation {
65 enum Animation {
63 NoAnimation = 0x0,
66 NoAnimation = 0x0,
64 GridAxisAnimations = 0x1,
67 GridAxisAnimations = 0x1,
65 SeriesAnimations =0x2,
68 SeriesAnimations =0x2,
66 AllAnimations = 0x3
69 AllAnimations = 0x3
67 };
70 };
68
71
69 enum SeriesType {
72 enum SeriesType {
70 SeriesTypeLine,
73 SeriesTypeLine,
71 SeriesTypeArea,
74 SeriesTypeArea,
72 SeriesTypeBar,
75 SeriesTypeBar,
73 SeriesTypeStackedBar,
76 SeriesTypeStackedBar,
74 SeriesTypePercentBar,
77 SeriesTypePercentBar,
75 SeriesTypePie,
78 SeriesTypePie,
76 SeriesTypeScatter,
79 SeriesTypeScatter,
77 SeriesTypeSpline,
80 SeriesTypeSpline,
78 SeriesTypeHorizontalBar,
81 SeriesTypeHorizontalBar,
79 SeriesTypeHorizontalStackedBar,
82 SeriesTypeHorizontalStackedBar,
80 SeriesTypeHorizontalPercentBar
83 SeriesTypeHorizontalPercentBar
81 };
84 };
82
85
83 public:
86 public:
84 DeclarativeChart(QDeclarativeItem *parent = 0);
87 DeclarativeChart(QDeclarativeItem *parent = 0);
85 ~DeclarativeChart();
88 ~DeclarativeChart();
86
89
87 public: // From QDeclarativeItem/QGraphicsItem
90 public: // From QDeclarativeItem/QGraphicsItem
88 void childEvent(QChildEvent *event);
91 void childEvent(QChildEvent *event);
89 void componentComplete();
92 void componentComplete();
90 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
93 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
91
94
92 public:
95 public:
93 void setTheme(DeclarativeChart::Theme theme);
96 void setTheme(DeclarativeChart::Theme theme);
94 DeclarativeChart::Theme theme();
97 DeclarativeChart::Theme theme();
95 void setAnimationOptions(DeclarativeChart::Animation animations);
98 void setAnimationOptions(DeclarativeChart::Animation animations);
96 DeclarativeChart::Animation animationOptions();
99 DeclarativeChart::Animation animationOptions();
97 void setTitle(QString title);
100 void setTitle(QString title);
98 QString title();
101 QString title();
99 QLegend *legend();
102 QLegend *legend();
100 QFont titleFont() const;
103 QFont titleFont() const;
101 void setTitleFont(const QFont& font);
104 void setTitleFont(const QFont& font);
102 void setTitleColor(QColor color);
105 void setTitleColor(QColor color);
103 QColor titleColor();
106 QColor titleColor();
104 void setBackgroundColor(QColor color);
107 void setBackgroundColor(QColor color);
105 QColor backgroundColor();
108 QColor backgroundColor();
106 int count();
109 int count();
107 void setDropShadowEnabled(bool enabled);
110 void setDropShadowEnabled(bool enabled);
108 bool dropShadowEnabled();
111 bool dropShadowEnabled();
109 qreal topMargin();
112 qreal topMargin();
110 qreal bottomMargin();
113 qreal bottomMargin();
111 qreal leftMargin();
114 qreal leftMargin();
112 qreal rightMargin();
115 qreal rightMargin();
113 void createDefaultAxes(QAbstractSeries* series);
116 void createDefaultAxes(QAbstractSeries* series);
117 DeclarativeMargins *minimumMargins() { return m_minMargins; }
114
118
115 public:
119 public:
116 Q_INVOKABLE QAbstractSeries *series(int index);
120 Q_INVOKABLE QAbstractSeries *series(int index);
117 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
121 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
118 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
122 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
119 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
123 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
120 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
124 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
121 Q_INVOKABLE void createDefaultAxes();
125 Q_INVOKABLE void createDefaultAxes();
122 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
126 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
123 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
127 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
124
128
125 Q_INVOKABLE void zoom(qreal factor);
129 Q_INVOKABLE void zoom(qreal factor);
126 Q_INVOKABLE void scrollLeft(qreal pixels);
130 Q_INVOKABLE void scrollLeft(qreal pixels);
127 Q_INVOKABLE void scrollRight(qreal pixels);
131 Q_INVOKABLE void scrollRight(qreal pixels);
128 Q_INVOKABLE void scrollUp(qreal pixels);
132 Q_INVOKABLE void scrollUp(qreal pixels);
129 Q_INVOKABLE void scrollDown(qreal pixels);
133 Q_INVOKABLE void scrollDown(qreal pixels);
130
134
131 Q_SIGNALS:
135 Q_SIGNALS:
132 void axisLabelsChanged();
136 void axisLabelsChanged();
133 void titleColorChanged(QColor color);
137 void titleColorChanged(QColor color);
134 void backgroundColorChanged();
138 void backgroundColorChanged();
135 void dropShadowEnabledChanged(bool enabled);
139 void dropShadowEnabledChanged(bool enabled);
136 void topMarginChanged(qreal margin);
140 void topMarginChanged(qreal margin);
137 void bottomMarginChanged(qreal margin);
141 void bottomMarginChanged(qreal margin);
138 void leftMarginChanged(qreal margin);
142 void leftMarginChanged(qreal margin);
139 void rightMarginChanged(qreal margin);
143 void rightMarginChanged(qreal margin);
140
144
141 public Q_SLOTS:
145 public Q_SLOTS:
142 void handleMarginsChanged(QRectF newMargins);
146 // void handleMarginsChanged(QRectF newMargins);
147 void changeMinimumMargins(int top, int bottom, int left, int right);
143 void handleAxisXSet(QAbstractAxis *axis);
148 void handleAxisXSet(QAbstractAxis *axis);
144 void handleAxisYSet(QAbstractAxis *axis);
149 void handleAxisYSet(QAbstractAxis *axis);
145
150
146 private:
151 private:
147 // Extending QChart with DeclarativeChart is not possible because QObject does not support
152 // Extending QChart with DeclarativeChart is not possible because QObject does not support
148 // multi inheritance, so we now have a QChart as a member instead
153 // multi inheritance, so we now have a QChart as a member instead
149 QChart *m_chart;
154 QChart *m_chart;
150 QMargins m_chartMargins;
155 //QMargins m_chartMargins;
156 DeclarativeMargins *m_minMargins;
151 };
157 };
152
158
153 QTCOMMERCIALCHART_END_NAMESPACE
159 QTCOMMERCIALCHART_END_NAMESPACE
154
160
155 #endif // DECLARATIVECHART_H
161 #endif // DECLARATIVECHART_H
@@ -1,157 +1,160
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
22 #include <QtDeclarative/qdeclarative.h>
22 #include <QtDeclarative/qdeclarative.h>
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qabstractaxis.h"
24 #include "qabstractaxis.h"
25 #include "qvalueaxis.h"
25 #include "qvalueaxis.h"
26 #include "qdatetimeaxis.h"
26 #include "qdatetimeaxis.h"
27 #include "declarativecategoryaxis.h"
27 #include "declarativecategoryaxis.h"
28 #include "qbarcategoryaxis.h"
28 #include "qbarcategoryaxis.h"
29 #include "declarativechart.h"
29 #include "declarativechart.h"
30 #include "declarativexypoint.h"
30 #include "declarativexypoint.h"
31 #include "declarativelineseries.h"
31 #include "declarativelineseries.h"
32 #include "declarativesplineseries.h"
32 #include "declarativesplineseries.h"
33 #include "declarativeareaseries.h"
33 #include "declarativeareaseries.h"
34 #include "declarativescatterseries.h"
34 #include "declarativescatterseries.h"
35 #include "declarativebarseries.h"
35 #include "declarativebarseries.h"
36 #include "declarativepieseries.h"
36 #include "declarativepieseries.h"
37 #include "qvxymodelmapper.h"
37 #include "qvxymodelmapper.h"
38 #include "qhxymodelmapper.h"
38 #include "qhxymodelmapper.h"
39 #include "qhpiemodelmapper.h"
39 #include "qhpiemodelmapper.h"
40 #include "qvpiemodelmapper.h"
40 #include "qvpiemodelmapper.h"
41 #include "qhbarmodelmapper.h"
41 #include "qhbarmodelmapper.h"
42 #include "qvbarmodelmapper.h"
42 #include "qvbarmodelmapper.h"
43 #include "declarativemargins.h"
43 #include <QAbstractItemModel>
44 #include <QAbstractItemModel>
44
45
45 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46
47
47 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
48 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
48 {
49 {
49 Q_OBJECT
50 Q_OBJECT
50 public:
51 public:
51 virtual void registerTypes(const char *uri)
52 virtual void registerTypes(const char *uri)
52 {
53 {
53 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
54 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
54
55
55 // QtCommercial.Chart 1.0
56 // QtCommercial.Chart 1.0
56 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
57 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
57 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
58 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
58 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
59 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
59 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
60 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
60 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
61 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
61 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
62 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
62 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
63 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
63 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
64 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
64 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
65 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
65 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
66 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
66 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
67 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
67 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
68 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
68 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
69 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
69 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
70 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
70 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
71 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
71 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
72 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
72 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
73 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
73 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
74 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
74 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
75 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
75 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
76 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
76 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
77 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
77 QLatin1String("Trying to create uncreatable: Legend."));
78 QLatin1String("Trying to create uncreatable: Legend."));
78 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
79 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
79 QLatin1String("Trying to create uncreatable: XYSeries."));
80 QLatin1String("Trying to create uncreatable: XYSeries."));
80 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
81 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
81 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
82 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
82 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
83 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
83 QLatin1String("Trying to create uncreatable: XYModelMapper."));
84 QLatin1String("Trying to create uncreatable: XYModelMapper."));
84 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
85 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
85 QLatin1String("Trying to create uncreatable: PieModelMapper."));
86 QLatin1String("Trying to create uncreatable: PieModelMapper."));
86 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
87 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
87 QLatin1String("Trying to create uncreatable: BarModelMapper."));
88 QLatin1String("Trying to create uncreatable: BarModelMapper."));
88 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
89 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
89 QLatin1String("Trying to create uncreatable: AbstractSeries."));
90 QLatin1String("Trying to create uncreatable: AbstractSeries."));
90 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
91 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
91 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
92 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
92 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
93 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
93 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
94 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
94 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
95 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
95 QLatin1String("Trying to create uncreatable: BarsetBase."));
96 QLatin1String("Trying to create uncreatable: BarsetBase."));
96 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
97 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
97 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
98 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
98
99
99 // QtCommercial.Chart 1.1
100 // QtCommercial.Chart 1.1
100 qmlRegisterType<DeclarativeChart>(uri, 1, 1, "ChartView");
101 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
101 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 1, "XYPoint");
102 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 1, "XYPoint");
102 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
103 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
103 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
104 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
104 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
105 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
105 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
106 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
106 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
107 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
107 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
108 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
108 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
109 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
109 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
110 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
110 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
111 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
111 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
112 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
112 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
113 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
113 qmlRegisterType<QPieSlice>(uri, 1, 1, "PieSlice");
114 qmlRegisterType<QPieSlice>(uri, 1, 1, "PieSlice");
114 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
115 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
115 qmlRegisterType<QHXYModelMapper>(uri, 1, 1, "HXYModelMapper");
116 qmlRegisterType<QHXYModelMapper>(uri, 1, 1, "HXYModelMapper");
116 qmlRegisterType<QVXYModelMapper>(uri, 1, 1, "VXYModelMapper");
117 qmlRegisterType<QVXYModelMapper>(uri, 1, 1, "VXYModelMapper");
117 qmlRegisterType<QHPieModelMapper>(uri, 1, 1, "HPieModelMapper");
118 qmlRegisterType<QHPieModelMapper>(uri, 1, 1, "HPieModelMapper");
118 qmlRegisterType<QVPieModelMapper>(uri, 1, 1, "VPieModelMapper");
119 qmlRegisterType<QVPieModelMapper>(uri, 1, 1, "VPieModelMapper");
119 qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper");
120 qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper");
120 qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper");
121 qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper");
121 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
122 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
122 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
123 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
123 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
124 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
124 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
125 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
125 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
126 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
126 qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend",
127 qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend",
127 QLatin1String("Trying to create uncreatable: Legend."));
128 QLatin1String("Trying to create uncreatable: Legend."));
128 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 1, "XYSeries",
129 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 1, "XYSeries",
129 QLatin1String("Trying to create uncreatable: XYSeries."));
130 QLatin1String("Trying to create uncreatable: XYSeries."));
130 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 1, "AbstractItemModel",
131 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 1, "AbstractItemModel",
131 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
132 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
132 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 1, "XYModelMapper",
133 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 1, "XYModelMapper",
133 QLatin1String("Trying to create uncreatable: XYModelMapper."));
134 QLatin1String("Trying to create uncreatable: XYModelMapper."));
134 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 1, "PieModelMapper",
135 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 1, "PieModelMapper",
135 QLatin1String("Trying to create uncreatable: PieModelMapper."));
136 QLatin1String("Trying to create uncreatable: PieModelMapper."));
136 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 1, "BarModelMapper",
137 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 1, "BarModelMapper",
137 QLatin1String("Trying to create uncreatable: BarModelMapper."));
138 QLatin1String("Trying to create uncreatable: BarModelMapper."));
138 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 1, "AbstractSeries",
139 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 1, "AbstractSeries",
139 QLatin1String("Trying to create uncreatable: AbstractSeries."));
140 QLatin1String("Trying to create uncreatable: AbstractSeries."));
140 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 1, "AbstractBarSeries",
141 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 1, "AbstractBarSeries",
141 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
142 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
142 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 1, "AbstractAxis",
143 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 1, "AbstractAxis",
143 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
144 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
144 qmlRegisterUncreatableType<QBarSet>(uri, 1, 1, "BarSetBase",
145 qmlRegisterUncreatableType<QBarSet>(uri, 1, 1, "BarSetBase",
145 QLatin1String("Trying to create uncreatable: BarsetBase."));
146 QLatin1String("Trying to create uncreatable: BarsetBase."));
146 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 1, "QPieSeries",
147 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 1, "QPieSeries",
147 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
148 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
149 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
150 QLatin1String("Trying to create uncreatable: Margins."));
148 }
151 }
149 };
152 };
150
153
151 #include "plugin.moc"
154 #include "plugin.moc"
152
155
153 QTCOMMERCIALCHART_END_NAMESPACE
156 QTCOMMERCIALCHART_END_NAMESPACE
154
157
155 QTCOMMERCIALCHART_USE_NAMESPACE
158 QTCOMMERCIALCHART_USE_NAMESPACE
156
159
157 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
160 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,110 +1,113
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant series: chartView
28 property variant series: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XYPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XYPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onTopMarginChanged: {
45 onTopMarginChanged: {
46 console.log("chart.onTopMarginChanged: " + margin);
46 console.log("chart.onTopMarginChanged: " + margin);
47 marginVisualizer.opacity = 1.0;
47 marginVisualizer.opacity = 1.0;
48 }
48 }
49 onBottomMarginChanged: {
49 onBottomMarginChanged: {
50 console.log("chart.onBottomMarginChanged: " + margin);
50 console.log("chart.onBottomMarginChanged: " + margin);
51 marginVisualizer.opacity = 1.0;
51 marginVisualizer.opacity = 1.0;
52 }
52 }
53 onLeftMarginChanged: {
53 onLeftMarginChanged: {
54 console.log("chart.onLeftMarginChanged: " + margin);
54 console.log("chart.onLeftMarginChanged: " + margin);
55 marginVisualizer.opacity = 1.0;
55 marginVisualizer.opacity = 1.0;
56 }
56 }
57 onRightMarginChanged: {
57 onRightMarginChanged: {
58 console.log("chart.onRightMarginChanged: " + margin);
58 console.log("chart.onRightMarginChanged: " + margin);
59 marginVisualizer.opacity = 1.0;
59 marginVisualizer.opacity = 1.0;
60 }
60 }
61
61
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
67
67 minimumMargins.onTopChanged: console.log("chart.minimumMargins.onTopChanged: " + top);
68 minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom);
69 minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left);
70 minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right);
68
71
69 ValueAxis{
72 ValueAxis{
70 onColorChanged: console.log("axisX.onColorChanged: " + color);
73 onColorChanged: console.log("axisX.onColorChanged: " + color);
71 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
74 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
72 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
75 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
73 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
76 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
74 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
77 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
75 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
78 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
76 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
79 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
77 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
80 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
78 onMinChanged: console.log("axisX.onMinChanged: " + min);
81 onMinChanged: console.log("axisX.onMinChanged: " + min);
79 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
82 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
80 }
83 }
81
84
82 ValueAxis{
85 ValueAxis{
83 onColorChanged: console.log("axisY.onColorChanged: " + color);
86 onColorChanged: console.log("axisY.onColorChanged: " + color);
84 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
87 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
85 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
88 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
86 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
89 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
87 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
90 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
88 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
91 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
89 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
92 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
90 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
93 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
91 onMinChanged: console.log("axisY.onMinChanged: " + min);
94 onMinChanged: console.log("axisY.onMinChanged: " + min);
92 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
95 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
93 }
96 }
94
97
95 Rectangle {
98 Rectangle {
96 id: marginVisualizer
99 id: marginVisualizer
97 color: "transparent"
100 color: "transparent"
98 border.color: "red"
101 border.color: "red"
99 anchors.fill: parent
102 anchors.fill: parent
100 anchors.topMargin: parent.topMargin
103 anchors.topMargin: parent.topMargin
101 anchors.bottomMargin: parent.bottomMargin
104 anchors.bottomMargin: parent.bottomMargin
102 anchors.leftMargin: parent.leftMargin
105 anchors.leftMargin: parent.leftMargin
103 anchors.rightMargin: parent.rightMargin
106 anchors.rightMargin: parent.rightMargin
104 opacity: 0.0
107 opacity: 0.0
105 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
108 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
106 Behavior on opacity {
109 Behavior on opacity {
107 NumberAnimation { duration: 800 }
110 NumberAnimation { duration: 800 }
108 }
111 }
109 }
112 }
110 }
113 }
@@ -1,96 +1,132
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22
22
23 Row {
23 Row {
24 anchors.fill: parent
24 anchors.fill: parent
25 spacing: 5
25 spacing: 5
26 property variant chart
26 property variant chart
27
27
28 Flow {
28 Flow {
29 flow: Flow.TopToBottom
29 flow: Flow.TopToBottom
30 spacing: 5
30 spacing: 5
31 Button {
31 Button {
32 text: "visible"
32 text: "visible"
33 onClicked: chart.visible = !chart.visible;
33 onClicked: chart.visible = !chart.visible;
34 }
34 }
35 Button {
35 Button {
36 text: "theme +"
36 text: "theme +"
37 onClicked: chart.theme++;
37 onClicked: chart.theme++;
38 }
38 }
39 Button {
39 Button {
40 text: "theme -"
40 text: "theme -"
41 onClicked: chart.theme--;
41 onClicked: chart.theme--;
42 }
42 }
43 Button {
43 Button {
44 text: "animation opt +"
44 text: "animation opt +"
45 onClicked: chart.animationOptions++;
45 onClicked: chart.animationOptions++;
46 }
46 }
47 Button {
47 Button {
48 text: "animation opt -"
48 text: "animation opt -"
49 onClicked: chart.animationOptions--;
49 onClicked: chart.animationOptions--;
50 }
50 }
51 Button {
51 Button {
52 text: "background color"
52 text: "background color"
53 onClicked: chart.backgroundColor = main.nextColor();
53 onClicked: chart.backgroundColor = main.nextColor();
54 }
54 }
55 Button {
55 Button {
56 text: "drop shadow enabled"
56 text: "drop shadow enabled"
57 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
57 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
58 }
58 }
59 Button {
59 Button {
60 text: "zoom +"
60 text: "zoom +"
61 onClicked: chart.zoom(2);
61 onClicked: chart.zoom(2);
62 }
62 }
63 Button {
63 Button {
64 text: "zoom -"
64 text: "zoom -"
65 onClicked: chart.zoom(0.5);
65 onClicked: chart.zoom(0.5);
66 }
66 }
67 Button {
67 Button {
68 text: "scroll left"
68 text: "scroll left"
69 onClicked: chart.scrollLeft(10);
69 onClicked: chart.scrollLeft(10);
70 }
70 }
71 Button {
71 Button {
72 text: "scroll right"
72 text: "scroll right"
73 onClicked: chart.scrollRight(10);
73 onClicked: chart.scrollRight(10);
74 }
74 }
75 Button {
75 Button {
76 text: "scroll up"
76 text: "scroll up"
77 onClicked: chart.scrollUp(10);
77 onClicked: chart.scrollUp(10);
78 }
78 }
79 Button {
79 Button {
80 text: "scroll down"
80 text: "scroll down"
81 onClicked: chart.scrollDown(10);
81 onClicked: chart.scrollDown(10);
82 }
82 }
83 Button {
83 Button {
84 text: "title color"
84 text: "title color"
85 onClicked: chart.titleColor = main.nextColor();
85 onClicked: chart.titleColor = main.nextColor();
86 }
86 }
87 Button {
88 text: "zoom -"
89 onClicked: chart.zoom(0.5);
90 }
91 Button {
92 text: "top min margin +"
93 onClicked: chart.minimumMargins.top += 5;
94 }
95 Button {
96 text: "top min margin -"
97 onClicked: chart.minimumMargins.top -= 5;
98 }
99 Button {
100 text: "bottom min margin +"
101 onClicked: chart.minimumMargins.bottom += 5;
102 }
103 Button {
104 text: "bottom min margin -"
105 onClicked: chart.minimumMargins.bottom -= 5;
106 }
107 Button {
108 text: "left min margin +"
109 onClicked: chart.minimumMargins.left += 5;
110 }
111 Button {
112 text: "left min margin -"
113 onClicked: chart.minimumMargins.left -= 5;
114 }
115 Button {
116 text: "right min margin +"
117 onClicked: chart.minimumMargins.right += 5;
118 }
119 Button {
120 text: "right min margin -"
121 onClicked: chart.minimumMargins.right -= 5;
122 }
87 }
123 }
88
124
89 FontEditor {
125 FontEditor {
90 id: fontEditor
126 id: fontEditor
91 fontDescription: "title"
127 fontDescription: "title"
92 function editedFont() {
128 function editedFont() {
93 return chart.titleFont;
129 return chart.titleFont;
94 }
130 }
95 }
131 }
96 }
132 }
General Comments 0
You need to be logged in to leave comments. Login now