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

317
Vistas
How can I use conditional CSS to change the color of this graph?

I don't know if I need to use js with my css to change the color of my graph. The color of the graph must depend the number inside it. The numbers with styling I want: 20<= green, >20 or ==30 yellow, >30 red. I already styled the graph with green but like I said I want to make this dynamic with conditional CSS. I also tried using ngClasses but I am not familiar with them and don't know how to use them yet.

The class ppc-progress-fill is styled with green.

My HTML:

<div class="progressDiv">
            <div class="statChartHolder">
                <div class="progress-pie-chart"><!--Pie Chart -->
                    <div class="ppc-progress">
                        <div class="ppc-progress-fill" [ngClass="{'red' :colorStatus==1, 'yellow' :colorStatus==2, 'green' : colorStatus==3}"]></div>
                    </div>
                    <div class="ppc-percents">
                    <div class="pcc-percents-wrapper">
                        <span>49</span>
                        <span id="pending">projects pending</span>
                    </div>
                    </div>  
                </div><!--End Chart -->
            </div>    
        </div>

my CSS: This has the color of circle:

    .ppc-progress .ppc-progress-fill {
  content: "";
  position: absolute;
  border-radius: 50%;
  left: calc(50% - 100px);
  top: calc(50% - 100px);
  width: 200px;
  height: 200px;
  background: #81CE97;
  transform: rotate(90deg);
}

this has the color of the text:

    .ppc-percents span {
  display: block;
  font-size: 2.6em;
  font-weight: bold;
  color: #81CE97;
}

enter image description here

about 4 years ago · Juan Pablo Isaza
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