|
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: "version", type: "int" }, |
|
44 { name: "code", type: "string" }, |
|
45 { name: "name", type: "string" }, |
|
46 { name: "pv_mlt", type: "float" }, |
|
47 { name: "pv_bk", type: "float" }, |
|
48 { name: "pv_hlt", type: "float" }, |
|
49 { name: "pv_room", type: "float" }, |
|
50 { name: "sp_mlt", type: "float" }, |
|
51 { name: "sp_bk", type: "float" }, |
|
52 { name: "sp_hlt", type: "float" }, |
|
53 { name: "event", type: "string" } |
|
54 ], |
|
55 url: 'getbrewlog.php?code=' + my_code |
|
56 }; |
|
57 var dataAdapter = new $.jqx.dataAdapter(sourceA, { |
|
58 autoBind: true, |
|
59 async: false, |
|
60 loadComplete: function () { |
|
61 $('#jqxLoader').jqxLoader('close'); |
|
62 }, |
|
63 loadError: function (jqXHR, status, error) { |
|
64 } |
|
65 }); |
|
66 |
|
67 var settings = { |
|
68 title: my_code + ' "' + my_name + '"', |
|
69 description: "", |
|
70 source: dataAdapter, |
|
71 xAxis: { |
|
72 dataField: 'date', |
|
73 type: 'date', |
|
74 formatFunction: function (value) { |
|
75 return value.getHours() + ':' + value.getMinutes(); |
|
76 }, |
|
77 toolTipFormatFunction: function (value) { |
|
78 var h = value.getHours(); |
|
79 var m = value.getMinutes(); |
|
80 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() |
|
81 + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); |
|
82 }, |
|
83 textRotationAngle: 300, |
|
84 }, |
|
85 colorScheme: 'scheme01', |
|
86 seriesGroups: [ |
|
87 { |
|
88 type: 'spline', |
|
89 valueAxis: { |
|
90 minValue: 0, |
|
91 description: 'Graden C' |
|
92 }, |
|
93 series: [ |
|
94 { dataField: "pv_mlt", lineWidth: 2, displayText: "MLT" }, |
|
95 { dataField: "sp_mlt", lineWidth: 1, displayText: "mlt", opacity: 0.7 }, |
|
96 { dataField: "pv_bk", lineWidth: 2, displayText: "BK" }, |
|
97 { dataField: "sp_bk", lineWidth: 1, displayText: "bk", opacity: 0.7 }, |
|
98 { dataField: "pv_hlt", lineWidth: 1, displayText: "HLT" }, |
|
99 { dataField: "sp_hlt", lineWidth: 1, displayText: "hlt", opacity: 0.7 }, |
|
100 { dataField: "pv_room", lineWidth: 1, displayText: "Room", opacity: 0.5 } |
|
101 ] |
|
102 } |
|
103 ] |
|
104 }; |
|
105 $("#brew_chart").jqxChart(settings); |
|
106 |
|
107 $("#print").click(function () { |
|
108 var content = $("#brew_chart")[0].outerHTML; |
|
109 var newWindow = window.open("", "", "width=865, height=425"), |
|
110 document = newWindow.document.open(), |
|
111 pageContent = |
|
112 '<!DOCTYPE html>' + |
|
113 '<html>' + |
|
114 '<head>' + |
|
115 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + |
|
116 '<meta charset="utf-8" />' + |
|
117 '<title>jQWidgets Chart</title>' + |
|
118 '</head>' + |
|
119 '<body>' + content + '</body></html>'; |
|
120 document.write(pageContent); |
|
121 document.close(); |
|
122 newWindow.print(); |
|
123 }); |
|
124 $("#print").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
125 |
|
126 |
|
127 $("#pdfButton").click(function () { |
|
128 $("#brew_chart").jqxChart("saveAsPDF", "brouw_"+my_code+".pdf", getExportServer()); |
|
129 }); |
|
130 $("#pdfButton").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
131 |
|
132 $("#pngButton").click(function () { |
|
133 $("#brew_chart").jqxChart("saveAsPNG", "brouw_"+my_code+".png", getExportServer()); |
|
134 }); |
|
135 $("#pngButton").jqxButton({ template: "primary", width: 125, theme: theme }); |
|
136 |
|
137 $("#Close").jqxButton({ template: "success", width: 125, theme: theme }); |
|
138 $("#Close").click(function () { |
|
139 window.close(); |
|
140 }); |
|
141 }); |
|
142 |