www/js/log_ispindel.js

changeset 580
9cd6873bda75
child 591
28738f44d42e
equal deleted inserted replaced
579:1253a237b620 580:9cd6873bda75
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' },
83 series: [{ dataField: 'sg', lineWidth: 3, displayText: 'SG' }]
84 },
85 {
86 type: 'spline',
87 valueAxis: { displayValueAxis: false, description: 'Graden C' },
88 series: [{ dataField: 'temperature', lineWidth: 1, displayText: 'Temperatuur' }]
89 }
90 ]
91 };
92 $('#ispindel_chart').jqxChart(settings);
93
94 $('#print').click(function() {
95 var content = $('#ispindel_chart')[0].outerHTML,
96 newWindow = window.open('', '', 'width=865, height=425'),
97 document = newWindow.document.open(),
98 pageContent =
99 '<!DOCTYPE html>' +
100 '<html>' +
101 '<head>' +
102 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
103 '<meta charset="utf-8" />' +
104 '<title>' + my_code + ' ' + my_name + ' vergisting</title>' +
105 '</head>' +
106 '<body>' + content + '</body></html>';
107 document.write(pageContent);
108 document.close();
109 newWindow.print();
110 });
111 $('#print').jqxButton({ template: 'primary', width: 125, theme: theme });
112
113 $('#pdfButton').click(function() {
114 $('#ispindel_chart').jqxChart('saveAsPDF', 'vergisting_' + my_code + '.pdf', getExportServer());
115 });
116 $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme });
117
118 $('#pngButton').click(function() {
119 $('#ispindel_chart').jqxChart('saveAsPNG', 'vergisting_' + my_code + '.png', getExportServer());
120 });
121 $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme });
122
123 $('#Close').jqxButton({ template: 'success', width: 125, theme: theme });
124 $('#Close').click(function() {
125 window.close();
126 });
127 });
128

mercurial