##// END OF EJS Templates
Separated series model stuff from data api in QML examples
Tero Ahola -
r1202:d898436e4875
parent child
Show More
@@ -0,0 +1,35
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 <QtGui/QApplication>
22 #include <QDeclarativeEngine>
23 #include "qmlapplicationviewer.h"
24
25 Q_DECL_EXPORT int main(int argc, char *argv[])
26 {
27 QScopedPointer<QApplication> app(createApplication(argc, argv));
28 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
29
30 viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
31 viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml"));
32 viewer->showExpanded();
33
34 return app->exec();
35 }
@@ -0,0 +1,37
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 import QtQuick 1.0
22
23 Item {
24 id: container
25 width: 400
26 height: 300
27 Component.onCompleted: {
28 var co = Qt.createComponent("main.qml")
29 if (co.status == Component.Ready) {
30 var o = co.createObject(container)
31 } else {
32 console.log(co.errorString())
33 console.log("QtCommercial.Chart 1.1 not available")
34 console.log("Please use correct QML_IMPORT_PATH export")
35 }
36 }
37 }
@@ -0,0 +1,105
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 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
23
24 Rectangle {
25 width: parent.width
26 height: parent.height
27
28 ChartView {
29 id: chart
30 title: "Top-5 car brand shares in Finland"
31 anchors.fill: parent
32 theme: ChartView.ChartThemeLight
33
34 // For dynamic data you can use the ChartModel API.
35 ChartModel {
36 id: chartModel
37 ChartModelElement { values: [0, "Volkswagen", 13.5] }
38 ChartModelElement { values: [0, "Toyota", 10.9] }
39 ChartModelElement { values: [0, "Ford", 8.6] }
40 ChartModelElement { values: [0, "Skoda", 8.2] }
41 ChartModelElement { values: [0, "Volvo", 6.8] }
42 }
43
44 LineSeries {
45 name: "line"
46 model: chartModel
47 modelMapper.mapX: 2
48 modelMapper.mapY: 2
49 }
50
51 PieSeries {
52 id: pieSeries
53 model: chartModel
54 size: 0.4
55 horizontalPosition: 0.2
56 verticalPosition: 0.3
57 // Define how your data maps to pie slices with the ModelMapper API of the pie series
58 modelMapper.mapLabels: 1
59 modelMapper.mapValues: 2
60 modelMapper.first: 0
61 modelMapper.count: -1 // "Undefined" = -1 by default
62 modelMapper.orientation: PieModelMapper.Vertical
63 }
64
65 AreaSeries {
66 name: "area"
67 upperSeries: LineSeries {
68 model: chartModel
69 modelMapper.mapX: 2
70 modelMapper.mapY: 2
71 }
72 lowerSeries: LineSeries {
73 model: chartModel
74 modelMapper.mapX: 2
75 modelMapper.mapY: 0
76 }
77 }
78
79 // TODO: BarSeries with ChartModel base model API
80 // BarSeries {
81 // model: chartModel
82 // modelMapper.first: 0
83 // }
84 }
85
86
87 // TODO: you could also implement appending to your model, for example:
88 // pieSeries.model.append(["Others", 52.0]);
89
90 // TODO: show how to use data from a list model in a chart view
91 // i.e. copy the data into a chart model
92 // ListModel {
93 // id: listModel
94 // ListElement {
95 // label: "Volkswagen"
96 // value: 13.5
97 // }
98 // ListElement {
99 // label: "Toyota"
100 // value: 10.9
101 // }
102 // // and so on...
103 // }
104
105 }
@@ -0,0 +1,200
1 // checksum 0x78c version 0x60010
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
9 */
10
11 #include "qmlapplicationviewer.h"
12
13 #include <QtCore/QDir>
14 #include <QtCore/QFileInfo>
15 #include <QtDeclarative/QDeclarativeComponent>
16 #include <QtDeclarative/QDeclarativeEngine>
17 #include <QtDeclarative/QDeclarativeContext>
18 #include <QtGui/QApplication>
19
20 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
21
22 #ifdef HARMATTAN_BOOSTER
23 #include <MDeclarativeCache>
24 #endif
25
26 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
27
28 #include <qt_private/qdeclarativedebughelper_p.h>
29
30 #if !defined(NO_JSDEBUGGER)
31 #include <jsdebuggeragent.h>
32 #endif
33 #if !defined(NO_QMLOBSERVER)
34 #include <qdeclarativeviewobserver.h>
35 #endif
36
37 // Enable debugging before any QDeclarativeEngine is created
38 struct QmlJsDebuggingEnabler
39 {
40 QmlJsDebuggingEnabler()
41 {
42 QDeclarativeDebugHelper::enableDebugging();
43 }
44 };
45
46 // Execute code in constructor before first QDeclarativeEngine is instantiated
47 static QmlJsDebuggingEnabler enableDebuggingHelper;
48
49 #endif // QMLJSDEBUGGER
50
51 class QmlApplicationViewerPrivate
52 {
53 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
54
55 QString mainQmlFile;
56 QDeclarativeView *view;
57 friend class QmlApplicationViewer;
58 QString adjustPath(const QString &path);
59 };
60
61 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
62 {
63 #ifdef Q_OS_UNIX
64 #ifdef Q_OS_MAC
65 if (!QDir::isAbsolutePath(path))
66 return QCoreApplication::applicationDirPath()
67 + QLatin1String("/../Resources/") + path;
68 #else
69 QString pathInInstallDir;
70 const QString applicationDirPath = QCoreApplication::applicationDirPath();
71 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
72
73 if (QFileInfo(pathInInstallDir).exists())
74 return pathInInstallDir;
75 #endif
76 #endif
77 return path;
78 }
79
80 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
81 : QDeclarativeView(parent)
82 , d(new QmlApplicationViewerPrivate(this))
83 {
84 connect(engine(), SIGNAL(quit()), SLOT(close()));
85 setResizeMode(QDeclarativeView::SizeRootObjectToView);
86 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
87 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
88 #if !defined(NO_JSDEBUGGER)
89 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
90 #endif
91 #if !defined(NO_QMLOBSERVER)
92 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
93 #endif
94 #endif
95 }
96
97 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
98 : QDeclarativeView(parent)
99 , d(new QmlApplicationViewerPrivate(view))
100 {
101 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
102 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
103 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
104 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
105 #if !defined(NO_JSDEBUGGER)
106 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
107 #endif
108 #if !defined(NO_QMLOBSERVER)
109 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
110 #endif
111 #endif
112 }
113
114 QmlApplicationViewer::~QmlApplicationViewer()
115 {
116 delete d;
117 }
118
119 QmlApplicationViewer *QmlApplicationViewer::create()
120 {
121 #ifdef HARMATTAN_BOOSTER
122 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
123 #else
124 return new QmlApplicationViewer();
125 #endif
126 }
127
128 void QmlApplicationViewer::setMainQmlFile(const QString &file)
129 {
130 d->mainQmlFile = d->adjustPath(file);
131 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
132 }
133
134 void QmlApplicationViewer::addImportPath(const QString &path)
135 {
136 d->view->engine()->addImportPath(d->adjustPath(path));
137 }
138
139 void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
140 {
141 #if defined(Q_OS_SYMBIAN)
142 // If the version of Qt on the device is < 4.7.2, that attribute won't work
143 if (orientation != ScreenOrientationAuto) {
144 const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
145 if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
146 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
147 return;
148 }
149 }
150 #endif // Q_OS_SYMBIAN
151
152 Qt::WidgetAttribute attribute;
153 switch (orientation) {
154 #if QT_VERSION < 0x040702
155 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
156 case ScreenOrientationLockPortrait:
157 attribute = static_cast<Qt::WidgetAttribute>(128);
158 break;
159 case ScreenOrientationLockLandscape:
160 attribute = static_cast<Qt::WidgetAttribute>(129);
161 break;
162 default:
163 case ScreenOrientationAuto:
164 attribute = static_cast<Qt::WidgetAttribute>(130);
165 break;
166 #else // QT_VERSION < 0x040702
167 case ScreenOrientationLockPortrait:
168 attribute = Qt::WA_LockPortraitOrientation;
169 break;
170 case ScreenOrientationLockLandscape:
171 attribute = Qt::WA_LockLandscapeOrientation;
172 break;
173 default:
174 case ScreenOrientationAuto:
175 attribute = Qt::WA_AutoOrientation;
176 break;
177 #endif // QT_VERSION < 0x040702
178 };
179 setAttribute(attribute, true);
180 }
181
182 void QmlApplicationViewer::showExpanded()
183 {
184 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
185 d->view->showFullScreen();
186 #elif defined(Q_WS_MAEMO_5)
187 d->view->showMaximized();
188 #else
189 d->view->show();
190 #endif
191 }
192
193 QApplication *createApplication(int &argc, char **argv)
194 {
195 #ifdef HARMATTAN_BOOSTER
196 return MDeclarativeCache::qApplication(argc, argv);
197 #else
198 return new QApplication(argc, argv);
199 #endif
200 }
@@ -0,0 +1,47
1 // checksum 0x82ed version 0x60010
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
9 */
10
11 #ifndef QMLAPPLICATIONVIEWER_H
12 #define QMLAPPLICATIONVIEWER_H
13
14 #include <QtDeclarative/QDeclarativeView>
15
16 class QmlApplicationViewer : public QDeclarativeView
17 {
18 Q_OBJECT
19
20 public:
21 enum ScreenOrientation {
22 ScreenOrientationLockPortrait,
23 ScreenOrientationLockLandscape,
24 ScreenOrientationAuto
25 };
26
27 explicit QmlApplicationViewer(QWidget *parent = 0);
28 virtual ~QmlApplicationViewer();
29
30 static QmlApplicationViewer *create();
31
32 void setMainQmlFile(const QString &file);
33 void addImportPath(const QString &path);
34
35 // Note that this will only have an effect on Symbian and Fremantle.
36 void setOrientation(ScreenOrientation orientation);
37
38 void showExpanded();
39
40 private:
41 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
42 class QmlApplicationViewerPrivate *d;
43 };
44
45 QApplication *createApplication(int &argc, char **argv);
46
47 #endif // QMLAPPLICATIONVIEWER_H
@@ -0,0 +1,13
1 QT += declarative
2
3 SOURCES += $$PWD/qmlapplicationviewer.cpp
4 HEADERS += $$PWD/qmlapplicationviewer.h
5 INCLUDEPATH += $$PWD
6
7 # Include JS debugger library if QMLJSDEBUGGER_PATH is set
8 !isEmpty(QMLJSDEBUGGER_PATH) {
9 include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
10 } else {
11 DEFINES -= QMLJSDEBUGGER
12 }
13
@@ -0,0 +1,93
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <svg
3 xmlns:dc="http://purl.org/dc/elements/1.1/"
4 xmlns:cc="http://creativecommons.org/ns#"
5 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6 xmlns:svg="http://www.w3.org/2000/svg"
7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 height="44px"
11 version="1.1"
12 viewBox="0 0 44 44"
13 width="44px"
14 x="0px"
15 y="0px"
16 id="svg2"
17 inkscape:version="0.47 r22583"
18 sodipodi:docname="qt.svg">
19 <metadata
20 id="metadata18">
21 <rdf:RDF>
22 <cc:Work
23 rdf:about="">
24 <dc:format>image/svg+xml</dc:format>
25 <dc:type
26 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
27 </cc:Work>
28 </rdf:RDF>
29 </metadata>
30 <defs
31 id="defs16">
32 <inkscape:perspective
33 sodipodi:type="inkscape:persp3d"
34 inkscape:vp_x="0 : 22 : 1"
35 inkscape:vp_y="0 : 1000 : 0"
36 inkscape:vp_z="44 : 22 : 1"
37 inkscape:persp3d-origin="22 : 14.666667 : 1"
38 id="perspective2836" />
39 </defs>
40 <sodipodi:namedview
41 pagecolor="#ffffff"
42 bordercolor="#666666"
43 borderopacity="1"
44 objecttolerance="10"
45 gridtolerance="10"
46 guidetolerance="10"
47 inkscape:pageopacity="0"
48 inkscape:pageshadow="2"
49 inkscape:window-width="1920"
50 inkscape:window-height="1020"
51 id="namedview14"
52 showgrid="false"
53 inkscape:zoom="21.454545"
54 inkscape:cx="49.412871"
55 inkscape:cy="21.894358"
56 inkscape:window-x="-4"
57 inkscape:window-y="-4"
58 inkscape:window-maximized="1"
59 inkscape:current-layer="g3" />
60 <g
61 transform="matrix(0.18308778,0,0,0.18308778,6.6100946,3.2385199)"
62 id="g3">
63 <path
64 d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
65 style="fill:#006225"
66 id="path5"
67 sodipodi:nodetypes="cccccccc" />
68 <path
69 d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
70 style="fill:#80c342"
71 id="path7" />
72 <path
73 d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
74 style="fill:#006225"
75 id="path11" />
76 <path
77 d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
78 style="fill:#006225"
79 id="path13" />
80 <path
81 id="path17"
82 style="fill:#ffffff"
83 d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z" />
84 <path
85 d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
86 style="fill:#006225"
87 id="path19" />
88 <path
89 id="path21"
90 style="fill:#006225"
91 d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z" />
92 </g>
93 </svg>
@@ -0,0 +1,10
1 !include( ../demos.pri ) {
2 error( "Couldn't find the demos.pri file!" )
3 }
4
5 RESOURCES += resources.qrc
6 SOURCES += main.cpp
7
8 include(qmlapplicationviewer/qmlapplicationviewer.pri)
9
10 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_DEMOS_BIN_DIR"
@@ -0,0 +1,6
1 <RCC>
2 <qresource prefix="/">
3 <file>qml/qmlcustommodel/loader.qml</file>
4 <file>qml/qmlcustommodel/main.qml</file>
5 </qresource>
6 </RCC>
@@ -1,11 +1,12
1 CURRENTLY_BUILDING_COMPONENTS = "demos"
1 CURRENTLY_BUILDING_COMPONENTS = "demos"
2 !include( ../config.pri ) {
2 !include( ../config.pri ) {
3 error( "Couldn't find the config.pri file!" )
3 error( "Couldn't find the config.pri file!" )
4 }
4 }
5
5
6 TEMPLATE = subdirs
6 TEMPLATE = subdirs
7 SUBDIRS += chartthemes \
7 SUBDIRS += chartthemes \
8 piechartcustomization \
8 piechartcustomization \
9 dynamicspline \
9 dynamicspline \
10 qmlchart \
10 qmlchart \
11 qmlweather
11 qmlweather \
12 qmlcustommodel
@@ -1,142 +1,102
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26 property int __explodedIndex: -1
26 property int __explodedIndex: -1
27
27
28 ChartView {
28 ChartView {
29 id: chart
29 id: chart
30 title: "Top-5 car brand shares in Finland"
30 title: "Top-5 car brand shares in Finland"
31 anchors.top: parent.top
31 anchors.top: parent.top
32 anchors.bottom: button.top
32 anchors.bottom: button.top
33 anchors.left: parent.left
33 anchors.left: parent.left
34 anchors.right: parent.right
34 anchors.right: parent.right
35 theme: ChartView.ChartThemeLight
35 theme: ChartView.ChartThemeLight
36 legend: ChartView.LegendBottom
36 legend: ChartView.LegendBottom
37 animationOptions: ChartView.SeriesAnimations
37 animationOptions: ChartView.SeriesAnimations
38
38
39 // If you have static data, you can simply use the PieSlice API
39 // If you have static data, you can simply use the PieSlice API
40 PieSeries {
40 PieSeries {
41 id: pieSeries
41 id: pieSeries
42 PieSlice { id: volkswagenSlice; label: "Volkswagen"; value: 13.5 }
42 PieSlice { id: volkswagenSlice; label: "Volkswagen"; value: 13.5 }
43 PieSlice { label: "Toyota"; value: 10.9 }
43 PieSlice { label: "Toyota"; value: 10.9 }
44 PieSlice { label: "Ford"; value: 8.6 }
44 PieSlice { label: "Ford"; value: 8.6 }
45 PieSlice { label: "Skoda"; value: 8.2 }
45 PieSlice { label: "Skoda"; value: 8.2 }
46 PieSlice { label: "Volvo"; value: 6.8 }
46 PieSlice { label: "Volvo"; value: 6.8 }
47 }
47 }
48
49 // TODO: move ChartModel API into a demo application instead of making it a public API
50 // // For dynamic data you can use the ChartModel API.
51 // ChartModel {
52 // id: chartModel
53 // ChartModelElement { values: ["Volkswagen", 13.5] }
54 // ChartModelElement { values: ["Toyota", 10.9] }
55 // ChartModelElement { values: ["Ford", 8.6] }
56 // ChartModelElement { values: ["Skoda", 8.2] }
57 // ChartModelElement { values: ["Volvo", 6.8] }
58 // }
59 // // In this case you need to define how the data maps to pie slices with the ModelMapper API of the pie series.
60 // PieSeries {
61 // id: pieSeries
62 // model: chartModel
63 // modelMapper.mapLabels: 0
64 // modelMapper.mapValues: 1
65 // modelMapper.first: 0
66 // modelMapper.count: -1 // "Undefined" = -1 by default
67 // modelMapper.orientation: PieModelMapper.Vertical
68 // }
69
70 // TODO: you could also append to your model, for example:
71 // pieSeries.model.append(["Others", 52.0]);
72 }
48 }
73
49
74 Component.onCompleted: {
50 Component.onCompleted: {
75 volkswagenSlice.exploded = true;
51 volkswagenSlice.exploded = true;
76 // You can also add slices dynamically
52 // You can also add slices dynamically
77 var newSlice = pieSeries.append("Others", 52.0);
53 var newSlice = pieSeries.append("Others", 52.0);
78 }
54 }
79
55
80 Timer {
56 Timer {
81 repeat: true
57 repeat: true
82 interval: 2000
58 interval: 2000
83 running: true
59 running: true
84 onTriggered: {
60 onTriggered: {
85 // Set all slices as not exploded
61 // Set all slices as not exploded
86 for (var i = 0; i < pieSeries.count; i++)
62 for (var i = 0; i < pieSeries.count; i++)
87 pieSeries.at(i).exploded = false;
63 pieSeries.at(i).exploded = false;
88
64
89 // Explode one of the slices
65 // Explode one of the slices
90 __explodedIndex = (__explodedIndex + 1) % pieSeries.count;
66 __explodedIndex = (__explodedIndex + 1) % pieSeries.count;
91 pieSeries.at(__explodedIndex).exploded = true;
67 pieSeries.at(__explodedIndex).exploded = true;
92
68
69 pieSeries.find("Volkswagen").exploded = true;
93 // TODO: implement for convenience
70 // TODO: implement for convenience
94 // pieSeries.find("Ford").exploded = true;
71 // pieSeries.removeAll("Ford");
95 // pieSeries.removeAll("Ford")
96 }
72 }
97 }
73 }
98
74
99 Rectangle {
75 Rectangle {
100 id: button
76 id: button
101 anchors.bottom: parent.bottom
77 anchors.bottom: parent.bottom
102 anchors.bottomMargin: 10
78 anchors.bottomMargin: 10
103 anchors.horizontalCenter: parent.horizontalCenter
79 anchors.horizontalCenter: parent.horizontalCenter
104 height: 40
80 height: 40
105 width: 100
81 width: 100
106 color: "orange"
82 color: "orange"
107 radius: 5
83 radius: 5
108 Text {
84 Text {
109 id: buttonText
85 id: buttonText
110 anchors.centerIn: parent
86 anchors.centerIn: parent
111 text: "Hide others"
87 text: "Hide others"
112 }
88 }
113 MouseArea {
89 MouseArea {
114 anchors.fill: parent
90 anchors.fill: parent
115 onClicked: {
91 onClicked: {
116 if (buttonText.text == "Show others") {
92 if (buttonText.text == "Show others") {
117 pieSeries.modelMapper.count = -1;
93 pieSeries.modelMapper.count = -1;
118 buttonText.text = "Hide others";
94 buttonText.text = "Hide others";
119 } else {
95 } else {
120 pieSeries.modelMapper.count = 5;
96 pieSeries.modelMapper.count = 5;
121 buttonText.text = "Show others";
97 buttonText.text = "Show others";
122 }
98 }
123 }
99 }
124 }
100 }
125 }
101 }
126
127 // TODO: show how to use data from a list model in a chart view
128 // i.e. copy the data into a chart model
129 // ListModel {
130 // id: listModel
131 // ListElement {
132 // label: "Volkswagen"
133 // value: 13.5
134 // }
135 // ListElement {
136 // label: "Toyota"
137 // value: 10.9
138 // }
139 // // and so on...
140 // }
141
142 }
102 }
@@ -1,62 +1,55
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 ChartView {
27 ChartView {
28 title: "Line&Spline"
28 title: "Line&Spline"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: ChartView.ChartThemeBrownSand
30 theme: ChartView.ChartThemeBrownSand
31 animationOptions: ChartView.NoAnimation
31 animationOptions: ChartView.NoAnimation
32
32
33 LineSeries {
33 LineSeries {
34 name: "Line"
34 name: "Line"
35 model: chartModel
35 XyPoint { x: 0; y: 0 }
36 modelMapper.mapX: 0
36 XyPoint { x: 1.1; y: 2.1 }
37 modelMapper.mapY: 1
37 XyPoint { x: 1.9; y: 3.3 }
38 modelMapper.first: 0
38 XyPoint { x: 2.1; y: 2.1 }
39 modelMapper.count: -1
39 XyPoint { x: 2.9; y: 4.9 }
40 modelMapper.orientation: XYModelMapper.Vertical
40 XyPoint { x: 3.4; y: 3.0 }
41 XyPoint { x: 4.1; y: 3.3 }
41 }
42 }
42
43
43 SplineSeries {
44 SplineSeries {
44 name: "Spline"
45 name: "Spline"
45 model: chartModel
46 XyPoint { x: 0; y: 0.3 }
46 modelMapper.mapX: 0
47 XyPoint { x: 1.1; y: 3.2 }
47 modelMapper.mapY: 2
48 XyPoint { x: 1.9; y: 2.4 }
49 XyPoint { x: 2.1; y: 2.1 }
50 XyPoint { x: 2.9; y: 2.6 }
51 XyPoint { x: 3.4; y: 2.3 }
52 XyPoint { x: 4.1; y: 3.1 }
48 }
53 }
49 }
54 }
50
51 ChartModel {
52 id: chartModel
53 ChartModelElement { values: [0.0, 0.0, 0.3] }
54 ChartModelElement { values: [1.1, 2.1, 3.2] }
55 ChartModelElement { values: [1.9, 3.3, 2.4] }
56 ChartModelElement { values: [2.1, 2.1, 2.1] }
57 ChartModelElement { values: [2.9, 4.9, 2.6] }
58 ChartModelElement { values: [3.4, 3.0, 2.3] }
59 ChartModelElement { values: [4.1, 3.3, 3.1] }
60 }
61
62 }
55 }
@@ -1,78 +1,130
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 ChartView {
27 ChartView {
28 title: "NHL All-Star Team Players"
28 title: "NHL All-Star Team Players"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: ChartView.ChartThemeHighContrast
30 theme: ChartView.ChartThemeHighContrast
31 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
31 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
32 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
32 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
33
33
34 AreaSeries {
34 AreaSeries {
35 name: "Russian"
35 name: "Russian"
36 upperModel: chartModel
36 upperSeries: LineSeries {
37 upperModelMapper.mapX: 0
37 XyPoint { x: 0; y: 1 }
38 upperModelMapper.mapY: 2
38 XyPoint { x: 1; y: 1 }
39 lowerModel: chartModel
39 XyPoint { x: 2; y: 1 }
40 lowerModelMapper.mapX: 0
40 XyPoint { x: 3; y: 1 }
41 lowerModelMapper.mapY: 1
41 XyPoint { x: 4; y: 1 }
42 XyPoint { x: 5; y: 0 }
43 XyPoint { x: 6; y: 1 }
44 XyPoint { x: 7; y: 1 }
45 XyPoint { x: 8; y: 4 }
46 XyPoint { x: 9; y: 3 }
47 XyPoint { x: 10; y: 2 }
48 XyPoint { x: 11; y: 1 }
49 }
50 lowerSeries: LineSeries {
51 XyPoint { x: 0; y: 0 }
52 XyPoint { x: 1; y: 0 }
53 XyPoint { x: 2; y: 0 }
54 XyPoint { x: 3; y: 0 }
55 XyPoint { x: 4; y: 0 }
56 XyPoint { x: 5; y: 0 }
57 XyPoint { x: 6; y: 0 }
58 XyPoint { x: 7; y: 0 }
59 XyPoint { x: 8; y: 0 }
60 XyPoint { x: 9; y: 0 }
61 XyPoint { x: 10; y: 0 }
62 XyPoint { x: 11; y: 0 }
63 }
42 }
64 }
65
43 AreaSeries {
66 AreaSeries {
44 name: "Swedish"
67 name: "Swedish"
45 upperModel: chartModel
68 upperSeries: LineSeries {
46 upperModelMapper.mapX: 0
69 XyPoint { x: 0; y: 1 }
47 upperModelMapper.mapY: 3
70 XyPoint { x: 1; y: 1 }
48 lowerModel: chartModel
71 XyPoint { x: 2; y: 3 }
49 lowerModelMapper.mapX: 0
72 XyPoint { x: 3; y: 3 }
50 lowerModelMapper.mapY: 1
73 XyPoint { x: 4; y: 2 }
74 XyPoint { x: 5; y: 0 }
75 XyPoint { x: 6; y: 2 }
76 XyPoint { x: 7; y: 1 }
77 XyPoint { x: 8; y: 2 }
78 XyPoint { x: 9; y: 1 }
79 XyPoint { x: 10; y: 3 }
80 XyPoint { x: 11; y: 3 }
81 }
82 lowerSeries: LineSeries {
83 XyPoint { x: 0; y: 0 }
84 XyPoint { x: 1; y: 0 }
85 XyPoint { x: 2; y: 0 }
86 XyPoint { x: 3; y: 0 }
87 XyPoint { x: 4; y: 0 }
88 XyPoint { x: 5; y: 0 }
89 XyPoint { x: 6; y: 0 }
90 XyPoint { x: 7; y: 0 }
91 XyPoint { x: 8; y: 0 }
92 XyPoint { x: 9; y: 0 }
93 XyPoint { x: 10; y: 0 }
94 XyPoint { x: 11; y: 0 }
95 }
51 }
96 }
97
52 AreaSeries {
98 AreaSeries {
53 name: "Finnish"
99 name: "Swedish"
54 upperModel: chartModel
100 upperSeries: LineSeries {
55 upperModelMapper.mapX: 0
101 XyPoint { x: 0; y: 0 }
56 upperModelMapper.mapY: 4
102 XyPoint { x: 1; y: 0 }
57 lowerModel: chartModel
103 XyPoint { x: 2; y: 0 }
58 lowerModelMapper.mapX: 0
104 XyPoint { x: 3; y: 0 }
59 lowerModelMapper.mapY: 1
105 XyPoint { x: 4; y: 0 }
106 XyPoint { x: 5; y: 0 }
107 XyPoint { x: 6; y: 1 }
108 XyPoint { x: 7; y: 0 }
109 XyPoint { x: 8; y: 0 }
110 XyPoint { x: 9; y: 0 }
111 XyPoint { x: 10; y: 0 }
112 XyPoint { x: 11; y: 1 }
113 }
114 lowerSeries: LineSeries {
115 XyPoint { x: 0; y: 0 }
116 XyPoint { x: 1; y: 0 }
117 XyPoint { x: 2; y: 0 }
118 XyPoint { x: 3; y: 0 }
119 XyPoint { x: 4; y: 0 }
120 XyPoint { x: 5; y: 0 }
121 XyPoint { x: 6; y: 0 }
122 XyPoint { x: 7; y: 0 }
123 XyPoint { x: 8; y: 0 }
124 XyPoint { x: 9; y: 0 }
125 XyPoint { x: 10; y: 0 }
126 XyPoint { x: 11; y: 0 }
127 }
60 }
128 }
61 }
129 }
62
63 ChartModel {
64 id: chartModel
65 ChartModelElement { values: [0, 0, 1, 1, 0] }
66 ChartModelElement { values: [1, 0, 1, 1, 0] }
67 ChartModelElement { values: [2, 0, 1, 3, 0] }
68 ChartModelElement { values: [3, 0, 1, 3, 0] }
69 ChartModelElement { values: [4, 0, 1, 2, 0] }
70 ChartModelElement { values: [5, 0, 0, 0, 0] }
71 ChartModelElement { values: [6, 0, 1, 2, 1] }
72 ChartModelElement { values: [7, 0, 1, 1, 0] }
73 ChartModelElement { values: [8, 0, 4, 2, 0] }
74 ChartModelElement { values: [9, 0, 3, 1, 0] }
75 ChartModelElement { values: [10, 0, 2, 3, 0] }
76 ChartModelElement { values: [11, 0, 1, 3, 1] }
77 }
78 }
130 }
@@ -1,53 +1,54
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 ChartView {
27 ChartView {
28 title: "Scatters"
28 title: "Scatters"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: ChartView.ChartThemeBlueCerulean
30 theme: ChartView.ChartThemeBlueCerulean
31
31
32 ScatterSeries {
32 ScatterSeries {
33 id: scatter1
33 id: scatter1
34 name: "Scatter1"
34 name: "Scatter1"
35 XyPoint { x: 1.5; y: 1.5 }
35 XyPoint { x: 1.5; y: 1.5 }
36 XyPoint { x: 1.5; y: 1.6 }
36 XyPoint { x: 1.5; y: 1.6 }
37 XyPoint { x: 1.57; y: 1.55 }
37 XyPoint { x: 1.57; y: 1.55 }
38 XyPoint { x: 1.8; y: 1.8 }
38 XyPoint { x: 1.8; y: 1.8 }
39 XyPoint { x: 1.9; y: 1.6 }
39 XyPoint { x: 1.9; y: 1.6 }
40 XyPoint { x: 2.1; y: 1.3 }
40 XyPoint { x: 2.1; y: 1.3 }
41 XyPoint { x: 2.5; y: 2.1 }
41 XyPoint { x: 2.5; y: 2.1 }
42 }
42 }
43
43 ScatterSeries {
44 ScatterSeries {
44 name: "Scatter2"
45 name: "Scatter2"
45 XyPoint { x: 2.0; y: 2.0 }
46 XyPoint { x: 2.0; y: 2.0 }
46 XyPoint { x: 2.0; y: 2.1 }
47 XyPoint { x: 2.0; y: 2.1 }
47 XyPoint { x: 2.07; y: 2.05 }
48 XyPoint { x: 2.07; y: 2.05 }
48 XyPoint { x: 2.2; y: 2.9 }
49 XyPoint { x: 2.2; y: 2.9 }
49 XyPoint { x: 2.4; y: 2.7 }
50 XyPoint { x: 2.4; y: 2.7 }
50 XyPoint { x: 2.67; y: 2.65 }
51 XyPoint { x: 2.67; y: 2.65 }
51 }
52 }
52 }
53 }
53 }
54 }
@@ -1,58 +1,43
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 ChartView {
27 ChartView {
28 title: "Bar series"
28 title: "Bar series"
29 anchors.fill: parent
29 anchors.fill: parent
30 theme: ChartView.ChartThemeLight
30 theme: ChartView.ChartThemeLight
31 legend: ChartView.LegendBottom
31 legend: ChartView.LegendBottom
32 // TODO: labels defined by x-axis, not by bar series
32 // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"]
33 // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"]
33 axisX.max: 10
34 axisX.max: 10
34
35
35 BarSeries {
36 BarSeries {
36 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
37 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
37 BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] }
38 BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] }
38 BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] }
39 BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] }
39 BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] }
40 BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] }
40 }
41 }
41
42 // TODO: optional syntax with ChartModel base model API
43 // BarSeries {
44 // model: chartModel
45 // modelMapping: BarSeriesMapping {
46 // ?
47 // startIndex: 0 // defaults to 0
48 // count: BarSeriesMapping.Undefined // defaults to "Undefined"
49 // }
50 // }
51 // ChartModel {
52 // id: chartModel
53 // ChartModelElement { values: ["Bob", 2, 2, 3, 4, 5, 6] }
54 // ChartModelElement { values: ["Susan", 5, 1, 2, 4, 1, 7] }
55 // ChartModelElement { values: ["James", 3, 5, 8, 13, 5, 8] }
56 // }
57 }
42 }
58 }
43 }
@@ -1,94 +1,55
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 "declarativeareaseries.h"
21 #include "declarativeareaseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qxymodelmapper.h"
24 #include "qxymodelmapper.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
28 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
29 QAreaSeries(new QLineSeries(parent), new QLineSeries(parent))
29 QAreaSeries(parent)
30 {
30 {
31 QXYModelMapper *upperMapper = new QXYModelMapper(upperSeries());
32 upperMapper->setMapX(0);
33 upperMapper->setMapY(1);
34 upperMapper->setFirst(0);
35 upperMapper->setCount(-1);
36 upperMapper->setOrientation(Qt::Vertical);
37 upperSeries()->setModelMapper(upperMapper);
38
39 QXYModelMapper *lowerMapper = new QXYModelMapper(lowerSeries());
40 lowerMapper->setMapX(2);
41 lowerMapper->setMapY(3);
42 lowerMapper->setFirst(0);
43 lowerMapper->setCount(-1);
44 lowerMapper->setOrientation(Qt::Vertical);
45 lowerSeries()->setModelMapper(lowerMapper);
46 }
47
48 bool DeclarativeAreaSeries::setDeclarativeUpperModel(DeclarativeTableModel *model)
49 {
50 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
51 bool value(false);
52 if (m) {
53 upperSeries()->setModel(m);
54 } else {
55 qWarning("DeclarativeAreaSeries: Illegal model");
56 }
57 return value;
58 }
59
60 DeclarativeTableModel *DeclarativeAreaSeries::declarativeUpperModel()
61 {
62 return qobject_cast<DeclarativeTableModel *>(upperSeries()->model());
63 }
31 }
64
32
65 bool DeclarativeAreaSeries::setDeclarativeLowerModel(DeclarativeTableModel *model)
33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
66 {
34 {
67 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
35 QAreaSeries::setUpperSeries(series);
68 bool value(false);
69 if (m) {
70 lowerSeries()->setModel(m);
71 } else {
72 qWarning("DeclarativeAreaSeries: Illegal model");
73 }
74 return value;
75 }
36 }
76
37
77 DeclarativeTableModel *DeclarativeAreaSeries::declarativeLowerModel()
38 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
78 {
39 {
79 return qobject_cast<DeclarativeTableModel *>(lowerSeries()->model());
40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
80 }
41 }
81
42
82 QXYModelMapper* DeclarativeAreaSeries::upperModelMapper() const
43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
83 {
44 {
84 return upperSeries()->modelMapper();
45 QAreaSeries::setLowerSeries(series);
85 }
46 }
86
47
87 QXYModelMapper* DeclarativeAreaSeries::lowerModelMapper() const
48 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
88 {
49 {
89 return lowerSeries()->modelMapper();
50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
90 }
51 }
91
52
92 #include "moc_declarativeareaseries.cpp"
53 #include "moc_declarativeareaseries.cpp"
93
54
94 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,52 +1,55
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 DECLARATIVEAREASERIES_H
21 #ifndef DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qareaseries.h"
25 #include "qareaseries.h"
26 #include "declarativelineseries.h"
26 #include "declarativelineseries.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class DeclarativeAreaSeries : public QAreaSeries
30 class DeclarativeAreaSeries : public QAreaSeries
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33 Q_PROPERTY(DeclarativeTableModel *upperModel READ declarativeUpperModel WRITE setDeclarativeUpperModel)
33 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
34 Q_PROPERTY(DeclarativeTableModel *lowerModel READ declarativeLowerModel WRITE setDeclarativeLowerModel)
34 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
35 Q_PROPERTY(QXYModelMapper *upperModelMapper READ upperModelMapper)
36 Q_PROPERTY(QXYModelMapper *lowerModelMapper READ lowerModelMapper)
37
35
38 public:
36 public:
39 explicit DeclarativeAreaSeries(QObject *parent = 0);
37 explicit DeclarativeAreaSeries(QObject *parent = 0);
40
38
41 public:
39 public:
42 bool setDeclarativeUpperModel(DeclarativeTableModel *model);
40 bool setDeclarativeUpperModel(DeclarativeTableModel *model);
43 DeclarativeTableModel *declarativeUpperModel();
41 DeclarativeTableModel *declarativeUpperModel();
44 bool setDeclarativeLowerModel(DeclarativeTableModel *model);
42 bool setDeclarativeLowerModel(DeclarativeTableModel *model);
45 DeclarativeTableModel *declarativeLowerModel();
43 DeclarativeTableModel *declarativeLowerModel();
46 QXYModelMapper* upperModelMapper() const;
44 QXYModelMapper* upperModelMapper() const;
47 QXYModelMapper* lowerModelMapper() const;
45 QXYModelMapper* lowerModelMapper() const;
46 public:
47 void setUpperSeries(DeclarativeLineSeries* series);
48 DeclarativeLineSeries* upperSeries() const;
49 void setLowerSeries(DeclarativeLineSeries* series);
50 DeclarativeLineSeries* lowerSeries() const;
48 };
51 };
49
52
50 QTCOMMERCIALCHART_END_NAMESPACE
53 QTCOMMERCIALCHART_END_NAMESPACE
51
54
52 #endif // DECLARATIVEAREASERIES_H
55 #endif // DECLARATIVEAREASERIES_H
@@ -1,106 +1,105
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 "declarativebarseries.h"
21 #include "declarativebarseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include <QBarSet>
23 #include <QBarSet>
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
27 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
28 QBarSet("", parent)
28 QBarSet("", parent)
29 {
29 {
30 }
30 }
31
31
32 QVariantList DeclarativeBarSet::values()
32 QVariantList DeclarativeBarSet::values()
33 {
33 {
34 QVariantList values;
34 QVariantList values;
35 for (int i(0); i < count(); i++)
35 for (int i(0); i < count(); i++)
36 values.append(QVariant(at(i)));
36 values.append(QVariant(at(i)));
37 return values;
37 return values;
38 }
38 }
39
39
40 void DeclarativeBarSet::setValues(QVariantList values)
40 void DeclarativeBarSet::setValues(QVariantList values)
41 {
41 {
42 while (count())
42 while (count())
43 remove(count() - 1);
43 remove(count() - 1);
44
44
45 for (int i(0); i < values.count(); i++) {
45 for (int i(0); i < values.count(); i++) {
46 if (values.at(i).canConvert(QVariant::Double))
46 if (values.at(i).canConvert(QVariant::Double))
47 append(values[i].toDouble());
47 append(values[i].toDouble());
48 }
48 }
49 }
49 }
50
50
51 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
51 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
52 QGroupedBarSeries(parent)
52 QGroupedBarSeries(parent)
53 {
53 {
54 }
54 }
55
55
56 void DeclarativeBarSeries::classBegin()
56 void DeclarativeBarSeries::classBegin()
57 {
57 {
58 }
58 }
59
59
60 void DeclarativeBarSeries::componentComplete()
60 void DeclarativeBarSeries::componentComplete()
61 {
61 {
62 foreach(QObject *child, children()) {
62 foreach(QObject *child, children()) {
63 if (qobject_cast<QBarSet *>(child)) {
63 if (qobject_cast<QBarSet *>(child)) {
64 qDebug() << "append bar set:" << child;
65 QBarSeries::append(qobject_cast<QBarSet *>(child));
64 QBarSeries::append(qobject_cast<QBarSet *>(child));
66 }
65 }
67 }
66 }
68 }
67 }
69
68
70 QDeclarativeListProperty<DeclarativeBarSet> DeclarativeBarSeries::initialBarSets()
69 QDeclarativeListProperty<DeclarativeBarSet> DeclarativeBarSeries::initialBarSets()
71 {
70 {
72 return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets);
71 return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets);
73 }
72 }
74
73
75 bool DeclarativeBarSeries::setDeclarativeModel(DeclarativeTableModel *model)
74 bool DeclarativeBarSeries::setDeclarativeModel(DeclarativeTableModel *model)
76 {
75 {
77 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
76 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
78 bool value(false);
77 bool value(false);
79 if (m) {
78 if (m) {
80 setModel(m);
79 setModel(m);
81 //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
80 //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
82 // setModelMapping(0, 1, 1, Qt::Vertical);
81 // setModelMapping(0, 1, 1, Qt::Vertical);
83 } else {
82 } else {
84 qWarning("DeclarativeBarSeries: Illegal model");
83 qWarning("DeclarativeBarSeries: Illegal model");
85 }
84 }
86 return value;
85 return value;
87 }
86 }
88
87
89 DeclarativeTableModel *DeclarativeBarSeries::declarativeModel()
88 DeclarativeTableModel *DeclarativeBarSeries::declarativeModel()
90 {
89 {
91 return qobject_cast<DeclarativeTableModel *>(model());
90 return qobject_cast<DeclarativeTableModel *>(model());
92 }
91 }
93
92
94 void DeclarativeBarSeries::setBarCategories(QStringList categories)
93 void DeclarativeBarSeries::setBarCategories(QStringList categories)
95 {
94 {
96 setCategories(categories);
95 setCategories(categories);
97 }
96 }
98
97
99 QStringList DeclarativeBarSeries::barCategories()
98 QStringList DeclarativeBarSeries::barCategories()
100 {
99 {
101 return categories();
100 return categories();
102 }
101 }
103
102
104 #include "moc_declarativebarseries.cpp"
103 #include "moc_declarativebarseries.cpp"
105
104
106 QTCOMMERCIALCHART_END_NAMESPACE
105 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,35 +1,50
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 "declarativelineseries.h"
21 #include "declarativelineseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qlineseries.h"
24 #include "qlineseries.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
29 QLineSeries(parent)
29 QLineSeries(parent)
30 {
30 {
31 }
31 }
32
32
33 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
34 {
35 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
36 }
37
38 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
39 {
40 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
41 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
42 if (series && point) {
43 qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point;
44 series->append(*point);
45 }
46 }
47
33 #include "moc_declarativelineseries.cpp"
48 #include "moc_declarativelineseries.cpp"
34
49
35 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,42 +1,48
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 DECLARATIVELINESERIES_H
21 #ifndef DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qlineseries.h"
25 #include "qlineseries.h"
26 #include "declarativexyseries.h"
26 #include "declarativexyseries.h"
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries
31 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
35
37
36 public:
38 public:
37 explicit DeclarativeLineSeries(QObject *parent = 0);
39 explicit DeclarativeLineSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QObject> declarativeChildren();
41
42 public Q_SLOTS:
43 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
38 };
44 };
39
45
40 QTCOMMERCIALCHART_END_NAMESPACE
46 QTCOMMERCIALCHART_END_NAMESPACE
41
47
42 #endif // DECLARATIVELINESERIES_H
48 #endif // DECLARATIVELINESERIES_H
@@ -1,95 +1,104
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 "declarativepieseries.h"
21 #include "declarativepieseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include <qdeclarativelist.h>
24 #include <qdeclarativelist.h>
25 #include "qpiemodelmapper.h"
25 #include "qpiemodelmapper.h"
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
29 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
30 QPieSeries(parent)
30 QPieSeries(parent)
31 {
31 {
32 // TODO: set default model on init?
32 // TODO: set default model on init?
33 // setModel(new DeclarativeTableModel());
33 // setModel(new DeclarativeTableModel());
34
34
35 // TODO: Set default mapper parameters to allow easy to use PieSeries api?
35 // TODO: Set default mapper parameters to allow easy to use PieSeries api?
36 QPieModelMapper *mapper = modelMapper();//new QPieModelMapper();
36 QPieModelMapper *mapper = modelMapper();//new QPieModelMapper();
37 mapper->setMapLabels(0);
37 mapper->setMapLabels(0);
38 mapper->setMapValues(1);
38 mapper->setMapValues(1);
39 mapper->setOrientation(Qt::Vertical);
39 mapper->setOrientation(Qt::Vertical);
40 mapper->setFirst(0);
40 mapper->setFirst(0);
41 mapper->setCount(-1);
41 mapper->setCount(-1);
42 // setModelMapper(mapper);
42 // setModelMapper(mapper);
43 }
43 }
44
44
45 void DeclarativePieSeries::classBegin()
45 void DeclarativePieSeries::classBegin()
46 {
46 {
47 }
47 }
48
48
49 void DeclarativePieSeries::componentComplete()
49 void DeclarativePieSeries::componentComplete()
50 {
50 {
51 foreach(QObject *child, children()) {
51 foreach(QObject *child, children()) {
52 if (qobject_cast<QPieSlice *>(child)) {
52 if (qobject_cast<QPieSlice *>(child)) {
53 QPieSeries::append(qobject_cast<QPieSlice *>(child));
53 QPieSeries::append(qobject_cast<QPieSlice *>(child));
54 }
54 }
55 }
55 }
56 }
56 }
57
57
58 QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::initialSlices()
58 QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::initialSlices()
59 {
59 {
60 return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendInitialSlices);
60 return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendInitialSlices);
61 }
61 }
62
62
63 QPieSlice *DeclarativePieSeries::at(int index)
63 QPieSlice *DeclarativePieSeries::at(int index)
64 {
64 {
65 QList<QPieSlice*> sliceList = slices();
65 QList<QPieSlice*> sliceList = slices();
66 if (index < sliceList.count())
66 if (index < sliceList.count())
67 return sliceList[index];
67 return sliceList[index];
68
68
69 return 0;
69 return 0;
70 }
70 }
71
71
72 QPieSlice* DeclarativePieSeries::find(QString label)
73 {
74 foreach (QPieSlice *slice, slices()) {
75 if (slice->label() == label)
76 return slice;
77 }
78 return 0;
79 }
80
72 QPieSlice* DeclarativePieSeries::append(QString name, qreal value)
81 QPieSlice* DeclarativePieSeries::append(QString name, qreal value)
73 {
82 {
74 // TODO: parameter order is wrong, switch it:
83 // TODO: parameter order is wrong, switch it:
75 return QPieSeries::append(value, name);
84 return QPieSeries::append(value, name);
76 }
85 }
77
86
78 void DeclarativePieSeries::setPieModel(DeclarativeTableModel *model)
87 void DeclarativePieSeries::setPieModel(DeclarativeTableModel *model)
79 {
88 {
80 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
89 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
81 if (m) {
90 if (m) {
82 QPieSeries::setModel(m);
91 QPieSeries::setModel(m);
83 } else {
92 } else {
84 qWarning("DeclarativePieSeries: Illegal model");
93 qWarning("DeclarativePieSeries: Illegal model");
85 }
94 }
86 }
95 }
87
96
88 DeclarativeTableModel *DeclarativePieSeries::pieModel()
97 DeclarativeTableModel *DeclarativePieSeries::pieModel()
89 {
98 {
90 return qobject_cast<DeclarativeTableModel *>(model());
99 return qobject_cast<DeclarativeTableModel *>(model());
91 }
100 }
92
101
93 #include "moc_declarativepieseries.cpp"
102 #include "moc_declarativepieseries.cpp"
94
103
95 QTCOMMERCIALCHART_END_NAMESPACE
104 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,63 +1,64
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 DECLARATIVEPIESERIES_H
21 #ifndef DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QPieSlice>
25 #include <QPieSlice>
26 #include <QPieSeries>
26 #include <QPieSeries>
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeListProperty>
28 #include <QDeclarativeListProperty>
29 #include <QAbstractItemModel>
29 #include <QAbstractItemModel>
30 #include <QVariant>
30 #include <QVariant>
31 #include "declarativemodel.h"
31 #include "declarativemodel.h"
32
32
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
34
35 class QChart;
35 class QChart;
36
36
37 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
37 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
38 {
38 {
39 Q_OBJECT
39 Q_OBJECT
40 Q_INTERFACES(QDeclarativeParserStatus)
40 Q_INTERFACES(QDeclarativeParserStatus)
41 Q_PROPERTY(DeclarativeTableModel *model READ pieModel WRITE setPieModel)
41 Q_PROPERTY(DeclarativeTableModel *model READ pieModel WRITE setPieModel)
42 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> initialSlices READ initialSlices)
42 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> initialSlices READ initialSlices)
43 Q_CLASSINFO("DefaultProperty", "initialSlices")
43 Q_CLASSINFO("DefaultProperty", "initialSlices")
44
44
45 public:
45 public:
46 explicit DeclarativePieSeries(QObject *parent = 0);
46 explicit DeclarativePieSeries(QObject *parent = 0);
47 QDeclarativeListProperty<QPieSlice> initialSlices();
47 QDeclarativeListProperty<QPieSlice> initialSlices();
48 DeclarativeTableModel *pieModel();
48 DeclarativeTableModel *pieModel();
49 void setPieModel(DeclarativeTableModel *model);
49 void setPieModel(DeclarativeTableModel *model);
50 Q_INVOKABLE QPieSlice *at(int index);
50 Q_INVOKABLE QPieSlice *at(int index);
51 Q_INVOKABLE QPieSlice* append(QString name, qreal value);
51 Q_INVOKABLE QPieSlice* find(QString label);
52 Q_INVOKABLE QPieSlice* append(QString label, qreal value);
52
53
53 public:
54 public:
54 void classBegin();
55 void classBegin();
55 void componentComplete();
56 void componentComplete();
56
57
57 public Q_SLOTS:
58 public Q_SLOTS:
58 static void appendInitialSlices(QDeclarativeListProperty<QPieSlice> */*list*/, QPieSlice */*element*/) {}
59 static void appendInitialSlices(QDeclarativeListProperty<QPieSlice> */*list*/, QPieSlice */*element*/) {}
59 };
60 };
60
61
61 QTCOMMERCIALCHART_END_NAMESPACE
62 QTCOMMERCIALCHART_END_NAMESPACE
62
63
63 #endif // DECLARATIVEPIESERIES_H
64 #endif // DECLARATIVEPIESERIES_H
@@ -1,47 +1,48
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 "declarativescatterseries.h"
21 #include "declarativescatterseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qscatterseries.h"
24 #include "qscatterseries.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
29 QScatterSeries(parent)
29 QScatterSeries(parent)
30 {
30 {
31 }
31 }
32
32
33 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
33 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
34 {
34 {
35 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
35 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
36 }
36 }
37
37
38 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
38 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
39 {
39 {
40 DeclarativeScatterSeries *series = qobject_cast<DeclarativeScatterSeries *>(list->object);
40 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
41 if (series && qobject_cast<DeclarativeXyPoint *>(element))
41 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
42 series->declarativeModel()->appendPoint(series->modelMapper(), qobject_cast<DeclarativeXyPoint *>(element));
42 if (series && point)
43 series->append(*point);
43 }
44 }
44
45
45 #include "moc_declarativescatterseries.cpp"
46 #include "moc_declarativescatterseries.cpp"
46
47
47 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,34 +1,48
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 "declarativesplineseries.h"
21 #include "declarativesplineseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include <QChart>
23 #include <QChart>
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
27 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
28 QSplineSeries(parent)
28 QSplineSeries(parent)
29 {
29 {
30 }
30 }
31
31
32 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
33 {
34 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
35 }
36
37 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
38 {
39 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
40 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
41 if (series && point) {
42 qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point;
43 series->append(*point);
44 }
45 }
32 #include "moc_declarativesplineseries.cpp"
46 #include "moc_declarativesplineseries.cpp"
33
47
34 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,42 +1,48
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 DECLARATIVESPLINESERIES_H
21 #ifndef DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qsplineseries.h"
25 #include "qsplineseries.h"
26 #include "declarativexyseries.h"
26 #include "declarativexyseries.h"
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries
31 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
35
37
36 public:
38 public:
37 explicit DeclarativeSplineSeries(QObject *parent = 0);
39 explicit DeclarativeSplineSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QObject> declarativeChildren();
41
42 public Q_SLOTS:
43 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
38 };
44 };
39
45
40 QTCOMMERCIALCHART_END_NAMESPACE
46 QTCOMMERCIALCHART_END_NAMESPACE
41
47
42 #endif // DECLARATIVESPLINESERIES_H
48 #endif // DECLARATIVESPLINESERIES_H
@@ -1,70 +1,69
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 "DeclarativeXySeries.h"
21 //#include "DeclarativeXySeries.h"
22 #include "declarativexyseries.h"
22 #include "declarativexyseries.h"
23 #include "declarativechart.h"
23 #include "declarativechart.h"
24 #include <QXYSeries>
24 #include <QXYSeries>
25 #include <QXYModelMapper>
25 #include <QXYModelMapper>
26 #include <QDeclarativeListProperty>
26 #include <QDeclarativeListProperty>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 DeclarativeXySeries::DeclarativeXySeries()
30 DeclarativeXySeries::DeclarativeXySeries()
31 {
31 {
32 // All the inherited objects must be of type QXYSeries, so it is safe to cast
32 // All the inherited objects must be of type QXYSeries, so it is safe to cast
33 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
33 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
34 // TODO: set default model on init?
34 // TODO: mapper should be available on the series by default
35 series->setModel(new DeclarativeTableModel());
36 QXYModelMapper *mapper = new QXYModelMapper(series);
35 QXYModelMapper *mapper = new QXYModelMapper(series);
37 mapper->setMapX(0);
36 mapper->setMapX(0);
38 mapper->setMapY(1);
37 mapper->setMapY(1);
39 mapper->setFirst(0);
38 mapper->setFirst(0);
40 mapper->setCount(-1);
39 mapper->setCount(-1);
41 mapper->setOrientation(Qt::Vertical);
40 mapper->setOrientation(Qt::Vertical);
42 series->setModelMapper(mapper);
41 series->setModelMapper(mapper);
43 }
42 }
44
43
45 DeclarativeXySeries::~DeclarativeXySeries()
44 DeclarativeXySeries::~DeclarativeXySeries()
46 {
45 {
47 }
46 }
48
47
49 bool DeclarativeXySeries::setDeclarativeModel(DeclarativeTableModel *model)
48 bool DeclarativeXySeries::setDeclarativeModel(DeclarativeTableModel *model)
50 {
49 {
51 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
50 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
52 bool value(false);
51 bool value(false);
53 if (m) {
52 if (m) {
54 // All the inherited objects must be of type QXYSeries, so it is safe to cast
53 // All the inherited objects must be of type QXYSeries, so it is safe to cast
55 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
54 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
56 series->setModel(m);
55 series->setModel(m);
57 } else {
56 } else {
58 qWarning("DeclarativeXySeries: Illegal model");
57 qWarning("DeclarativeXySeries: Illegal model");
59 }
58 }
60 return value;
59 return value;
61 }
60 }
62
61
63 DeclarativeTableModel *DeclarativeXySeries::declarativeModel()
62 DeclarativeTableModel *DeclarativeXySeries::declarativeModel()
64 {
63 {
65 // All the inherited objects must be of type QXYSeries, so it is safe to cast
64 // All the inherited objects must be of type QXYSeries, so it is safe to cast
66 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
65 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
67 return qobject_cast<DeclarativeTableModel *>(series->model());
66 return qobject_cast<DeclarativeTableModel *>(series->model());
68 }
67 }
69
68
70 QTCOMMERCIALCHART_END_NAMESPACE
69 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,284 +1,304
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 "qareaseries.h"
21 #include "qareaseries.h"
22 #include "qareaseries_p.h"
22 #include "qareaseries_p.h"
23 #include "qlineseries.h"
23 #include "qlineseries.h"
24 #include "areachartitem_p.h"
24 #include "areachartitem_p.h"
25 #include "legendmarker_p.h"
25 #include "legendmarker_p.h"
26 #include "domain_p.h"
26 #include "domain_p.h"
27 #include "chartdataset_p.h"
27 #include "chartdataset_p.h"
28 #include "charttheme_p.h"
28 #include "charttheme_p.h"
29 #include "chartanimator_p.h"
29 #include "chartanimator_p.h"
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 /*!
33 /*!
34 \class QAreaSeries
34 \class QAreaSeries
35 \brief The QAreaSeries class is used for making area charts.
35 \brief The QAreaSeries class is used for making area charts.
36
36
37 \mainclass
37 \mainclass
38
38
39 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
39 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
40 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
40 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
41 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
41 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
42 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
42 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
43 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
43 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
44
44
45 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
45 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
46 \image examples_areachart.png
46 \image examples_areachart.png
47 */
47 */
48
48
49 /*!
49 /*!
50 \fn virtual QSeriesType QAreaSeries::type() const
50 \fn virtual QSeriesType QAreaSeries::type() const
51 \brief Returns type of series.
51 \brief Returns type of series.
52 \sa QAbstractSeries, QSeriesType
52 \sa QAbstractSeries, QSeriesType
53 */
53 */
54
54
55 /*!
55 /*!
56 \fn QLineSeries* QAreaSeries::upperSeries() const
56 \fn QLineSeries* QAreaSeries::upperSeries() const
57 \brief Returns upperSeries used to define one of area boundaries.
57 \brief Returns upperSeries used to define one of area boundaries.
58 */
58 */
59
59
60 /*!
60 /*!
61 \fn QLineSeries* QAreaSeries::lowerSeries() const
61 \fn QLineSeries* QAreaSeries::lowerSeries() const
62 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
62 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
63 this function return Null pointer.
63 this function return Null pointer.
64 */
64 */
65
65
66 /*!
66 /*!
67 \fn QPen QAreaSeries::pen() const
67 \fn QPen QAreaSeries::pen() const
68 \brief Returns the pen used to draw line for this series.
68 \brief Returns the pen used to draw line for this series.
69 \sa setPen()
69 \sa setPen()
70 */
70 */
71
71
72 /*!
72 /*!
73 \fn QPen QAreaSeries::brush() const
73 \fn QPen QAreaSeries::brush() const
74 \brief Returns the brush used to draw line for this series.
74 \brief Returns the brush used to draw line for this series.
75 \sa setBrush()
75 \sa setBrush()
76 */
76 */
77
77
78 /*!
78 /*!
79 \fn bool QAreaSeries::pointsVisible() const
79 \fn bool QAreaSeries::pointsVisible() const
80 \brief Returns if the points are drawn for this series.
80 \brief Returns if the points are drawn for this series.
81 \sa setPointsVisible()
81 \sa setPointsVisible()
82 */
82 */
83
83
84 /*!
84 /*!
85 \fn void QAreaSeries::clicked(const QPointF& point)
85 \fn void QAreaSeries::clicked(const QPointF& point)
86 \brief Signal is emitted when user clicks the \a point on area chart.
86 \brief Signal is emitted when user clicks the \a point on area chart.
87 */
87 */
88
88
89 /*!
89 /*!
90 \fn void QAreaSeries::selected()
90 \fn void QAreaSeries::selected()
91
91
92 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
92 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
93 implemented by the user of QAreaSeries API.
93 implemented by the user of QAreaSeries API.
94 */
94 */
95
95
96 /*!
96 /*!
97 \fn void QAreaSeriesPrivate::updated()
97 \fn void QAreaSeriesPrivate::updated()
98 \brief \internal
98 \brief \internal
99 */
99 */
100
100
101 /*!
101 /*!
102 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
102 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
103 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
103 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
104 When series object is added to QChartView or QChart instance ownerships is transferred.
104 When series object is added to QChartView or QChart instance ownerships is transferred.
105 */
105 */
106 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
106 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
107 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
107 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
108 {
108 {
109 }
109 }
110
110
111 /*!
111 /*!
112 Constructs area series object without upper or lower series.
113 */
114 QAreaSeries::QAreaSeries(QObject *parent)
115 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
116 {
117 }
118
119 /*!
112 Destroys the object. Series added to QChartView or QChart instances are owned by those,
120 Destroys the object. Series added to QChartView or QChart instances are owned by those,
113 and are deleted when mentioned object are destroyed.
121 and are deleted when mentioned object are destroyed.
114 */
122 */
115 QAreaSeries::~QAreaSeries()
123 QAreaSeries::~QAreaSeries()
116 {
124 {
117 }
125 }
118
126
119
127
120 QAbstractSeries::SeriesType QAreaSeries::type() const
128 QAbstractSeries::SeriesType QAreaSeries::type() const
121 {
129 {
122 return QAbstractSeries::SeriesTypeArea;
130 return QAbstractSeries::SeriesTypeArea;
123 }
131 }
124
132
133 void QAreaSeries::setUpperSeries(QLineSeries* series)
134 {
135 Q_D(QAreaSeries);
136 d->m_upperSeries = series;
137 }
138
125 QLineSeries* QAreaSeries::upperSeries() const
139 QLineSeries* QAreaSeries::upperSeries() const
126 {
140 {
127 Q_D(const QAreaSeries);
141 Q_D(const QAreaSeries);
128 return d->m_upperSeries;
142 return d->m_upperSeries;
129 }
143 }
130
144
145 void QAreaSeries::setLowerSeries(QLineSeries* series)
146 {
147 Q_D(QAreaSeries);
148 d->m_lowerSeries = series;
149 }
150
131 QLineSeries* QAreaSeries::lowerSeries() const
151 QLineSeries* QAreaSeries::lowerSeries() const
132 {
152 {
133 Q_D(const QAreaSeries);
153 Q_D(const QAreaSeries);
134 return d->m_lowerSeries;
154 return d->m_lowerSeries;
135 }
155 }
136
156
137 /*!
157 /*!
138 Sets \a pen used for drawing area outline.
158 Sets \a pen used for drawing area outline.
139 */
159 */
140 void QAreaSeries::setPen(const QPen &pen)
160 void QAreaSeries::setPen(const QPen &pen)
141 {
161 {
142 Q_D(QAreaSeries);
162 Q_D(QAreaSeries);
143 if (d->m_pen != pen) {
163 if (d->m_pen != pen) {
144 d->m_pen = pen;
164 d->m_pen = pen;
145 emit d->updated();
165 emit d->updated();
146 }
166 }
147 }
167 }
148
168
149 QPen QAreaSeries::pen() const
169 QPen QAreaSeries::pen() const
150 {
170 {
151 Q_D(const QAreaSeries);
171 Q_D(const QAreaSeries);
152 return d->m_pen;
172 return d->m_pen;
153 }
173 }
154
174
155 /*!
175 /*!
156 Sets \a brush used for filling the area.
176 Sets \a brush used for filling the area.
157 */
177 */
158 void QAreaSeries::setBrush(const QBrush &brush)
178 void QAreaSeries::setBrush(const QBrush &brush)
159 {
179 {
160 Q_D(QAreaSeries);
180 Q_D(QAreaSeries);
161 if (d->m_brush != brush) {
181 if (d->m_brush != brush) {
162 d->m_brush = brush;
182 d->m_brush = brush;
163 emit d->updated();
183 emit d->updated();
164 }
184 }
165 }
185 }
166
186
167 QBrush QAreaSeries::brush() const
187 QBrush QAreaSeries::brush() const
168 {
188 {
169 Q_D(const QAreaSeries);
189 Q_D(const QAreaSeries);
170 return d->m_brush;
190 return d->m_brush;
171 }
191 }
172 /*!
192 /*!
173 Sets if data points are \a visible and should be drawn on line.
193 Sets if data points are \a visible and should be drawn on line.
174 */
194 */
175 void QAreaSeries::setPointsVisible(bool visible)
195 void QAreaSeries::setPointsVisible(bool visible)
176 {
196 {
177 Q_D(QAreaSeries);
197 Q_D(QAreaSeries);
178 if (d->m_pointsVisible != visible) {
198 if (d->m_pointsVisible != visible) {
179 d->m_pointsVisible = visible;
199 d->m_pointsVisible = visible;
180 emit d->updated();
200 emit d->updated();
181 }
201 }
182 }
202 }
183
203
184 bool QAreaSeries::pointsVisible() const
204 bool QAreaSeries::pointsVisible() const
185 {
205 {
186 Q_D(const QAreaSeries);
206 Q_D(const QAreaSeries);
187 return d->m_pointsVisible;
207 return d->m_pointsVisible;
188 }
208 }
189
209
190 /*!
210 /*!
191 Does nothing at present. Paremeter \a model is not used. Always returns false.
211 Does nothing at present. Paremeter \a model is not used. Always returns false.
192 To set the model for area series set the models for upperSeries, lowerSeries
212 To set the model for area series set the models for upperSeries, lowerSeries
193 */
213 */
194 void QAreaSeries::setModel(QAbstractItemModel* model)
214 void QAreaSeries::setModel(QAbstractItemModel* model)
195 {
215 {
196 Q_UNUSED(model);
216 Q_UNUSED(model);
197 qWarning()<<"Not implemented";
217 qWarning()<<"Not implemented";
198 }
218 }
199
219
200 /*!
220 /*!
201 Does nothing at present. Always returns 0;
221 Does nothing at present. Always returns 0;
202 To get the model set for area series call upperSeries->model(), lowerSeries->model()
222 To get the model set for area series call upperSeries->model(), lowerSeries->model()
203 */
223 */
204 QAbstractItemModel* QAreaSeries::model() const
224 QAbstractItemModel* QAreaSeries::model() const
205 {
225 {
206 return 0;
226 return 0;
207 }
227 }
208
228
209 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
229 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
210
230
211 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
231 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
212 QAbstractSeriesPrivate(q),
232 QAbstractSeriesPrivate(q),
213 m_upperSeries(upperSeries),
233 m_upperSeries(upperSeries),
214 m_lowerSeries(lowerSeries),
234 m_lowerSeries(lowerSeries),
215 m_pointsVisible(false)
235 m_pointsVisible(false)
216 {
236 {
217 }
237 }
218
238
219 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
239 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
220 {
240 {
221 Q_Q(QAreaSeries);
241 Q_Q(QAreaSeries);
222
242
223 qreal minX(domain.minX());
243 qreal minX(domain.minX());
224 qreal minY(domain.minY());
244 qreal minY(domain.minY());
225 qreal maxX(domain.maxX());
245 qreal maxX(domain.maxX());
226 qreal maxY(domain.maxY());
246 qreal maxY(domain.maxY());
227 int tickXCount(domain.tickXCount());
247 int tickXCount(domain.tickXCount());
228 int tickYCount(domain.tickYCount());
248 int tickYCount(domain.tickYCount());
229
249
230 QLineSeries* upperSeries = q->upperSeries();
250 QLineSeries* upperSeries = q->upperSeries();
231 QLineSeries* lowerSeries = q->lowerSeries();
251 QLineSeries* lowerSeries = q->lowerSeries();
232
252
233 const QList<QPointF>& points = upperSeries->points();
253 const QList<QPointF>& points = upperSeries->points();
234
254
235 for (int i = 0; i < points.count(); i++)
255 for (int i = 0; i < points.count(); i++)
236 {
256 {
237 qreal x = points[i].x();
257 qreal x = points[i].x();
238 qreal y = points[i].y();
258 qreal y = points[i].y();
239 minX = qMin(minX, x);
259 minX = qMin(minX, x);
240 minY = qMin(minY, y);
260 minY = qMin(minY, y);
241 maxX = qMax(maxX, x);
261 maxX = qMax(maxX, x);
242 maxY = qMax(maxY, y);
262 maxY = qMax(maxY, y);
243 }
263 }
244 if(lowerSeries) {
264 if(lowerSeries) {
245
265
246 const QList<QPointF>& points = lowerSeries->points();
266 const QList<QPointF>& points = lowerSeries->points();
247
267
248 for (int i = 0; i < points.count(); i++)
268 for (int i = 0; i < points.count(); i++)
249 {
269 {
250 qreal x = points[i].x();
270 qreal x = points[i].x();
251 qreal y = points[i].y();
271 qreal y = points[i].y();
252 minX = qMin(minX, x);
272 minX = qMin(minX, x);
253 minY = qMin(minY, y);
273 minY = qMin(minY, y);
254 maxX = qMax(maxX, x);
274 maxX = qMax(maxX, x);
255 maxY = qMax(maxY, y);
275 maxY = qMax(maxY, y);
256 }}
276 }}
257
277
258 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
278 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
259 }
279 }
260
280
261 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
281 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
262 {
282 {
263 Q_Q(QAreaSeries);
283 Q_Q(QAreaSeries);
264
284
265 AreaChartItem* area = new AreaChartItem(q,presenter);
285 AreaChartItem* area = new AreaChartItem(q,presenter);
266 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
286 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
267 presenter->animator()->addAnimation(area->upperLineItem());
287 presenter->animator()->addAnimation(area->upperLineItem());
268 if(q->lowerSeries()) presenter->animator()->addAnimation(area->lowerLineItem());
288 if(q->lowerSeries()) presenter->animator()->addAnimation(area->lowerLineItem());
269 }
289 }
270 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
290 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
271 return area;
291 return area;
272 }
292 }
273
293
274 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
294 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
275 {
295 {
276 Q_Q(QAreaSeries);
296 Q_Q(QAreaSeries);
277 QList<LegendMarker*> list;
297 QList<LegendMarker*> list;
278 return list << new AreaLegendMarker(q,legend);
298 return list << new AreaLegendMarker(q,legend);
279 }
299 }
280
300
281 #include "moc_qareaseries.cpp"
301 #include "moc_qareaseries.cpp"
282 #include "moc_qareaseries_p.cpp"
302 #include "moc_qareaseries_p.cpp"
283
303
284 QTCOMMERCIALCHART_END_NAMESPACE
304 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,71 +1,74
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 QAREASERIES_H
21 #ifndef QAREASERIES_H
22 #define QAREASERIES_H
22 #define QAREASERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qabstractseries.h>
25 #include <qabstractseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 class QLineSeries;
30 class QLineSeries;
31 class QAreaSeriesPrivate;
31 class QAreaSeriesPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 public:
36 public:
37 explicit QAreaSeries(QObject *parent = 0);
37 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
38 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
38 ~QAreaSeries();
39 ~QAreaSeries();
39
40
40 public:
41 public:
41 QAbstractSeries::SeriesType type() const;
42 QAbstractSeries::SeriesType type() const;
42
43
44 void setUpperSeries(QLineSeries* series);
43 QLineSeries* upperSeries() const;
45 QLineSeries* upperSeries() const;
46 void setLowerSeries(QLineSeries* series);
44 QLineSeries* lowerSeries() const;
47 QLineSeries* lowerSeries() const;
45
48
46 void setPen(const QPen &pen);
49 void setPen(const QPen &pen);
47 QPen pen() const;
50 QPen pen() const;
48
51
49 void setBrush(const QBrush &brush);
52 void setBrush(const QBrush &brush);
50 QBrush brush() const;
53 QBrush brush() const;
51
54
52 void setPointsVisible(bool visible = true);
55 void setPointsVisible(bool visible = true);
53 bool pointsVisible() const;
56 bool pointsVisible() const;
54
57
55 void setModel(QAbstractItemModel* model);
58 void setModel(QAbstractItemModel* model);
56 QAbstractItemModel* model() const;
59 QAbstractItemModel* model() const;
57
60
58 Q_SIGNALS:
61 Q_SIGNALS:
59 void clicked(const QPointF &point);
62 void clicked(const QPointF &point);
60 void selected();
63 void selected();
61
64
62 private:
65 private:
63 Q_DECLARE_PRIVATE(QAreaSeries);
66 Q_DECLARE_PRIVATE(QAreaSeries);
64 Q_DISABLE_COPY(QAreaSeries);
67 Q_DISABLE_COPY(QAreaSeries);
65 friend class AreaLegendMarker;
68 friend class AreaLegendMarker;
66 friend class AreaChartItem;
69 friend class AreaChartItem;
67 };
70 };
68
71
69 QTCOMMERCIALCHART_END_NAMESPACE
72 QTCOMMERCIALCHART_END_NAMESPACE
70
73
71 #endif
74 #endif
General Comments 0
You need to be logged in to leave comments. Login now