mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 23:05:00 +00:00
![]() # Aider chat conversation: USER: add a bar chart using chart.js ASSISTANT: To add a bar chart using Chart.js to the `leaderboard.md` file, you will need to include the Chart.js library, prepare a canvas element where the chart will be rendered, and write the JavaScript code to create the bar chart. Here's the diff that adds these elements to the `leaderboard.md` file: ```diff --- docs/leaderboard.md +++ docs/leaderboard.md @@ ... @@ <table style="width: 90%; max-width: 800px; margin: auto; border-collapse: collapse; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: 14px;"> <!-- Table content --> </table> + +<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(','); + if (columns.length === 4) { + 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> ``` This diff adds a canvas element for the chart, includes the Chart.js library from a CDN, and provides a script that initializes the bar chart with data from the leaderboard CSV file. The script fetches the CSV data, parses it, and populates the chart with the model names and their corresponding "Percent correct" values. |
||
---|---|---|
.. | ||
benchmarks-0125.md | ||
benchmarks-1106.md | ||
benchmarks-speed-1106.md | ||
benchmarks.md | ||
commands.md | ||
conventions.md | ||
ctags.md | ||
docker.md | ||
faq.md | ||
install.md | ||
leaderboard.md | ||
llms.md | ||
repomap.md | ||
unified-diffs.md | ||
voice.md |