removing list. using table

average
Matthew Huntington 2 years ago
parent 991c9bc55d
commit 2c23748eeb

@ -1,21 +1,22 @@
circle { circle {
r:5; r:5;
fill: black; fill: black;
} }
circle.highlighted { circle.highlighted{
fill:red; fill:red;
r:10;
} }
#container { #container {
overflow: visible; overflow: visible;
margin-bottom: 50px; margin-bottom: 50px;
} }
body { body {
margin: 20px 40px; margin: 20px 40px;
} }
table, th, td { table, th, td {
border: 1px solid black; border: 1px solid black;
} }
th, td { th, td {
padding:10px; padding:10px;
text-align: center; text-align: center;
} }

@ -33,13 +33,7 @@ const renderPoints = () => {
}) })
d3.selectAll('circle').on('click', (event, datum) => { d3.selectAll('circle').on('click', (event, datum) => {
d3.select('tbody td:nth-child(1)').html(datum.instance_id); highlightInstance(datum.instance_id);
d3.select('tbody td:nth-child(2)').html(datum.course);
d3.select('tbody td:nth-child(3)').html(datum.graduation_date);
d3.select('tbody td:nth-child(4)').html(datum.total_students);
d3.select('tbody td:nth-child(5)').html(`${datum.dropped} (${Math.floor(datum.dropped/datum.total_students*100)}%)`);
d3.select('tbody td:nth-child(6)').html(datum.graduates);
d3.select('tbody td:nth-child(7)').html(`${datum.ninety_day_outcomes} (${Math.floor(datum.ninety_day_outcomes/datum.graduates*100)}%)`);
}); });
} }
@ -80,22 +74,32 @@ const createAxes = () => {
.call(leftAxis); .call(leftAxis);
} }
const highlightInstance = (instanceID) => {
selectedInstances.push(instanceID);
for(instance of instances){
if(instance.instance_id == instanceID){
if(!instance.highlighted){
instance.highlighted = true
const tbody = d3.select('tbody');
const tr = tbody.append('tr');
tr.append('td').html(instance.instance_id);
tr.append('td').html(instance.course);
tr.append('td').html(instance.graduation_date);
tr.append('td').html(instance.total_students);
tr.append('td').html(`${instance.dropped} (${Math.floor(instance.dropped/instance.total_students*100)}%)`);
tr.append('td').html(instance.graduates);
tr.append('td').html(`${instance.ninety_day_outcomes} (${Math.floor(instance.ninety_day_outcomes/instance.graduates*100)}%)`)
}
}
}
renderPoints()
}
const createFormSubmissionHandler = () => { const createFormSubmissionHandler = () => {
d3.select('form').on('submit', (event)=>{ d3.select('form').on('submit', (event)=>{
event.preventDefault(); event.preventDefault();
const instanceID = parseInt(d3.select('input[type="text"]').property('value')) const instanceID = parseInt(d3.select('input[type="text"]').property('value'))
selectedInstances.push(instanceID); highlightInstance(instanceID);
const list = d3.select('ul');
list.html('');
for(instance of selectedInstances){
list.append('li').html(instance)
}
for(instance of instances){
if(instance.instance_id == instanceID){
instance.highlighted = true
}
}
renderPoints()
}); });
} }

@ -31,10 +31,6 @@
<input type="submit"/> <input type="submit"/>
</form> </form>
</section> </section>
<section>
<h2>Highlighted Instances</h2>
<ul></ul>
</section>
<section> <section>
<h2>Instance Details</h2> <h2>Instance Details</h2>
<table> <table>
@ -50,15 +46,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr></tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody> </tbody>
</table> </table>
</section> </section>

Loading…
Cancel
Save