www/js/log_co2pressure.js

changeset 527
9dfefad3ae1d
parent 507
17f244137a9b
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: 'temperature', type: 'float' },
45 { name: 'pressure', type: 'float' },
46 { name: 'uuid', type: 'string' }
47 ],
48 url: 'getco2pressurelog.php?code=' + my_code + '&name=' + my_name
49 },
50 dataAdapter = new $.jqx.dataAdapter(sourceA, {
51 autoBind: true,
52 async: false,
53 loadComplete: function() {
54 $('#jqxLoader').jqxLoader('close');
55 },
56 loadError: function(jqXHR, status, error) {
57 }
58 }),
59 settings = {
60 title: my_code + ' "' + my_name + '"',
61 description: '',
62 source: dataAdapter,
63 xAxis: {
64 dataField: 'date',
65 type: 'date',
66 formatFunction: function(value) {
67 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear();
68 },
69 toolTipFormatFunction: function(value) {
70 var h = value.getHours(), m = value.getMinutes();
71 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() +
72 ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
73 },
74 textRotationAngle: 45,
75 howGridLines: false
76 },
77 colorScheme: 'scheme01',
78 seriesGroups: [
79 {
80 type: 'area',
81 valueAxis: { minValue: 0, displayValueAxis: false, description: 'Druk in bar' },
82 series: [{ dataField: 'pressure', lineWidth: 1, displayText: 'Druk', opacity: 0.4 }]
83 },
84 {
85 type: 'spline',
86 valueAxis: { minValue: 0, description: 'Graden C' },
87 series: [{ dataField: 'temperature', lineWidth: 1, displayText: 'Temperatuur' }]
88 }
89 ]
90 };
91 $('#pressure_chart').jqxChart(settings);
40 92
41 var sourceA = { 93 $('#print').click(function() {
42 datatype: "json", 94 var content = $('#pressure_chart')[0].outerHTML,
43 datafields: [ 95 newWindow = window.open('', '', 'width=865, height=425'),
44 { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, 96 document = newWindow.document.open(),
45 { name: "temperature", type: "float" }, 97 pageContent =
46 { name: "pressure", type: "float" }, 98 '<!DOCTYPE html>' +
47 { name: "uuid", type: "string" } 99 '<html>' +
48 ], 100 '<head>' +
49 url: 'getco2pressurelog.php?code=' + my_code + '&name=' + my_name 101 '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
50 }, 102 '<meta charset="utf-8" />' +
51 dataAdapter = new $.jqx.dataAdapter(sourceA, { 103 '<title>' + my_code + ' ' + my_name + ' hergisting</title>' +
52 autoBind: true, 104 '</head>' +
53 async: false, 105 '<body>' + content + '</body></html>';
54 loadComplete: function () { 106 document.write(pageContent);
55 $('#jqxLoader').jqxLoader('close'); 107 document.close();
56 }, 108 newWindow.print();
57 loadError: function (jqXHR, status, error) { 109 });
58 } 110 $('#print').jqxButton({ template: 'primary', width: 125, theme: theme });
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(),
72 m = value.getMinutes();
73 return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear()
74 + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
75 },
76 textRotationAngle: 45,
77 howGridLines: false
78 },
79 colorScheme: 'scheme01',
80 seriesGroups: [
81 {
82 type: "area",
83 valueAxis: {
84 minValue: 0,
85 displayValueAxis: false,
86 description: "Druk in bar"
87 },
88 series: [
89 { dataField: "pressure", lineWidth: 1, displayText: "Druk", opacity: 0.4 }
90 ]
91 },
92 {
93 type: 'spline',
94 valueAxis: {
95 minValue: 0,
96 description: 'Graden C'
97 },
98 series: [
99 { dataField: "temperature", lineWidth: 1, displayText: "Temperatuur" }
100 ]
101 }
102 ]
103 };
104 $("#pressure_chart").jqxChart(settings);
105 111
106 $("#print").click(function () { 112 $('#pdfButton').click(function() {
107 var content = $("#pressure_chart")[0].outerHTML, 113 $('#pressure_chart').jqxChart('saveAsPDF', 'hergisting_' + my_code + '.pdf', getExportServer());
108 newWindow = window.open("", "", "width=865, height=425"), 114 });
109 document = newWindow.document.open(), 115 $('#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 + ' hergisting</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 116
117 $('#pngButton').click(function() {
118 $('#pressure_chart').jqxChart('saveAsPNG', 'hergisting_' + my_code + '.png', getExportServer());
119 });
120 $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme });
125 121
126 $("#pdfButton").click(function () { 122 $('#Close').jqxButton({ template: 'success', width: 125, theme: theme });
127 $("#pressure_chart").jqxChart("saveAsPDF", "hergisting_"+my_code+".pdf", getExportServer()); 123 $('#Close').click(function() {
128 }); 124 window.close();
129 $("#pdfButton").jqxButton({ template: "primary", width: 125, theme: theme }); 125 });
130
131 $("#pngButton").click(function () {
132 $("#pressure_chart").jqxChart("saveAsPNG", "hergisting_"+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 }); 126 });
141 127

mercurial