Skip to content

Commit

Permalink
fix for max value
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed Nov 21, 2024
1 parent 09ebed1 commit 3d6c300
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,8 @@ export class DashboardComponent implements AfterViewInit, AfterContentInit {

constructor() {
effect(() => {
const score = this.score();
const scoreIndicator = this.scoreIndicator();

if (!score || !scoreIndicator) {
return;
}

const [score, scoreIndicator] = [this.score(), this.scoreIndicator()];
if (!score || !scoreIndicator) return;
untracked(() => colorizeScoreIndicator(scoreIndicator, score, this.scoreColors));
});
}
Expand Down Expand Up @@ -316,14 +311,17 @@ const CLASSIFICATION_RESOLUTION = 10;
/** Colorizes the score indicator based on the given score and breakpoints */
function colorizeScoreIndicator(element: MatProgressSpinner, score: number, breakpoints: Array<ColorBreakpoint>): void {
const circle = element._elementRef.nativeElement.getElementsByTagName('circle')[0];
if (!circle) {
if (!circle || breakpoints.length === 0) {
return;
}

for (let i = 0; i < breakpoints.length - 1; i++) {
if (score >= breakpoints[i].value && score < breakpoints[i + 1].value) {
circle.style.stroke = breakpoints[i].color.rgbaCssString();
return;
let color = breakpoints[0].color;
for (const breakpoint of breakpoints) {
if (score < breakpoint.value) {
break;
}
color = breakpoint.color;
}

circle.style.stroke = color.rgbaCssString();
}

0 comments on commit 3d6c300

Please sign in to comment.