Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

314
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!