-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbCagliata.html
184 lines (183 loc) · 6.63 KB
/
dbCagliata.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- link href="css/pms.css" rel="stylesheet" type="text/css" / -->
<script src="js/plotly-2.24.1.min.js"></script>
<!-- script src="js/fast-stats.js"></script -->
<!-- script src="js/sfunc.js"></script -->
<!-- script src="js/sprintf.js"></script -->
<!-- script src="js/readers.js"></script -->
<!-- script src="js/d3.v7.min.js"></script -->
<title>Dashboard, beta Version</title>
<style>
.resizable {
resize: both;
/*
overflow: scroll;
border: 1px solid black;
*/
width: 600px;
height: 300px;
}
</style>
</head>
<body>
<h1>Dashboard Cagliata, beta-Version</h1>
Aus GQMS-Bericht von den interessierenden Chargen die Spalten
von Charge bis EW markieren, kopieren und in das Datenfeld einfügen. Dann
"Make" drücken
<table>
<tr>
<td>Daten</td>
<td>
<textarea id="tdata" rows="8" cols="135"></textarea>
</td>
</tr>
<tr>
<td><button onclick="makeDiag()">Make</button></td>
<td><button onclick="makeImg('myDiv', 'jpg-export')">Copy</button></td>
</tr>
</table>
<table>
<tr>
<td><div id="pHDiv" class="resizable" onresize="doResize(this)"></div></td>
<td><div id="TSDiv" class="resizable" onresize="doResize(this)"></div></td>
<td><div id="FiTrDiv" class="resizable" onresize="doResize(this)"></div></td>
</tr>
<tr>
<td><div id="SalzDiv" class="resizable" onresize="doResize(this)"></div></td>
<td><div id="FettDiv" class="resizable" onresize="doResize(this)"></div></td>
<td><div id="ProtDiv" class="resizable" onresize="doResize(this)"></div></td>
</tr>
</table>
</body>
<script>
let specRanges = [
{
'HF' : 'HF Bio Cagliata 45% Dalton DF 15kg',
'pH' : ['5.55','5.85'],
'TS' : ['55', '58'],
'FiTr': ['45','48'],
'Salz': ['0.5','0.8'],
'Fett': ['26','28'],
'Prot': ['','']
},
{
'HF' : 'HF Bio Cagliata 45% Dalton DF 15kg',
'pH' : ['',''],
'TS' : ['', ''],
'FiTr': ['',''],
'Salz': ['',''],
'Fett': ['',''],
'Prot': ['','']
},
];
let sections = [
{
name : 'pH', // Switch to 'pH nach Turm' for Cagliata types
title: 'pH nach Turm',
div: 'pHDiv',
},
{
name: 'TS',
title: 'TS',
div: 'TSDiv',
},
{
name : 'FiTr',
title: 'Fett in TS',
div: 'FiTrDiv',
},
{
name : 'Salz',
title: 'Salz',
div: 'SalzDiv',
},
{
name : 'Fett',
title: 'Fett',
div: 'FettDiv',
},
{
name : 'Prot',
title: 'Protein',
div: 'ProtDiv',
},
];
function addLimits(sampleData, limits){
limits.forEach(function(limit){
sampleData.push({
type: 'scatter',
x: [0, 2],
y: [limit, limit],
xaxis: 'x2',
mode: 'lines',
showlegend: false,
line: {
color: 'red',
width: 2,
dash: 'dash'
}
});
});
return sampleData;
}
function demoReader(inText){
let sampleData = {}
inText.trim().split('\n').
forEach(function(line){
let key= ''
let values = [];
if (line ==='') return;
let fields = line.trim().split(/[\t;]/);
key = 'C'+(fields.shift()-0);
kf = fields.shift();
if (!(key in sampleData)) sampleData[key] = {};
if (!(kf in sampleData[key])) sampleData[key][kf]= {}
if ( (fields.length >3)&& fields[3] !=='')
sampleData[key][kf].pH = parseFloat((fields[3].replace(',', '.')));
if( fields.length > 11){
if(fields[ 5] !=='') sampleData[key][kf].TS = parseFloat((fields[ 5].replace(',', '.')));
if(fields[ 6] !=='') sampleData[key][kf].Fett = parseFloat((fields[ 6].replace(',', '.')));
if(fields[ 7] !=='') sampleData[key][kf].FiTr = parseFloat((fields[ 7].replace(',', '.')));
if(fields[ 8] !=='') sampleData[key][kf].Salz = parseFloat((fields[ 8].replace(',', '.')));
if(fields[11] !=='') sampleData[key][kf].Prot = parseFloat((fields[11].replace(',', '.')));
}
//sampleData[key][
});
console.log('Ready reading data');
//console.log(sampleData);
return sampleData;
}
function makeDiag(){
let plotData = [];
sampleData = demoReader( document.getElementById('tdata').value );
// Loop over sections
sections.forEach(function(section){
let layout = [];
let plotData = [];
layout.title = section.title;
layout.xaxis = { type: 'category'};
layout.xaxis2 = {overlaying: 'x', range: [0,1], showticklabels: false};
Object.keys(sampleData).forEach(function(key){
let data = [];
Object.keys(sampleData[key]).forEach(function(kf){
let ds = sampleData[key][kf];
if( section.name in ds) data.push(ds[section.name]);
});
plotData.push({
type: 'box',
boxpoints : 'suspectedoutliers',
boxmean : 'sd',
showlegend: false,
y : data,
name : key,
});
});
// FIXME plotData = addLimits(plotData, section.limits);
Plotly.newPlot(section.div, plotData, layout, {editable: true, responsive: true})
});
}
</script>
</html>