Project web dashboard
Project web dashboard
Purpose
Turns a measurement CSV (time, item, value) into a one-file web dashboard, `index.html`. Plain HTML, CSS, and JavaScript with no libraries or CDN; charts are inline SVG. Data sits in CSV blocks inside, so it opens offline.
The AI never makes up a value, never fills a blank with 0, and never passes hypothetical data off as real readings.
Input
- Required: a CSV (or table) with times and values, and the unit of each column. If missing, ask only: "Please send the first 5 lines of the CSV and the unit of each column."
- Helpful: capacity basis (DC kWp or AC kW), whether times mark interval start or end, the interval, data source.
- Unknown time convention: ask. With no answer, use "interval end" and say so on screen.
- Unknown capacity basis: no capacity factor card; write "capacity basis [check needed]".
- If your school or instructor gave you a template or screen spec, that template comes first.
Output
1. One `index.html`. Data in two `<script type="text/csv">` blocks: today's 30-min values, and buildings with month to date.
2. In the chat, 3–7 "Please check" lines: the three card values and their timestamp, no-data cells, time convention, capacity basis, data source, whether you opened the page.
3. No browser? Hand over the file and say "I did not open the page." Never claim a screenshot you did not take.
Rules
1. Steps
1) Check column names, units, interval, and time convention.
2) Count blanks and zeros apart. 0 kW at night is a measured 0; a blank is "no data".
3) Paste the CSV into the `today` and `month` blocks.
4) Open it; check the cards, chart, and table against a hand calculation.
5) View 1440 px and 390 px wide, light and dark.
2. Layout
- Top to bottom: title, data badge, update time → 3 cards (today's energy, month to date, capacity factor) → chart → table by building → definitions.
- One big number per screen (today's energy, 52 px). Other cards 32 px.
- Under each number, one line with the period and the formula: "Energy ÷ (400 kWp × 24 h × 27 days), DC capacity basis".
- Number columns right-aligned with `tabular-nums`.
3. Phone and dark mode
- At 700 px or less, cards stack and the big number drops to 48 px.
- The table scrolls sideways, first column pinned, with a phone-only hint.
- The chart redraws to its width; text stays 12 px, ticks 3 h apart when narrow.
- The theme follows the OS; the button overrides and is remembered. `?theme=dark` opens dark.
- Dark colors are picked, not inverted: background #191919, text #efefef, line #338ced.
4. Numbers, units, timestamps
- Every number has a unit. kW is power, kWh is energy; never in one cell.
- 30-min average 40 kW → 40 × 0.5 h = 20 kWh for that half hour.
- Show update time and time convention at the top: "Updated 2026-11-28 14:30 (30-min averages, time = interval end)".
- Each number carries its period: today 06:00–14:30, month 11/1–11/28 14:30, capacity factor 11/1–11/27.
- Capacity factor = energy ÷ (capacity × 24 h × days). Say "DC capacity basis" when it is DC.
- Round once, at display; note that the total row can differ from the row sum by 0.1.
5. No data
- A blank is "no data", not 0. Filling 0 draws a false dip and shrinks the total.
- If any building is missing in an interval, show no total there: break the line, hatch the span.
- A sum that skips blanks says so: "3 missing values left out of the sum. The real value is higher."
- Before → after
- "Today's energy 1,174 kWh" → "Today's energy 1,174 kWh · 3 missing values left out of the sum"
- "Gym output now 0 kW" → "Gym output now: No data (last 14:00)"
- "Max 266" → "Peak 266.2 kW · 12:30 (30-min average)"
6. Not by color alone
- Status uses a symbol and words: "✓ OK", "⚠ No data: 2 values".
- No-data spans get gray 45° hatching (visible in a B&W print) and are named above the chart.
- Text uses the text color; the series color (#257de0) is for lines and dots only.
- Line 2 px, dots 8 px with a 2 px ring, area 10 %, 1 px grid. Only the peak gets a label.
- Hover shows the interval's kW and kWh or "No data (building)"; the table repeats them.
7. Measured vs. hypothetical
- The top badge comes from the Source column: all hypothetical → "Hypothetical data · not real meter readings"; mixed → "Measured and hypothetical mixed · see Source column".
- The table marks each building. A slide showing hypothetical data keeps the label.
8. The file
The file below ran end to end on a hypothetical case: a Renewable Energy course team project, 5 buildings, 400 kWp DC, 30-min data for 2026-11-28. New data: edit only the two CSV blocks and the constants `DAY`, `DAYS`, `H`.
- Run: open the file. No server, no install.
- Here: today 1,174 kWh (3 missing values left out), month 28,134 kWh, capacity factor 10.4 %, peak 266.2 kW at 12:30.
- In headless Chrome, 38 numbers on the page matched a separate Python calculation from the same CSV. Screens 1440×900 and 390×844 were captured light and dark.
9. Final check
- Every number with a unit and a period? No cell mixing kW and kWh?
- No blank drawn or added as 0? Hatching and "No data" present?
- Status by symbol or text, not color alone? Data badge at top?
- Nothing cut off at 390 px? Dark mode readable?
- No outside addresses (`http`, CDN)?
- Said whether you opened the page or only wrote the file?
Attachment 1 · index.html (HTML)
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Campus Solar PV Dashboard (hypothetical data)</title>
<!-- One-file dashboard: no external libraries, no CDN. The data is the two CSV blocks in the script tags below. -->
<style>
:root{color-scheme:light;--plane:#f9f9f9;--surface:#fff;--ink:#191919;--sub:#666;--grid:#e7e7e7;--axis:#c2c2c2;
--ring:rgba(11,11,11,.1);--s1:#257de0;--good:#0aac23;--warn:#fbb315;--miss:#a8a8a8}
@media (prefers-color-scheme:dark){:root:where(:not([data-theme=light])){color-scheme:dark;--plane:#0b0b0b;--surface:#191919;
--ink:#efefef;--sub:#9c9c9c;--grid:#303030;--axis:#474747;--ring:rgba(255,255,255,.1);--s1:#338ced;--miss:#5c5c5c}}
:root[data-theme=dark]{color-scheme:dark;--plane:#0b0b0b;--surface:#191919;--ink:#efefef;--sub:#9c9c9c;--grid:#303030;
--axis:#474747;--ring:rgba(255,255,255,.1);--s1:#338ced;--miss:#5c5c5c}
*{box-sizing:border-box}
body{margin:0;background:var(--plane);color:var(--ink);
font:15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif}
main{max-width:1200px;margin:0 auto;padding:24px}
header{display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center;justify-content:space-between;margin-bottom:16px}
h1{font-size:22px;margin:0}
h2{font-size:16px;margin:0}
.sub,.label,.note,th,footer{color:var(--sub)}
.sub{font-size:13px}
.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;font-size:13px}
.badge{border:1.5px dashed var(--ink);border-radius:6px;padding:2px 8px;font-weight:600}
button{font:inherit;color:var(--ink);background:var(--surface);border:1px solid var(--axis);border-radius:8px;padding:4px 12px;cursor:pointer}
.card{background:var(--surface);border:1px solid var(--ring);border-radius:12px;padding:16px 20px;margin-bottom:16px}
.cards{display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:16px}
.label{font-size:13px}
.hero{font-size:52px;font-weight:600;line-height:1.15}
.val{font-size:32px;font-weight:600;line-height:1.3}
.unit{font-size:16px;font-weight:500;color:var(--sub);margin-left:6px}
.note{font-size:12px;margin-top:4px}
#chart{position:relative;margin-top:8px}
#tip{position:absolute;top:8px;pointer-events:none;background:var(--surface);border:1px solid var(--axis);border-radius:8px;
padding:6px 10px;font-size:12px;white-space:nowrap;display:none}
.scroll{overflow-x:auto}
table{border-collapse:collapse;width:100%;font-size:14px;font-variant-numeric:tabular-nums}
th,td{padding:8px 10px;border-bottom:1px solid var(--grid);text-align:right;white-space:nowrap}
th{font-size:12px;font-weight:600}
th:first-child,td:first-child{text-align:left;position:sticky;left:0;background:var(--surface)}
tr.sum td{font-weight:600;border-bottom:0}
.none{color:var(--sub)}
.ok{color:var(--good)}.warn{color:var(--warn)}
.m{display:none}
footer{font-size:12px}
footer p{margin:4px 0}
@media (max-width:700px){main{padding:14px}.cards{grid-template-columns:1fr;gap:0}.hero{font-size:48px}h1{font-size:19px}.m{display:block}}
</style>
</head>
<body>
<main>
<header>
<div><h1>Campus Solar PV Dashboard</h1><div class="sub">Renewable Energy course team project · 5 rooftops, 400 kWp DC</div></div>
<div class="bar"><span class="badge">Hypothetical data · not real meter readings</span><span id="updated"></span><button id="theme">Dark / Light</button></div>
</header>
<section class="cards" id="cards"></section>
<section class="card">
<h2>Output by time of day · 5 buildings total (kW, 30-min average)</h2>
<div class="note" id="gaps"></div>
<div id="chart"></div>
</section>
<section class="card">
<h2>By building</h2>
<div class="note m">Swipe the table sideways.</div>
<div class="scroll"><table>
<thead><tr><th>Building</th><th>Capacity (kWp, DC)</th><th id="nowh">Output now (kW)</th><th>Today (kWh)</th><th>This month (kWh)</th>
<th>Capacity factor 11/1–27 (%)</th><th>Source</th><th>Status</th></tr></thead>
<tbody id="rows"></tbody></table></div>
<div class="note">Rounding can make the total row differ from the sum of the building rows by 0.1 kWh.</div>
</section>
<footer>
<p>kW is power (30-min average); kWh is the energy made over a period. A 30-min average of 40 kW means 40 × 0.5 h = 20 kWh in that half hour.</p>
<p>Capacity factor = energy ÷ (DC capacity × 24 h × days). Blank cells stay "no data" and are never filled with 0. A 0 kW at night is a measured 0.</p>
<p>Source column: hypothetical = values made up for the course example; measured = values from a meter. If both appear, each building is marked.</p>
</footer>
</main>
<!-- Today's 30-min data (hypothetical). time = end of the 30-min interval, value = average kW over it, blank = no data -->
<script type="text/csv" id="today">
time,Engineering,Library,Dormitory,Gym,Main Hall
06:30,0.0,0.0,0.0,0.0,0.0
07:00,0.0,0.0,0.0,0.0,0.0
07:30,0.0,0.0,0.0,0.0,0.0
08:00,7.5,4.7,5.7,3.7,2.1
08:30,18.1,11.4,13.8,8.9,5.2
09:00,29.8,18.7,22.7,14.7,8.5
09:30,41.7,26.2,31.8,20.6,11.9
10:00,53.1,33.4,40.5,26.2,15.2
10:30,63.3,39.8,48.2,31.2,18.1
11:00,71.9,45.2,,35.4,20.5
11:30,78.4,49.3,,38.6,22.4
12:00,82.5,51.8,62.8,40.6,23.6
12:30,84.0,52.8,64.0,41.4,24.0
13:00,51.4,32.3,39.2,25.3,14.7
13:30,67.3,42.3,51.3,33.2,19.2
14:00,73.1,45.9,55.7,36.0,20.9
14:30,64.8,40.7,49.4,,18.5
</script>
<!-- Buildings and this month's energy through yesterday (hypothetical) -->
<script type="text/csv" id="month">
building,capacity_kWp_DC,through_yesterday_kWh,source
Engineering,120,8340,hypothetical
Library,80,5310,hypothetical
Dormitory,100,6710,hypothetical
Gym,60,4120,hypothetical
Main Hall,40,2480,hypothetical
</script>
<script>
const DAY = '2026-11-28', DAYS = 27, H = 0.5; // date shown, days this month through yesterday, 30 min = 0.5 h
const csv = id => document.getElementById(id).textContent.trim().split('\n').map(l => l.split(','));
const [head, ...rows] = csv('today'), [, ...mon] = csv('month');
const B = head.slice(1), T = rows.map(r => r[0]);
const KW = rows.map(r => r.slice(1).map(v => v === '' ? null : +v)); // blank is null, which is not 0
const cap = mon.map(r => +r[1]), prev = mon.map(r => +r[2]), src = mon.map(r => r[3]);
const sum = a => a.reduce((s, v) => s + v, 0);
const f = (v, d = 0) => v.toLocaleString('en-US', {minimumFractionDigits: d, maximumFractionDigits: d});
const mm = t => +t.slice(0, 2) * 60 + +t.slice(3), hm = m => `${String(m / 60 | 0).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
const kwh = B.map((_, j) => sum(KW.map(r => r[j] ?? 0)) * H); // today's kWh per building, missing cells left out
const miss = B.map((_, j) => KW.filter(r => r[j] === null).length);
const total = KW.map(r => r.includes(null) ? null : sum(r)); // one building missing = no total for that interval
const now = T.at(-1), start = hm(mm(T[0]) - 30), capSum = sum(cap), today = sum(kwh), missN = sum(miss);
const cf = (e, c) => f(100 * e / (c * 24 * DAYS), 1);
const kinds = [...new Set(src)]; // the top badge follows the source column
document.querySelector('.badge').textContent = kinds.length > 1 ? 'Measured and hypothetical mixed · see Source column'
: kinds[0] === 'measured' ? 'Measured data' : 'Hypothetical data · not real meter readings';
document.getElementById('updated').textContent = `Updated ${DAY} ${now} (30-min averages, time = interval end)`;
document.getElementById('nowh').textContent = `Output now (kW, ${now})`;
document.getElementById('cards').innerHTML = `
<div class="card"><div class="label">Today's energy · ${start}–${now}</div><div class="hero">${f(today)}<span class="unit">kWh</span></div>
<div class="note">${missN ? `⚠ ${missN} missing values left out of the sum. The real value is higher.` : 'No missing values'}</div></div>
<div class="card"><div class="label">This month · 11/1–${DAY.slice(5).replace('-', '/')} ${now}</div>
<div class="val">${f(sum(prev) + today)}<span class="unit">kWh</span></div><div class="note">Through yesterday ${f(sum(prev))} kWh + today ${f(today)} kWh</div></div>
<div class="card"><div class="label">Capacity factor · 11/1–11/${DAYS}</div><div class="val">${cf(sum(prev), capSum)}<span class="unit">%</span></div>
<div class="note">Energy ÷ (${capSum} kWp × 24 h × ${DAYS} days), DC capacity basis</div></div>`;
const runs = []; // no-data spans: [start, end, building]
T.forEach((t, i) => B.forEach((b, j) => {
if (KW[i][j] !== null) return;
const r = runs.find(x => x[2] === b && x[1] === mm(t) - 30);
r ? r[1] = mm(t) : runs.push([mm(t) - 30, mm(t), b]);
}));
document.getElementById('gaps').textContent = runs.length ? 'Hatched = no data (not filled with 0): ' +
runs.map(([a, z, b]) => `${b} ${hm(a)}–${hm(z)}`).join(', ') + '. No total is drawn there.' : '';
document.getElementById('rows').innerHTML = B.map((b, j) => {
const last = KW.at(-1)[j], seen = T[KW.map(r => r[j]).findLastIndex(v => v !== null)];
return `<tr><td>${b}</td><td>${cap[j]}</td><td>${last === null ? `<span class="none">No data (last ${seen})</span>` : f(last, 1)}</td>
<td>${f(kwh[j], 1)}</td><td>${f(prev[j] + kwh[j])}</td><td>${cf(prev[j], cap[j])}</td><td>${src[j]}</td>
<td>${miss[j] ? `<span class="warn">⚠</span> No data: ${miss[j]} value${miss[j] > 1 ? 's' : ''}` : '<span class="ok">✓</span> OK'}</td></tr>`;
}).join('') + `<tr class="sum"><td>Total</td><td>${capSum}</td><td>${total.at(-1) === null ? '<span class="none">No data</span>' : f(total.at(-1), 1)}</td>
<td>${f(today, 1)}</td><td>${f(sum(prev) + today)}</td><td>${cf(sum(prev), capSum)}</td><td></td><td>Missing: ${missN}</td></tr>`;
function draw() {
const el = document.getElementById('chart'), W = el.clientWidth, Hh = W < 600 ? 230 : 290, m = {l: 48, r: 16, t: 24, b: 30};
const x0 = mm(T[0]) - 30, x1 = mm(now), top = Math.ceil(Math.max(...total.filter(v => v !== null)) / 50) * 50;
const X = t => m.l + (t - x0) / (x1 - x0) * (W - m.l - m.r), Y = v => Hh - m.b - v / top * (Hh - m.t - m.b);
const pts = T.map((t, i) => [X(mm(t)), total[i] === null ? null : Y(total[i])]), k = total.indexOf(Math.max(...total));
let s = `<svg width="${W}" height="${Hh}" role="img" aria-label="Total output of 5 buildings, peak ${f(total[k], 1)} kW (${T[k]}). Hatched = no data."
style="font-size:12px;fill:var(--sub);font-variant-numeric:tabular-nums"><defs><pattern id="hatch" width="6" height="6"
patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><line x1="0" y1="0" x2="0" y2="6" style="stroke:var(--miss);stroke-width:2"/></pattern></defs>`;
for (let v = 0; v <= top; v += 50) s += `<line x1="${m.l}" x2="${W - m.r}" y1="${Y(v)}" y2="${Y(v)}" style="stroke:${v ? 'var(--grid)' : 'var(--axis)'}"/>
<text x="${m.l - 8}" y="${Y(v) + 4}" text-anchor="end">${v}</text>`;
s += `<text x="${m.l - 8}" y="${m.t - 10}" text-anchor="end">kW</text>`;
for (let t = Math.ceil(x0 / 120) * 120; t <= x1; t += W < 600 ? 180 : 120) s += `<text x="${X(t)}" y="${Hh - 8}" text-anchor="middle">${hm(t)}</text>`;
runs.forEach(([a, z]) => s += `<rect x="${X(a)}" y="${m.t}" width="${X(z) - X(a)}" height="${Hh - m.t - m.b}" fill="url(#hatch)" opacity=".8"/>`);
let seg = []; // break the line at missing points
const flush = () => { if (seg.length > 1) s += `<path d="M${seg.join('L')}L${seg.at(-1)[0]},${Y(0)}L${seg[0][0]},${Y(0)}Z" style="fill:var(--s1);opacity:.1"/>
<path d="M${seg.join('L')}" style="fill:none;stroke:var(--s1);stroke-width:2;stroke-linejoin:round;stroke-linecap:round"/>`; seg = []; };
pts.forEach(p => p[1] === null ? flush() : seg.push(p)); flush();
pts.forEach(([x, y]) => { if (y !== null) s += `<circle cx="${x}" cy="${y}" r="4" style="fill:var(--s1);stroke:var(--surface);stroke-width:2"/>`; });
const [kx, ky] = pts[k];
s += `<text x="${Math.min(kx, W - m.r - 130)}" y="${ky - 12}" style="fill:var(--ink);font-weight:600;paint-order:stroke;stroke:var(--surface);stroke-width:4px">Peak ${f(total[k], 1)} kW · ${T[k]}</text>
<line id="cross" y1="${m.t}" y2="${Hh - m.b}" style="stroke:var(--axis);display:none"/></svg><div id="tip"></div>`;
el.innerHTML = s;
const svg = el.querySelector('svg'), cross = el.querySelector('#cross'), tip = el.querySelector('#tip');
svg.onpointermove = e => {
const x = e.offsetX, i = pts.reduce((b, p, j) => Math.abs(p[0] - x) < Math.abs(pts[b][0] - x) ? j : b, 0);
const gone = B.filter((_, j) => KW[i][j] === null);
cross.setAttribute('x1', pts[i][0]); cross.setAttribute('x2', pts[i][0]); cross.style.display = '';
tip.style.display = 'block'; tip.style.left = Math.min(pts[i][0] + 10, W - 250) + 'px';
tip.textContent = `${hm(mm(T[i]) - 30)}–${T[i]} · ` + (gone.length ? `No data (${gone.join(', ')}), no total`
: `Total ${f(total[i], 1)} kW · ${f(total[i] * H, 1)} kWh in this half hour`);
};
svg.onpointerleave = () => { cross.style.display = 'none'; tip.style.display = 'none'; };
}
draw();
addEventListener('resize', draw);
const root = document.documentElement, btn = document.getElementById('theme');
const pick = new URLSearchParams(location.search).get('theme') || localStorage.getItem('theme');
if (pick) root.dataset.theme = pick; // open with ?theme=dark for dark
btn.onclick = () => {
const dark = (root.dataset.theme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark';
root.dataset.theme = dark ? 'light' : 'dark';
localStorage.setItem('theme', root.dataset.theme);
};
</script>
</body>
</html>
```
Connect ChatGPT or Claude and use this prompt now · More prompts