Skip to content

Commit

Permalink
fix: 💄 add focus class on wheel button & remove empty css file
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-gss committed Jun 19, 2024
1 parent d87671c commit 5757a3e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 1 addition & 3 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

@import './wheel.css';

@import './legend.css';

@import './media.css';
@import './legend.css';
Empty file removed css/media.css
Empty file.
3 changes: 3 additions & 0 deletions css/wheel.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@
font-weight: bolder;
border-radius: 100%;
cursor: pointer;
}
.wheel-button:focus {
outline : none;
}
16 changes: 9 additions & 7 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ const myChart = new Chart(ctx, {
}
});


var text = [];
text.push('<ul class="list-group legend-ul">');

var ds = myChart.data.datasets[0];
var sum = ds.data.reduce(function add(a, b) {
return a + b;
}, 0);

for (var i = 0; i < ds.data.length; i++) {
text.push('<li class="list-group-item">');
var perc = Math.round(100 * ds.data[i] / sum, 0);
text.push('<span style="background-color:' + ds.backgroundColor[i] + '">' + '</span>' + myChart.data.labels[i] + ' (' + perc + '%)');
text.push('</li>');
}

text.push('</ul>');
document.querySelector(".legend").innerHTML = text.join("");

Expand All @@ -65,13 +67,13 @@ function legendClickCallback(event) {
var item = meta.data[index];

if (item.hidden === true) {
target.classList.remove('text-danger');
target.classList.remove('legend-hidden');
item.hidden = null;
target.classList.remove('text-danger');
target.classList.remove('legend-hidden');
item.hidden = null;
} else {
target.classList.add('text-danger');
target.classList.add('legend-hidden');
item.hidden = true;
target.classList.add('text-danger');
target.classList.add('legend-hidden');
item.hidden = true;
}
myChart.update();
}
Expand Down

0 comments on commit 5757a3e

Please sign in to comment.