|
1 /***************************************************************************** |
|
2 * Copyright (C) 2019 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of BMS |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * Brewery Managment System is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 |
|
24 $(document).ready(function () { |
|
25 |
|
26 $("#jqxLoader").jqxLoader({ |
|
27 width: 250, |
|
28 height: 150, |
|
29 isModal: true, |
|
30 text: "Opmaken grafiek ...", |
|
31 theme: theme |
|
32 }); |
|
33 $('#jqxLoader').jqxLoader('open'); |
|
34 |
|
35 function getExportServer() { |
|
36 return "https://www.jqwidgets.com/export_server/export.php"; |
|
37 } |
|
38 |
|
39 var sourceA = { |
|
40 datatype: "json", |
|
41 datafields: [ |
|
42 { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, |
|
43 { name: "air", type: "float" }, |
|
44 { name: "beer", type: "float" }, |
|
45 { name: "tlo", type: "float" }, |
|
46 { name: "thi", type: "float" }, |
|
47 { name: "heater", type: "int" }, |
|
48 { name: "cooler", type: "int" }, |
|
49 { name: "room", type: "float" }, |
|
50 { name: "chiller", type: "float" } |
|
51 ], |
|
52 url: 'getfermentlog.php?code=' + my_code |
|
53 }; |
|
54 var dataAdapter = new $.jqx.dataAdapter(sourceA, { |
|
55 autoBind: true, |
|
56 async: false, |
|
57 loadComplete: function () { |
|
58 $('#jqxLoader').jqxLoader('close'); |
|
59 }, |
|
60 loadError: function (jqXHR, status, error) { |
|
61 } |
|
62 }); |
|
63 |
|
64 var settings = { |
|
65 title: my_code + ' "' + my_name + '"', |
|
66 description: "", |
|
67 source: dataAdapter, |
|
68 xAxis: { |
|
69 dataField: 'date', |
|
70 type: 'date', |
|
71 formatFunction: function (value) { |
|
72 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear(); |
|
73 }, |
|
74 toolTipFormatFunction: function (value) { |
|
75 var h = value.getHours(); |
|
76 var m = value.getMinutes(); |
|
77 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() |
|
78 + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); |
|
79 }, |
|
80 textRotationAngle: 45, |
|
81 howGridLines: false, |
|
82 rangeSelector: { |
|
83 size: 90, |
|
84 dataField: 'beer', |
|
85 serieType: 'line', |
|
86 gridLines: {visible: false}, |
|
87 } |
|
88 }, |
|
89 colorScheme: 'scheme01', |
|
90 seriesGroups: [ |
|
91 { |
|
92 type: "line", |
|
93 valueAxis: { |
|
94 minValue: 0, |
|
95 maxValue: 100, |
|
96 displayValueAxis: false, |
|
97 description: "Heat/Cool %" |
|
98 }, |
|
99 series: [ |
|
100 { dataField: "cooler", lineWidth: 1, displayText: "Cool %", opacity: 0.3 }, |
|
101 { dataField: "heater", lineWidth: 1, displayText: "Heat %", opacity: 0.3 } |
|
102 ] |
|
103 }, |
|
104 { |
|
105 type: 'spline', |
|
106 valueAxis: { |
|
107 minValue: 0, |
|
108 description: 'Graden C' |
|
109 }, |
|
110 series: [ |
|
111 { dataField: "air", lineWidth: 1, displayText: "Air" }, |
|
112 { dataField: "beer", lineWidth: 2, displayText: "Beer" }, |
|
113 { dataField: "tlo", lineWidth: 1, displayText: "Target Lo", opacity: 0.7 }, |
|
114 { dataField: "thi", lineWidth: 1, displayText: "Target Hi", opacity: 0.7 }, |
|
115 { dataField: "room", lineWidth: 1, displayText: "Room", opacity: 0.5 }, |
|
116 { dataField: "chiller", lineWidth: 1, displayText: "Chiller", color: '#0000bb' } |
|
117 ] |
|
118 } |
|
119 ] |
|
120 }; |
|
121 $("#fermentor_chart").jqxChart(settings); |
|
122 |
|
123 $("#print").click(function () { |
|
124 var content = $("#fermentor_chart")[0].outerHTML; |
|
125 var newWindow = window.open("", "", "width=865, height=425"), |
|
126 document = newWindow.document.open(), |
|
127 pageContent = |
|
128 '<!DOCTYPE html>' + |
|
129 '<html>' + |
|
130 '<head>' + |
|
131 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + |
|
132 '<meta charset="utf-8" />' + |
|
133 '<title>jQWidgets Chart</title>' + |
|
134 '</head>' + |
|
135 '<body>' + content + '</body></html>'; |
|
136 document.write(pageContent); |
|
137 document.close(); |
|
138 newWindow.print(); |
|
139 }); |
|
140 $("#print").jqxButton({ template: "info", width: 125, theme: theme }); |
|
141 |
|
142 |
|
143 $("#pdfButton").click(function () { |
|
144 $("#fermentor_chart").jqxChart("saveAsPDF", "vergisting_"+my_code+".pdf", getExportServer()); |
|
145 }); |
|
146 $("#pdfButton").jqxButton({ template: "info", width: 125, theme: theme }); |
|
147 |
|
148 $("#pngButton").click(function () { |
|
149 $("#fermentor_chart").jqxChart("saveAsPNG", "vergisting_"+my_code+".png", getExportServer()); |
|
150 }); |
|
151 $("#pngButton").jqxButton({ template: "info", width: 125, theme: theme }); |
|
152 |
|
153 $("#Close").jqxButton({ template: "success", width: 125, theme: theme }); |
|
154 $("#Close").click(function () { |
|
155 window.close(); |
|
156 }); |
|
157 }); |
|
158 |