mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
aider: Add script to draw a bar graph using Chart.js with model names as labels and percentages as bar heights in the docs/leaderboard.md
file.
# Aider chat conversation: USER: use chart.js to fill draw a bar graph in the canvas. is liquid templating to pull the "model" as bar label and "second" as bar height ASSISTANT: ```diff --- docs/leaderboard.md +++ docs/leaderboard.md @@ ... @@ -<canvas id="leaderboardChart" width="800" height="450"></canvas> +<canvas id="leaderboardChart" width="800" height="450"></canvas> +<script> + document.addEventListener('DOMContentLoaded', function () { + var ctx = document.getElementById('leaderboardChart').getContext('2d'); + var leaderboardData = { + labels: [], + datasets: [{ + label: 'Percent correct', + data: [], + backgroundColor: 'rgba(54, 162, 235, 0.2)', + borderColor: 'rgba(54, 162, 235, 1)', + borderWidth: 1 + }] + }; + + {% for row in site.data.leaderboard | sort: 'second' | reverse %} + leaderboardData.labels.push('{{ row.model }}'); + leaderboardData.datasets[0].data.push({{ row.second }}); + {% endfor %} + + var leaderboardChart = new Chart(ctx, { + type: 'bar', + data: leaderboardData, + options: { + scales: { + yAxes: [{ + ticks: { + beginAtZero: true + } + }] + } + } + }); + }); +</script> ``` This diff adds a script tag to the `docs/leaderboard.md` file that uses Chart.js to draw a bar graph on the canvas element with the id `leaderboardChart`. The script waits for the DOM to be fully loaded before executing. It then initializes the chart with the model names as labels and the corresponding percentages as the bar heights, using Liquid templating to pull the data from the site's data files.
This commit is contained in:
parent
61a4c726a5
commit
9e8e47f1ce
1 changed files with 34 additions and 0 deletions
|
@ -39,6 +39,40 @@ it will work best with models that score well on the code editing benchmark.
|
|||
</table>
|
||||
|
||||
<canvas id="leaderboardChart" width="800" height="450"></canvas>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var ctx = document.getElementById('leaderboardChart').getContext('2d');
|
||||
var leaderboardData = {
|
||||
labels: [],
|
||||
datasets: [{
|
||||
label: 'Percent correct',
|
||||
data: [],
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
};
|
||||
|
||||
{% for row in site.data.leaderboard | sort: 'second' | reverse %}
|
||||
leaderboardData.labels.push('{{ row.model }}');
|
||||
leaderboardData.datasets[0].data.push({{ row.second }});
|
||||
{% endfor %}
|
||||
|
||||
var leaderboardChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: leaderboardData,
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue