##// END OF EJS Templates
Added horizontal bar series to qml tester
Tero Ahola -
r1914:2325cc247e94
parent child
Show More
@@ -0,0 +1,64
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 title: "Bar series"
26 anchors.fill: parent
27 theme: ChartView.ChartThemeLight
28 legend.alignment: Qt.AlignBottom
29 animationOptions: ChartView.SeriesAnimations
30
31 property variant series: mySeries
32
33
34 HorizontalBarSeries {
35 id: mySeries
36 name: "bar"
37 axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
38 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
39 onClicked: console.log("barset.onClicked: " + index);
40 onHovered: console.log("barset.onHovered: " + status);
41 onPenChanged: console.log("barset.onPenChanged: " + pen);
42 onBrushChanged: console.log("barset.onBrushChanged: " + brush);
43 onLabelChanged: console.log("barset.onLabelChanged: " + label);
44 onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush);
45 onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont);
46 onColorChanged: console.log("barset.onColorChanged: " + color);
47 onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color);
48 onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color);
49 onCountChanged: console.log("barset.onCountChanged: " + count);
50 onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count);
51 onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count);
52 onValueChanged: console.log("barset.onValuesChanged: " + index);
53 }
54 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
55 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
56
57 onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name);
58 onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible);
59 onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index);
60 onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status);
61 onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
62 onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count);
63 }
64 }
@@ -0,0 +1,64
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 title: "Percent bar series"
26 anchors.fill: parent
27 theme: ChartView.ChartThemeLight
28 legend.alignment: Qt.AlignBottom
29 animationOptions: ChartView.SeriesAnimations
30
31 property variant series: mySeries
32
33 HorizontalPercentBarSeries {
34 id: mySeries
35 name: "bar"
36 axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
37
38 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
39 onClicked: console.log("barset.onClicked: " + index);
40 onHovered: console.log("barset.onHovered: " + status);
41 onPenChanged: console.log("barset.onPenChanged: " + pen);
42 onBrushChanged: console.log("barset.onBrushChanged: " + brush);
43 onLabelChanged: console.log("barset.onLabelChanged: " + label);
44 onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush);
45 onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont);
46 onColorChanged: console.log("barset.onColorChanged: " + color);
47 onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color);
48 onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color);
49 onCountChanged: console.log("barset.onCountChanged: " + count);
50 onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count);
51 onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count);
52 onValueChanged: console.log("barset.onValuesChanged: " + index);
53 }
54 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
55 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
56
57 onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name);
58 onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible);
59 onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index);
60 onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status);
61 onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
62 onCountChanged: console.log("percentBarSeries.onCountChanged: " + count);
63 }
64 }
@@ -0,0 +1,63
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 title: "Stacked bar series"
26 anchors.fill: parent
27 theme: ChartView.ChartThemeLight
28 legend.alignment: Qt.AlignBottom
29 animationOptions: ChartView.SeriesAnimations
30
31 property variant series: mySeries
32
33 HorizontalStackedBarSeries {
34 id: mySeries
35 name: "bar"
36 axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
37 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
38 onClicked: console.log("barset.onClicked: " + index);
39 onHovered: console.log("barset.onHovered: " + status);
40 onPenChanged: console.log("barset.onPenChanged: " + pen);
41 onBrushChanged: console.log("barset.onBrushChanged: " + brush);
42 onLabelChanged: console.log("barset.onLabelChanged: " + label);
43 onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush);
44 onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont);
45 onColorChanged: console.log("barset.onColorChanged: " + color);
46 onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color);
47 onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color);
48 onCountChanged: console.log("barset.onCountChanged: " + count);
49 onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count);
50 onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count);
51 onValueChanged: console.log("barset.onValuesChanged: " + index);
52 }
53 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
54 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
55
56 onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name);
57 onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible);
58 onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index);
59 onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status);
60 onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
61 onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count);
62 }
63 }
@@ -1,77 +1,77
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 23 Flow {
24 24 id: flow
25 25 spacing: 5
26 26 flow: Flow.TopToBottom
27 27 property variant series
28 28
29 29 Button {
30 30 text: "visible"
31 31 onClicked: series.visible = !series.visible;
32 32 }
33 33 Button {
34 34 text: "color"
35 35 onClicked: series.color = main.nextColor();
36 36 }
37 37 Button {
38 38 text: "borderColor"
39 39 onClicked: series.borderColor = main.nextColor();
40 40 }
41 41 Button {
42 text: "borderWidth + (" + series.borderWidth + ")"
42 text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : ""
43 43 onClicked: series.borderWidth += 0.5;
44 44 }
45 45 Button {
46 text: "borderWidth - (" + series.borderWidth + ")"
46 text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : ""
47 47 onClicked: series.borderWidth -= 0.5;
48 48 }
49 49 Button {
50 50 id: upperButton
51 51 text: "upper series"
52 52 unpressedColor: "#79bd8f"
53 53 onClicked: {
54 54 lineEditor.visible = true;
55 55 color = "#00a388";
56 56 lowerButton.color = "#79bd8f";
57 57 lineEditor.series = series.upperSeries;
58 58 }
59 59 }
60 60 Button {
61 61 id: lowerButton
62 62 text: "lower series"
63 63 unpressedColor: "#79bd8f"
64 64 onClicked: {
65 65 lineEditor.visible = true;
66 66 color = "#00a388";
67 67 upperButton.color = "#79bd8f";
68 68 lineEditor.series = series.lowerSeries;
69 69 }
70 70 }
71 71 LineEditor {
72 72 id: lineEditor
73 73 visible: false
74 74 }
75 75
76 76 onSeriesChanged: lineEditor.series = series.upperSeries;
77 77 }
@@ -1,178 +1,178
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 23 Row {
24 24 anchors.fill: parent
25 25 spacing: 5
26 26 property variant series
27 27
28 28 // buttons for selecting the edited object: series, barset or label
29 29 Flow {
30 30 spacing: 5
31 31 flow: Flow.TopToBottom
32 32 Button {
33 33 id: seriesButton
34 34 text: "series"
35 35 unpressedColor: "#79bd8f"
36 36 onClicked: {
37 37 seriesFlow.visible = true;
38 38 setFlow.visible = false;
39 39 labelsFlow.visible = false;
40 40 color = "#00a388";
41 41 sliceButton.color = "#79bd8f";
42 42 labelButton.color = "#79bd8f";
43 43 }
44 44 }
45 45 Button {
46 46 id: setButton
47 47 text: "BarSet"
48 48 unpressedColor: "#79bd8f"
49 49 onClicked: {
50 50 seriesFlow.visible = false;
51 51 setFlow.visible = true;
52 52 labelsFlow.visible = false;
53 53 color = "#00a388";
54 54 seriesButton.color = "#79bd8f";
55 55 labelButton.color = "#79bd8f";
56 56 }
57 57 }
58 58 Button {
59 59 id: labelButton
60 60 text: "label"
61 61 unpressedColor: "#79bd8f"
62 62 onClicked: {
63 63 seriesFlow.visible = false;
64 64 setFlow.visible = false;
65 65 labelsFlow.visible = true;
66 66 color = "#00a388";
67 67 seriesButton.color = "#79bd8f";
68 68 sliceButton.color = "#79bd8f";
69 69 }
70 70 }
71 71 }
72 72
73 73 // Buttons for editing series
74 74 Flow {
75 75 id: seriesFlow
76 76 spacing: 5
77 77 flow: Flow.TopToBottom
78 78 visible: false
79 79
80 80 Button {
81 81 text: "visible"
82 82 onClicked: series.visible = !series.visible;
83 83 }
84 84 Button {
85 85 text: "bar width +"
86 86 onClicked: series.barWidth += 0.1;
87 87 }
88 88 Button {
89 89 text: "bar width -"
90 90 onClicked: series.barWidth -= 0.1;
91 91 }
92 92 }
93 93
94 94 // Buttons for editing sets
95 95 Flow {
96 96 id: setFlow
97 97 spacing: 5
98 98 flow: Flow.TopToBottom
99 99 visible: false
100 100
101 101 Button {
102 102 text: "append set"
103 103 onClicked: {
104 104 var count = series.count;
105 105 series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
106 106 }
107 107 }
108 108 Button {
109 109 text: "insert set"
110 110 onClicked: {
111 111 var count = series.count;
112 112 series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
113 113 }
114 114 }
115 115 Button {
116 116 text: "remove set"
117 117 onClicked: series.remove(series.at(series.count - 1));
118 118 }
119 119 Button {
120 120 text: "clear sets"
121 121 onClicked: series.clear();
122 122 }
123 123
124 124 Button {
125 125 text: "set 1 append"
126 126 onClicked: series.at(0).append(series.at(0).count + 1);
127 127 }
128 128 Button {
129 129 text: "set 1 replace"
130 130 onClicked: series.at(0).replace(series.at(0).count - 1, series.at(0).at(series.at(0).count - 1) + 1.5);
131 131 }
132 132 Button {
133 133 text: "set 1 remove"
134 134 onClicked: series.at(0).remove(series.at(0).count - 1);
135 135 }
136 136
137 137 Button {
138 138 text: "set 1 color"
139 139 onClicked: series.at(0).color = main.nextColor();
140 140 }
141 141 Button {
142 142 text: "set 1 border color"
143 143 onClicked: series.at(0).borderColor = main.nextColor();
144 144 }
145 145 Button {
146 text: "set 1 borderWidth + (" + series.at(0).borderWidth + ")"
146 text: "set 1 borderWidth +"
147 147 onClicked: series.at(0).borderWidth += 0.5;
148 148 }
149 149 Button {
150 text: "set 1 borderWidth - (" + series.at(0).borderWidth + ")"
150 text: "set 1 borderWidth -"
151 151 onClicked: series.at(0).borderWidth -= 0.5;
152 152 }
153 153 }
154 154
155 155
156 156 Flow {
157 157 id: labelsFlow
158 158 spacing: 5
159 159 flow: Flow.TopToBottom
160 160 visible: false
161 161
162 162 Button {
163 163 text: "labels visible"
164 164 onClicked: series.labelsVisible = !series.labelsVisible;
165 165 }
166 166 Button {
167 167 text: "set 1 label color"
168 168 onClicked: series.at(0).labelColor = main.nextColor();
169 169 }
170 170 FontEditor {
171 171 id: fontEditor
172 172 fontDescription: "label"
173 173 function editedFont() {
174 174 return series.at(0).labelFont;
175 175 }
176 176 }
177 177 }
178 178 }
@@ -1,89 +1,89
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 23
24 24 Flow {
25 25 id: flow
26 26 spacing: 5
27 27 flow: Flow.TopToBottom
28 28 property variant series
29 29
30 30 Button {
31 31 text: "visible"
32 32 onClicked: series.visible = !series.visible;
33 33 }
34 34 Button {
35 35 text: "color"
36 36 onClicked: series.color = main.nextColor();
37 37 }
38 38 Button {
39 text: "width + (" + series.width + ")"
39 text: series != undefined ? "width + (" + series.width + ")" : ""
40 40 onClicked: series.width += 0.5;
41 41 }
42 42 Button {
43 text: "width - (" + series.width + ")"
43 text: series != undefined ? "width - (" + series.width + ")" : ""
44 44 onClicked: series.width -= 0.5;
45 45 }
46 46 Button {
47 text: "style + (" + series.style + ")"
47 text: series != undefined ? "style + (" + series.style + ")" : ""
48 48 onClicked: series.style++;
49 49 }
50 50 Button {
51 text: "style - (" + series.style + ")"
51 text: series != undefined ? "style - (" + series.style + ")" : ""
52 52 onClicked: series.style--;
53 53 }
54 54 Button {
55 text: "cap style + (" + series.capStyle + ")"
55 text: series != undefined ? "cap style + (" + series.capStyle + ")" : ""
56 56 onClicked: series.capStyle++;
57 57 }
58 58 Button {
59 text: "cap style - (" +series.capStyle + ")"
59 text: series != undefined ? "cap style - (" +series.capStyle + ")" : ""
60 60 onClicked: series.capStyle--;
61 61 }
62 62 Button {
63 63 text: "points visible"
64 64 onClicked: series.pointsVisible = !series.pointsVisible;
65 65 }
66 66 Button {
67 67 text: "append point"
68 68 onClicked: series.append(series.count - 1, series.count - 1);
69 69 }
70 70 Button {
71 71 text: "replace point"
72 72 onClicked: {
73 73 var xyPoint = series.at(series.count - 1);
74 74 series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1);
75 75 }
76 76 }
77 77 Button {
78 78 text: "remove point"
79 79 onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y);
80 80 }
81 81 Button {
82 82 text: "insert point"
83 83 onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2);
84 84 }
85 85 Button {
86 86 text: "clear"
87 87 onClicked: series.clear();
88 88 }
89 89 }
@@ -1,84 +1,84
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 23 Flow {
24 24 id: flow
25 25 spacing: 5
26 26 flow: Flow.TopToBottom
27 27 property variant series
28 28
29 29 Button {
30 30 text: "visible"
31 31 onClicked: series.visible = !series.visible;
32 32 }
33 33 Button {
34 34 text: "color"
35 35 onClicked: series.color = main.nextColor();
36 36 }
37 37 Button {
38 38 text: "borderColor"
39 39 onClicked: series.borderColor = main.nextColor();
40 40 }
41 41 Button {
42 text: "borderWidth + (" + series.borderWidth + ")"
42 text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : ""
43 43 onClicked: series.borderWidth += 0.5;
44 44 }
45 45 Button {
46 text: "borderWidth - (" + series.borderWidth + ")"
46 text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : ""
47 47 onClicked: series.borderWidth -= 0.5;
48 48 }
49 49 Button {
50 50 text: "markerSize +"
51 51 onClicked: series.markerSize += 1.0;
52 52 }
53 53 Button {
54 54 text: "markerSize -"
55 55 onClicked: series.markerSize -= 1.0;
56 56 }
57 57 Button {
58 58 text: "markerShape"
59 59 onClicked: series.markerShape = ((series.markerShape + 1) % 2);
60 60 }
61 61 Button {
62 62 text: "append point"
63 63 onClicked: series.append(series.count - 1, series.count - 1);
64 64 }
65 65 Button {
66 66 text: "replace point"
67 67 onClicked: {
68 68 var xyPoint = series.at(series.count - 1);
69 69 series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1);
70 70 }
71 71 }
72 72 Button {
73 73 text: "remove point"
74 74 onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y);
75 75 }
76 76 Button {
77 77 text: "insert point"
78 78 onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2);
79 79 }
80 80 Button {
81 81 text: "clear"
82 82 onClicked: series.clear();
83 83 }
84 84 }
@@ -1,121 +1,171
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 23 Rectangle {
24 24 id: main
25 25 width: parent.width
26 26 height: parent.height
27 property int viewNumber: 0
28 27 property int viewCount: 9
29 28 property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"]
30 29 property int colorIndex: 0
30 property int buttonWidth: 42
31 31
32 32 function nextColor() {
33 33 colorIndex++;
34 34 return colors[colorIndex % colors.length];
35 35 }
36 36
37 onViewNumberChanged: {
38 if (viewNumber == 0) {
39 chartLoader.source = "Chart.qml";
40 editorLoader.source = "ChartEditor.qml";
41 } else if (viewNumber == 1) {
42 chartLoader.source = "PieChart.qml";
43 editorLoader.source = "PieEditor.qml";
44 } else if (viewNumber == 2) {
45 chartLoader.source = "LineChart.qml";
46 editorLoader.source = "LineEditor.qml";
47 } else if (viewNumber == 3) {
48 chartLoader.source = "SplineChart.qml";
49 editorLoader.source = "LineEditor.qml";
50 } else if (viewNumber == 4) {
51 chartLoader.source = "ScatterChart.qml";
52 editorLoader.source = "ScatterEditor.qml";
53 } else if (viewNumber == 5) {
54 chartLoader.source = "AreaChart.qml";
55 editorLoader.source = "AreaEditor.qml";
56 } else if (viewNumber == 6) {
57 chartLoader.source = "BarChart.qml";
58 editorLoader.source = "BarEditor.qml";
59 } else if (viewNumber == 7) {
60 chartLoader.source = "StackedBarChart.qml";
61 editorLoader.source = "BarEditor.qml";
62 } else if (viewNumber == 8) {
63 chartLoader.source = "PercentBarChart.qml";
64 editorLoader.source = "BarEditor.qml";
65 } else {
66 console.log("Illegal view number");
67 }
68 }
69
70 37 Row {
71 38 anchors.top: parent.top
72 39 anchors.bottom: buttonRow.top
73 40 anchors.bottomMargin: 10
74 41 anchors.left: parent.left
75 42 anchors.right: parent.right
76 43
77 44 Loader {
78 45 id: chartLoader
79 46 width: main.width - editorLoader.width
80 47 height: parent.height
81 48 source: "Chart.qml"
82 49 onStatusChanged: {
83 50 if (status == Loader.Ready && editorLoader.status == Loader.Ready && chartLoader.item)
84 51 editorLoader.item.series = chartLoader.item.series;
85 52 }
86 53 }
87 54
88 55 Loader {
89 56 id: editorLoader
90 57 width: 280
91 58 height: parent.height
92 59 source: "ChartEditor.qml"
93 60 onStatusChanged: {
94 61 if (status == Loader.Ready && chartLoader.status == Loader.Ready && chartLoader.item)
95 62 editorLoader.item.series = chartLoader.item.series;
96 63 }
97 64 }
98 65 }
99 66
100 67 Row {
101 68 id: buttonRow
102 69 height: 40
103 70 anchors.bottom: parent.bottom
104 71 anchors.horizontalCenter: parent.horizontalCenter
105 72 spacing: 10
106 73
107 74 Button {
108 text: "previous"
75 text: "chart"
76 width: buttonWidth
109 77 onClicked: {
110 viewNumber = (viewNumber + viewCount - 1) % viewCount;
78 chartLoader.source = "Chart.qml";
79 editorLoader.source = "ChartEditor.qml";
80 }
81 }
82 Button {
83 text: "pie"
84 width: buttonWidth
85 onClicked: {
86 chartLoader.source = "PieChart.qml";
87 editorLoader.source = "PieEditor.qml";
88 }
89 }
90 Button {
91 text: "line"
92 width: buttonWidth
93 onClicked: {
94 chartLoader.source = "LineChart.qml";
95 editorLoader.source = "PieEditor.qml";
96 }
97 }
98 Button {
99 text: "spline"
100 width: buttonWidth
101 onClicked: {
102 chartLoader.source = "SplineChart.qml";
103 editorLoader.source = "PieEditor.qml";
111 104 }
112 105 }
113
114 106 Button {
115 text: "next"
107 text: "scatter"
108 width: buttonWidth
116 109 onClicked: {
117 viewNumber = (viewNumber + 1) % viewCount;
110 chartLoader.source = "ScatterChart.qml";
111 editorLoader.source = "ScatterEditor.qml";
112 }
113 }
114 Button {
115 text: "area"
116 width: buttonWidth
117 onClicked: {
118 chartLoader.source = "AreaChart.qml";
119 editorLoader.source = "AreaEditor.qml";
120 }
121 }
122 Button {
123 text: "bar"
124 width: buttonWidth
125 onClicked: {
126 chartLoader.source = "BarChart.qml";
127 editorLoader.source = "BarEditor.qml";
128 }
129 }
130 Button {
131 text: "sbar"
132 width: buttonWidth
133 onClicked: {
134 chartLoader.source = "StackedBarChart.qml";
135 editorLoader.source = "BarEditor.qml";
136 }
137 }
138 Button {
139 text: "pbar"
140 width: buttonWidth
141 onClicked: {
142 chartLoader.source = "PercentBarChart.qml";
143 editorLoader.source = "BarEditor.qml";
144 }
145 }
146 Button {
147 text: "hbar"
148 width: buttonWidth
149 onClicked: {
150 chartLoader.source = "HorizontalBarChart.qml";
151 editorLoader.source = "BarEditor.qml";
152 }
153 }
154 Button {
155 text: "hsbar"
156 width: buttonWidth
157 onClicked: {
158 chartLoader.source = "HorizontalStackedBarChart.qml";
159 editorLoader.source = "BarEditor.qml";
160 }
161 }
162 Button {
163 text: "hpbar"
164 width: buttonWidth
165 onClicked: {
166 chartLoader.source = "HorizontalPercentBarChart.qml";
167 editorLoader.source = "BarEditor.qml";
118 168 }
119 169 }
120 170 }
121 171 }
@@ -1,26 +1,29
1 1 <RCC>
2 2 <qresource prefix="/">
3 3 <file>qml/qmlchartproperties/loader.qml</file>
4 4 <file>qml/qmlchartproperties/main.qml</file>
5 5 <file>qml/qmlchartproperties/Button.qml</file>
6 6 <file>qml/qmlchartproperties/PieChart.qml</file>
7 7 <file>qml/qmlchartproperties/PieEditor.qml</file>
8 8 <file>qml/qmlchartproperties/LineChart.qml</file>
9 9 <file>qml/qmlchartproperties/LineEditor.qml</file>
10 10 <file>qml/qmlchartproperties/SplineChart.qml</file>
11 11 <file>qml/qmlchartproperties/ScatterChart.qml</file>
12 12 <file>qml/qmlchartproperties/AreaChart.qml</file>
13 13 <file>qml/qmlchartproperties/BarChart.qml</file>
14 14 <file>qml/qmlchartproperties/BarEditor.qml</file>
15 15 <file>qml/qmlchartproperties/ScatterEditor.qml</file>
16 16 <file>qml/qmlchartproperties/AreaEditor.qml</file>
17 17 <file>qml/qmlchartproperties/StackedBarChart.qml</file>
18 18 <file>qml/qmlchartproperties/PercentBarChart.qml</file>
19 19 <file>qml/qmlchartproperties/Chart.qml</file>
20 20 <file>qml/qmlchartproperties/ChartEditor.qml</file>
21 21 <file>qml/qmlchartproperties/ChartEditor1.qml</file>
22 22 <file>qml/qmlchartproperties/ChartEditor2.qml</file>
23 23 <file>qml/qmlchartproperties/ChartEditor3.qml</file>
24 24 <file>qml/qmlchartproperties/FontEditor.qml</file>
25 <file>qml/qmlchartproperties/HorizontalBarChart.qml</file>
26 <file>qml/qmlchartproperties/HorizontalPercentBarChart.qml</file>
27 <file>qml/qmlchartproperties/HorizontalStackedBarChart.qml</file>
25 28 </qresource>
26 29 </RCC>
General Comments 0
You need to be logged in to leave comments. Login now