@@ -1,142 +1,142 | |||||
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 |
|
48 | |||
49 | // TODO: move ChartModel API into a demo application instead of making it a public API |
|
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. |
|
50 | // // For dynamic data you can use the ChartModel API. | |
51 | // ChartModel { |
|
51 | // ChartModel { | |
52 | // id: chartModel |
|
52 | // id: chartModel | |
53 |
// ChartModel |
|
53 | // ChartModelElement { values: ["Volkswagen", 13.5] } | |
54 |
// ChartModel |
|
54 | // ChartModelElement { values: ["Toyota", 10.9] } | |
55 |
// ChartModel |
|
55 | // ChartModelElement { values: ["Ford", 8.6] } | |
56 |
// ChartModel |
|
56 | // ChartModelElement { values: ["Skoda", 8.2] } | |
57 |
// ChartModel |
|
57 | // ChartModelElement { values: ["Volvo", 6.8] } | |
58 | // } |
|
58 | // } | |
59 | // // In this case you need to define how the data maps to pie slices with the ModelMapper API of the pie series. |
|
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 { |
|
60 | // PieSeries { | |
61 | // id: pieSeries |
|
61 | // id: pieSeries | |
62 | // model: chartModel |
|
62 | // model: chartModel | |
63 | // modelMapper.mapLabels: 0 |
|
63 | // modelMapper.mapLabels: 0 | |
64 | // modelMapper.mapValues: 1 |
|
64 | // modelMapper.mapValues: 1 | |
65 | // modelMapper.first: 0 |
|
65 | // modelMapper.first: 0 | |
66 | // modelMapper.count: -1 // "Undefined" = -1 by default |
|
66 | // modelMapper.count: -1 // "Undefined" = -1 by default | |
67 | // modelMapper.orientation: PieModelMapper.Vertical |
|
67 | // modelMapper.orientation: PieModelMapper.Vertical | |
68 | // } |
|
68 | // } | |
69 |
|
69 | |||
70 | // TODO: you could also append to your model, for example: |
|
70 | // TODO: you could also append to your model, for example: | |
71 | // pieSeries.model.append(["Others", 52.0]); |
|
71 | // pieSeries.model.append(["Others", 52.0]); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | Component.onCompleted: { |
|
74 | Component.onCompleted: { | |
75 | volkswagenSlice.exploded = true; |
|
75 | volkswagenSlice.exploded = true; | |
76 | // You can also add slices dynamically |
|
76 | // You can also add slices dynamically | |
77 | var newSlice = pieSeries.append("Others", 52.0); |
|
77 | var newSlice = pieSeries.append("Others", 52.0); | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | Timer { |
|
80 | Timer { | |
81 | repeat: true |
|
81 | repeat: true | |
82 | interval: 2000 |
|
82 | interval: 2000 | |
83 | running: true |
|
83 | running: true | |
84 | onTriggered: { |
|
84 | onTriggered: { | |
85 | // Set all slices as not exploded |
|
85 | // Set all slices as not exploded | |
86 | for (var i = 0; i < pieSeries.count; i++) |
|
86 | for (var i = 0; i < pieSeries.count; i++) | |
87 | pieSeries.at(i).exploded = false; |
|
87 | pieSeries.at(i).exploded = false; | |
88 |
|
88 | |||
89 | // Explode one of the slices |
|
89 | // Explode one of the slices | |
90 | __explodedIndex = (__explodedIndex + 1) % pieSeries.count; |
|
90 | __explodedIndex = (__explodedIndex + 1) % pieSeries.count; | |
91 | pieSeries.at(__explodedIndex).exploded = true; |
|
91 | pieSeries.at(__explodedIndex).exploded = true; | |
92 |
|
92 | |||
93 | // TODO: implement for convenience |
|
93 | // TODO: implement for convenience | |
94 | // pieSeries.find("Ford").exploded = true; |
|
94 | // pieSeries.find("Ford").exploded = true; | |
95 | // pieSeries.removeAll("Ford") |
|
95 | // pieSeries.removeAll("Ford") | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | Rectangle { |
|
99 | Rectangle { | |
100 | id: button |
|
100 | id: button | |
101 | anchors.bottom: parent.bottom |
|
101 | anchors.bottom: parent.bottom | |
102 | anchors.bottomMargin: 10 |
|
102 | anchors.bottomMargin: 10 | |
103 | anchors.horizontalCenter: parent.horizontalCenter |
|
103 | anchors.horizontalCenter: parent.horizontalCenter | |
104 | height: 40 |
|
104 | height: 40 | |
105 | width: 100 |
|
105 | width: 100 | |
106 | color: "orange" |
|
106 | color: "orange" | |
107 | radius: 5 |
|
107 | radius: 5 | |
108 | Text { |
|
108 | Text { | |
109 | id: buttonText |
|
109 | id: buttonText | |
110 | anchors.centerIn: parent |
|
110 | anchors.centerIn: parent | |
111 | text: "Hide others" |
|
111 | text: "Hide others" | |
112 | } |
|
112 | } | |
113 | MouseArea { |
|
113 | MouseArea { | |
114 | anchors.fill: parent |
|
114 | anchors.fill: parent | |
115 | onClicked: { |
|
115 | onClicked: { | |
116 | if (buttonText.text == "Show others") { |
|
116 | if (buttonText.text == "Show others") { | |
117 | pieSeries.modelMapper.count = -1; |
|
117 | pieSeries.modelMapper.count = -1; | |
118 | buttonText.text = "Hide others"; |
|
118 | buttonText.text = "Hide others"; | |
119 | } else { |
|
119 | } else { | |
120 | pieSeries.modelMapper.count = 5; |
|
120 | pieSeries.modelMapper.count = 5; | |
121 | buttonText.text = "Show others"; |
|
121 | buttonText.text = "Show others"; | |
122 | } |
|
122 | } | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | // TODO: show how to use data from a list model in a chart view |
|
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 |
|
128 | // i.e. copy the data into a chart model | |
129 | // ListModel { |
|
129 | // ListModel { | |
130 | // id: listModel |
|
130 | // id: listModel | |
131 | // ListElement { |
|
131 | // ListElement { | |
132 | // label: "Volkswagen" |
|
132 | // label: "Volkswagen" | |
133 | // value: 13.5 |
|
133 | // value: 13.5 | |
134 | // } |
|
134 | // } | |
135 | // ListElement { |
|
135 | // ListElement { | |
136 | // label: "Toyota" |
|
136 | // label: "Toyota" | |
137 | // value: 10.9 |
|
137 | // value: 10.9 | |
138 | // } |
|
138 | // } | |
139 | // // and so on... |
|
139 | // // and so on... | |
140 | // } |
|
140 | // } | |
141 |
|
141 | |||
142 | } |
|
142 | } |
@@ -1,62 +1,62 | |||||
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 | model: chartModel | |
36 | modelMapper.mapX: 0 |
|
36 | modelMapper.mapX: 0 | |
37 | modelMapper.mapY: 1 |
|
37 | modelMapper.mapY: 1 | |
38 | modelMapper.first: 0 |
|
38 | modelMapper.first: 0 | |
39 | modelMapper.count: -1 |
|
39 | modelMapper.count: -1 | |
40 | modelMapper.orientation: XYModelMapper.Vertical |
|
40 | modelMapper.orientation: XYModelMapper.Vertical | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | SplineSeries { |
|
43 | SplineSeries { | |
44 | name: "Spline" |
|
44 | name: "Spline" | |
45 | model: chartModel |
|
45 | model: chartModel | |
46 | modelMapper.mapX: 0 |
|
46 | modelMapper.mapX: 0 | |
47 | modelMapper.mapY: 2 |
|
47 | modelMapper.mapY: 2 | |
48 | } |
|
48 | } | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | ChartModel { |
|
51 | ChartModel { | |
52 | id: chartModel |
|
52 | id: chartModel | |
53 |
ChartModel |
|
53 | ChartModelElement { values: [0.0, 0.0, 0.3] } | |
54 |
ChartModel |
|
54 | ChartModelElement { values: [1.1, 2.1, 3.2] } | |
55 |
ChartModel |
|
55 | ChartModelElement { values: [1.9, 3.3, 2.4] } | |
56 |
ChartModel |
|
56 | ChartModelElement { values: [2.1, 2.1, 2.1] } | |
57 |
ChartModel |
|
57 | ChartModelElement { values: [2.9, 4.9, 2.6] } | |
58 |
ChartModel |
|
58 | ChartModelElement { values: [3.4, 3.0, 2.3] } | |
59 |
ChartModel |
|
59 | ChartModelElement { values: [4.1, 3.3, 3.1] } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | } |
|
62 | } |
@@ -1,78 +1,78 | |||||
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 | upperModel: chartModel | |
37 | upperModelMapper.mapX: 0 |
|
37 | upperModelMapper.mapX: 0 | |
38 | upperModelMapper.mapY: 2 |
|
38 | upperModelMapper.mapY: 2 | |
39 | lowerModel: chartModel |
|
39 | lowerModel: chartModel | |
40 | lowerModelMapper.mapX: 0 |
|
40 | lowerModelMapper.mapX: 0 | |
41 | lowerModelMapper.mapY: 1 |
|
41 | lowerModelMapper.mapY: 1 | |
42 | } |
|
42 | } | |
43 | AreaSeries { |
|
43 | AreaSeries { | |
44 | name: "Swedish" |
|
44 | name: "Swedish" | |
45 | upperModel: chartModel |
|
45 | upperModel: chartModel | |
46 | upperModelMapper.mapX: 0 |
|
46 | upperModelMapper.mapX: 0 | |
47 | upperModelMapper.mapY: 3 |
|
47 | upperModelMapper.mapY: 3 | |
48 | lowerModel: chartModel |
|
48 | lowerModel: chartModel | |
49 | lowerModelMapper.mapX: 0 |
|
49 | lowerModelMapper.mapX: 0 | |
50 | lowerModelMapper.mapY: 1 |
|
50 | lowerModelMapper.mapY: 1 | |
51 | } |
|
51 | } | |
52 | AreaSeries { |
|
52 | AreaSeries { | |
53 | name: "Finnish" |
|
53 | name: "Finnish" | |
54 | upperModel: chartModel |
|
54 | upperModel: chartModel | |
55 | upperModelMapper.mapX: 0 |
|
55 | upperModelMapper.mapX: 0 | |
56 | upperModelMapper.mapY: 4 |
|
56 | upperModelMapper.mapY: 4 | |
57 | lowerModel: chartModel |
|
57 | lowerModel: chartModel | |
58 | lowerModelMapper.mapX: 0 |
|
58 | lowerModelMapper.mapX: 0 | |
59 | lowerModelMapper.mapY: 1 |
|
59 | lowerModelMapper.mapY: 1 | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | ChartModel { |
|
63 | ChartModel { | |
64 | id: chartModel |
|
64 | id: chartModel | |
65 |
ChartModel |
|
65 | ChartModelElement { values: [0, 0, 1, 1, 0] } | |
66 |
ChartModel |
|
66 | ChartModelElement { values: [1, 0, 1, 1, 0] } | |
67 |
ChartModel |
|
67 | ChartModelElement { values: [2, 0, 1, 3, 0] } | |
68 |
ChartModel |
|
68 | ChartModelElement { values: [3, 0, 1, 3, 0] } | |
69 |
ChartModel |
|
69 | ChartModelElement { values: [4, 0, 1, 2, 0] } | |
70 |
ChartModel |
|
70 | ChartModelElement { values: [5, 0, 0, 0, 0] } | |
71 |
ChartModel |
|
71 | ChartModelElement { values: [6, 0, 1, 2, 1] } | |
72 |
ChartModel |
|
72 | ChartModelElement { values: [7, 0, 1, 1, 0] } | |
73 |
ChartModel |
|
73 | ChartModelElement { values: [8, 0, 4, 2, 0] } | |
74 |
ChartModel |
|
74 | ChartModelElement { values: [9, 0, 3, 1, 0] } | |
75 |
ChartModel |
|
75 | ChartModelElement { values: [10, 0, 2, 3, 0] } | |
76 |
ChartModel |
|
76 | ChartModelElement { values: [11, 0, 1, 3, 1] } | |
77 | } |
|
77 | } | |
78 | } |
|
78 | } |
@@ -1,78 +1,77 | |||||
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 | // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
32 | // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |
33 | axisX.max: 10 |
|
33 | axisX.max: 10 | |
34 |
|
34 | |||
35 | BarSeries { |
|
35 | BarSeries { | |
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
37 | model: barModel |
|
37 | model: barModel | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 |
|
||||
41 | // // TODO: optional syntax with ChartModel base model API |
|
40 | // // TODO: optional syntax with ChartModel base model API | |
42 | // BarSeries { |
|
41 | // BarSeries { | |
43 | // model: chartModel |
|
42 | // model: chartModel | |
44 | // modelMapping: BarSeriesMapping { |
|
43 | // modelMapping: BarSeriesMapping { | |
45 | // // Giving "undefined" x mapping value means that the indexes are used as x-values |
|
44 | // // Giving "undefined" x mapping value means that the indexes are used as x-values | |
46 | // setIndexes: [BarSeriesMapping.Undefined, 0, |
|
45 | // setIndexes: [BarSeriesMapping.Undefined, 0, | |
47 | // BarSeriesMapping.Undefined, 1, |
|
46 | // BarSeriesMapping.Undefined, 1, | |
48 | // BarSeriesMapping.Undefined, 2] // defaults to [] |
|
47 | // BarSeriesMapping.Undefined, 2] // defaults to [] | |
49 | //// setValues: [ |
|
48 | //// setValues: [ | |
50 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 0}, |
|
49 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 0}, | |
51 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 1}, |
|
50 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 1}, | |
52 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 2} |
|
51 | //// BarSetMapping {x: BarSetMapping.Undefined; y: 2} | |
53 | //// ] |
|
52 | //// ] | |
54 | // orientation: BarSeriesMapping.Vertical // defaults to Vertical |
|
53 | // orientation: BarSeriesMapping.Vertical // defaults to Vertical | |
55 | // startIndex: 0 // defaults to 0 |
|
54 | // startIndex: 0 // defaults to 0 | |
56 | // count: BarSeriesMapping.Undefined // defaults to "Undefined" |
|
55 | // count: BarSeriesMapping.Undefined // defaults to "Undefined" | |
57 | // } |
|
56 | // } | |
58 | // } |
|
57 | // } | |
59 | } |
|
58 | } | |
60 |
|
59 | |||
61 | // ChartModel { |
|
60 | // ChartModel { | |
62 | // id: chartModel |
|
61 | // id: chartModel | |
63 | // } |
|
62 | // } | |
64 |
|
63 | |||
65 | BarModel { |
|
64 | BarModel { | |
66 | id: barModel |
|
65 | id: barModel | |
67 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
66 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
68 |
BarSet { name: " |
|
67 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
69 |
BarSet { name: " |
|
68 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
70 | } |
|
69 | } | |
71 |
|
70 | |||
72 | // TODO |
|
71 | // TODO | |
73 | // Component.onCompleted: { |
|
72 | // Component.onCompleted: { | |
74 | // bobBars.append(1.2); |
|
73 | // bobBars.append(1.2); | |
75 | // bobBars.append(1.5); |
|
74 | // bobBars.append(1.5); | |
76 | // bobBars.append([1.5, 1.4, 1.9]); |
|
75 | // bobBars.append([1.5, 1.4, 1.9]); | |
77 | // } |
|
76 | // } | |
78 | } |
|
77 | } |
@@ -1,168 +1,132 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativemodel.h" |
|
21 | #include "declarativemodel.h" | |
22 | #include <qdeclarativelist.h> |
|
22 | #include <qdeclarativelist.h> | |
23 | #include <QDebug> |
|
23 | #include <QDebug> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | ////////////// Table model row /////////////////// |
|
28 | ////////////// Table model row /////////////////// | |
29 |
|
29 | |||
30 |
DeclarativeTableModel |
|
30 | DeclarativeTableModelElement::DeclarativeTableModelElement(QObject *parent) | |
31 | : QObject(parent) |
|
31 | : QObject(parent) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 |
QVariantList DeclarativeTableModel |
|
35 | QVariantList DeclarativeTableModelElement::values() | |
36 | { |
|
36 | { | |
37 | return m_values; |
|
37 | return m_values; | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 |
void DeclarativeTableModel |
|
40 | void DeclarativeTableModelElement::setValues(QVariantList values) | |
41 | { |
|
41 | { | |
42 | m_values = values; |
|
42 | m_values = values; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | ////////////// Table model /////////////////// |
|
45 | ////////////// Table model /////////////////// | |
46 |
|
46 | |||
47 | DeclarativeTableModel::DeclarativeTableModel(QObject *parent) : |
|
47 | DeclarativeTableModel::DeclarativeTableModel(QObject *parent) : | |
48 | ChartTableModel(parent) |
|
48 | ChartTableModel(parent) | |
49 | { |
|
49 | { | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void DeclarativeTableModel::classBegin() |
|
52 | void DeclarativeTableModel::classBegin() | |
53 | { |
|
53 | { | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | void DeclarativeTableModel::componentComplete() |
|
56 | void DeclarativeTableModel::componentComplete() | |
57 | { |
|
57 | { | |
58 | foreach (QObject *child, children()) { |
|
58 | foreach (QObject *child, children()) { | |
59 |
if (qobject_cast<DeclarativeTableModel |
|
59 | if (qobject_cast<DeclarativeTableModelElement *>(child)) { | |
60 |
append(qobject_cast<DeclarativeTableModel |
|
60 | append(qobject_cast<DeclarativeTableModelElement *>(child)->values()); | |
61 | } |
|
61 | } | |
62 | } |
|
62 | } | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | QDeclarativeListProperty<QObject> DeclarativeTableModel::modelChildren() |
|
65 | QDeclarativeListProperty<QObject> DeclarativeTableModel::modelChildren() | |
66 | { |
|
66 | { | |
67 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeTableModel::appendModelChild); |
|
67 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeTableModel::appendModelChild); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> *list, |
|
70 | void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> *list, | |
71 | QObject *child) |
|
71 | QObject *child) | |
72 | { |
|
72 | { | |
73 | // childs are added in componentComplete instead |
|
73 | // childs are added in componentComplete instead | |
74 | Q_UNUSED(list) |
|
74 | Q_UNUSED(list) | |
75 | Q_UNUSED(child) |
|
75 | Q_UNUSED(child) | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | void DeclarativeTableModel::append(QVariantList values) |
|
78 | void DeclarativeTableModel::append(QVariantList values) | |
79 | { |
|
79 | { | |
80 | // qDebug() << "DeclarativeTableModel::append:" << values; |
|
80 | // qDebug() << "DeclarativeTableModel::append:" << values; | |
81 |
|
81 | |||
82 | while (columnCount() < values.count()) |
|
82 | while (columnCount() < values.count()) | |
83 | insertColumn(columnCount()); |
|
83 | insertColumn(columnCount()); | |
84 |
|
84 | |||
85 | insertRow(rowCount()); |
|
85 | insertRow(rowCount()); | |
86 |
|
86 | |||
87 | QModelIndex beginIndex = QModelIndex(); |
|
87 | QModelIndex beginIndex = QModelIndex(); | |
88 | QModelIndex endIndex = QModelIndex(); |
|
88 | QModelIndex endIndex = QModelIndex(); | |
89 | for (int i(0); i < values.count(); i++) { |
|
89 | for (int i(0); i < values.count(); i++) { | |
90 | QModelIndex modelIndex = createIndex(rowCount() - 1, i); |
|
90 | QModelIndex modelIndex = createIndex(rowCount() - 1, i); | |
91 | if (i == 0) |
|
91 | if (i == 0) | |
92 | beginIndex = modelIndex; |
|
92 | beginIndex = modelIndex; | |
93 | if (i == (values.count() - 1)) |
|
93 | if (i == (values.count() - 1)) | |
94 | endIndex = modelIndex; |
|
94 | endIndex = modelIndex; | |
95 | setData(modelIndex, values.at(i)); |
|
95 | setData(modelIndex, values.at(i)); | |
96 | } |
|
96 | } | |
97 | dataChanged(beginIndex, endIndex); |
|
97 | dataChanged(beginIndex, endIndex); | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point) |
|
100 | void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point) | |
101 | { |
|
101 | { | |
102 | qDebug() << "DeclarativeTableModel::appendPoint:" << point; |
|
102 | // qDebug() << "DeclarativeTableModel::appendPoint:" << point; | |
103 | QVariantList values; |
|
103 | QVariantList values; | |
104 | values.insert(mapper->mapX(), point->x()); |
|
104 | values.insert(mapper->mapX(), point->x()); | |
105 | values.insert(mapper->mapY(), point->y()); |
|
105 | values.insert(mapper->mapY(), point->y()); | |
106 | append(values); |
|
106 | append(values); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | //void DeclarativeTableModel::appendPoints(QVariantList points) |
|
|||
110 | //{ |
|
|||
111 | // qreal x = 0.0; |
|
|||
112 | // for (int i(0); i < points.count(); i++) { |
|
|||
113 | // if (i % 2) { |
|
|||
114 | // bool ok(false); |
|
|||
115 | // qreal y = points.at(i).toReal(&ok); |
|
|||
116 | // if (ok) { |
|
|||
117 | // DeclarativeXyPoint *point= new DeclarativeXyPoint(); |
|
|||
118 | // point->setX(x); |
|
|||
119 | // point->setY(y); |
|
|||
120 | // appendPoint(point); |
|
|||
121 | // } else { |
|
|||
122 | // qWarning() << "Illegal y value"; |
|
|||
123 | // } |
|
|||
124 | // } else { |
|
|||
125 | // bool ok(false); |
|
|||
126 | // x = points.at(i).toReal(&ok); |
|
|||
127 | // if (!ok) { |
|
|||
128 | // qWarning() << "Illegal x value"; |
|
|||
129 | // } |
|
|||
130 | // } |
|
|||
131 | // } |
|
|||
132 | //} |
|
|||
133 |
|
||||
134 | //void DeclarativeTableModel::appendPoint(DeclarativeXyPoint* point) |
|
|||
135 | //{ |
|
|||
136 | //// qDebug() << "DeclarativeTableModel::append:" << point->x() << " " << point->y(); |
|
|||
137 | // insertRow(rowCount()); |
|
|||
138 | // QModelIndex xModelIndex = createIndex(rowCount() - 1, 0); |
|
|||
139 | // QModelIndex yModelIndex = createIndex(rowCount() - 1, 1); |
|
|||
140 | // setData(xModelIndex, point->x()); |
|
|||
141 | // setData(yModelIndex, point->y()); |
|
|||
142 | // dataChanged(xModelIndex, yModelIndex); |
|
|||
143 | //} |
|
|||
144 |
|
||||
145 | ////////////// Bar model /////////////////////// |
|
109 | ////////////// Bar model /////////////////////// | |
146 |
|
110 | |||
147 | DeclarativeBarModel::DeclarativeBarModel(QObject *parent) : |
|
111 | DeclarativeBarModel::DeclarativeBarModel(QObject *parent) : | |
148 | DeclarativeTableModel(parent) |
|
112 | DeclarativeTableModel(parent) | |
149 | { |
|
113 | { | |
150 | } |
|
114 | } | |
151 |
|
115 | |||
152 | void DeclarativeBarModel::append(QBarSet* barSet) |
|
116 | void DeclarativeBarModel::append(QBarSet* barSet) | |
153 | { |
|
117 | { | |
154 | insertColumn(columnCount()); |
|
118 | insertColumn(columnCount()); | |
155 | for (int i(0); i < barSet->count(); i++) { |
|
119 | for (int i(0); i < barSet->count(); i++) { | |
156 | if (rowCount() < (i + 1)) |
|
120 | if (rowCount() < (i + 1)) | |
157 | insertRow(rowCount()); |
|
121 | insertRow(rowCount()); | |
158 | setData(createIndex(i, columnCount() - 1), barSet->at(i)); |
|
122 | setData(createIndex(i, columnCount() - 1), barSet->at(i)); | |
159 | // insertRow(rowCount()); |
|
123 | // insertRow(rowCount()); | |
160 | // setData(createIndex(rowCount() - 1, 0), ); |
|
124 | // setData(createIndex(rowCount() - 1, 0), ); | |
161 | // setData(createIndex(rowCount() - 1, 1), barSet->at(i)); |
|
125 | // setData(createIndex(rowCount() - 1, 1), barSet->at(i)); | |
162 | } |
|
126 | } | |
163 | // TODO: setModelMapping(0, 1, columnCount(), Qt::Vertical); |
|
127 | // TODO: setModelMapping(0, 1, columnCount(), Qt::Vertical); | |
164 | } |
|
128 | } | |
165 |
|
129 | |||
166 | #include "moc_declarativemodel.cpp" |
|
130 | #include "moc_declarativemodel.cpp" | |
167 |
|
131 | |||
168 | QTCOMMERCIALCHART_END_NAMESPACE |
|
132 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,84 +1,84 | |||||
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 DECLARATIVEMODEL_H |
|
21 | #ifndef DECLARATIVEMODEL_H | |
22 | #define DECLARATIVEMODEL_H |
|
22 | #define DECLARATIVEMODEL_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "declarativexypoint.h" |
|
25 | #include "declarativexypoint.h" | |
26 | #include <QPieSlice> |
|
26 | #include <QPieSlice> | |
27 | #include "../src/charttablemodel.h" // TODO |
|
27 | #include "../src/charttablemodel.h" // TODO | |
28 | #include <QBarSet> |
|
28 | #include <QBarSet> | |
29 | #include <QXYModelMapper> |
|
29 | #include <QXYModelMapper> | |
30 | #include <QDeclarativeListProperty> |
|
30 | #include <QDeclarativeListProperty> | |
31 | #include <QVariant> |
|
31 | #include <QVariant> | |
32 | #include <QDeclarativeParserStatus> |
|
32 | #include <QDeclarativeParserStatus> | |
33 |
|
33 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
35 | |||
36 |
class DeclarativeTableModel |
|
36 | class DeclarativeTableModelElement : public QObject | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
39 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
40 |
|
40 | |||
41 | public: |
|
41 | public: | |
42 |
explicit DeclarativeTableModel |
|
42 | explicit DeclarativeTableModelElement(QObject *parent = 0); | |
43 | QVariantList values(); |
|
43 | QVariantList values(); | |
44 | void setValues(QVariantList values); |
|
44 | void setValues(QVariantList values); | |
45 | private: |
|
45 | private: | |
46 | QVariantList m_values; |
|
46 | QVariantList m_values; | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 | class DeclarativeTableModel : public ChartTableModel, public QDeclarativeParserStatus |
|
49 | class DeclarativeTableModel : public ChartTableModel, public QDeclarativeParserStatus | |
50 | { |
|
50 | { | |
51 | Q_OBJECT |
|
51 | Q_OBJECT | |
52 | Q_INTERFACES(QDeclarativeParserStatus) |
|
52 | Q_INTERFACES(QDeclarativeParserStatus) | |
53 | Q_PROPERTY(QDeclarativeListProperty<QObject> modelChildren READ modelChildren) |
|
53 | Q_PROPERTY(QDeclarativeListProperty<QObject> modelChildren READ modelChildren) | |
54 | Q_CLASSINFO("DefaultProperty", "modelChildren") |
|
54 | Q_CLASSINFO("DefaultProperty", "modelChildren") | |
55 |
|
55 | |||
56 | public: |
|
56 | public: | |
57 | explicit DeclarativeTableModel(QObject *parent = 0); |
|
57 | explicit DeclarativeTableModel(QObject *parent = 0); | |
58 | QDeclarativeListProperty<QObject> modelChildren(); |
|
58 | QDeclarativeListProperty<QObject> modelChildren(); | |
59 | void appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point); |
|
59 | void appendPoint(QXYModelMapper *mapper, DeclarativeXyPoint *point); | |
60 |
|
60 | |||
61 | public: // from QDeclarativeParserStatus |
|
61 | public: // from QDeclarativeParserStatus | |
62 | void classBegin(); |
|
62 | void classBegin(); | |
63 | void componentComplete(); |
|
63 | void componentComplete(); | |
64 |
|
64 | |||
65 | public Q_SLOTS: |
|
65 | public Q_SLOTS: | |
66 | void append(QVariantList slices); |
|
66 | void append(QVariantList slices); | |
67 | static void appendModelChild(QDeclarativeListProperty<QObject> *list, |
|
67 | static void appendModelChild(QDeclarativeListProperty<QObject> *list, | |
68 | QObject *element); |
|
68 | QObject *element); | |
69 | }; |
|
69 | }; | |
70 |
|
70 | |||
71 | class DeclarativeBarModel : public DeclarativeTableModel |
|
71 | class DeclarativeBarModel : public DeclarativeTableModel | |
72 | { |
|
72 | { | |
73 | Q_OBJECT |
|
73 | Q_OBJECT | |
74 |
|
74 | |||
75 | public: |
|
75 | public: | |
76 | explicit DeclarativeBarModel(QObject *parent = 0); |
|
76 | explicit DeclarativeBarModel(QObject *parent = 0); | |
77 |
|
77 | |||
78 | public Q_SLOTS: |
|
78 | public Q_SLOTS: | |
79 | void append(QBarSet* barSet); |
|
79 | void append(QBarSet* barSet); | |
80 | }; |
|
80 | }; | |
81 |
|
81 | |||
82 | QTCOMMERCIALCHART_END_NAMESPACE |
|
82 | QTCOMMERCIALCHART_END_NAMESPACE | |
83 |
|
83 | |||
84 | #endif // DECLARATIVEMODEL_H |
|
84 | #endif // DECLARATIVEMODEL_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qaxiscategories.h" |
|
24 | #include "qaxiscategories.h" | |
25 | #include "declarativechart.h" |
|
25 | #include "declarativechart.h" | |
26 | #include "declarativexypoint.h" |
|
26 | #include "declarativexypoint.h" | |
27 | #include "declarativelineseries.h" |
|
27 | #include "declarativelineseries.h" | |
28 | #include "declarativesplineseries.h" |
|
28 | #include "declarativesplineseries.h" | |
29 | #include "declarativeareaseries.h" |
|
29 | #include "declarativeareaseries.h" | |
30 | #include "declarativescatterseries.h" |
|
30 | #include "declarativescatterseries.h" | |
31 | #include "declarativebarseries.h" |
|
31 | #include "declarativebarseries.h" | |
32 | #include "declarativepieseries.h" |
|
32 | #include "declarativepieseries.h" | |
33 | #include "declarativemodel.h" |
|
33 | #include "declarativemodel.h" | |
34 | #include <QPieModelMapper> |
|
34 | #include <QPieModelMapper> | |
35 | #include <QXYModelMapper> |
|
35 | #include <QXYModelMapper> | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
39 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | virtual void registerTypes(const char *uri) |
|
43 | virtual void registerTypes(const char *uri) | |
44 | { |
|
44 | { | |
45 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
45 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
46 |
|
46 | |||
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", | |
49 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
49 | QLatin1String("Trying to create uncreatable: Axis.")); | |
50 | //qmlRegisterType<DeclarativeAxisCategory>(uri, 1, 0, "AxisCategory"); |
|
50 | //qmlRegisterType<DeclarativeAxisCategory>(uri, 1, 0, "AxisCategory"); | |
51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); |
|
59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); | |
60 |
qmlRegisterType<DeclarativeTableModel |
|
60 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); | |
61 | //qmlRegisterType<DeclarativePieMapping>(uri, 1, 0, "PieMapping"); |
|
61 | //qmlRegisterType<DeclarativePieMapping>(uri, 1, 0, "PieMapping"); | |
62 | //qmlRegisterType<QPieModelMapper>(uri, 1, 0, "PieModelMapper"); |
|
62 | //qmlRegisterType<QPieModelMapper>(uri, 1, 0, "PieModelMapper"); | |
63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
65 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
65 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
66 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
66 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
67 |
|
67 | |||
68 | qmlRegisterType<DeclarativeBarModel>(uri, 1, 0, "BarModel"); |
|
68 | qmlRegisterType<DeclarativeBarModel>(uri, 1, 0, "BarModel"); | |
69 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
69 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
70 | } |
|
70 | } | |
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 | #include "plugin.moc" |
|
73 | #include "plugin.moc" | |
74 |
|
74 | |||
75 | QTCOMMERCIALCHART_END_NAMESPACE |
|
75 | QTCOMMERCIALCHART_END_NAMESPACE | |
76 |
|
76 | |||
77 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
77 | QTCOMMERCIALCHART_USE_NAMESPACE | |
78 |
|
78 | |||
79 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
79 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
General Comments 0
You need to be logged in to leave comments.
Login now