Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Amalene committed Aug 12, 2013
2 parents dfbd071 + 8939dc7 commit f044caa
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 20 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ var rect = layer.selectAll("rect")


var Offset = document.getElementById("graphSteak").offsetTop;
var pos=parseInt(data[0].length-(event.pageY-Offset-margin.top-300)/(height/yStackMax));
var pos=parseInt(data[0].length-(event.pageY-Offset-margin.top-340)/(height/yStackMax));
var line=parseInt((event.pageX-parseFloat($("body").css('margin-left'))-margin.left)/(x.rangeBand()+1.2)-1.5);
console.log(line);
$("line").remove();
var myLine = d3.selectAll(".mysteak").append("svg:line")
.attr("x1", margin.left)
.attr("y1", event.pageY-Offset-295)
.attr("y1", event.pageY-Offset-342)
.attr("x2", width*32/30)
.attr("y2", event.pageY-Offset-295)
.attr("y2", event.pageY-Offset-342)
.style("z-index",-1)
.style("stroke", "grey");
//console.log(d3.event.pageX-parseFloat($("body").css('margin-left')));
Expand All @@ -205,7 +205,7 @@ console.log(line);
ttip.html(toF(parseFloat(data[line][pos])).toFixed(2)+ "\xB0F") }
else{
ttip.html(parseFloat(data[line][pos]).toFixed(2)+ "\xB0C")}
// ttip.html(line.toFixed(2)+ "\xB0C")
// ttip.html(pos.toFixed(2)+ "\xB0C")

ttip.style("opacity", 1)
.style("left", (d3.event.pageX-parseFloat($("body").css('margin-left'))+10) + "px")
Expand Down
13 changes: 8 additions & 5 deletions perfectSteak.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.inputTable{
#table{
position: relative;
width: 100% !important;
width: 95% !important;
text-align: center;
top: 0px !important;
padding: 0px !important;
margin: 0px!important;

height:260px;
overflow-y:auto;
overflow-x:hidden
}

