vineelagampa TheFrogGod commited on
Commit
f1898f5
·
verified ·
1 Parent(s): 65626dc

profile to show the max number at proper place in bar (#50)

Browse files

- profile to show the max number at proper place in bar (a556baa1e7b4bc084164752e37acd1ed32b0860d)


Co-authored-by: Aanya Choudhary <TheFrogGod@users.noreply.huggingface.co>

Files changed (1) hide show
  1. web/profile.html +24 -9
web/profile.html CHANGED
@@ -409,15 +409,30 @@
409
 
410
  barContainer.appendChild(bar);
411
 
412
- const minMaxDiv = document.createElement("div");
413
- minMaxDiv.className = "min-max-labels";
414
- const minLabel = document.createElement("span");
415
- minLabel.textContent = "Min: " + m.min;
416
- const maxLabel = document.createElement("span");
417
- maxLabel.textContent = "Max: " + m.max;
418
- minMaxDiv.appendChild(minLabel);
419
- minMaxDiv.appendChild(maxLabel);
420
- barContainer.appendChild(minMaxDiv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
  card.appendChild(barContainer);
423
  container.appendChild(card);
 
409
 
410
  barContainer.appendChild(bar);
411
 
412
+ const minMaxDiv = document.createElement("div");
413
+ minMaxDiv.className = "min-max-labels relative w-full";
414
+
415
+ const minLabel = document.createElement("span");
416
+ minLabel.textContent = "Min: " + m.min;
417
+ minLabel.style.position = "absolute";
418
+ minLabel.style.left = "0";
419
+
420
+ const maxLabel = document.createElement("span");
421
+ maxLabel.textContent = "Max: " + m.max;
422
+ maxLabel.style.position = "absolute";
423
+
424
+ // put the max label at the end of the green section
425
+ let maxPercent = 100;
426
+ if (m.value > m.max) {
427
+ maxPercent = ((m.max - m.min) / (m.value - m.min)) * 100;
428
+ }
429
+ maxLabel.style.left = maxPercent + "%";
430
+ maxLabel.style.transform = "translateX(-100%)"; // anchor it properly
431
+
432
+ minMaxDiv.appendChild(minLabel);
433
+ minMaxDiv.appendChild(maxLabel);
434
+ barContainer.appendChild(minMaxDiv);
435
+
436
 
437
  card.appendChild(barContainer);
438
  container.appendChild(card);