Skip to content

Commit f0eac14

Browse files
committed
Align PV label spacing and ignore extra files
1 parent fb3140c commit f0eac14

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.html
2+
*.md
3+
!README.md

compact-power-card.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,11 @@ class CompactPowerCard extends (window.LitElement ||
36383638

36393639
const pvLabelPositions = [];
36403640
const pvLabelPad = Math.max(16, baseWidth * 0.05);
3641-
const pvLabelSpacingBase = 56 * (baseWidth / designWidth);
3641+
const pvColumnWidth = columnCount > 0 ? baseWidth / columnCount : baseWidth / 12;
3642+
const pvLabelSpacingBase = Math.max(
3643+
pvColumnWidth * 1.5,
3644+
56 * (baseWidth / designWidth)
3645+
);
36423646
const pvLabelCap = Math.max(4, maxItemsByColumns);
36433647
const pvLabelY = 28;
36443648

@@ -3772,14 +3776,15 @@ class CompactPowerCard extends (window.LitElement ||
37723776
(rowCount === 3 && gridLabels.length <= 1 && batteryLabelSource.length <= 1) ||
37733777
(rowCount === 4 && (gridLabels.length <= 2 || batteryLabelSource.length <= 2));
37743778
const pvLabelLimit = rowCount >= 5 || allowExtraPvLabels ? pvLabelCap : 4;
3775-
const pvRings = Math.max(1, Math.ceil(pvLabelLimit / 2));
3779+
const pvLabelCount = Math.min(pvLabels.length, pvLabelLimit);
3780+
const pvRings = Math.max(1, Math.ceil(pvLabelCount / 2));
37763781
const pvMaxSpacing = (baseWidth / 2 - pvLabelPad) / pvRings;
37773782
const pvLabelSpacing = Math.max(0, Math.min(pvLabelSpacingBase, pvMaxSpacing));
3778-
for (let ring = 1; pvLabelPositions.length < pvLabelLimit; ring++) {
3783+
for (let ring = 1; pvLabelPositions.length < pvLabelCount; ring++) {
37793784
const leftX = pvCenterX - pvLabelSpacing * ring;
37803785
const rightX = pvCenterX + pvLabelSpacing * ring;
37813786
pvLabelPositions.push({ x: leftX });
3782-
if (pvLabelPositions.length < pvLabelLimit) {
3787+
if (pvLabelPositions.length < pvLabelCount) {
37833788
pvLabelPositions.push({ x: rightX });
37843789
}
37853790
if (ring >= pvRings) break;

0 commit comments

Comments
 (0)