Updated leaderboard chart to dynamically fetch and populate data from a CSV file using Chart.js.

This commit is contained in:
Paul Gauthier 2024-05-04 10:14:11 -07:00
parent c28d22f9b1
commit 61a4c726a5

View file

@ -40,47 +40,6 @@ it will work best with models that score well on the code editing benchmark.
<canvas id="leaderboardChart" width="800" height="450"></canvas>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var ctx = document.getElementById('leaderboardChart').getContext('2d');
var leaderboardData = {
labels: [], // Populate with model names
datasets: [{
label: 'Percent correct',
data: [], // Populate with percent correct values
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
};
// Fetch leaderboard data and populate the chart
fetch('/_data/leaderboard.csv')
.then(function (response) {
return response.text();
})
.then(function (text) {
var rows = text.split('\n');
rows.forEach(function (row) {
var columns = row.split(',');
leaderboardData.labels.push(columns[0]);
leaderboardData.datasets[0].data.push(parseFloat(columns[1]));
});
new Chart(ctx, {
type: 'bar',
data: leaderboardData,
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
});
</script>
## Edit format