var OL3040JSON = []; var OW3040JSON = []; var IL3040JSON = []; var IW3040JSON = []; var R123040JSON = []; var R343040JSON = []; var Rau3040JSON = []; var OL3030JSON = []; var OW3030JSON = []; var IL3030JSON = []; var IW3030JSON = []; var R123030JSON = []; var R343030JSON = []; var Rau3030JSON = []; var OL2121JSON = []; var OW2121JSON = []; var IL2121JSON = []; var IW2121JSON = []; var R122121JSON = []; var R342121JSON = []; var Rau2121JSON = []; var OL2121CJSON = []; var OW2121CJSON = []; var IL2121CJSON = []; var IW2121CJSON = []; var R122121CJSON = []; var R342121CJSON = []; var Rau2121CJSON = []; var rows = []; function dispChart(binder, values, bezeichnerArr, lblText){ setTimeout(function () { chart = c3.generate({ bindto: binder, data: { json: values, keys: { x: 'code', value: bezeichnerArr } }, axis: { x: { type: 'category', label: { text: lblText, position: "inner-center" } }, y: { tick: { format: d3.format(".2f") } }, y2: {inner: true }, color: { pattern: ['violet', 'yellow', 'red', 'green', 'blue'] } } }); }, 250); } $("body").off("click", "#btnChart1"); $("body").off("click", "#btnChart2"); $("body").off("click", "#btnChart3"); $("body").off("click", "#btnChart4"); $("body").off("click", "#btnChart5"); $("body").off("click", "#btnChart6"); $("body").off("click", "#btnChart7"); $("body").on("click", "#btnChart1", function(e){ dispChart("#chart", OL3040JSON, ['OL1', 'OL2', 'min', 'nom', 'max'], "Outer Length"); dispChart("#chart2", OW3040JSON, ['OW1', 'OW2', 'min', 'nom', 'max'], "Outer Width"); }); $("body").on("click", "#btnChart2", function(e){ dispChart("#chart", IL3040JSON, ['OL1', 'OL2', 'min', 'nom', 'max'], "Inner Length"); dispChart("#chart2", IW3040JSON, ['OW1', 'OW2', 'min', 'nom', 'max'], "Inner Width"); }); $("body").on("click", "#btnChart3", function(e){ /* FOO */ }); $("body").on("click", "#btnChart4", function(e){ /* FOO */ }); $("body").on("click", "#btnChart5", function(e){ /* FOO */ }); $("body").on("click", "#btnChart6", function(e){ /* FOO */ }); $("body").off("click", "#btnChart7"); $("body").on("click", "#btnChart7", function(e){ rows = []; OL3040JSON = []; OW3040JSON = []; IL3040JSON = []; IW3040JSON = []; R123040JSON = []; R343040JSON = []; Rau3040JSON = []; OL3030JSON = []; OW3030JSON = []; IL3030JSON = []; IW3030JSON = []; R123030JSON = []; R343030JSON = []; Rau3030JSON = []; OL2121JSON = []; OW2121JSON = []; IL2121JSON = []; IW2121JSON = []; R122121JSON = []; R342121JSON = []; Rau2121JSON = []; OL2121CJSON = []; OW2121CJSON = []; IL2121CJSON = []; IW2121CJSON = []; R122121CJSON = []; R342121CJSON = []; Rau2121CJSON = []; var actType = $('#selTmpTyp')[0].value; var objMesswerte = HTMLTable2Array(actType); foo(objMesswerte); }); function foo(messwerte, actType){ OL3040JSON = []; OW3040JSON = []; IL3040JSON = []; IW3040JSON = []; R123040JSON = []; R343040JSON = []; Rau3040JSON = []; OL3030JSON = []; OW3030JSON = []; IL3030JSON = []; IW3030JSON = []; R123030JSON = []; R343030JSON = []; Rau3030JSON = []; OL2121JSON = []; OW2121JSON = []; IL2121JSON = []; IW2121JSON = []; R122121JSON = []; R342121JSON = []; Rau2121JSON = []; OL2121CJSON = []; OW2121CJSON = []; IL2121CJSON = []; IW2121CJSON = []; R122121CJSON = []; R342121CJSON = []; Rau2121CJSON = []; switch ( actType ){ case "3040": $.each(messwerte, function(i, item) { partNr = item.TXLCode.substring(item.TXLCode.length -4); toolNr = item.TXLCode.substring(3,5); toolpart = toolNr + "-" + partNr; OL3040JSON.push({ code: toolpart, OL1: Number(item.OL1), OL2: Number(item.OL2), min: 429.40, nom: 429.50, max: 429.60 }); OW3040JSON.push({ code: toolpart, OW1: Number(item.OW1), OW2: Number(item.OW2), min: 310.50, nom: 310.60, max: 310.70 }); IL3040JSON.push({ code: toolpart, IL1: Number(item.IL1), IL2: Number(item.IL2), min: 421.98, nom: 422.18, max: 422.38 }); IW3040JSON.push({ code: toolpart, IW1: Number(item.IW1), IW2: Number(item.IW2), min: 303.08, nom: 303.28, max: 303.48 }); }); break; case "3030": $.each(messwerte, function(i, item) { partNr = item.TXLCode.substring(item.TXLCode.length -4); toolNr = item.TXLCode.substring(3,5); toolpart = toolNr + "-" + partNr; OL3030JSON.push({ code: toolpart, OL1: Number(item.OL1), OL2: Number(item.OL2), min: 323.20, nom: 323.40, max: 323.60 }); OW3030JSON.push({ code: toolpart, OW1: Number(item.OW1), OW2: Number(item.OW2), min: 323.20, nom: 323.40, max: 323.60 }); IL3030JSON.push({ code: toolpart, IL1: Number(item.IL1), IL2: Number(item.IL2), min: 315.48, nom: 315.68, max: 315.88 }); IW3030JSON.push({ code: toolpart, IW1: Number(item.IW1), IW2: Number(item.IW2), min: 315.48, nom: 315.68, max: 315.88 }); }); break; case "2121": $.each(messwerte, function(i, item) { partNr = item.TXLCode.substring(item.TXLCode.length -4); toolNr = item.TXLCode.substring(3,5); toolpart = toolNr + "-" + partNr; OL2121JSON.push({ code: toolpart, OL: Number(item.OL), min: 222.00, nom: 222.10, max: 222.20 }); OW2121JSON.push({ code: toolpart, OW: Number(item.OW), min: 222.00, nom: 222.10, max: 222.20 }); IL2121JSON.push({ code: toolpart, IL: Number(item.IL), min: 213.78, nom: 213.98, max: 214.18 }); IW2121JSON.push({ code: toolpart, IW: Number(item.IW), min: 213.78, nom: 213.98, max: 214.18 }); }); break; case "2121C": $.each(messwerte, function(i, item) { partNr = item.TXLCode.substring(item.TXLCode.length -4); toolNr = item.TXLCode.substring(3,5); toolpart = toolNr + "-" + partNr; OL2121CJSON.push({ code: toolpart, OL: Number(item.OL), min: 217.60, nom: 217.70, max: 217.80 }); OW2121CJSON.push({ code: toolpart, OW: Number(item.OW), min: 217.60, nom: 217.70, max: 217.80 }); IL2121CJSON.push({ code: toolpart, IL: Number(item.IL), min: 213.78, nom: 213.98, max: 214.18 }); IW2121CJSON.push({ code: toolpart, IW: Number(item.IW), min: 213.78, nom: 213.98, max: 214.18 }); }); break; } } function HTMLTable2Array(type) { if ( type === "3040" || type === "3030" ) { $('#tbodyMesswerte tr').each(function(i, n){ var $row = $(n); rows.push({ TXLCode: $row.find('td:eq(0)').text().trim(), OL1: $row.find('td:eq(1)').text().trim(), OL2: $row.find('td:eq(2)').text().trim(), OW1: $row.find('td:eq(3)').text().trim(), OW2: $row.find('td:eq(4)').text().trim(), IL1: $row.find('td:eq(5)').text().trim(), IL2: $row.find('td:eq(6)').text().trim(), IW1: $row.find('td:eq(7)').text().trim(), IW2: $row.find('td:eq(8)').text().trim(), R1: $row.find('td:eq(9)').text().trim(), R2: $row.find('td:eq(10)').text().trim(), R3: $row.find('td:eq(11)').text().trim(), R4: $row.find('td:eq(12)').text().trim() }); }); } else if ( type === "2121" || type === "2121C" ) { $('#tbodyMesswerte tr').each(function(i, n){ var $row = $(n); rows.push({ TXLCode: $row.find('td:eq(0)').text().trim(), OL: $row.find('td:eq(1)').text().trim(), OW: $row.find('td:eq(2)').text().trim(), IL: $row.find('td:eq(3)').text().trim(), IW: $row.find('td:eq(4)').text().trim(), R1: $row.find('td:eq(5)').text().trim(), R2: $row.find('td:eq(6)').text().trim(), R3: $row.find('td:eq(7)').text().trim(), R4: $row.find('td:eq(8)').text().trim() }); }); } return rows; }