J'ai besoin de faire fonctionner 4 barres en même temps, sans dupliquer le code JS. peut-être en utilisant foreach ou autre, avec index. en fait je ne suis pas un utilisateur pro js, donc je ne peux pas l'améliorer par moi-même(((((((((((
// Progress bar
let number = document.getElementById('number');
let counter = 0;
setInterval(() => {
if(counter == 65) {
clearInterval();
} else {
counter += 1;
number.innerHTML = counter + "%";
}
}, 28);
// progress bar
.bar {
width: 110px;
height: 110px;
position: relative;
transform: scale(0.8);
}
.bar:not(:last-child) {
margin-right: 50px;
}
.bar__text {
text-align: center;
font-size: 14px;
line-height: 19px;
color: #2E2D2E;
margin-top: 5px;
}
.outer {
position: relative;
width: 100px;
height: 100px;
border-radius: 50%;
box-shadow: 6px 6px 10px -1px rgba(0,0,0,0.15),
-6px -6px 10px -1px rgba(255,255,255,0.7);
}
.inner {
display: flex;
justify-content: center;
align-items: center;
width: 90px;
height: 90px;
border-radius: 50%;
box-shadow: inset 4px 4px 6px -1px rgba(0,0,0,.2),
inset 4px 4px 6px -1px rgba(255,255,255,0.7),
-0.5px -0.5px 0px rgba(255,255,255,1),
0.5px 0.5px 0px rgba(0,0,0,.15),
0px 12px 10px -10px rgba(0,0,0,.05);
position: absolute;
inset: 0;
margin: auto;
}
#number {
font-weight: 600;
color: #2E2D2E;
}
.bar svg {
position: absolute;
top: 0;
left: 0;
z-index: 2;
}
circle {
fill: none;
stroke: url(#GradientColor);
stroke-width: 5px;
stroke-dasharray: 478;
stroke-dashoffset: 478;
animation: anim 2s linear forwards;
}
@keyframes anim {
100% {
stroke-dashoffset: 250;
}
}
<div class="progress__bars bars">
<div class="bar">
<div class="outer">
<div class="inner">
<div id="number">
</div>
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
<defs>
<linearGradient id="GradientColor">
<stop offset="0%" stop-color="#e91e63" />
<stop offset="100%" stop-color="#673ab7" />
</linearGradient>
</defs>
<circle cx="52" cy="52" r="45" stroke-linecap="round" />
</svg>
<div class="bar__text">
Today's Visitors
</div>
</div>
<div class="bar">
<div class="outer">
<div class="inner">
<div id="number">
</div>
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
<defs>
<linearGradient id="GradientColor">
<stop offset="0%" stop-color="#e91e63" />
<stop offset="100%" stop-color="#673ab7" />
</linearGradient>
</defs>
<circle cx="52" cy="52" r="45" stroke-linecap="round" />
</svg>
<div class="bar__text">
Total Visitors
</div>
</div>
<div class="bar">
<div class="outer">
<div class="inner">
<div id="number">
</div>
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
<defs>
<linearGradient id="GradientColor">
<stop offset="0%" stop-color="#e91e63" />
<stop offset="100%" stop-color="#673ab7" />
</linearGradient>
</defs>
<circle cx="52" cy="52" r="45" stroke-linecap="round" />
</svg>
<div class="bar__text">
Today's Hits
</div>
</div>
<div class="bar">
<div class="outer">
<div class="inner">
<div id="number">
</div>
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
<defs>
<linearGradient id="GradientColor">
<stop offset="0%" stop-color="#e91e63" />
<stop offset="100%" stop-color="#673ab7" />
</linearGradient>
</defs>
<circle cx="52" cy="52" r="45" stroke-linecap="round" />
</svg>
<div class="bar__text">
Total Hits
</div>
</div>
</div>
Ajouter un extrait. Il y a quelques artefacts, mais c'est bon. On travaille toujours dans le snippet. ah les exigences en matière de description sont tellement ennuyeuses XD