mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
feat: Add responsive options to the Chart.js configuration
This commit is contained in:
parent
d1dd640577
commit
1099cda9e4
1 changed files with 23 additions and 5 deletions
|
@ -40,6 +40,12 @@ top coding models, as compared to their previous "solo" scores (striped bars).
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#passRateChart {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation@1.0.2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation@1.0.2"></script>
|
||||||
{% assign sorted_data = site.data.architect | sort: "pass_rate_2" | reverse %}
|
{% assign sorted_data = site.data.architect | sort: "pass_rate_2" | reverse %}
|
||||||
|
@ -47,6 +53,11 @@ top coding models, as compared to their previous "solo" scores (striped bars).
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
var ctx = document.getElementById('passRateChart').getContext('2d');
|
var ctx = document.getElementById('passRateChart').getContext('2d');
|
||||||
|
|
||||||
|
// Function to determine aspect ratio based on screen width
|
||||||
|
function getAspectRatio() {
|
||||||
|
return window.innerWidth < 600 ? 1.5 : 2;
|
||||||
|
}
|
||||||
var labels = [];
|
var labels = [];
|
||||||
var data = [];
|
var data = [];
|
||||||
var colorMapping = {
|
var colorMapping = {
|
||||||
|
@ -84,21 +95,22 @@ top coding models, as compared to their previous "solo" scores (striped bars).
|
||||||
data.reverse();
|
data.reverse();
|
||||||
backgroundColors.reverse();
|
backgroundColors.reverse();
|
||||||
borderColors.reverse();
|
borderColors.reverse();
|
||||||
new Chart(ctx, {
|
var chart = new Chart(ctx, {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Pass Rate',
|
label: 'Pass Rate',
|
||||||
data: data,
|
data: data,
|
||||||
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
|
||||||
borderColor: 'rgba(75, 192, 192, 1)',
|
|
||||||
borderWidth: 1,
|
|
||||||
backgroundColor: backgroundColors,
|
backgroundColor: backgroundColors,
|
||||||
borderColor: borderColors
|
borderColor: borderColors,
|
||||||
|
borderWidth: 1
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: true,
|
||||||
|
aspectRatio: getAspectRatio(),
|
||||||
scales: {
|
scales: {
|
||||||
y: {
|
y: {
|
||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
|
@ -186,6 +198,12 @@ top coding models, as compared to their previous "solo" scores (striped bars).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
// Update aspect ratio on window resize
|
||||||
|
window.addEventListener('resize', function() {
|
||||||
|
chart.options.aspectRatio = getAspectRatio();
|
||||||
|
chart.resize();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function createStripePattern(baseColor) {
|
function createStripePattern(baseColor) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue