-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_chart_data.js
More file actions
89 lines (84 loc) · 3.08 KB
/
Copy pathget_chart_data.js
File metadata and controls
89 lines (84 loc) · 3.08 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
fetch('results.json')
.then(response => response.json())
.then(data => {
const modelNames = Object.keys(data);
const uniqueModelNames = Array.from(new Set(modelNames));
uniqueModelNames.sort();
uniqueModelNames.forEach(modelName => {
const metrics = data[modelName];
const accs = [metrics['coverage']['acc'], metrics['state'], metrics['path'], metrics['output']];
const avgAcc = accs.reduce((a, b) => a + b, 0) / accs.length * 100;
metrics['avg_acc'] = avgAcc;
});
const keys = ['avg_acc', 'consistency'];
const bgColors = ['lightblue', 'lightgreen'];
const bdColors = ['darkblue', 'darkgreen'];
var chartData = {
labels: uniqueModelNames,
datasets: ['Avg. Acc. (%)', 'IC Score'].map((key, index) => {
return {
yAxisID: `${index}`,
label: key,
data: uniqueModelNames.map(modelName => data[modelName][keys[index]]),
backgroundColor: bgColors[index],
borderColor: bdColors[index],
borderWidth: 1
}
}
)
};
var ctx = document.getElementById('chart').getContext('2d');
var myLineChart = new Chart(ctx, {
type: 'line',
data: chartData,
options: {
scales: {
x: {
grid: {
display: false
},
ticks: {
autoSkip: false,
maxRotation: 45,
minRotation: 45
}
},
'0': {
beginAtZero: true,
max: 80,
position: 'left',
title: {
display: true,
text: 'Avg. Acc. (%)',
font: {
size: 20,
style: 'normal',
lineHeight: 1.2
},
}
},
'1': {
beginAtZero: true,
max: 60,
position: 'right',
title: {
display: true,
text: 'IC Score',
font: {
size: 20,
style: 'normal',
lineHeight: 1.2
},
}
}
},
plugins: {
legend: {
position: 'top',
},
},
maintainAspectRatio: false
}
});
})
.catch(error => console.error('Error fetching JSON:', error));