@@ -1,42 +1,40 | |||||
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", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
33 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
|||
34 |
|
33 | |||
35 | GroupedBarSeries { |
|
34 | GroupedBarSeries { | |
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
|||
37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
38 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
40 | } |
|
38 | } | |
41 | } |
|
39 | } | |
42 | } |
|
40 | } |
@@ -1,128 +1,127 | |||||
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 | import QmlCustomModel 1.0 |
|
23 | import QmlCustomModel 1.0 | |
24 |
|
24 | |||
25 | Rectangle { |
|
25 | Rectangle { | |
26 | width: parent.width |
|
26 | width: parent.width | |
27 | height: parent.height |
|
27 | height: parent.height | |
28 |
|
28 | |||
29 | ChartView { |
|
29 | ChartView { | |
30 | id: chart |
|
30 | id: chart | |
31 | title: "Custom model example" |
|
31 | title: "Custom model example" | |
32 | anchors.fill: parent |
|
32 | anchors.fill: parent | |
33 | theme: ChartView.ChartThemeLight |
|
33 | theme: ChartView.ChartThemeLight | |
34 | axisX.max: 10 |
|
34 | axisX.max: 10 | |
35 | axisX.min: 0 |
|
35 | axisX.min: 0 | |
36 | axisY.max: 20 |
|
36 | axisY.max: 20 | |
37 | axisY.min: 0 |
|
37 | axisY.min: 0 | |
38 |
|
38 | |||
39 | // For dynamic data we use a custom data model derived from QAbstractiItemModel |
|
39 | // For dynamic data we use a custom data model derived from QAbstractiItemModel | |
40 | CustomModel { |
|
40 | CustomModel { | |
41 | id: customModel |
|
41 | id: customModel | |
42 | CustomModelElement { values: [0, "Manufacturer", 1, 2] } |
|
42 | CustomModelElement { values: [0, "Manufacturer", 1, 2] } | |
43 | CustomModelElement { values: [1, "Volkswagen", 13.5, 12.5] } |
|
43 | CustomModelElement { values: [1, "Volkswagen", 13.5, 12.5] } | |
44 | CustomModelElement { values: [2, "Toyota", 10.9, 9.9] } |
|
44 | CustomModelElement { values: [2, "Toyota", 10.9, 9.9] } | |
45 | CustomModelElement { values: [3, "Ford", 8.6, 7.6] } |
|
45 | CustomModelElement { values: [3, "Ford", 8.6, 7.6] } | |
46 | CustomModelElement { values: [4, "Skoda", 8.2, 7.2] } |
|
46 | CustomModelElement { values: [4, "Skoda", 8.2, 7.2] } | |
47 | CustomModelElement { values: [5, "Volvo", 6.8, 5.8] } |
|
47 | CustomModelElement { values: [5, "Volvo", 6.8, 5.8] } | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | LineSeries { |
|
50 | LineSeries { | |
51 | name: "Volkswagen" |
|
51 | name: "Volkswagen" | |
52 | HXYModelMapper { |
|
52 | HXYModelMapper { | |
53 | model: customModel |
|
53 | model: customModel | |
54 | xRow: 0 |
|
54 | xRow: 0 | |
55 | yRow: 1 |
|
55 | yRow: 1 | |
56 | first: 2 |
|
56 | first: 2 | |
57 | } |
|
57 | } | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | LineSeries { |
|
60 | LineSeries { | |
61 | name: "Toyota" |
|
61 | name: "Toyota" | |
62 | HXYModelMapper { |
|
62 | HXYModelMapper { | |
63 | model: customModel |
|
63 | model: customModel | |
64 | xRow: 0 |
|
64 | xRow: 0 | |
65 | yRow: 2 |
|
65 | yRow: 2 | |
66 | first: 2 |
|
66 | first: 2 | |
67 | } |
|
67 | } | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | PieSeries { |
|
70 | PieSeries { | |
71 | id: pieSeries |
|
71 | id: pieSeries | |
72 | size: 0.4 |
|
72 | size: 0.4 | |
73 | horizontalPosition: 0.7 |
|
73 | horizontalPosition: 0.7 | |
74 | verticalPosition: 0.3 |
|
74 | verticalPosition: 0.3 | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | VPieModelMapper { |
|
77 | VPieModelMapper { | |
78 | series: pieSeries |
|
78 | series: pieSeries | |
79 | model: customModel |
|
79 | model: customModel | |
80 | labelsColumn: 1 |
|
80 | labelsColumn: 1 | |
81 | valuesColumn: 2 |
|
81 | valuesColumn: 2 | |
82 | first: 1 |
|
82 | first: 1 | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | AreaSeries { |
|
85 | AreaSeries { | |
86 | name: "Ford" |
|
86 | name: "Ford" | |
87 | upperSeries: LineSeries { |
|
87 | upperSeries: LineSeries { | |
88 | HXYModelMapper { |
|
88 | HXYModelMapper { | |
89 | model: customModel |
|
89 | model: customModel | |
90 | xRow: 0 |
|
90 | xRow: 0 | |
91 | yRow: 3 |
|
91 | yRow: 3 | |
92 | first: 2 |
|
92 | first: 2 | |
93 | } |
|
93 | } | |
94 | } |
|
94 | } | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | GroupedBarSeries { |
|
97 | GroupedBarSeries { | |
98 | name: "Skoda and Volvo" |
|
98 | name: "Skoda and Volvo" | |
99 | barCategories: [ "1", "2", "3", "4", "5", "6" ] |
|
|||
100 | HBarModelMapper { |
|
99 | HBarModelMapper { | |
101 | model: customModel |
|
100 | model: customModel | |
102 | firstBarSetRow: 4 |
|
101 | firstBarSetRow: 4 | |
103 | lastBarSetRow: 5 |
|
102 | lastBarSetRow: 5 | |
104 | first: 2 |
|
103 | first: 2 | |
105 | } |
|
104 | } | |
106 | } |
|
105 | } | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 |
|
108 | |||
110 | // TODO: you could also implement appending to your model, for example: |
|
109 | // TODO: you could also implement appending to your model, for example: | |
111 | // pieSeries.model.append(["Others", 52.0]); |
|
110 | // pieSeries.model.append(["Others", 52.0]); | |
112 |
|
111 | |||
113 | // TODO: show how to use data from a list model in a chart view |
|
112 | // TODO: show how to use data from a list model in a chart view | |
114 | // i.e. copy the data into a custom model |
|
113 | // i.e. copy the data into a custom model | |
115 | // ListModel { |
|
114 | // ListModel { | |
116 | // id: listModel |
|
115 | // id: listModel | |
117 | // ListElement { |
|
116 | // ListElement { | |
118 | // label: "Volkswagen" |
|
117 | // label: "Volkswagen" | |
119 | // value: 13.5 |
|
118 | // value: 13.5 | |
120 | // } |
|
119 | // } | |
121 | // ListElement { |
|
120 | // ListElement { | |
122 | // label: "Toyota" |
|
121 | // label: "Toyota" | |
123 | // value: 10.9 |
|
122 | // value: 10.9 | |
124 | // } |
|
123 | // } | |
125 | // // and so on... |
|
124 | // // and so on... | |
126 | // } |
|
125 | // } | |
127 |
|
126 | |||
128 | } |
|
127 | } |
@@ -1,159 +1,158 | |||||
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.1 |
|
21 | import QtQuick 1.1 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Rectangle { |
|
24 | Rectangle { | |
25 | width: 360 |
|
25 | width: 360 | |
26 | height: 360 |
|
26 | height: 360 | |
27 |
|
27 | |||
28 | //![1] |
|
28 | //![1] | |
29 | ChartView { |
|
29 | ChartView { | |
30 | id: chartView |
|
30 | id: chartView | |
31 | title: "Weather forecast" |
|
31 | title: "Weather forecast" | |
32 | //![1] |
|
32 | //![1] | |
33 | anchors.top: parent.top |
|
33 | anchors.top: parent.top | |
34 | anchors.bottom: weatherImageRow.top |
|
34 | anchors.bottom: weatherImageRow.top | |
35 | anchors.left: parent.left |
|
35 | anchors.left: parent.left | |
36 | anchors.right: parent.right |
|
36 | anchors.right: parent.right | |
37 | legend: ChartView.LegendTop |
|
37 | legend: ChartView.LegendTop | |
|
38 | axisXLabels: ["0", "Mo", "1", "Tu", "2", "We", "3", "Th", "4", "Fr", "5", "Sa"] | |||
38 |
|
39 | |||
39 | //![2] |
|
40 | //![2] | |
40 |
|
|
41 | BarSeries { | |
41 | GroupedBarSeries { |
|
|||
42 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
|||
43 | BarSet { |
|
42 | BarSet { | |
44 | id: rainfallSet |
|
43 | id: rainfallSet | |
45 | name: "Rainfall" |
|
44 | name: "Rainfall" | |
46 | } |
|
45 | } | |
47 | } |
|
46 | } | |
48 |
|
47 | |||
49 | ScatterSeries { |
|
48 | ScatterSeries { | |
50 | id: maxTempSeries |
|
49 | id: maxTempSeries | |
51 | name: "Max. temperature" |
|
50 | name: "Max. temperature" | |
52 | } |
|
51 | } | |
53 |
|
52 | |||
54 | ScatterSeries { |
|
53 | ScatterSeries { | |
55 | id: minTempSeries |
|
54 | id: minTempSeries | |
56 | name: "Min. temperature" |
|
55 | name: "Min. temperature" | |
57 | } |
|
56 | } | |
58 | //![2] |
|
57 | //![2] | |
59 | } |
|
58 | } | |
60 |
|
59 | |||
61 | // A timer to refresh the forecast every 5 minutes |
|
60 | // A timer to refresh the forecast every 5 minutes | |
62 | Timer { |
|
61 | Timer { | |
63 | interval: 300000 |
|
62 | interval: 300000 | |
64 | repeat: true |
|
63 | repeat: true | |
65 | triggeredOnStart: true |
|
64 | triggeredOnStart: true | |
66 | running: true |
|
65 | running: true | |
67 | onTriggered: { |
|
66 | onTriggered: { | |
68 | if (weatherAppKey != "") { |
|
67 | if (weatherAppKey != "") { | |
69 | //![3] |
|
68 | //![3] | |
70 | // Make HTTP GET request and parse the result |
|
69 | // Make HTTP GET request and parse the result | |
71 | var xhr = new XMLHttpRequest; |
|
70 | var xhr = new XMLHttpRequest; | |
72 | xhr.open("GET", |
|
71 | xhr.open("GET", | |
73 | "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key=" |
|
72 | "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key=" | |
74 | + weatherAppKey); |
|
73 | + weatherAppKey); | |
75 | xhr.onreadystatechange = function() { |
|
74 | xhr.onreadystatechange = function() { | |
76 | if (xhr.readyState == XMLHttpRequest.DONE) { |
|
75 | if (xhr.readyState == XMLHttpRequest.DONE) { | |
77 | var a = JSON.parse(xhr.responseText); |
|
76 | var a = JSON.parse(xhr.responseText); | |
78 | parseWeatherData(a); |
|
77 | parseWeatherData(a); | |
79 | } |
|
78 | } | |
80 | } |
|
79 | } | |
81 | xhr.send(); |
|
80 | xhr.send(); | |
82 | //![3] |
|
81 | //![3] | |
83 | } else { |
|
82 | } else { | |
84 | // No app key for worldweatheronline.com given by the user -> use static data |
|
83 | // No app key for worldweatheronline.com given by the user -> use static data | |
85 | var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}"; |
|
84 | var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}"; | |
86 | var a = JSON.parse(responseText); |
|
85 | var a = JSON.parse(responseText); | |
87 | parseWeatherData(a); |
|
86 | parseWeatherData(a); | |
88 | } |
|
87 | } | |
89 | } |
|
88 | } | |
90 | } |
|
89 | } | |
91 |
|
90 | |||
92 | Row { |
|
91 | Row { | |
93 | id: weatherImageRow |
|
92 | id: weatherImageRow | |
94 | anchors.bottom: parent.bottom |
|
93 | anchors.bottom: parent.bottom | |
95 | anchors.bottomMargin: 10 |
|
94 | anchors.bottomMargin: 10 | |
96 | anchors.left: parent.left |
|
95 | anchors.left: parent.left | |
97 | anchors.leftMargin: 25 |
|
96 | anchors.leftMargin: 25 | |
98 | anchors.right: parent.right |
|
97 | anchors.right: parent.right | |
99 | anchors.rightMargin: 25 |
|
98 | anchors.rightMargin: 25 | |
100 |
|
99 | |||
101 | ListModel { |
|
100 | ListModel { | |
102 | id: weatherImageModel |
|
101 | id: weatherImageModel | |
103 | } |
|
102 | } | |
104 |
|
103 | |||
105 | Repeater { |
|
104 | Repeater { | |
106 | id: repeater |
|
105 | id: repeater | |
107 | model: weatherImageModel |
|
106 | model: weatherImageModel | |
108 | delegate: Image { |
|
107 | delegate: Image { | |
109 | source: imageSource |
|
108 | source: imageSource | |
110 | width: weatherImageRow.width / weatherImageModel.count |
|
109 | width: weatherImageRow.width / weatherImageModel.count | |
111 | height: width |
|
110 | height: width | |
112 | fillMode: Image.PreserveAspectCrop |
|
111 | fillMode: Image.PreserveAspectCrop | |
113 | } |
|
112 | } | |
114 | } |
|
113 | } | |
115 | } |
|
114 | } | |
116 |
|
115 | |||
117 | function parseWeatherData(weatherData) { |
|
116 | function parseWeatherData(weatherData) { | |
118 | // Clear previous values |
|
117 | // Clear previous values | |
119 | chartView.axisX.min = 0; |
|
118 | chartView.axisX.min = 0; | |
120 | chartView.axisX.max = 5; |
|
119 | chartView.axisX.max = 5; | |
121 | chartView.axisY.min = 0; |
|
120 | chartView.axisY.min = 0; | |
122 | chartView.axisY.max = 5; |
|
121 | chartView.axisY.max = 5; | |
123 | maxTempSeries.clear(); |
|
122 | maxTempSeries.clear(); | |
124 | minTempSeries.clear(); |
|
123 | minTempSeries.clear(); | |
125 | weatherImageModel.clear(); |
|
124 | weatherImageModel.clear(); | |
126 |
|
125 | |||
127 | //![4] |
|
126 | //![4] | |
128 | // Loop through the parsed JSON |
|
127 | // Loop through the parsed JSON | |
129 | for (var i in weatherData.data.weather) { |
|
128 | for (var i in weatherData.data.weather) { | |
130 | var weatherObj = weatherData.data.weather[i]; |
|
129 | var weatherObj = weatherData.data.weather[i]; | |
131 | //![4] |
|
130 | //![4] | |
132 |
|
131 | |||
133 | //![5] |
|
132 | //![5] | |
134 | // Store temperature values, rainfall and weather icon |
|
133 | // Store temperature values, rainfall and weather icon | |
135 | maxTempSeries.append(i, weatherObj.tempMaxC); |
|
134 | maxTempSeries.append(i, weatherObj.tempMaxC); | |
136 | minTempSeries.append(i, weatherObj.tempMinC); |
|
135 | minTempSeries.append(i, weatherObj.tempMinC); | |
137 | rainfallSet.append(i, weatherObj.precipMM); |
|
136 | rainfallSet.append(i, weatherObj.precipMM); | |
138 |
|
137 | |||
139 | weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value}); |
|
138 | weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value}); | |
140 | //![5] |
|
139 | //![5] | |
141 |
|
140 | |||
142 | // Update scale of the chart |
|
141 | // Update scale of the chart | |
143 | chartView.axisX.min = 0; |
|
142 | chartView.axisX.min = 0; | |
144 | chartView.axisX.max = i; |
|
143 | chartView.axisX.max = i; | |
145 | while (chartView.axisY.min >= Number(weatherObj.tempMinC)) |
|
144 | while (chartView.axisY.min >= Number(weatherObj.tempMinC)) | |
146 | chartView.axisY.min = chartView.axisY.min - 10; |
|
145 | chartView.axisY.min = chartView.axisY.min - 10; | |
147 | while (chartView.axisY.max <= Number(weatherObj.tempMaxC)) |
|
146 | while (chartView.axisY.max <= Number(weatherObj.tempMaxC)) | |
148 | chartView.axisY.max = chartView.axisY.max + 10; |
|
147 | chartView.axisY.max = chartView.axisY.max + 10; | |
149 |
|
148 | |||
150 | // Set the x-axis labels to the dates of the forecast |
|
149 | // Set the x-axis labels to the dates of the forecast | |
151 | // TODO: the API could probably be more intuitive.. |
|
150 | // TODO: the API could probably be more intuitive.. | |
152 | // Now it takes an array of strings: chartView.axisXLabels = ["value1", "label1", "value2", "label2", ...] |
|
151 | // Now it takes an array of strings: chartView.axisXLabels = ["value1", "label1", "value2", "label2", ...] | |
153 | var xLabels = chartView.axisXLabels; |
|
152 | var xLabels = chartView.axisXLabels; | |
154 | xLabels[Number(i) * 2] = i; |
|
153 | xLabels[Number(i) * 2] = i; | |
155 | xLabels[(Number(i) * 2) + 1] = weatherObj.date.substring(5, 10); |
|
154 | xLabels[(Number(i) * 2) + 1] = weatherObj.date.substring(5, 10); | |
156 | chartView.axisXLabels = xLabels; |
|
155 | chartView.axisXLabels = xLabels; | |
157 | } |
|
156 | } | |
158 | } |
|
157 | } | |
159 | } |
|
158 | } |
@@ -1,291 +1,271 | |||||
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 | #include <QVBarModelMapper> |
|
24 | #include <QVBarModelMapper> | |
25 | #include <QHBarModelMapper> |
|
25 | #include <QHBarModelMapper> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : |
|
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : | |
30 | QBarSet("", parent) |
|
30 | QBarSet("", parent) | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | QVariantList DeclarativeBarSet::values() |
|
34 | QVariantList DeclarativeBarSet::values() | |
35 | { |
|
35 | { | |
36 | QVariantList values; |
|
36 | QVariantList values; | |
37 | for (int i(0); i < count(); i++) |
|
37 | for (int i(0); i < count(); i++) | |
38 | values.append(QVariant(at(i))); |
|
38 | values.append(QVariant(at(i))); | |
39 | return values; |
|
39 | return values; | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void DeclarativeBarSet::setValues(QVariantList values) |
|
42 | void DeclarativeBarSet::setValues(QVariantList values) | |
43 | { |
|
43 | { | |
44 | while (count()) |
|
44 | while (count()) | |
45 | remove(count() - 1); |
|
45 | remove(count() - 1); | |
46 |
|
46 | |||
47 | for (int i(0); i < values.count(); i++) { |
|
47 | for (int i(0); i < values.count(); i++) { | |
48 | if (values.at(i).canConvert(QVariant::Double)) |
|
48 | if (values.at(i).canConvert(QVariant::Double)) | |
49 | append(values[i].toDouble()); |
|
49 | append(values[i].toDouble()); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | QColor DeclarativeBarSet::color() |
|
53 | QColor DeclarativeBarSet::color() | |
54 | { |
|
54 | { | |
55 | return brush().color(); |
|
55 | return brush().color(); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void DeclarativeBarSet::setColor(QColor color) |
|
58 | void DeclarativeBarSet::setColor(QColor color) | |
59 | { |
|
59 | { | |
60 | QBrush b = brush(); |
|
60 | QBrush b = brush(); | |
61 | b.setColor(color); |
|
61 | b.setColor(color); | |
62 | setBrush(b); |
|
62 | setBrush(b); | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | QColor DeclarativeBarSet::borderColor() |
|
65 | QColor DeclarativeBarSet::borderColor() | |
66 | { |
|
66 | { | |
67 | return pen().color(); |
|
67 | return pen().color(); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void DeclarativeBarSet::setBorderColor(QColor color) |
|
70 | void DeclarativeBarSet::setBorderColor(QColor color) | |
71 | { |
|
71 | { | |
72 | QPen p = pen(); |
|
72 | QPen p = pen(); | |
73 | p.setColor(color); |
|
73 | p.setColor(color); | |
74 | setPen(p); |
|
74 | setPen(p); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | QColor DeclarativeBarSet::labelColor() |
|
77 | QColor DeclarativeBarSet::labelColor() | |
78 | { |
|
78 | { | |
79 | return labelBrush().color(); |
|
79 | return labelBrush().color(); | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | void DeclarativeBarSet::setLabelColor(QColor color) |
|
82 | void DeclarativeBarSet::setLabelColor(QColor color) | |
83 | { |
|
83 | { | |
84 | QBrush b = labelBrush(); |
|
84 | QBrush b = labelBrush(); | |
85 | b.setColor(color); |
|
85 | b.setColor(color); | |
86 | setLabelBrush(b); |
|
86 | setLabelBrush(b); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
89 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
90 | QBarSeries(parent) |
|
90 | QBarSeries(parent) | |
91 | { |
|
91 | { | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | void DeclarativeBarSeries::classBegin() |
|
94 | void DeclarativeBarSeries::classBegin() | |
95 | { |
|
95 | { | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | void DeclarativeBarSeries::componentComplete() |
|
98 | void DeclarativeBarSeries::componentComplete() | |
99 | { |
|
99 | { | |
100 | foreach(QObject *child, children()) { |
|
100 | foreach(QObject *child, children()) { | |
101 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
101 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
102 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
102 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
103 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
103 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
104 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
104 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
105 | mapper->setSeries(this); |
|
105 | mapper->setSeries(this); | |
106 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
106 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
107 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
107 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
108 | mapper->setSeries(this); |
|
108 | mapper->setSeries(this); | |
109 | } |
|
109 | } | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
113 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
114 | { |
|
114 | { | |
115 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
115 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
118 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
119 | { |
|
119 | { | |
120 | // Empty implementation; the children are parsed in componentComplete instead |
|
120 | // Empty implementation; the children are parsed in componentComplete instead | |
121 | Q_UNUSED(list); |
|
121 | Q_UNUSED(list); | |
122 | Q_UNUSED(element); |
|
122 | Q_UNUSED(element); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | void DeclarativeBarSeries::setBarCategories(QStringList categories) |
|
|||
126 | { |
|
|||
127 | setCategories(categories); |
|
|||
128 | } |
|
|||
129 |
|
||||
130 | QStringList DeclarativeBarSeries::barCategories() |
|
|||
131 | { |
|
|||
132 | return categories(); |
|
|||
133 | } |
|
|||
134 |
|
||||
135 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
125 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
136 | { |
|
126 | { | |
137 | QList<QBarSet*> setList = barSets(); |
|
127 | QList<QBarSet*> setList = barSets(); | |
138 | if (index < setList.count()) |
|
128 | if (index < setList.count()) | |
139 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
129 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
140 |
|
130 | |||
141 | return 0; |
|
131 | return 0; | |
142 | } |
|
132 | } | |
143 |
|
133 | |||
144 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : |
|
134 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : | |
145 | QGroupedBarSeries(parent) |
|
135 | QGroupedBarSeries(parent) | |
146 | { |
|
136 | { | |
147 | } |
|
137 | } | |
148 |
|
138 | |||
149 | void DeclarativeGroupedBarSeries::classBegin() |
|
139 | void DeclarativeGroupedBarSeries::classBegin() | |
150 | { |
|
140 | { | |
151 | } |
|
141 | } | |
152 |
|
142 | |||
153 | void DeclarativeGroupedBarSeries::componentComplete() |
|
143 | void DeclarativeGroupedBarSeries::componentComplete() | |
154 | { |
|
144 | { | |
155 | foreach(QObject *child, children()) { |
|
145 | foreach(QObject *child, children()) { | |
156 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
146 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
157 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
147 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
158 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
148 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
159 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
149 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
160 | mapper->setSeries(this); |
|
150 | mapper->setSeries(this); | |
161 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
151 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
162 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
152 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
163 | mapper->setSeries(this); |
|
153 | mapper->setSeries(this); | |
164 | } |
|
154 | } | |
165 | } |
|
155 | } | |
166 | } |
|
156 | } | |
167 |
|
157 | |||
168 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() |
|
158 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() | |
169 | { |
|
159 | { | |
170 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
160 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
171 | } |
|
161 | } | |
172 |
|
162 | |||
173 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
163 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
174 | { |
|
164 | { | |
175 | // Empty implementation; the children are parsed in componentComplete instead |
|
165 | // Empty implementation; the children are parsed in componentComplete instead | |
176 | Q_UNUSED(list); |
|
166 | Q_UNUSED(list); | |
177 | Q_UNUSED(element); |
|
167 | Q_UNUSED(element); | |
178 | } |
|
168 | } | |
179 |
|
169 | |||
180 | void DeclarativeGroupedBarSeries::setBarCategories(QStringList categories) |
|
|||
181 | { |
|
|||
182 | setCategories(categories); |
|
|||
183 | } |
|
|||
184 |
|
||||
185 | QStringList DeclarativeGroupedBarSeries::barCategories() |
|
|||
186 | { |
|
|||
187 | return categories(); |
|
|||
188 | } |
|
|||
189 |
|
||||
190 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) |
|
170 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) | |
191 | { |
|
171 | { | |
192 | QList<QBarSet*> setList = barSets(); |
|
172 | QList<QBarSet*> setList = barSets(); | |
193 | if (index < setList.count()) |
|
173 | if (index < setList.count()) | |
194 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
174 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
195 |
|
175 | |||
196 | return 0; |
|
176 | return 0; | |
197 | } |
|
177 | } | |
198 |
|
178 | |||
199 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
179 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
200 | QStackedBarSeries(parent) |
|
180 | QStackedBarSeries(parent) | |
201 | { |
|
181 | { | |
202 | } |
|
182 | } | |
203 |
|
183 | |||
204 | void DeclarativeStackedBarSeries::classBegin() |
|
184 | void DeclarativeStackedBarSeries::classBegin() | |
205 | { |
|
185 | { | |
206 | } |
|
186 | } | |
207 |
|
187 | |||
208 | void DeclarativeStackedBarSeries::componentComplete() |
|
188 | void DeclarativeStackedBarSeries::componentComplete() | |
209 | { |
|
189 | { | |
210 | foreach(QObject *child, children()) { |
|
190 | foreach(QObject *child, children()) { | |
211 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
191 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
212 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
192 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
213 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
193 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
214 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
194 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
215 | mapper->setSeries(this); |
|
195 | mapper->setSeries(this); | |
216 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
196 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
217 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
197 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
218 | mapper->setSeries(this); |
|
198 | mapper->setSeries(this); | |
219 | } |
|
199 | } | |
220 | } |
|
200 | } | |
221 | } |
|
201 | } | |
222 |
|
202 | |||
223 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
203 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
224 | { |
|
204 | { | |
225 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
205 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
226 | } |
|
206 | } | |
227 |
|
207 | |||
228 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
208 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
229 | { |
|
209 | { | |
230 | // Empty implementation; the children are parsed in componentComplete instead |
|
210 | // Empty implementation; the children are parsed in componentComplete instead | |
231 | Q_UNUSED(list); |
|
211 | Q_UNUSED(list); | |
232 | Q_UNUSED(element); |
|
212 | Q_UNUSED(element); | |
233 | } |
|
213 | } | |
234 |
|
214 | |||
235 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
215 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
236 | { |
|
216 | { | |
237 | QList<QBarSet*> setList = barSets(); |
|
217 | QList<QBarSet*> setList = barSets(); | |
238 | if (index < setList.count()) |
|
218 | if (index < setList.count()) | |
239 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
219 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
240 |
|
220 | |||
241 | return 0; |
|
221 | return 0; | |
242 | } |
|
222 | } | |
243 |
|
223 | |||
244 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
224 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
245 | QPercentBarSeries(parent) |
|
225 | QPercentBarSeries(parent) | |
246 | { |
|
226 | { | |
247 | } |
|
227 | } | |
248 |
|
228 | |||
249 | void DeclarativePercentBarSeries::classBegin() |
|
229 | void DeclarativePercentBarSeries::classBegin() | |
250 | { |
|
230 | { | |
251 | } |
|
231 | } | |
252 |
|
232 | |||
253 | void DeclarativePercentBarSeries::componentComplete() |
|
233 | void DeclarativePercentBarSeries::componentComplete() | |
254 | { |
|
234 | { | |
255 | foreach(QObject *child, children()) { |
|
235 | foreach(QObject *child, children()) { | |
256 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
236 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
257 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
237 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
258 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
238 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
259 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
239 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
260 | mapper->setSeries(this); |
|
240 | mapper->setSeries(this); | |
261 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
241 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
262 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
242 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
263 | mapper->setSeries(this); |
|
243 | mapper->setSeries(this); | |
264 | } |
|
244 | } | |
265 | } |
|
245 | } | |
266 | } |
|
246 | } | |
267 |
|
247 | |||
268 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
248 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
269 | { |
|
249 | { | |
270 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
250 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
271 | } |
|
251 | } | |
272 |
|
252 | |||
273 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
253 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
274 | { |
|
254 | { | |
275 | // Empty implementation; the children are parsed in componentComplete instead |
|
255 | // Empty implementation; the children are parsed in componentComplete instead | |
276 | Q_UNUSED(list); |
|
256 | Q_UNUSED(list); | |
277 | Q_UNUSED(element); |
|
257 | Q_UNUSED(element); | |
278 | } |
|
258 | } | |
279 |
|
259 | |||
280 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
260 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
281 | { |
|
261 | { | |
282 | QList<QBarSet*> setList = barSets(); |
|
262 | QList<QBarSet*> setList = barSets(); | |
283 | if (index < setList.count()) |
|
263 | if (index < setList.count()) | |
284 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
264 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
285 |
|
265 | |||
286 | return 0; |
|
266 | return 0; | |
287 | } |
|
267 | } | |
288 |
|
268 | |||
289 | #include "moc_declarativebarseries.cpp" |
|
269 | #include "moc_declarativebarseries.cpp" | |
290 |
|
270 | |||
291 | QTCOMMERCIALCHART_END_NAMESPACE |
|
271 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,152 +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 | #ifndef DECLARATIVEBARSERIES_H |
|
21 | #ifndef DECLARATIVEBARSERIES_H | |
22 | #define DECLARATIVEBARSERIES_H |
|
22 | #define DECLARATIVEBARSERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QGroupedBarSeries> |
|
25 | #include <QGroupedBarSeries> | |
26 | #include <QStackedBarSeries> |
|
26 | #include <QStackedBarSeries> | |
27 | #include <QPercentBarSeries> |
|
27 | #include <QPercentBarSeries> | |
28 | #include <QBarSet> |
|
28 | #include <QBarSet> | |
29 | #include <QDeclarativeItem> |
|
29 | #include <QDeclarativeItem> | |
30 | #include <QDeclarativeParserStatus> |
|
30 | #include <QDeclarativeParserStatus> | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | class QChart; |
|
34 | class QChart; | |
35 |
|
35 | |||
36 | class DeclarativeBarSet : public QBarSet |
|
36 | class DeclarativeBarSet : public QBarSet | |
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 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) |
|
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) | |
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) |
|
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
45 | explicit DeclarativeBarSet(QObject *parent = 0); | |
46 | QVariantList values(); |
|
46 | QVariantList values(); | |
47 | void setValues(QVariantList values); |
|
47 | void setValues(QVariantList values); | |
48 | QColor color(); |
|
48 | QColor color(); | |
49 | void setColor(QColor color); |
|
49 | void setColor(QColor color); | |
50 | QColor borderColor(); |
|
50 | QColor borderColor(); | |
51 | void setBorderColor(QColor color); |
|
51 | void setBorderColor(QColor color); | |
52 | QColor labelColor(); |
|
52 | QColor labelColor(); | |
53 | void setLabelColor(QColor color); |
|
53 | void setLabelColor(QColor color); | |
54 |
|
54 | |||
55 | public: // From QBarSet |
|
55 | public: // From QBarSet | |
56 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
56 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
57 | Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } |
|
57 | Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
60 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
61 | { |
|
61 | { | |
62 | Q_OBJECT |
|
62 | Q_OBJECT | |
63 | Q_INTERFACES(QDeclarativeParserStatus) |
|
63 | Q_INTERFACES(QDeclarativeParserStatus) | |
64 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
|||
65 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
64 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
66 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
65 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
67 |
|
66 | |||
68 | public: |
|
67 | public: | |
69 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
68 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
70 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
69 | QDeclarativeListProperty<QObject> seriesChildren(); | |
71 |
|
||||
72 | void setBarCategories(QStringList categories); |
|
|||
73 | QStringList barCategories(); |
|
|||
74 |
|
||||
75 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
70 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
76 |
|
71 | |||
77 | public: // from QDeclarativeParserStatus |
|
72 | public: // from QDeclarativeParserStatus | |
78 | void classBegin(); |
|
73 | void classBegin(); | |
79 | void componentComplete(); |
|
74 | void componentComplete(); | |
80 |
|
75 | |||
81 | public Q_SLOTS: |
|
76 | public Q_SLOTS: | |
82 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
77 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
83 | }; |
|
78 | }; | |
84 |
|
79 | |||
85 | class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus |
|
80 | class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus | |
86 | { |
|
81 | { | |
87 | Q_OBJECT |
|
82 | Q_OBJECT | |
88 | Q_INTERFACES(QDeclarativeParserStatus) |
|
83 | Q_INTERFACES(QDeclarativeParserStatus) | |
89 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
|||
90 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
84 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
91 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
85 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
92 |
|
86 | |||
93 | public: |
|
87 | public: | |
94 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); |
|
88 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); | |
95 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
89 | QDeclarativeListProperty<QObject> seriesChildren(); | |
96 |
|
||||
97 | void setBarCategories(QStringList categories); |
|
|||
98 | QStringList barCategories(); |
|
|||
99 |
|
||||
100 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
90 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
101 |
|
91 | |||
102 | public: // from QDeclarativeParserStatus |
|
92 | public: // from QDeclarativeParserStatus | |
103 | void classBegin(); |
|
93 | void classBegin(); | |
104 | void componentComplete(); |
|
94 | void componentComplete(); | |
105 |
|
95 | |||
106 | public Q_SLOTS: |
|
96 | public Q_SLOTS: | |
107 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
97 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
108 | }; |
|
98 | }; | |
109 |
|
99 | |||
110 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
100 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
111 | { |
|
101 | { | |
112 | Q_OBJECT |
|
102 | Q_OBJECT | |
113 | Q_INTERFACES(QDeclarativeParserStatus) |
|
103 | Q_INTERFACES(QDeclarativeParserStatus) | |
114 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
104 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
115 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
105 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
116 |
|
106 | |||
117 | public: |
|
107 | public: | |
118 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
108 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
119 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
109 | QDeclarativeListProperty<QObject> seriesChildren(); | |
120 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
110 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
121 |
|
111 | |||
122 | public: // from QDeclarativeParserStatus |
|
112 | public: // from QDeclarativeParserStatus | |
123 | void classBegin(); |
|
113 | void classBegin(); | |
124 | void componentComplete(); |
|
114 | void componentComplete(); | |
125 |
|
115 | |||
126 | public Q_SLOTS: |
|
116 | public Q_SLOTS: | |
127 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
117 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
128 | }; |
|
118 | }; | |
129 |
|
119 | |||
130 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
120 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
131 | { |
|
121 | { | |
132 | Q_OBJECT |
|
122 | Q_OBJECT | |
133 | Q_INTERFACES(QDeclarativeParserStatus) |
|
123 | Q_INTERFACES(QDeclarativeParserStatus) | |
134 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
124 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
135 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
125 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
136 |
|
126 | |||
137 | public: |
|
127 | public: | |
138 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
128 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
139 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
129 | QDeclarativeListProperty<QObject> seriesChildren(); | |
140 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
130 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
141 |
|
131 | |||
142 | public: // from QDeclarativeParserStatus |
|
132 | public: // from QDeclarativeParserStatus | |
143 | void classBegin(); |
|
133 | void classBegin(); | |
144 | void componentComplete(); |
|
134 | void componentComplete(); | |
145 |
|
135 | |||
146 | public Q_SLOTS: |
|
136 | public Q_SLOTS: | |
147 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
137 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
148 | }; |
|
138 | }; | |
149 |
|
139 | |||
150 | QTCOMMERCIALCHART_END_NAMESPACE |
|
140 | QTCOMMERCIALCHART_END_NAMESPACE | |
151 |
|
141 | |||
152 | #endif // DECLARATIVEBARSERIES_H |
|
142 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,41 +1,39 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Bar series" |
|
25 | title: "Bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend: ChartView.LegendBottom |
|
28 | legend: ChartView.LegendBottom | |
29 | // TODO: labels defined by x-axis, not by bar series |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
|||
31 |
|
30 | |||
32 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
33 |
|
32 | |||
34 | BarSeries { |
|
33 | BarSeries { | |
35 | id: daSeries |
|
34 | id: daSeries | |
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
35 | BarSet { name: "Bob"; values: [4, 7, 3, 10, 5, 6] } | |
37 |
BarSet { name: " |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 8] } | |
38 |
BarSet { name: " |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 5, 4, 7] } | |
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
|||
40 | } |
|
38 | } | |
41 | } |
|
39 | } |
@@ -1,41 +1,39 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Grouped bar series" |
|
25 | title: "Grouped bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend: ChartView.LegendBottom |
|
28 | legend: ChartView.LegendBottom | |
29 | // TODO: labels defined by x-axis, not by bar series |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
|||
31 |
|
30 | |||
32 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
33 |
|
32 | |||
34 | GroupedBarSeries { |
|
33 | GroupedBarSeries { | |
35 | id: daSeries |
|
34 | id: daSeries | |
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
|||
37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
38 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
40 | } |
|
38 | } | |
41 | } |
|
39 | } |
@@ -1,40 +1,39 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Percent bar series" |
|
25 | title: "Percent bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend: ChartView.LegendBottom |
|
28 | legend: ChartView.LegendBottom | |
29 | // TODO: labels defined by x-axis, not by bar series |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] |
|
|||
31 |
|
30 | |||
32 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
33 |
|
32 | |||
34 | PercentBarSeries { |
|
33 | PercentBarSeries { | |
35 | id: daSeries |
|
34 | id: daSeries | |
36 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
37 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
38 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
39 | } |
|
38 | } | |
40 | } |
|
39 | } |
@@ -1,39 +1,39 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Stacked bar series" |
|
25 | title: "Stacked bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend: ChartView.LegendBottom |
|
28 | legend: ChartView.LegendBottom | |
29 |
axisXLabels: ["0", "200 |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
32 |
|
32 | |||
33 | StackedBarSeries { |
|
33 | StackedBarSeries { | |
34 | id: daSeries |
|
34 | id: daSeries | |
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
38 | } | |
39 | } |
|
39 | } |
General Comments 0
You need to be logged in to leave comments.
Login now