-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (51 loc) · 1.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.plot.ly/plotly-2.11.1.min.js"></script>
<script src="https://d3js.org/d3.v7.min.js"></script>
<meta charset="UTF-8">
<title>CAC scoring</title>
</head>
<body>
<div id="myDiv" style="width:100%;height:100vh;">
</div>
<script>
d3.json('./data/poster.json').then(_poster=> {
const poster = {};
_poster.forEach(p=>{
poster[p.id] = p;
});
d3.json('./data/poster-survey.json').then(data => {
const highest = {}
const groupsPerson = d3.groups(data, d => d.presenter_id).map(d => [d[0], d3.mean(d[1], e => e.criteria_1)]);
groupsPerson.sort((a,b)=>-a[1]+b[1])
const maxSubmit = d3.max(groupsPerson, d => d[1]);
groupsPerson.filter(d=>d[1]===maxSubmit).forEach(d=>highest[d[0]]=true);
const plotdata = [{
x: groupsPerson.map(d => `Poster#${(+d[0])} <br> ${poster[d[0]].name}`),
y: groupsPerson.map(d => d[1]),
type: 'bar',
text: groupsPerson.map((d,i) => i>4?'':Math.round(d[1]*10)/10),
textposition: 'auto',
marker:{
color: groupsPerson.map(d => highest[d[0]]?'rgba(222,45,38,0.8)':'#4682b49e')
},
}];
var layout = {
title: 'CAC Poster scoring',
barmode: 'group',
showlegend: false,
margin: {
l: 50,
r: 50,
b: 100,
t: 100
},
xaxis: {tickvals:groupsPerson.map(d => `Poster#${(+d[0])} <br> ${poster[d[0]].name}`),ticktext:groupsPerson.map((d,i) => (i>4?'':`Poster#${(+d[0])} <br> ${poster[d[0]].name}`))}
};
Plotly.newPlot('myDiv', plotdata, layout);
})
})
</script>
</body>
</html>