mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: Show one decimal point for numbers atop bars on wide screens
This commit is contained in:
parent
9a893c9a6e
commit
84e24bd5a2
1 changed files with 3 additions and 1 deletions
|
@ -108,6 +108,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
plugins: [{
|
plugins: [{
|
||||||
afterDraw: function(chart) {
|
afterDraw: function(chart) {
|
||||||
var ctx = chart.ctx;
|
var ctx = chart.ctx;
|
||||||
|
var isWideScreen = window.innerWidth > 768; // Assuming 768px as the breakpoint for wide screens
|
||||||
chart.data.datasets.forEach(function(dataset, i) {
|
chart.data.datasets.forEach(function(dataset, i) {
|
||||||
var meta = chart.getDatasetMeta(i);
|
var meta = chart.getDatasetMeta(i);
|
||||||
meta.data.forEach(function(bar, index) {
|
meta.data.forEach(function(bar, index) {
|
||||||
|
@ -116,7 +117,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
ctx.fillStyle = '#000000';
|
ctx.fillStyle = '#000000';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'bottom';
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue