Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Problem with Rounded progress bars in React

so i'm doing like a diet app that you put the meal, amount, its carb, protein and fat amount and it creates a list. And there's a box where there's three rounded progress bars, the active value is the percentage of each macronutrient, and the empty bar is the calories. And it is working fine, when i add something, the value goes 20%, add again, goes to 32%, if i take something out, it answer fine. The problem is that let's i have 2 meals, one have 20g of carb, and the other have 0. When i added the first one, the bar went to let's say 30%. When i added the other one, nothing happened. But if i remove de 20g carb meal, the value of the bar don't change at all. Stays like that.

enter image description here

When i take off the second banana, the bar stays the same

enter image description here

I have the carb percentage

const carbPercentage = ((carbSum * 4 * 100) / calorieSum).toFixed(1);

And i tried the ternary operator at the value of the progress bar

<CircularProgressbar
            value={Number(carbPercentage) === 0 ? 1 : Number(carbPercentage)}
            maxValue={totalCarbBar}
            text={carbPercentage + "%"}
            styles={buildStyles({
              pathTransitionDuration: 1,
              pathColor: "#e5383b",
              textColor: "#242423",
              trailColor: "#333533",
            })}
          ></CircularProgressbar>

I deployed it, so you can check it out here https://macro-trackerreact.web.app/ And here's the git repository https://github.com/JosephKorel/macro-count

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try to keep this but you would change the Circular Progress bar like this following https://mui.com/components/progress/

<CircularProgressbar
            value={Number(carbPercentage) === 0 ? 1 : Number(carbPercentage)}
            maxValue={totalCarbBar}
            text={carbPercentage + "%"}
            styles={buildStyles({
              pathTransitionDuration: 1,
              pathColor: "#e5383b",
              textColor: "#242423",
              trailColor: "#333533",
            })}
          />
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda