add bettor count trend to public trend panel
This commit is contained in:
@@ -581,16 +581,45 @@ function renderPublicTrend() {
|
|||||||
{chair: 'C', amount: c, pct: c/total*100},
|
{chair: 'C', amount: c, pct: c/total*100},
|
||||||
].sort((x, y) => y.amount - x.amount);
|
].sort((x, y) => y.amount - x.amount);
|
||||||
|
|
||||||
el.innerHTML = renderTrendBars(ranked.slice(0, 2));
|
// Count unique bettors per chair
|
||||||
|
const bettorCount = {A: 0, B: 0, C: 0};
|
||||||
|
for (const rb of Object.values(roundBettors)) {
|
||||||
|
for (const ch of CHAIRS) if ((rb.chairs[ch] || 0) > 0) bettorCount[ch]++;
|
||||||
|
}
|
||||||
|
const totalBettors = Object.keys(roundBettors).length;
|
||||||
|
const bettorRanked = CHAIRS.map(c => ({chair: c, count: bettorCount[c], pct: totalBettors > 0 ? bettorCount[c] / totalBettors * 100 : 0}))
|
||||||
|
.sort((x, y) => y.count - x.count);
|
||||||
|
|
||||||
|
let bettorHtml = '';
|
||||||
|
if (totalBettors > 0) {
|
||||||
|
bettorHtml = `<div style="margin-top:10px;padding-top:8px;border-top:1px solid var(--border)">
|
||||||
|
<div style="font-size:10px;color:var(--text3);font-weight:600;text-transform:uppercase;margin-bottom:6px">Most Bettors On</div>` +
|
||||||
|
bettorRanked.filter(r => r.count > 0).map((r, i) => `
|
||||||
|
<div class="trend-row">
|
||||||
|
<span class="trend-chair" style="color:${CHAIR_COLORS[r.chair]};font-size:14px">${r.chair}</span>
|
||||||
|
<div class="trend-bar-bg">
|
||||||
|
<div class="trend-bar-fill chair-${r.chair}" style="width:${r.pct}%"></div>
|
||||||
|
</div>
|
||||||
|
<span class="trend-pct" style="color:${CHAIR_COLORS[r.chair]}">${r.count}</span>
|
||||||
|
<span class="trend-amt">${r.pct.toFixed(0)}%</span>
|
||||||
|
</div>`).join('') +
|
||||||
|
`<div style="font-size:10px;color:var(--text3);margin-top:4px">${totalBettors} total bettors</div></div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
el.innerHTML = renderTrendBars(ranked.slice(0, 2)) + bettorHtml;
|
||||||
|
|
||||||
// Check if public favorite matches our prediction
|
// Check if public favorite matches our prediction
|
||||||
if (currentPrediction) {
|
if (currentPrediction) {
|
||||||
const pubFav = ranked[0].chair;
|
const pubFav = ranked[0].chair;
|
||||||
|
const mostBettors = bettorRanked[0].chair;
|
||||||
if (pubFav === currentPrediction) {
|
if (pubFav === currentPrediction) {
|
||||||
note.textContent = `Public agrees with model pick (${pubFav})`;
|
note.textContent = `Public agrees with model pick (${pubFav})`;
|
||||||
} else {
|
} else {
|
||||||
note.textContent = `Public favors ${pubFav}, model picks ${currentPrediction} \u2014 contrarian opportunity?`;
|
note.textContent = `Public favors ${pubFav}, model picks ${currentPrediction} \u2014 contrarian opportunity?`;
|
||||||
}
|
}
|
||||||
|
if (mostBettors !== pubFav) {
|
||||||
|
note.textContent += ` \u00b7 Most people on ${mostBettors} but most money on ${pubFav}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user