www/js/log_ispindel.js

branch
stable
changeset 665
4d01937ae7af
parent 627
f1a7c14d5601
child 700
89b7449d1fd9
equal deleted inserted replaced
521:9d1aa6f3a4da 665:4d01937ae7af
1 /*****************************************************************************
2 * Copyright (C) 2020
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: 'temperature', type: 'float' },
45 { name: 'plato', type: 'float' },
46 { name: 'sg', type: 'float' },
47 { name: 'battery', type: 'float' }
48 ],
49 url: 'getispindellog.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(), m = value.getMinutes();
72 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() +
73 ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
74 },
75 textRotationAngle: 45,
76 howGridLines: false
77 },
78 colorScheme: 'scheme01',
79 seriesGroups: [
80 {
81 type: 'spline',
82 valueAxis: { displayValueAxis: false, description: 'Densiteit SG', formatSettings: { decimalPlaces: 3 } },
83 series: [{ dataField: 'sg', lineWidth: 3, displayText: 'SG' }]
84 },
85 {
86 type: 'spline',
87 valueAxis: { displayValueAxis: false, description: 'Temperatuur °C' },
88 series: [{ dataField: 'temperature', lineWidth: 2, displayText: '°C' }]
89 },
90 {
91 type: 'spline',
92 valueAxis: { visible: false },
93 series: [{ dataField: 'battery', lineWidth: 1, displayText: 'Batterij' }]
94 }
95 ]
96 };
97 $('#ispindel_chart').jqxChart(settings);
98
99 $('#print').click(function() {
100 var content = $('#ispindel_chart')[0].outerHTML,
101 newWindow = window.open('', '', 'width=865, height=425'),
102 document = newWindow.document.open(),
103 pageContent =
104 '<!DOCTYPE html>' +
105 '<html>' +
106 '<head>' +
107 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
108 '<meta charset="utf-8" />' +
109 '<title>' + my_code + ' ' + my_name + ' vergisting</title>' +
110 '</head>' +
111 '<body>' + content + '</body></html>';
112 document.write(pageContent);
113 document.close();
114 newWindow.print();
115 });
116 $('#print').jqxButton({ template: 'primary', width: 125, theme: theme });
117
118 $('#pdfButton').click(function() {
119 $('#ispindel_chart').jqxChart('saveAsPDF', 'vergisting_' + my_code + '.pdf', getExportServer());
120 });
121 $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme });
122
123 $('#pngButton').click(function() {
124 $('#ispindel_chart').jqxChart('saveAsPNG', 'vergisting_' + my_code + '.png', getExportServer());
125 });
126 $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme });
127
128 $('#Close').jqxButton({ template: 'success', width: 125, theme: theme });
129 $('#Close').click(function() {
130 window.close();
131 });
132 });
133

mercurial