diff --git a/data.js b/data.js index 40e10a5..29b3baa 100644 --- a/data.js +++ b/data.js @@ -5,7 +5,9 @@ var tempScale={"Steak": {'info':'Myoglobin denatures 60-70\xB0 C','position':2}, {'info':'Actin denatures 70-120\xB0 C','position':1}, {'info':'Browning reactions occur 120+\xB0 C','position':0}], + "Tuna": + [{'info':'lack of protein denaturization below 40\xB0 C','position':5}, {'info':'Myosin breaks down 40-50\xB0 C','position':4}, {'info':'Myocommata begins to rupture 50\xB0 C','position':3}, @@ -27,6 +29,7 @@ var tempScale={"Steak": {'info':'Actin denatures 70-120\xB0 C','position':1}, {'info':'Browning reactions occur 120+\xB0 C','position':0}], + }; //color @@ -39,6 +42,7 @@ var color = { d3.scale.linear() .domain([0,1,5,9,10]) .range(['#692901','#FAEEE6','#FA3491', '#FAEEE6','#692901']), + "Turkey": d3.scale.linear() .domain([0,1,5,9,10]) @@ -46,7 +50,9 @@ var color = { "Tofu": d3.scale.linear() .domain([0,1,5,9,10]) + + .range(['#DE843A','#F7DEC8','#F5F2F0','#F7DEC8','#DE843A']) }; //boundaries where color change occurs -var boundaries= {"Steak":[120,70,60,55,40], "Tuna": [90,70,60,50,40],"Turkey":[120,70,60,55,40],"Tuna":[120,70,60,55,40]}; \ No newline at end of file +var boundaries= {"Steak":[120,70,60,55,40], "Tuna": [90,70,60,50,40],"Turkey":[120,70,60,55,40],"Tuna":[120,70,60,55,40]}; diff --git a/graph.js b/graph.js index 0d08348..b85a43f 100644 --- a/graph.js +++ b/graph.js @@ -131,7 +131,7 @@ var svg = d3.select("body").append("svg") .attr("x", width/1.3) .attr("y", -margin.top/2) .style("font-size",'30px') - .text("Steak temperature is: ______\xB0C"); + .text(meatType+ " temperature is: ______\xB0C"); var layer = svg.selectAll(".layer") .data(layers) @@ -170,8 +170,8 @@ var rect = layer.selectAll("rect") var Offset = document.getElementById("graphSteak").offsetTop; var pos=parseInt(data[0].length-(event.pageY-Offset-margin.top)/(height/yStackMax)); var line=parseInt((event.pageX-margin.left)/(x.rangeBand()+1)-4.0); -$(d3.select('.mylabel')[0][0]).text("Steak temperature is "+ data[line][pos].toFixed(2)+ "\xB0C"); - +$(d3.select('.mylabel')[0][0]).text( meatType+ " temperature is "+ data[line][pos].toFixed(2)+ "\xB0C"); + //$(d3.select('.mylabel')[0][0]).text("Steak temperature is "+ line.toFixed(2)+ "\xB0C"); }) @@ -236,7 +236,7 @@ svg.append("text") .attr("x", -height/3) .attr("y",-30) .attr("transform", "rotate(-90)") - .text("Steak Thickness (cm)"); + .text(meatType+" Thickness (cm)"); svg.append("text") .attr("class", "y label1") diff --git a/perfectSteak.css b/perfectSteak.css index 7278deb..729fe47 100644 --- a/perfectSteak.css +++ b/perfectSteak.css @@ -15,4 +15,9 @@ position: relative; top: 0%; float: left; +} + +#meatInp{ + position:relative; + float:left; } \ No newline at end of file diff --git a/perfectSteak.js b/perfectSteak.js index 05632b0..e722394 100644 --- a/perfectSteak.js +++ b/perfectSteak.js @@ -122,11 +122,14 @@ var perfectSteak = function (div) { timeFun(i); flipButtonFun(i); } + model.dataClear(); addButtonFun(); subButtonFun(); CookButtonFun(); }; + + var addRow = function (table) { flipButton = $(""); var row = $(""); @@ -145,12 +148,19 @@ var perfectSteak = function (div) { table.append(row); inp1.val(23); inp2.val(23); + if (numRows==2){ + subButton = $(""); + table.append(subButton); + subButtonFun(); + } model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]) } + + var delRow = function (table) { - $('.' + table.class + ' tr:last').remove(); } + var addButtonFun = function () { addButton.on("click", function () { numRows++; @@ -159,7 +169,6 @@ var perfectSteak = function (div) { }; var subButtonFun = function () { - subButton.on("click", function () { numRows--; delRow($(".inputTable")); @@ -168,7 +177,6 @@ var perfectSteak = function (div) { buildTable(numRows); subButton.remove(); } else { - $(".inputTable").empty(); buildTable(numRows); } @@ -214,7 +222,8 @@ var perfectSteak = function (div) { model.changeThickness(parseFloat($("#thicknessInp").val())) }; - + //add to on click and calculate(blah,blah,blah, meatType) + var meatType = $("input[type='radio'][name='rate']:checked").val(); //THIS WILL COOK THE STEAK IF WE HAVE VALID INPUTS if (OKtoCook==true){ var steak = [model.data[0][1]]; @@ -222,7 +231,7 @@ var perfectSteak = function (div) { steak.push(parseFloat($("#steakTemp").val())) } steak.push(model.data[0][2]); - calculate(model.data, steak) + calculate(model.data, $("input[type='radio'][name='rate']:checked").val()||steak) } }); } @@ -264,13 +273,21 @@ var perfectSteak = function (div) { //timeFun(0); view.buildTable(); + var thicknessInp = ($("
Meat Thickness (cm)
")); var steakTemp = ($("
Initial Meat Temperature (°C)
")); + //Item to hold inputs of meat. Append meatInput to your display + var meatInput=$('
What color type of meat are you cooking?
' + +'Steak
' + +'Tuna
' + +'Turkey
' + +'Tofu
'); + // thicknessInp.change(function(){ // model.changethickness(thicknessInp.val()); // }) - div.append(thicknessInp, steakTemp); + div.append(thicknessInp, steakTemp, meatInput); }; return { setup: setup diff --git a/sample.js b/sample.js index 11adaef..e0d444a 100644 --- a/sample.js +++ b/sample.js @@ -1,5 +1,5 @@ -var calculate=function(data,steak,meatType){ - +var calculate=function(data,steak){ +var meatType="fish"; var myheatsolver = HeatSolver(steak); console.log(data);