Browse Source

Replaced tick labels with Repeater. Reorganized and adjusted spacing.

Neal Wilson 11 years ago
parent
commit
155d19a62c
1 changed files with 50 additions and 118 deletions
  1. 50
    118
      qml/BrewPlot/BrewingControlChart.qml

+ 50
- 118
qml/BrewPlot/BrewingControlChart.qml View File

@@ -4,6 +4,13 @@ import QtQuick 1.0
4 4
 Item {
5 5
 	id: chartOuter
6 6
 
7
+    property real xmin: 0.14
8
+    property real xmax: 0.26
9
+    property real ymin: 0.008
10
+    property real ymax: 0.016
11
+    property real xrange: xmax - xmin
12
+    property real yrange: ymax - ymin
13
+
7 14
 	function plotPoint(px, py, pcolor) {
8 15
 		chart.plotPoint(px, py, pcolor);
9 16
 	}
@@ -22,6 +29,7 @@ Item {
22 29
 
23 30
 	Item {
24 31
 		id: chart
32
+
25 33
 		height: parent.height
26 34
 		width: parent.width
27 35
 
@@ -40,6 +48,7 @@ Item {
40 48
 			fitline.y1 = mapToY(y1);
41 49
 			fitline.y2 = mapToY(y2);
42 50
 		}
51
+
43 52
 		Line {
44 53
 			id: fitline
45 54
 
@@ -59,6 +68,12 @@ Item {
59 68
 		ListModel {
60 69
 			id: points
61 70
 		}
71
+        ListModel {
72
+            id: yLabels
73
+        }
74
+        ListModel {
75
+            id: xLabels
76
+        }
62 77
 
63 78
 		Repeater {
64 79
 			model: xGridLines
@@ -99,149 +114,66 @@ Item {
99 114
 			}
100 115
 		}
101 116
 	}
102
-	
103
-	property real xmin: 0.14
104
-	property real xmax: 0.26
105
-	property real ymin: 0.008
106
-	property real ymax: 0.016
107
-	property real xrange: xmax - xmin
108
-	property real yrange: ymax - ymin
109
-	
110
-	Item {
111
-		id: yLabels
117
+    Repeater {
118
+        id: yTickLabels
112 119
 
120
+        model: yLabels
113 121
         anchors.right: chart.left
114 122
         anchors.rightMargin: 10
115 123
         y: chart.y
116
-        Text {
117
-            text: "0.8%"
118
-            y: chart.mapToY(0.008) - (height/2)
119
-            x: -width
120
-        }
121
-        Text {
122
-            text: "0.9%"
123
-            y: chart.mapToY(0.009) - (height/2)
124
-            x: -width
125
-        }
126
-        Text {
127
-            text: "1.0%"
128
-            y: chart.mapToY(0.01) - (height/2)
129
-            x: -width
130
-        }
131
-        Text {
132
-            text: "1.1%"
133
-            y: chart.mapToY(0.011) - (height/2)
134
-            x: -width
135
-        }
136
-        Text {
137
-            text: "1.2%"
138
-            y: chart.mapToY(0.012) - (height/2)
139
-            x: -width
140
-        }
141
-        Text {
142
-            text: "1.3%"
143
-            y: chart.mapToY(0.013) - (height/2)
144
-            x: -width
145
-        }
146
-        Text {
147
-            text: "1.4%"
148
-            y: chart.mapToY(0.014) - (height/2)
149
-            x: -width
150
-        }
151
-        Text {
152
-            text: "1.5%"
153
-            y: chart.mapToY(0.015) - (height/2)
154
-            x: -width
124
+
125
+        Item {
126
+            Text {
127
+                text: (value * 100).toFixed(1) + "%"
128
+                y: chart.mapToY(value) - (height/2)
129
+                x: -width
130
+            }
155 131
         }
132
+    }
133
+    Item {
134
+        anchors.right: yTickLabels.left
135
+        anchors.rightMargin: 40
136
+        y: chart.y + (chart.height/2) - (strengthLabel.height/2)
137
+
156 138
         Text {
157
-            text: "1.6%"
158
-            y: chart.mapToY(0.016) - (height/2)
159
-            x: -width
139
+            id: strengthLabel
140
+
141
+            text: "STRENGTH - Solubles Concentration (%TDS)"
142
+            rotation: -90
143
+            x: -(width/2)
160 144
         }
161 145
     }
162
-    Item {
163
-        id: xLabels
146
+    Repeater {
147
+        id: xTickLabels
164 148
 
165
-        x: chart.x
166 149
         anchors.top: chart.bottom
167 150
         anchors.topMargin: 10
168
-        Text {
169
-            text: "14%"
170
-            x: chart.mapToX(0.14) - (width/2)
171
-        }
172
-        Text {
173
-            text: "15%"
174
-            x: chart.mapToX(0.15) - (width/2)
175
-        }
176
-        Text {
177
-            text: "16%"
178
-            x: chart.mapToX(0.16) - (width/2)
179
-        }
180
-        Text {
181
-            text: "17%"
182
-            x: chart.mapToX(0.17) - (width/2)
183
-        }
184
-        Text {
185
-            text: "18%"
186
-            x: chart.mapToX(0.18) - (width/2)
187
-        }
188
-        Text {
189
-            text: "19%"
190
-            x: chart.mapToX(0.19) - (width/2)
191
-        }
192
-        Text {
193
-            text: "20%"
194
-            x: chart.mapToX(0.2) - (width/2)
195
-        }
196
-        Text {
197
-            text: "21%"
198
-            x: chart.mapToX(0.21) - (width/2)
199
-        }
200
-        Text {
201
-            text: "22%"
202
-            x: chart.mapToX(0.22) - (width/2)
203
-        }
204
-        Text {
205
-            text: "23%"
206
-            x: chart.mapToX(0.23) - (width/2)
207
-        }
208
-        Text {
209
-            text: "24%"
210
-            x: chart.mapToX(0.24) - (width/2)
211
-        }
212
-        Text {
213
-            text: "25%"
214
-            x: chart.mapToX(0.25) - (width/2)
215
-        }
216
-        Text {
217
-            text: "26%"
218
-            x: chart.mapToX(0.26) - (width/2)
151
+        model: xLabels
152
+        x: chart.x
153
+
154
+        Item {
155
+            Text {
156
+                text: (value * 100).toFixed(0) + "%"
157
+                x: chart.mapToX(value) - (width/2)
158
+                y: xTickLabels.y
159
+            }
219 160
         }
220 161
     }
221 162
     Text {
222 163
         text: "EXTRACTION - Solubles Yield"
223 164
         x: chart.x + (chart.width/2) - (width/2)
224
-        anchors.top: xLabels.bottom
165
+        anchors.top: xTickLabels.bottom
225 166
         anchors.topMargin: 20
226 167
     }
227
-    Item {
228
-        anchors.right: yLabels.left
229
-        anchors.rightMargin: 40
230
-        y: chart.y + (chart.height/2) - (strengthLabel.height/2)
231
-        Text {
232
-            id: strengthLabel
233 168
 
234
-            text: "STRENGTH - Solubles Concentration (%TDS)"
235
-            rotation: -90
236
-            x: -(width/2)
237
-        }
238
-    }
239 169
 	Component.onCompleted: {
240 170
         for(var i = 0.14; i < 0.261; i += 0.01) {
241 171
             xGridLines.append({"value": i, "pwidth": i.toFixed(2) == 0.18 || i.toFixed(2) == 0.22 ? 2 : 1});
172
+            xLabels.append({"value": i});
242 173
         }
243 174
         for(var i = 0.008; i < 0.0161; i += 0.0005) {
244 175
             yGridLines.append({"value": i, "pwidth": i.toFixed(4) == 0.0115 || i.toFixed(4) == 0.0135 ? 2 : 1});
176
+            yLabels.append({"value": i});
245 177
         }
246 178
 	}
247 179
 }

Loading…
Cancel
Save