Skip to content

Commit 0af3da9

Browse files
committed
Bugfix - negative import colour
1 parent 5e08bc2 commit 0af3da9

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

‎dist/Predbat-Table-Card-Next.js‎

Lines changed: 18 additions & 14 deletions
Large diffs are not rendered by default.

‎src/utils/html-utils.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ export function barElement(value: number, maxValue: number, colour: string, inve
408408
const percentage = Math.min(Math.max((absValue / maxValue) * 100, 0), 100);
409409

410410
let barColour: string;
411-
const badColour = '#f00';
411+
const negativeColour = inverted ? '#f00' : '#0f0';
412412

413413
if (isNegative) {
414-
barColour = badColour;
414+
barColour = negativeColour;
415415
}
416416
else if (inverted) {
417417
const green = Math.round((percentage / 100) * 255);
@@ -430,9 +430,9 @@ export function barElement(value: number, maxValue: number, colour: string, inve
430430
barFill.style.width = `${percentage}%`;
431431
barFill.style.background = barColour;
432432
barFill.style.opacity = isNegative ? '0.25' : '0.3';
433-
if (isNegative) barFill.style.borderLeft = `2px solid ${badColour}`;
433+
if (isNegative) barFill.style.borderLeft = `2px solid ${negativeColour}`;
434434

435-
const valueText = spanElement('bar-element-value', isNegative ? badColour : 'var(--primary-text-color, #000)', value === 0 && hideZero ? undefined : value);
435+
const valueText = spanElement('bar-element-value', isNegative ? negativeColour : 'var(--primary-text-color, #000)', value === 0 && hideZero ? undefined : value);
436436

437437
container.appendChild(barFill);
438438
container.appendChild(valueText);

0 commit comments

Comments
 (0)