www/js/log_brew.js

changeset 527
9dfefad3ae1d
parent 494
af28ebe4a779
equal deleted inserted replaced
526:2991acd35cdb 527:9dfefad3ae1d
19 * along with ThermFerm; see the file COPYING. If not, write to the Free 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. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 $(document).ready(function () { 24 $(document).ready(function() {
25 25
26 $('#jqxMenu').jqxMenu('destroy'); 26 $('#jqxMenu').jqxMenu('destroy');
27 $('#jqxLoader').jqxLoader({
28 width: 250,
29 height: 150,
30 isModal: true,
31 text: 'Opmaken grafiek ...',
32 theme: theme
33 });
34 $('#jqxLoader').jqxLoader('open');
27 35
28 $("#jqxLoader").jqxLoader({ 36 function getExportServer() {
29 width: 250, 37 return 'https://www.jqwidgets.com/export_server/export.php';
30 height: 150, 38 }
31 isModal: true,
32 text: "Opmaken grafiek ...",
33 theme: theme
34 });
35 $('#jqxLoader').jqxLoader('open');
36 39
37 function getExportServer() { 40 var sourceA = {
38 return "https://www.jqwidgets.com/export_server/export.php"; 41 datatype: 'json',
39 } 42 datafields: [
43 { name: 'date', type: 'date', format: 'yyyy-MM-dd HH:mm' },
44 { name: 'version', type: 'int' },
45 { name: 'code', type: 'string' },
46 { name: 'name', type: 'string' },
47 { name: 'pv_mlt', type: 'float' },
48 { name: 'pv_hlt', type: 'float' },
49 { name: 'pv_room', type: 'float' },
50 { name: 'sp_mlt', type: 'float' },
51 { name: 'sp_hlt', type: 'float' },
52 { name: 'pwm_mlt', type: 'int' },
53 { name: 'pwm_hlt', type: 'int' },
54 { name: 'event', type: 'string' }
55 ],
56 url: 'getbrewlog.php?code=' + my_code
57 },
58 dataAdapter = new $.jqx.dataAdapter(sourceA, {
59 autoBind: true,
60 async: false,
61 loadComplete: function() {
62 $('#jqxLoader').jqxLoader('close');
63 },
64 loadError: function(jqXHR, status, error) {
65 }
66 }),
67 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(), m = value.getMinutes();
79 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() +
80 ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
81 },
82 textRotationAngle: 300,
83 },
84 colorScheme: 'scheme01',
85 seriesGroups: [{
86 type: 'spline',
87 valueAxis: {
88 minValue: 0,
89 description: 'Graden C'
90 },
91 series: [
92 { dataField: 'pv_mlt', lineWidth: 2, displayText: 'MLT' },
93 { dataField: 'sp_mlt', lineWidth: 1, displayText: 'mlt', opacity: 0.7 },
94 { dataField: 'pv_hlt', lineWidth: 1, displayText: 'HLT' },
95 { dataField: 'sp_hlt', lineWidth: 1, displayText: 'hlt', opacity: 0.7 },
96 { dataField: 'pv_room', lineWidth: 1, displayText: 'Ruimte', opacity: 0.5 }
97 ]
98 }]
99 };
100 $('#brew_chart').jqxChart(settings);
40 101
41 var sourceA = { 102 $('#print').click(function() {
42 datatype: "json", 103 var content = $('#brew_chart')[0].outerHTML,
43 datafields: [ 104 newWindow = window.open('', '', 'width=865, height=425'),
44 { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, 105 document = newWindow.document.open(),
45 { name: "version", type: "int" }, 106 pageContent =
46 { name: "code", type: "string" }, 107 '<!DOCTYPE html>' +
47 { name: "name", type: "string" }, 108 '<html>' +
48 { name: "pv_mlt", type: "float" }, 109 '<head>' +
49 { name: "pv_hlt", type: "float" }, 110 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
50 { name: "pv_room", type: "float" }, 111 '<meta charset="utf-8" />' +
51 { name: "sp_mlt", type: "float" }, 112 '<title>' + my_code + ' ' + my_name + ' brouwdag</title>' +
52 { name: "sp_hlt", type: "float" }, 113 '</head>' +
53 { name: "pwm_mlt", type: "int" }, 114 '<body>' + content + '</body></html>';
54 { name: "pwm_hlt", type: "int" }, 115 document.write(pageContent);
55 { name: "event", type: "string" } 116 document.close();
56 ], 117 newWindow.print();
57 url: 'getbrewlog.php?code=' + my_code 118 });
58 }, 119 $('#print').jqxButton({ template: 'primary', width: 125, theme: theme });
59 dataAdapter = new $.jqx.dataAdapter(sourceA, {
60 autoBind: true,
61 async: false,
62 loadComplete: function () {
63 $('#jqxLoader').jqxLoader('close');
64 },
65 loadError: function (jqXHR, status, error) {
66 }
67 }),
68 settings = {
69 title: my_code + ' "' + my_name + '"',
70 description: "",
71 source: dataAdapter,
72 xAxis: {
73 dataField: 'date',
74 type: 'date',
75 formatFunction: function (value) {
76 return value.getHours() + ':' + value.getMinutes();
77 },
78 toolTipFormatFunction: function (value) {
79 var h = value.getHours(),
80 m = value.getMinutes();
81 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear()
82 + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
83 },
84 textRotationAngle: 300,
85 },
86 colorScheme: 'scheme01',
87 seriesGroups: [
88 {
89 type: 'spline',
90 valueAxis: {
91 minValue: 0,
92 description: 'Graden C'
93 },
94 series: [
95 { dataField: "pv_mlt", lineWidth: 2, displayText: "MLT" },
96 { dataField: "sp_mlt", lineWidth: 1, displayText: "mlt", opacity: 0.7 },
97 { dataField: "pv_hlt", lineWidth: 1, displayText: "HLT" },
98 { dataField: "sp_hlt", lineWidth: 1, displayText: "hlt", opacity: 0.7 },
99 { dataField: "pv_room", lineWidth: 1, displayText: "Room", opacity: 0.5 }
100 ]
101 }
102 ]
103 };
104 $("#brew_chart").jqxChart(settings);
105 120
106 $("#print").click(function () { 121 $('#pdfButton').click(function() {
107 var content = $("#brew_chart")[0].outerHTML, 122 $('#brew_chart').jqxChart('saveAsPDF', 'brouw_' + my_code + '.pdf', getExportServer());
108 newWindow = window.open("", "", "width=865, height=425"), 123 });
109 document = newWindow.document.open(), 124 $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme });
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 + ' brouwdag</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 $('#pngButton').click(function() {
127 $('#brew_chart').jqxChart('saveAsPNG', 'brouw_' + my_code + '.png', getExportServer());
128 });
129 $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme });
125 130
126 $("#pdfButton").click(function () { 131 $('#Close').jqxButton({ template: 'success', width: 125, theme: theme });
127 $("#brew_chart").jqxChart("saveAsPDF", "brouw_"+my_code+".pdf", getExportServer()); 132 $('#Close').click(function() {
128 }); 133 window.close();
129 $("#pdfButton").jqxButton({ template: "primary", width: 125, theme: theme }); 134 });
130
131 $("#pngButton").click(function () {
132 $("#brew_chart").jqxChart("saveAsPNG", "brouw_"+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 }); 135 });
141 136

mercurial