added chart

This commit is contained in:
Kenneth Jao 2018-02-03 23:00:40 -05:00
parent 0b812dfd7e
commit 5551469c94
3 changed files with 61 additions and 24 deletions

View File

@ -203,11 +203,6 @@ a {
grid-gap: 2vh; grid-gap: 2vh;
} }
#dataValues {
grid-template-columns: 1fr 1fr;
grid-template-rows: 2fr 5fr 2fr;
}
#home { #home {
display: block; display: block;
@ -267,6 +262,25 @@ a {
font-weight: 300; font-weight: 300;
} }
.row {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 100%;
grid-gap: 2vh;
}
#dataValues > div {
margin-bottom: 2vh;
}
#dataValues .row {
height: 20%;
}
#dataValues #dataTable {
height: 42%;
}
#langSelect { #langSelect {
grid-column: 1; grid-column: 1;
grid-row: 1; grid-row: 1;
@ -290,11 +304,6 @@ a {
margin: auto 0 auto 4vh; margin: auto 0 auto 4vh;
} }
#dataTable {
grid-column: 1 / 3;
grid-row: 2;
}
#dataTableCont { #dataTableCont {
display: grid; display: grid;
font-weight: 300; font-weight: 300;

View File

@ -50,11 +50,7 @@ function updateMain(op) { // Updates the actual page.
setTimeout(function() { setTimeout(function() {
console.log(op); console.log(op);
document.getElementById(navSelect).style.display = "none"; document.getElementById(navSelect).style.display = "none";
if(op === "home") { document.getElementById(op).style.display = "block";
document.getElementById(op).style.display = "block";
} else {
document.getElementById(op).style.display = "grid";
}
setTimeout(function() { setTimeout(function() {
document.getElementById(op).style.opacity = "1"; document.getElementById(op).style.opacity = "1";
}, 30); }, 30);
@ -134,6 +130,7 @@ function generateDropOp() { // For options that change based on data.
} }
info.appendChild(p); info.appendChild(p);
info.appendChild(p2); info.appendChild(p2);
// Generate data box material. // Generate data box material.
var phonemes = Object.keys(langInfo.phonemes); var phonemes = Object.keys(langInfo.phonemes);
@ -171,6 +168,34 @@ function generateDropOp() { // For options that change based on data.
} }
info.style.opacity = "1"; info.style.opacity = "1";
dataBox.style.opacity = "1"; dataBox.style.opacity = "1";
var graphData = Object.entries(langInfo.phonemes).sort(function(a,b) {
return b[1] - a[1];
});
graphData = [graphData.map(function(a,b) {
return a[0];
}), graphData.map(function(a,b) {
return a[1];
})];
// Generate graphs.
var ctx = document.getElementById("dataGraph1").getContext("2d");
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'bar',
// The data for our dataset
data: {
labels: graphData[0],
datasets: [{
label: "Phoneme Prevalence",
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: graphData[1],
}]
},
// Configuration options go here
options: {}
});
}, 300); }, 300);
}].concat(["Select language..."].concat(data.languages)); }].concat(["Select language..."].concat(data.languages));
} }

View File

@ -27,14 +27,16 @@
<div id="home" class="optionContainer"> <div id="home" class="optionContainer">
</div> </div>
<div id="dataValues" class="optionContainer"> <div id="dataValues" class="optionContainer">
<div id="langSelect" class="card"> <div class="row">
<h2>Language</h2> <div id="langSelect" class="card">
<div option="langSelect" class="dropdown transition"> <h2>Language</h2>
<div option="langSelect" class="dropdown transition">
</div>
</div> </div>
</div> <div id="dataInfo" class="card">
<div id="dataInfo" class="card"> <h2>Info</h2>
<h2>Info</h2> <div id="langInfoCont" class="transition">
<div id="langInfoCont" class="transition"> </div>
</div> </div>
</div> </div>
<div id="dataTable" class="card"> <div id="dataTable" class="card">
@ -42,8 +44,9 @@
<div id="dataTableCont" class="transition"> <div id="dataTableCont" class="transition">
</div> </div>
</div> </div>
<canvas id="dataGraph1" class="card"></canvas> <div>
<canvas id="dataGraph2" class="card"></canvas> <canvas id="dataGraph1" class="card"></canvas>
</div>
</div> </div>
<div id="files" class="optionContainer"> <div id="files" class="optionContainer">
<div class="temp card"> <div class="temp card">