scale summary % to view timeframe, rename to Auslastung
This commit is contained in:
1 parent
1b17a3d4a2
commit
791dd5718c
1 file changed
+8
-2
+8
-2
@@ -98,7 +98,7 @@ async function loadView() {
|
||||
|
||||
function renderSummary(s) {
|
||||
$('summary').innerHTML = `
|
||||
<span>Zeitraum: <span class="cost">${pct(s.totalCost)}</span></span>
|
||||
<span>Auslastung: <span class="cost">${pctScaled(s.totalCost)}</span></span>
|
||||
<span>Einträge: <span class="val">${s.totalEntries}</span></span>
|
||||
`;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ function renderBucketChart(buckets, bucketMinutes) {
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'bar-wrapper';
|
||||
wrapper.innerHTML = `
|
||||
<div class="bar-tooltip">${pct(cost)} / ${count}</div>
|
||||
<div class="bar-tooltip">${pctScaled(cost)} / ${count}</div>
|
||||
<div class="bar" style="height:${Math.max(barPct, cost > 0 ? 2 : 0)}%"></div>
|
||||
`;
|
||||
|
||||
@@ -483,3 +483,9 @@ function escAttr(s) {
|
||||
function pct(cost) {
|
||||
return (cost / WEEKLY_BUDGET * 100).toFixed(3) + '%';
|
||||
}
|
||||
|
||||
function pctScaled(cost) {
|
||||
const days = (viewTo - viewFrom) / 86400000;
|
||||
const budget = WEEKLY_BUDGET / 7 * days;
|
||||
return (cost / budget * 100).toFixed(3) + '%';
|
||||
}
|
||||
Reference in new issue
Block a user