@@ -1,75 +1,77 | |||||
1 | import QtQuick 1.0 |
|
1 | import QtQuick 1.0 | |
2 | import QtCommercial.Chart 1.0 |
|
2 | import QtCommercial.Chart 1.0 | |
3 |
|
3 | |||
4 | Rectangle { |
|
4 | Rectangle { | |
5 | width: 360 |
|
5 | width: 360 | |
6 | height: 360 |
|
6 | height: 360 | |
7 | Text { |
|
|||
8 | text: qsTr("Hello World") |
|
|||
9 | anchors.centerIn: parent |
|
|||
10 | } |
|
|||
11 |
|
7 | |||
12 | // Another option for QML data api: |
|
8 | // Another option for QML data api: | |
13 | // ListModel { |
|
9 | // ListModel { | |
14 | // id: listModelForPie |
|
10 | // id: listModelForPie | |
15 | // // PieDataElement |
|
11 | // // PieDataElement | |
16 | // ListElement { |
|
12 | // ListElement { | |
17 | // label: "Apple" |
|
13 | // label: "Apple" | |
18 | // value: 4.3 |
|
14 | // value: 4.3 | |
19 | // } |
|
15 | // } | |
20 | // ListElement { |
|
16 | // ListElement { | |
21 | // label: "Blackberry" |
|
17 | // label: "Blackberry" | |
22 | // value: 15.1 |
|
18 | // value: 15.1 | |
23 | // } |
|
19 | // } | |
24 | // } |
|
20 | // } | |
25 |
|
21 | |||
26 | Component.onCompleted: { |
|
22 | Component.onCompleted: { | |
27 | // console.log("Component.onCompleted: " + scatterElement.x); |
|
23 | // console.log("Component.onCompleted: " + scatterElement.x); | |
28 | // console.log("Component.onCompleted: " + scatterElement.y); |
|
24 | // console.log("Component.onCompleted: " + scatterElement.y); | |
29 | // console.log("Component.onCompleted: " + scatterElement.dataX); |
|
25 | // console.log("Component.onCompleted: " + scatterElement.dataX); | |
30 | // console.log("Component.onCompleted: " + scatterElement.dataY); |
|
26 | // console.log("Component.onCompleted: " + scatterElement.dataY); | |
31 | //console.log("Component.onCompleted: " + chartModel.get(0).x); |
|
27 | //console.log("Component.onCompleted: " + chartModel.get(0).x); | |
32 | //console.log("Component.onCompleted: " + chartModel.scatterElements); |
|
28 | //console.log("Component.onCompleted: " + chartModel.scatterElements); | |
33 | // console.log("Component.onCompleted: " + elementt.dataX); |
|
29 | // console.log("Component.onCompleted: " + elementt.dataX); | |
34 | // console.log("Component.onCompleted: " + chartModel.get(0).dataX); |
|
30 | // console.log("Component.onCompleted: " + chartModel.get(0).dataX); | |
35 | } |
|
31 | } | |
36 |
|
32 | |||
|
33 | // TODO: a bug: drawing order affects the drawing; if you draw chart1 first (by changing the | |||
|
34 | // z-order), then chart2 is not shown at all. By drawing chart2 first, both are visible. | |||
37 | Chart { |
|
35 | Chart { | |
38 | anchors.fill: parent |
|
36 | id: chart2 | |
39 | theme: Chart.ThemeIcy |
|
37 | anchors.top: chart1.bottom | |
|
38 | anchors.bottom: parent.bottom | |||
|
39 | anchors.left: parent.left | |||
|
40 | anchors.right: parent.right | |||
|
41 | theme: Chart.ThemeScientific | |||
40 |
|
42 | |||
41 | ScatterSeries { |
|
43 | ScatterSeries { | |
42 | id: scatterSeries |
|
44 | id: scatterSeries | |
43 | data: [ |
|
45 | data: [ | |
44 | ScatterElement { x: 1.1; y: 2.1 }, |
|
46 | ScatterElement { x: 1.1; y: 2.1 }, | |
45 | ScatterElement { x: 1.2; y: 2.0 }, |
|
47 | ScatterElement { x: 1.2; y: 2.0 }, | |
46 | ScatterElement { x: 1.4; y: 2.3 }, |
|
48 | ScatterElement { x: 1.4; y: 2.3 }, | |
47 | ScatterElement { x: 1.9; y: 2.5 }, |
|
|||
48 | ScatterElement { x: 1.9; y: 3.4 }, |
|
|||
49 | ScatterElement { x: 2.9; y: 1.4 }, |
|
|||
50 | ScatterElement { x: 2.9; y: 2.4 }, |
|
|||
51 | ScatterElement { x: 3.1; y: 5.3 }, |
|
49 | ScatterElement { x: 3.1; y: 5.3 }, | |
52 | ScatterElement { x: 4.1; y: 3.7 } |
|
50 | ScatterElement { x: 4.1; y: 3.7 } | |
53 | ] |
|
51 | ] | |
54 | Component.onCompleted: { |
|
|||
55 | console.log("onCompleted " + data); |
|
|||
56 | // console.log("onCompleted " + data.get(0)); |
|
|||
57 | // console.log("onCompleted " + data.get(0).x); |
|
|||
58 | // var element = {"x": 9.9, "y": 8.5}; |
|
|||
59 | // data.append(element); |
|
|||
60 | } |
|
|||
61 | } |
|
52 | } | |
|
53 | } | |||
62 |
|
54 | |||
63 | // Series { |
|
55 | Chart { | |
64 | // seriesType: Series.SeriesTypePie |
|
56 | id: chart1 | |
65 | // } |
|
57 | anchors.top: parent.top | |
|
58 | anchors.left: parent.left | |||
|
59 | anchors.right: parent.right | |||
|
60 | height: parent.height / 2 | |||
|
61 | theme: Chart.ThemeIcy | |||
|
62 | opacity: 0.3 | |||
66 |
|
|
63 | ||
67 |
|
|
64 | Series { | |
68 |
|
|
65 | seriesType: Series.SeriesTypePie | |
69 |
|
|
66 | } | |
|
67 | ||||
|
68 | Series { | |||
|
69 | seriesType: Series.SeriesTypeLine | |||
|
70 | } | |||
70 |
|
|
71 | // TODO: | |
71 | // Series { |
|
72 | // Series { | |
72 | // seriesType: Series.SeriesTypeBar |
|
73 | // seriesType: Series.SeriesTypeBar | |
73 | // } |
|
74 | // } | |
74 | } |
|
75 | } | |
|
76 | ||||
75 | } |
|
77 | } |
General Comments 0
You need to be logged in to leave comments.
Login now