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