@@ -0,0 +1,57 | |||
|
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 | anchors.fill: parent | |
|
26 | ||
|
27 | Chart { | |
|
28 | title: "Scatters" | |
|
29 | anchors.fill: parent | |
|
30 | theme: Chart.ChartThemeBlueCerulean | |
|
31 | ||
|
32 | ScatterSeries { | |
|
33 | id: scatter1 | |
|
34 | name: "Scatter1" | |
|
35 | points: [ | |
|
36 | XyPoint { x: 1.5; y: 1.5 }, | |
|
37 | XyPoint { x: 1.5; y: 1.6 }, | |
|
38 | XyPoint { x: 1.57; y: 1.55 }, | |
|
39 | XyPoint { x: 1.8; y: 1.8 }, | |
|
40 | XyPoint { x: 1.9; y: 1.6 }, | |
|
41 | XyPoint { x: 2.1; y: 1.3 }, | |
|
42 | XyPoint { x: 2.5; y: 2.1 } | |
|
43 | ] | |
|
44 | } | |
|
45 | ScatterSeries { | |
|
46 | name: "Scatter2" | |
|
47 | points: [ | |
|
48 | XyPoint { x: 2.0; y: 2.0 }, | |
|
49 | XyPoint { x: 2.0; y: 2.1 }, | |
|
50 | XyPoint { x: 2.07; y: 2.05 }, | |
|
51 | XyPoint { x: 2.2; y: 2.9 }, | |
|
52 | XyPoint { x: 2.4; y: 2.7 }, | |
|
53 | XyPoint { x: 2.67; y: 2.65 } | |
|
54 | ] | |
|
55 | } | |
|
56 | } | |
|
57 | } |
@@ -53,7 +53,7 void DeclarativeBarSeries::componentComplete() | |||
|
53 | 53 | QBarSet *set2 = new QBarSet("Guybrush"); |
|
54 | 54 | |
|
55 | 55 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
56 |
*set1 << 5 << |
|
|
56 | *set1 << 5 << 1 << 2 << 4 << 1 << 7; | |
|
57 | 57 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
58 | 58 | |
|
59 | 59 | m_series->appendBarSet(set0); |
@@ -34,6 +34,7 class DeclarativeChart : public QDeclarativeItem | |||
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
37 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
|
37 | 38 | |
|
38 | 39 | public: |
|
39 | 40 | DeclarativeChart(QDeclarativeItem *parent = 0); |
@@ -46,6 +47,8 public: // From QDeclarativeItem/QGraphicsItem | |||
|
46 | 47 | public: |
|
47 | 48 | void setTheme(QChart::ChartTheme theme) {m_chart->setTheme(theme);} |
|
48 | 49 | QChart::ChartTheme theme(); |
|
50 | void setTitle(QString title) {m_chart->setTitle(title);} | |
|
51 | QString title() { return m_chart->title();} | |
|
49 | 52 | |
|
50 | 53 | public: |
|
51 | 54 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
@@ -22,53 +22,30 import QtQuick 1.0 | |||
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | Rectangle { |
|
25 | width: parent.width | |
|
26 | height: parent.height | |
|
27 | ||
|
28 | // Another option for QML data api: | |
|
29 | // ListModel { | |
|
30 | // id: listModelForPie | |
|
31 | // // PieDataElement | |
|
32 | // ListElement { | |
|
33 | // label: "Apple" | |
|
34 | // value: 4.3 | |
|
35 | // } | |
|
36 | // ListElement { | |
|
37 | // label: "Blackberry" | |
|
38 | // value: 15.1 | |
|
39 | // } | |
|
40 | // } | |
|
41 | ||
|
42 | Component.onCompleted: { | |
|
43 | // console.log("model:" + myModel.item(0)); | |
|
44 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); | |
|
45 | // scatter.appendData(); | |
|
46 | // chart1.theme = Chart.ThemeHighContrast; | |
|
47 | // chart2.theme = Chart.ThemeHighContrast; | |
|
48 | } | |
|
25 | anchors.fill: parent | |
|
49 | 26 | |
|
50 | 27 | Chart { |
|
51 | id: chart1 | |
|
28 | title: "Car brand shares in Finland" | |
|
52 | 29 | anchors.fill: parent |
|
53 |
theme: Chart.ChartTheme |
|
|
54 | ||
|
55 | BarSeries { | |
|
56 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
|
57 | // TBD: data | |
|
58 | } | |
|
30 | theme: Chart.ChartThemeLight | |
|
59 | 31 | |
|
60 | 32 | PieSeries { |
|
61 | 33 | horizontalPosition: 0.2 |
|
62 | 34 | verticalPosition: 0.3 |
|
63 | 35 | size: 0.4 |
|
64 | endAngle: 0.52 * 360 // The share of "others" is 52% | |
|
65 | 36 |
|
|
66 | 37 | PieSlice { label: "Volkswagen"; value: 13.5 }, |
|
67 | 38 | PieSlice { label: "Toyota"; value: 10.9 }, |
|
68 | 39 | PieSlice { label: "Ford"; value: 8.6 }, |
|
69 | 40 | PieSlice { label: "Skoda"; value: 8.2 }, |
|
70 | PieSlice { label: "Volvo"; value: 6.8 } | |
|
41 | PieSlice { label: "Volvo"; value: 6.8 }, | |
|
42 | PieSlice { label: "Others"; value: 52.0 } | |
|
71 | 43 | ] |
|
72 | 44 | } |
|
45 | ||
|
46 | BarSeries { | |
|
47 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
|
48 | // data implementation missing | |
|
49 | } | |
|
73 | 50 | } |
|
74 | 51 | } |
@@ -25,6 +25,7 Rectangle { | |||
|
25 | 25 | anchors.fill: parent |
|
26 | 26 | |
|
27 | 27 | Chart { |
|
28 | title: "Line&Spline" | |
|
28 | 29 | anchors.fill: parent |
|
29 | 30 | theme: Chart.ChartThemeBrownSand |
|
30 | 31 | |
@@ -33,8 +34,10 Rectangle { | |||
|
33 | 34 | points: [ |
|
34 | 35 | XyPoint { x: 0.0; y: 0.0 }, |
|
35 | 36 | XyPoint { x: 1.1; y: 2.1 }, |
|
37 | XyPoint { x: 1.9; y: 3.3 }, | |
|
36 | 38 | XyPoint { x: 2.9; y: 4.9 }, |
|
37 | XyPoint { x: 3.2; y: 3.0 } | |
|
39 | XyPoint { x: 3.2; y: 3.0 }, | |
|
40 | XyPoint { x: 4.0; y: 3.3 } | |
|
38 | 41 | ] |
|
39 | 42 | } |
|
40 | 43 | |
@@ -43,8 +46,11 Rectangle { | |||
|
43 | 46 | points: [ |
|
44 | 47 | XyPoint { x: 0.0; y: 0.3 }, |
|
45 | 48 | XyPoint { x: 1.1; y: 3.2 }, |
|
46 |
XyPoint { x: |
|
|
47 |
XyPoint { x: |
|
|
49 | XyPoint { x: 1.7; y: 2.4 }, | |
|
50 | XyPoint { x: 2.1; y: 2.1 }, | |
|
51 | XyPoint { x: 2.9; y: 2.6 }, | |
|
52 | XyPoint { x: 3.4; y: 2.3 }, | |
|
53 | XyPoint { x: 4.1; y: 3.1 } | |
|
48 | 54 | ] |
|
49 | 55 | } |
|
50 | 56 | } |
@@ -25,45 +25,103 Rectangle { | |||
|
25 | 25 | anchors.fill: parent |
|
26 | 26 | |
|
27 | 27 | Chart { |
|
28 | title: "NHL All-Star Team Players" | |
|
28 | 29 | anchors.fill: parent |
|
29 | 30 | theme: Chart.ChartThemeHighContrast |
|
30 | 31 | |
|
31 | 32 | AreaSeries { |
|
32 |
name: " |
|
|
33 | name: "Finnish" | |
|
33 | 34 | points: [ |
|
34 |
XyPoint { x: 0 |
|
|
35 |
XyPoint { x: |
|
|
36 |
XyPoint { x: |
|
|
35 | XyPoint { x: 0; y: 0 }, | |
|
36 | XyPoint { x: 1; y: 0 }, | |
|
37 | XyPoint { x: 2; y: 0 }, | |
|
38 | XyPoint { x: 3; y: 0 }, | |
|
39 | XyPoint { x: 4; y: 0 }, | |
|
40 | XyPoint { x: 5; y: 0 }, | |
|
41 | XyPoint { x: 6; y: 1 }, | |
|
42 | XyPoint { x: 7; y: 0 }, | |
|
43 | XyPoint { x: 8; y: 0 }, | |
|
44 | XyPoint { x: 9; y: 0 }, | |
|
45 | XyPoint { x: 10; y: 0 }, | |
|
46 | XyPoint { x: 11; y: 1 } | |
|
37 | 47 | ] |
|
38 | 48 | lowerPoints: [ |
|
39 |
XyPoint { x: 0 |
|
|
40 |
XyPoint { x: |
|
|
41 |
XyPoint { x: |
|
|
49 | XyPoint { x: 0; y: 0 }, | |
|
50 | XyPoint { x: 1; y: 0 }, | |
|
51 | XyPoint { x: 2; y: 0 }, | |
|
52 | XyPoint { x: 3; y: 0 }, | |
|
53 | XyPoint { x: 4; y: 0 }, | |
|
54 | XyPoint { x: 5; y: 0 }, | |
|
55 | XyPoint { x: 6; y: 0 }, | |
|
56 | XyPoint { x: 7; y: 0 }, | |
|
57 | XyPoint { x: 8; y: 0 }, | |
|
58 | XyPoint { x: 9; y: 0 }, | |
|
59 | XyPoint { x: 10; y: 0 }, | |
|
60 | XyPoint { x: 11; y: 0 } | |
|
42 | 61 | ] |
|
43 | 62 | } |
|
44 | 63 | |
|
45 |
|
|
|
46 |
name: " |
|
|
64 | AreaSeries { | |
|
65 | name: "Russian" | |
|
47 | 66 | points: [ |
|
48 |
XyPoint { x: |
|
|
49 |
XyPoint { x: 1 |
|
|
50 |
XyPoint { x: |
|
|
67 | XyPoint { x: 0; y: 1 }, | |
|
68 | XyPoint { x: 1; y: 1 }, | |
|
69 | XyPoint { x: 2; y: 1 }, | |
|
70 | XyPoint { x: 3; y: 1 }, | |
|
71 | XyPoint { x: 4; y: 1 }, | |
|
72 | XyPoint { x: 5; y: 0 }, | |
|
73 | XyPoint { x: 6; y: 1 }, | |
|
74 | XyPoint { x: 7; y: 1 }, | |
|
75 | XyPoint { x: 8; y: 4 }, | |
|
76 | XyPoint { x: 9; y: 3 }, | |
|
77 | XyPoint { x: 10; y: 2 }, | |
|
78 | XyPoint { x: 11; y: 1 } | |
|
51 | 79 | ] |
|
52 | } | |
|
53 | ScatterSeries { | |
|
54 | name: "Scatter2" | |
|
55 |
|
|
|
56 |
XyPoint { x: |
|
|
57 |
XyPoint { x: |
|
|
58 |
XyPoint { x: |
|
|
80 | lowerPoints: [ | |
|
81 | XyPoint { x: 0; y: 0 }, | |
|
82 | XyPoint { x: 1; y: 0 }, | |
|
83 | XyPoint { x: 2; y: 0 }, | |
|
84 | XyPoint { x: 3; y: 0 }, | |
|
85 | XyPoint { x: 4; y: 0 }, | |
|
86 | XyPoint { x: 5; y: 0 }, | |
|
87 | XyPoint { x: 6; y: 0 }, | |
|
88 | XyPoint { x: 7; y: 0 }, | |
|
89 | XyPoint { x: 8; y: 0 }, | |
|
90 | XyPoint { x: 9; y: 0 }, | |
|
91 | XyPoint { x: 10; y: 0 }, | |
|
92 | XyPoint { x: 11; y: 0 } | |
|
59 | 93 | ] |
|
60 | 94 | } |
|
61 | ScatterSeries { | |
|
62 | name: "Scatter3" | |
|
95 | ||
|
96 | AreaSeries { | |
|
97 | name: "Swedish" | |
|
63 | 98 | points: [ |
|
64 |
XyPoint { x: |
|
|
65 |
XyPoint { x: |
|
|
66 |
XyPoint { x: 2 |
|
|
99 | XyPoint { x: 0; y: 1 }, | |
|
100 | XyPoint { x: 1; y: 1 }, | |
|
101 | XyPoint { x: 2; y: 3 }, | |
|
102 | XyPoint { x: 3; y: 3 }, | |
|
103 | XyPoint { x: 4; y: 2 }, | |
|
104 | XyPoint { x: 5; y: 0 }, | |
|
105 | XyPoint { x: 6; y: 2 }, | |
|
106 | XyPoint { x: 7; y: 1 }, | |
|
107 | XyPoint { x: 8; y: 2 }, | |
|
108 | XyPoint { x: 9; y: 1 }, | |
|
109 | XyPoint { x: 10; y: 3 }, | |
|
110 | XyPoint { x: 11; y: 3 } | |
|
111 | ] | |
|
112 | lowerPoints: [ | |
|
113 | XyPoint { x: 0; y: 0 }, | |
|
114 | XyPoint { x: 1; y: 0 }, | |
|
115 | XyPoint { x: 2; y: 0 }, | |
|
116 | XyPoint { x: 3; y: 0 }, | |
|
117 | XyPoint { x: 4; y: 0 }, | |
|
118 | XyPoint { x: 5; y: 0 }, | |
|
119 | XyPoint { x: 6; y: 0 }, | |
|
120 | XyPoint { x: 7; y: 0 }, | |
|
121 | XyPoint { x: 8; y: 0 }, | |
|
122 | XyPoint { x: 9; y: 0 }, | |
|
123 | XyPoint { x: 10; y: 0 }, | |
|
124 | XyPoint { x: 11; y: 0 } | |
|
67 | 125 | ] |
|
68 | 126 | } |
|
69 | 127 | } |
@@ -31,9 +31,8 Rectangle { | |||
|
31 | 31 | running: true |
|
32 | 32 | repeat: true |
|
33 | 33 | interval: 5000 |
|
34 |
triggeredOnStart: |
|
|
34 | triggeredOnStart: false | |
|
35 | 35 | onTriggered: { |
|
36 | loader.source = "View" + (__viewNumber % 3 + 1) + ".qml"; | |
|
37 | 36 | __viewNumber++; |
|
38 | 37 | } |
|
39 | 38 | } |
@@ -41,13 +40,13 Rectangle { | |||
|
41 | 40 | Loader { |
|
42 | 41 | id: loader |
|
43 | 42 | anchors.fill: parent |
|
43 | source: "View" + (__viewNumber % 4 + 1) + ".qml"; | |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | MouseArea { |
|
47 | 47 | anchors.fill: parent |
|
48 | 48 | onClicked: { |
|
49 | 49 | timer.restart(); |
|
50 | loader.source = "View" + (__viewNumber % 3 + 1) + ".qml"; | |
|
51 | 50 | __viewNumber++; |
|
52 | 51 | } |
|
53 | 52 | } |
General Comments 0
You need to be logged in to leave comments.
Login now