Qt Quick based coffee brewing control chart.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BrewingControlChart.qml 6.1KB

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