|
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 $('#jqxMenu').jqxMenu('destroy'); |
|
27 |
|
28 $("#jqxLoader").jqxLoader({ |
|
29 width: 250, |
|
30 height: 150, |
|
31 isModal: true, |
|
32 text: "Opmaken grafiek ...", |
|
33 theme: theme |
|
34 }); |
|
35 $('#jqxLoader').jqxLoader('open'); |
|
36 |
|
37 function getExportServer() { |
|
38 return "https://www.jqwidgets.com/export_server/export.php"; |
|
39 } |
|
40 |
|
41 var sourceA = { |
|
42 datatype: "json", |
|
43 datafields: [ |
|
44 { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, |
|
45 { name: "temperature", type: "float" }, |
|
46 { name: "pressure", type: "float" }, |
|
47 { name: "uuid", type: "string" } |
|
48 ], |
|
49 url: 'getco2pressurelog.php?code=' + my_code + '&name=' + my_name |
|
50 }, |
|
51 dataAdapter = new $.jqx.dataAdapter(sourceA, { |
|
52 autoBind: true, |
|
53 async: false, |
|
54 loadComplete: function () { |
|
55 $('#jqxLoader').jqxLoader('close'); |
|
56 }, |
|
57 loadError: function (jqXHR, status, error) { |
|
58 } |
|
59 }), |
|
60 settings = { |
|
61 title: my_code + ' "' + my_name + '"', |
|
62 description: "", |
|
63 source: dataAdapter, |
|
64 xAxis: { |
|
65 dataField: 'date', |
|
66 type: 'date', |
|
67 formatFunction: function (value) { |
|
68 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear(); |
|
69 }, |
|
70 toolTipFormatFunction: function (value) { |
|
71 var h = value.getHours(), |
|
72 m = value.getMinutes(); |
|
73 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() |
|
74 + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); |
|
75 }, |
|
76 textRotationAngle: 45, |
|
77 howGridLines: false |
|
78 }, |
|
79 colorScheme: 'scheme01', |
|
80 seriesGroups: [ |
|
81 { |
|
82 type: "area", |
|
83 valueAxis: { |
|
84 minValue: 0, |
|
85 displayValueAxis: false, |
|
86 description: "Druk in bar" |
|
87 }, |
|
88 series: [ |
|
89 { dataField: "pressure", lineWidth: 1, displayText: "Druk", opacity: 0.4 } |
|
90 ] |
|
91 }, |
|
92 { |
|
93 type: 'spline', |
|
94 valueAxis: { |
|
95 minValue: 0, |
|
96 description: 'Graden C' |
|
97 }, |
|
98 series: [ |
|
99 { dataField: "temperature", lineWidth: 1, displayText: "Temperatuur" } |
|
100 ] |
|
101 } |
|
102 ] |
|
103 }; |
|
104 $("#pressure_chart").jqxChart(settings); |
|
105 |
|
106 $("#print").click(function () { |
|
107 var content = $("#pressure_chart")[0].outerHTML, |
|
108 newWindow = window.open("", "", "width=865, height=425"), |
|
109 document = newWindow.document.open(), |
|
110 pageContent = |
|
111 '<!DOCTYPE html>' + |
|
112 '<html>' + |
|
113 '<head>' + |
|
114 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + |
|
115 '<meta charset="utf-8" />' + |
|
116 '<title>' + my_code + ' ' + my_name + ' hergisting</title>' + |
|
117 '</head>' + |
|
118 '<body>' + content + '</body></html>'; |
|
119 document.write(pageContent); |
|
120 document.close(); |
|
121 newWindow.print(); |
|
122 }); |
|
123 $("#print").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
124 |
|
125 |
|
126 $("#pdfButton").click(function () { |
|
127 $("#pressure_chart").jqxChart("saveAsPDF", "hergisting_"+my_code+".pdf", getExportServer()); |
|
128 }); |
|
129 $("#pdfButton").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
130 |
|
131 $("#pngButton").click(function () { |
|
132 $("#pressure_chart").jqxChart("saveAsPNG", "hergisting_"+my_code+".png", getExportServer()); |
|
133 }); |
|
134 $("#pngButton").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
135 |
|
136 $("#Close").jqxButton({ template: "success", width: 125, theme: theme }); |
|
137 $("#Close").click(function () { |
|
138 window.close(); |
|
139 }); |
|
140 }); |
|
141 |