www/js/log_brew.js

changeset 803
45e87aa8d02c
parent 802
4a9f469d2201
child 804
ac5c3e97fcf1
equal deleted inserted replaced
802:4a9f469d2201 803:45e87aa8d02c
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 $('#jqxLoader').jqxLoader({
28 width: 250,
29 height: 150,
30 isModal: true,
31 text: 'Opmaken grafiek ...',
32 theme: theme
33 });
34 $('#jqxLoader').jqxLoader('open');
35
36 function getExportServer() {
37 return 'https://www.jqwidgets.com/export_server/export.php';
38 }
39
40 var sourceA = {
41 datatype: 'json',
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);
101
102 $('#print').click(function() {
103 var content = $('#brew_chart')[0].outerHTML,
104 newWindow = window.open('', '', 'width=865, height=425'),
105 document = newWindow.document.open(),
106 pageContent =
107 '<!DOCTYPE html>' +
108 '<html>' +
109 '<head>' +
110 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
111 '<meta charset="utf-8" />' +
112 '<title>' + my_code + ' ' + my_name + ' brouwdag</title>' +
113 '</head>' +
114 '<body>' + content + '</body></html>';
115 document.write(pageContent);
116 document.close();
117 newWindow.print();
118 });
119 $('#print').jqxButton({ template: 'primary', width: 125, theme: theme });
120
121 $('#pdfButton').click(function() {
122 $('#brew_chart').jqxChart('saveAsPDF', 'brouw_' + my_code + '.pdf', getExportServer());
123 });
124 $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme });
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 });
130
131 $('#Close').jqxButton({ template: 'success', width: 125, theme: theme });
132 $('#Close').click(function() {
133 window.close();
134 });
135 });
136

mercurial