From 84e24bd5a2961ead6eb3b19c7b4eed8e8c06e36d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 15 Aug 2024 14:36:11 -0700 Subject: [PATCH] feat: Show one decimal point for numbers atop bars on wide screens --- aider/website/_includes/code-in-json-benchmark.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aider/website/_includes/code-in-json-benchmark.js b/aider/website/_includes/code-in-json-benchmark.js index befcdc285..a2bf7b050 100644 --- a/aider/website/_includes/code-in-json-benchmark.js +++ b/aider/website/_includes/code-in-json-benchmark.js @@ -108,6 +108,7 @@ document.addEventListener('DOMContentLoaded', function () { plugins: [{ afterDraw: function(chart) { var ctx = chart.ctx; + var isWideScreen = window.innerWidth > 768; // Assuming 768px as the breakpoint for wide screens chart.data.datasets.forEach(function(dataset, i) { var meta = chart.getDatasetMeta(i); meta.data.forEach(function(bar, index) { @@ -116,7 +117,8 @@ document.addEventListener('DOMContentLoaded', function () { ctx.fillStyle = '#000000'; ctx.textAlign = 'center'; ctx.textBaseline = 'bottom'; - ctx.fillText(Math.round(data) + '%', bar.x, bar.y - 5); + var displayText = isWideScreen ? data.toFixed(1) + '%' : Math.round(data) + '%'; + ctx.fillText(displayText, bar.x, bar.y - 5); } }); });