-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4632369
commit d2b43a6
Showing
4 changed files
with
71 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
function load_listeners(){ | ||
document.getElementById("RD").addEventListener("click", switch_RD); | ||
document.getElementById("BD").addEventListener("click", switch_BD); | ||
document.getElementById("stop").addEventListener("click", stop_sim); | ||
//document.getElementById("clear_graph").addEventListener("click", clear_graph); | ||
} | ||
function switch_RD(){ | ||
clear_grid(); | ||
clear_stats(); | ||
clear_graph(); | ||
global_choose_deposition = 'RD'; | ||
//document.getElementById("describe-deposition") | ||
// .innerHtml = "random deposition"; | ||
turn_off_lights(); | ||
document.getElementById("rndtitle").style.color = "red"; | ||
} | ||
function switch_BD(){ | ||
clear_grid(); | ||
clear_stats(); | ||
clear_graph(); | ||
global_choose_deposition = 'BD'; | ||
//document.getElementById("describe-deposition") | ||
// .innerHtml = "ballistic deposition"; | ||
turn_off_lights(); | ||
document.getElementById("baltitle").style.color = "red"; | ||
} | ||
function stop_sim(){ | ||
global_choose_deposition = null; | ||
} | ||
function turn_off_lights(){ | ||
document.getElementById("rndtitle").style.color = ""; | ||
document.getElementById("baltitle").style.color = ""; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | ||
<script type="text/javascript" src="js/mersenne-twister.js"></script> | ||
<script> | ||
; | ||
//var randomNumber = m.random(); | ||
|
||
MT = new MersenneTwister(); | ||
var labels = []; | ||
var histo = []; | ||
nbin = 100; | ||
nthrow = 1000; | ||
for( var i=0; i<nbin; i++){ | ||
labels[i] = i; | ||
histo[i] = 0; | ||
} | ||
for(var i=0; i<nthrow; i++){ | ||
var rnd = MT.random()*nbin; | ||
var num = Math.floor(rnd)%nbin; | ||
//console.log(num); | ||
histo[num]++; | ||
} | ||
for(var i=0; i<nbin; i++){ | ||
histo[i] -= nthrow/nbin; | ||
} | ||
console.log(histo); | ||
|
||
|
||
</script><canvas id="myChart" width="100" height="100"></canvas> | ||
<script> | ||
var ctx = document.getElementById("myChart").getContext('2d'); | ||
var myChart = new Chart(ctx, { | ||
type: 'bar', | ||
data: { | ||
labels: labels, | ||
datasets: [{ | ||
label: '# of Votes', | ||
data: histo, | ||
}] | ||
}, | ||
options: { | ||
scales: { | ||
yAxes: [{ | ||
ticks: { | ||
beginAtZero:true | ||
} | ||
}] | ||
} | ||
} | ||
}); | ||
</script> |