feat(admin-dashboard): normalize plan share bar widths by top max

This commit is contained in:
萝卜
2026-03-16 14:59:30 +08:00
parent 9852d9b00e
commit 90794f9b5e
2 changed files with 37 additions and 2 deletions

View File

@@ -208,7 +208,7 @@
var bar = document.createElement('div');
bar.className = 'adm-mini-rank-bar';
bar.style.width = Math.round(ratio * 100) + '%';
bar.style.width = Math.round(barRatio * 100) + '%';
wrap.appendChild(bar);
@@ -253,11 +253,24 @@
return;
}
// 视觉口径bar 宽度按 Top5 内最大值归一(更易读);百分比仍按 total 分母计算。
var maxCnt = 0;
points.forEach(function (p) {
var v = Number(p && p.count ? p.count : 0);
if (v > maxCnt) {
maxCnt = v;
}
});
if (!maxCnt || maxCnt <= 0) {
maxCnt = 1;
}
el.innerHTML = '';
points.forEach(function (p, idx) {
var cnt = Number(p && p.count ? p.count : 0);
var ratio = total > 0 ? Math.max(0, Math.min(1, cnt / total)) : 0;
var barRatio = maxCnt > 0 ? Math.max(0, Math.min(1, cnt / maxCnt)) : 0;
var row = document.createElement('div');
row.className = 'adm-mini-share-row';
@@ -274,7 +287,7 @@
var bar = document.createElement('div');
bar.className = 'adm-mini-share-bar';
bar.style.width = Math.round(ratio * 100) + '%';
bar.style.width = Math.round(barRatio * 100) + '%';
wrap.appendChild(bar);