.displayDiv{
Expand Down Expand Up @@ -96,10 +98,11 @@ input[type="radio"].toggle-right + label {

#recipeName{
width: 200px !important;

}
.containerm{
width:100%;
height:100px;
height:260px;
}


Expand Down Expand Up @@ -152,7 +155,7 @@ input[type="text"] {
border: 1px solid black;
font-size: 12px;
width:100% !important;
height:100px !important;
height:300px !important;

}

Expand Down
57 changes: 49 additions & 8 deletions perfectSteak.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,42 @@ var perfectSteak = function (div) {

var timeStep = 15;
var inputTable = $(".inputTable");

var toC = function (F) {
return ((5 / 9) * (F - 32));
}
var toC = function (F) {
return ((5 / 9) * (F - 32));
}
var importRecipes=function(){
var saved=[{"name":"Heston Blumenthal","data":[[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[15,73,300],[15,300,73],[300,73,73]],"Temp":73},
{"name":"4 minutes a side","data":[[240,300,73],[240,73,300],[300,73,73]],"Temp":73},
{"name":"America's Test Kitchen","data":[[15,450,73],[15,73,450],[300,225,225],[900,73,73]],"Temp":73},
{"name":"Nathan Mhyrvold","data":[[3600,125,125],[30,-321,-321],[120,390,390]],"Temp":73}];
for (var i=0;i<4;i++){
var name=saved[i]["name"];
var data=saved[i]["data"];


for(var n=0;n<data.length;n++)
{
data[n][1]=toC(data[n][1]);
data[n][2]=toC(data[n][2]);
}

var steaktemp=saved[i]["Temp"];
var steak = [data[0][1]];
for (var m = 0; m < 30; m++) {
steak.push(toC(steaktemp))
}
steak.push(data[0][2]);
var myheatsolver = HeatSolver(steak);
var Thedata = myheatsolver.sixty_graph_arrays_duration(data);
var maxTemps = Thedata.maxTemps;
var meatType = "Steak";
var recipe = [meatType, maxTemps, data, steaktemp,3,'F'];
addRecipe(name, recipe);
}
}
var changeThickness = function (newVal) {

currentInfo["thickness"] = newVal;
Expand Down Expand Up @@ -122,7 +157,9 @@ var perfectSteak = function (div) {

var steak = [currentInfo["data"][0][1]];
for (var m = 0; m < parseFloat($("#thicknessInp").val()) * 10; m++) {
steak.push(parseFloat($("#steakTemp").val()))
if($('.mytog2:checked').attr('id')=='C'){
steak.push(parseFloat($("#steakTemp").val()))}
else{steak.push(toC(parseFloat($("#steakTemp").val())))}
}
steak.push(currentInfo["data"][0][2]);
var myheatsolver = HeatSolver(steak);
Expand Down Expand Up @@ -219,7 +256,8 @@ var perfectSteak = function (div) {
var steak=[];
for(var i=0;i<parsedThickness*10;i++)
{
steak.push(startingTemp);
if(celsius=='C'){steak.push(startingTemp)}
else{steak.push(toC(startingTemp))}
}
d3.selectAll(".mysteak").remove();
d3.selectAll(".containers").remove();
Expand Down Expand Up @@ -252,7 +290,8 @@ var perfectSteak = function (div) {
addRecipe: addRecipe,
browserInfo: browserInfo,
updateTotalTime: updateTotalTime,
parseRecipe: parseRecipe
parseRecipe: parseRecipe,
importRecipes:importRecipes
}
}

Expand All @@ -279,7 +318,7 @@ var perfectSteak = function (div) {
}
model.browserInfo(M);
})();

model.importRecipes();
var clicked = false;
var displayDiv = $("<div class='displayDiv'></div>");
var tableTabs = $('<ul class="nav nav-tabs"><li><a href="#table" data-toggle="tab">Table</a></li><li><a href="#text" data-toggle="tab">Text</a></li></ul>');
Expand All @@ -304,7 +343,7 @@ var perfectSteak = function (div) {
$('#si1').html("Side 1 (&#176;" + $('.mytog2:checked').attr('id') + ")");
$('#si2').html("Side 2 (&#176;" + $('.mytog2:checked').attr('id') + ")");
$('#work').html("&#176;" + $('.mytog2:checked').attr('id'));
graph(false, $('.mytog:checked').attr('id'));
//graph(false, $('.mytog:checked').attr('id'));
});
var addButton;

Expand Down Expand Up @@ -359,7 +398,7 @@ var perfectSteak = function (div) {
console.log(info);
d3.selectAll('.finalsteak').remove();

drawFinished(info[0], info[1], info[2], info[3], 0,info[4],info[4]);
drawFinished(info[0], info[1], info[2], info[3], 0,info[4],info[5]);
var inf = model.currentInfo['recipe'][name2];
drawFinished(inf[0], inf[1], inf[2], inf[3], 1,inf[4],inf[5]);
});
Expand Down Expand Up @@ -685,7 +724,9 @@ var perfectSteak = function (div) {
if (OKtoCook == true) {
var steak = [model.currentInfo["data"][0][1]];
for (var m = 0; m < parseFloat($("#thicknessInp").val()) * 10; m++) {
steak.push(parseFloat($("#steakTemp").val()))
if($('.mytog2:checked').attr('id')=='C'){
steak.push(parseFloat($("#steakTemp").val()))}
else{steak.push(toC(parseFloat($("#steakTemp").val())))}
}
steak.push(model.currentInfo["data"][0][2]);

Expand Down
9 changes: 6 additions & 3 deletions sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
with the function graphSteak
*/
var calculate=function(data,steak,meatType,first,totalTime,mode){

//sets the parameters for the iterations of the diffusion equations.
//parameters are initially set to a timestep of 1 second and a spacestep of 1mm,
//but these can be increased with minimal error if calculation time is too great
Expand All @@ -13,14 +14,16 @@ var calculate=function(data,steak,meatType,first,totalTime,mode){
{
return ((5/9)*(F-32));
}
if(mode!='C'){
if(mode=='F'){

for(var i=0;i<data.length;i++)
{
data[i][1]=toC(data[i][1]);
data[i][2]=toC(data[i][2]);
}
console.log(data);
}

var timestep = 1;
var spacestep = 1;
while(totalTime/timestep > 10000){
Expand All @@ -46,11 +49,11 @@ var calculate=function(data,steak,meatType,first,totalTime,mode){
var timestep=1/Thedata.step;
var maxTemps=Thedata.maxTemps;

if(first){
/* if(first){
drawFinished(meatType,maxTemps,data,steak[0],0,(steak.length-2)/10,'C');
drawFinished(meatType,maxTemps,data,steak[0],1,(steak.length-2)/10,'C');
}

*/
graphSteak(sampledata,flame,timestep,meatType,maxTemps,mode);


Expand Down

0 comments on commit f044caa

Please sign in to comment.