diff -r db898ec73277 -r 1e09d1d102a8 www/js/log_brew.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/log_brew.js Mon Feb 25 22:49:22 2019 +0100 @@ -0,0 +1,142 @@ +/***************************************************************************** + * Copyright (C) 2019 + * + * Michiel Broek + * + * This file is part of BMS + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Brewery Managment System is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ThermFerm; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + + +$(document).ready(function () { + + $("#jqxLoader").jqxLoader({ + width: 250, + height: 150, + isModal: true, + text: "Opmaken grafiek ...", + theme: theme + }); + $('#jqxLoader').jqxLoader('open'); + + function getExportServer() { + return "https://www.jqwidgets.com/export_server/export.php"; + } + + var sourceA = { + datatype: "json", + datafields: [ + { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, + { name: "version", type: "int" }, + { name: "code", type: "string" }, + { name: "name", type: "string" }, + { name: "pv_mlt", type: "float" }, + { name: "pv_bk", type: "float" }, + { name: "pv_hlt", type: "float" }, + { name: "pv_room", type: "float" }, + { name: "sp_mlt", type: "float" }, + { name: "sp_bk", type: "float" }, + { name: "sp_hlt", type: "float" }, + { name: "event", type: "string" } + ], + url: 'getbrewlog.php?code=' + my_code + }; + var dataAdapter = new $.jqx.dataAdapter(sourceA, { + autoBind: true, + async: false, + loadComplete: function () { + $('#jqxLoader').jqxLoader('close'); + }, + loadError: function (jqXHR, status, error) { + } + }); + + var settings = { + title: my_code + ' "' + my_name + '"', + description: "", + source: dataAdapter, + xAxis: { + dataField: 'date', + type: 'date', + formatFunction: function (value) { + return value.getHours() + ':' + value.getMinutes(); + }, + toolTipFormatFunction: function (value) { + var h = value.getHours(); + var m = value.getMinutes(); + return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() + + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); + }, + textRotationAngle: 300, + }, + colorScheme: 'scheme01', + seriesGroups: [ + { + type: 'spline', + valueAxis: { + minValue: 0, + description: 'Graden C' + }, + series: [ + { dataField: "pv_mlt", lineWidth: 2, displayText: "MLT" }, + { dataField: "sp_mlt", lineWidth: 1, displayText: "mlt", opacity: 0.7 }, + { dataField: "pv_bk", lineWidth: 2, displayText: "BK" }, + { dataField: "sp_bk", lineWidth: 1, displayText: "bk", opacity: 0.7 }, + { dataField: "pv_hlt", lineWidth: 1, displayText: "HLT" }, + { dataField: "sp_hlt", lineWidth: 1, displayText: "hlt", opacity: 0.7 }, + { dataField: "pv_room", lineWidth: 1, displayText: "Room", opacity: 0.5 } + ] + } + ] + }; + $("#brew_chart").jqxChart(settings); + + $("#print").click(function () { + var content = $("#brew_chart")[0].outerHTML; + var newWindow = window.open("", "", "width=865, height=425"), + document = newWindow.document.open(), + pageContent = + '' + + '' + + '' + + '' + + '' + + 'jQWidgets Chart' + + '' + + '' + content + ''; + document.write(pageContent); + document.close(); + newWindow.print(); + }); + $("#print").jqxButton({ template: "primary", width: 125, theme: theme }); + + + $("#pdfButton").click(function () { + $("#brew_chart").jqxChart("saveAsPDF", "brouw_"+my_code+".pdf", getExportServer()); + }); + $("#pdfButton").jqxButton({ template: "primary", width: 125, theme: theme }); + + $("#pngButton").click(function () { + $("#brew_chart").jqxChart("saveAsPNG", "brouw_"+my_code+".png", getExportServer()); + }); + $("#pngButton").jqxButton({ template: "primary", width: 125, theme: theme }); + + $("#Close").jqxButton({ template: "success", width: 125, theme: theme }); + $("#Close").click(function () { + window.close(); + }); +}); +