GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / globalgrid2050 / uk_energy_tracking_v3

Price History UI and 8 more files (part 1)

A style sheet in GlobalGrid2050.

512 lines of JavaScript and CSS from globalgrid2050, in 9 files. Topic: Electricity markets and data pipelines. Section 915 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Price History UI energy-data · globalgrid2050 / uk_energy_tracking_v3/price-history-ui.css lines 1–223
  2. Price History UI energy-data · globalgrid2050 / uk_energy_tracking_v3/price-history-ui.js lines 1–24
  3. Live App render · globalgrid2050 / uk_energy_tracking_v4/live-app.js lines 1–60
  4. Live Config other · globalgrid2050 / uk_energy_tracking_v4/live-config.js lines 1–7
  5. Live Gauges render · globalgrid2050 / uk_energy_tracking_v4/live-gauges.js lines 1–25
  6. Live Helpers transform · globalgrid2050 / uk_energy_tracking_v4/live-helpers.js lines 1–9
  7. Live Oil Chart render · globalgrid2050 / uk_energy_tracking_v4/live-oil-chart.js lines 1–97
  8. Live Transport energy-data · globalgrid2050 / uk_energy_tracking_v4/live-transport.js lines 1–37
  9. Price History Fullscreen energy-data · globalgrid2050 / uk_energy_tracking_v4/price-history-fullscreen.js lines 1–30

Price History UI

A style sheet in GlobalGrid2050.

energy-dataglobalgrid2050 / uk_energy_tracking_v3/price-history-ui.css · lines 1–223 of 223 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage hv_procurement (path word 'price'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary.
What it achieves
Electricity-price-history-panel.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v3 · style sheet
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v3/price-history-ui.css:1-223 · blob 23c00706383c80702a1cebbffe340069dbab7b00 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
#electricity-price-history-panel,
#electricity-price-history-panel * {
  box-sizing: border-box;
}

#electricity-price-history-panel {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

#electricity-price-history-panel .trend-panel {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: #070a10 !important;
  border: 1px solid #252b36 !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02), 0 0 22px rgba(0,255,255,.05);
}

#electricity-price-history-panel .price-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

#electricity-price-history-panel .price-history-actions strong {
  color: #00ffff !important;
  letter-spacing: .12em;
  text-transform: uppercase;
}

#electricity-price-history-panel .price-history-actions select {
  background: #050505 !important;
  color: #00ffff !important;
  border: 1px solid #252b36 !important;
  border-radius: 4px;
  padding: 7px 9px;
  font-family: "Courier New", monospace;
}

#electricity-price-history-panel .price-history-actions a {
  border: 1px solid #252b36 !important;
  border-radius: 4px;
  padding: 7px 9px;
  color: #7fdfff !important;
  text-decoration: none !important;
  background: rgba(255,255,255,.03) !important;
}

#electricity-price-history-panel #price-history-canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: clamp(200px, 32vw, 320px) !important;
  display: block;
  border: 1px solid #252b36 !important;
  background: #05070c !important;
  border-radius: 6px;
  touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}

#electricity-price-history-panel .price-history-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 10px;
  margin-top: 12px;
}

#electricity-price-history-panel .price-history-card {
  border: 1px solid #252b36 !important;
  background: #0b0f17 !important;
  border-radius: 6px;
  padding: 12px;
  min-width: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}

#electricity-price-history-panel .price-history-label {
  color: #9aa3b6 !important;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
}

#electricity-price-history-panel .price-history-value {
  color: #00ffff !important;
  font-size: 18px;
  font-weight: 800;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

#electricity-price-history-panel .price-history-table-toggle {
  margin-top: 12px;
  border: 1px solid #252b36 !important;
  border-radius: 6px;
  background: #0b0f17 !important;
  overflow: hidden;
}

#electricity-price-history-panel .price-history-table-toggle summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  color: #00ffff !important;
  background: #05070c !important;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 11px;
  border-bottom: 1px solid #252b36 !important;
}

#electricity-price-history-panel .price-history-table-toggle summary::-webkit-details-marker {
  display: none;
}

#electricity-price-history-panel .price-history-table-toggle summary::after {
  content: "Open";
  float: right;
  color: #9aa3b6;
  letter-spacing: .08em;
}

#electricity-price-history-panel .price-history-table-toggle[open] summary::after {
  content: "Close";
}

#electricity-price-history-panel .price-history-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  border: 0 !important;
  border-radius: 0;
  margin-top: 0;
  max-height: 320px;
  max-width: 100%;
  background: #070a10 !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}

#electricity-price-history-panel table.price-history-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 12px;
  color: #f5f7fb !important;
  background: #070a10 !important;
  font-family: "Courier New", monospace;
}

#electricity-price-history-panel table.price-history-table thead,
#electricity-price-history-panel table.price-history-table tbody,
#electricity-price-history-panel table.price-history-table tr {
  background: transparent !important;
}

#electricity-price-history-panel table.price-history-table th,
#electricity-price-history-panel table.price-history-table td {
  border: 0 !important;
  border-bottom: 1px solid #252b36 !important;
  border-right: 1px solid rgba(255,255,255,.045) !important;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  background: #0b0f17 !important;
  color: #f5f7fb !important;
}

#electricity-price-history-panel table.price-history-table tbody tr:nth-child(even) td {
  background: #0f1520 !important;
}

#electricity-price-history-panel table.price-history-table tbody tr:hover td {
  background: #111b29 !important;
}

#electricity-price-history-panel table.price-history-table th {
  color: #00ffff !important;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: #05070c !important;
  position: sticky;
  top: 0;
  z-index: 2;
}

#electricity-price-history-panel table.price-history-table td:nth-child(2) {
  color: #00ffff !important;
  font-weight: 800;
}

#electricity-price-history-panel table.price-history-table td:nth-child(5) {
  color: #9aa3b6 !important;
}

@media (max-width: 850px) {
  #electricity-price-history-panel .price-history-grid { grid-template-columns: 1fr 1fr; }
  #electricity-price-history-panel #price-history-canvas { height: 220px !important; }
  #electricity-price-history-panel table.price-history-table { font-size: 11px; min-width: 700px; }
}

@media (max-width: 560px) {
  #electricity-price-history-panel .price-history-grid { grid-template-columns: 1fr; }
  #electricity-price-history-panel .price-history-value { font-size: 22px; }
  #electricity-price-history-panel #price-history-canvas { height: 205px !important; }
}

/* V3 price history fullscreen chart */
#electricity-price-history-panel .price-history-fullscreen-btn{border:1px solid #252b36!important;border-radius:4px;padding:7px 9px;color:#00ffff!important;background:rgba(0,255,255,.05)!important;font-family:"Courier New",monospace;cursor:pointer}.price-history-fullscreen-overlay{position:fixed;inset:0;display:none;z-index:9999;background:rgba(0,0,0,.92);padding:14px;box-sizing:border-box}.price-  … [line shortened here: 1,620 characters; full line on GitHub]

/* V3 price history calendar range controls */
#electricity-price-history-panel .price-history-date-label{display:flex;align-items:center;gap:6px;color:#9aa3b6;text-transform:uppercase;letter-spacing:.08em;font-size:11px}
#electricity-price-history-panel .price-history-date-label input{background:#050505!important;color:#00ffff!important;border:1px solid #252b36!important;border-radius:4px;padding:7px 9px;font-family:"Courier New",monospace}
#electricity-price-history-panel .price-history-date-apply{border:1px solid #252b36!important;border-radius:4px;padding:7px 9px;color:#00ffff!important;background:rgba(0,255,255,.05)!important;font-family:"Courier New",monospace;cursor:pointer}
#electricity-price-history-panel table.price-history-table tr.price-warning td{background:#20160b!important;color:#ffd28a!important}
#electricity-price-history-panel table.price-history-table tr.price-warning td:nth-child(2){color:#ffcc66!important}

#electricity-price-history-panel .price-history-range-status{width:100%;color:#9aa3b6;font-size:11px;line-height:1.45;border:1px solid #252b36;border-radius:4px;padding:7px 9px;background:#070a10;}
#electricity-price-history-panel table.price-history-table tr.price-warning td{background:#20160b!important;color:#ffd28a!important}
#electricity-price-history-panel table.price-history-table tr.price-warning td:nth-child(2){color:#ffcc66!important}

Price History UI

A JavaScript file in GlobalGrid2050 that loads CSV (`loadCsv`) and draws on a canvas, covering electricity price history and Elexon system prices half hourly.

energy-dataglobalgrid2050 / uk_energy_tracking_v3/price-history-ui.js · lines 1–24 of 24 · Not reached from any entry point (candidate for review) · pattern csvLine (shared by 4 files)

What it does
It draws electricity price history and Elexon system prices half hourly. Defines 14 functions or classes, including $, fmt, dlab, tlab, set. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage hv_procurement (path word 'price'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary.
Inputs & outputs
In: JSON file electricity_price_history.json; CSV file elexon_system_prices_half_hourly.csv. Out: canvas drawing.
What it achieves
It loads JSON (`loadJson`) and loads CSV (`loadCsv`). Defines `fmt`, `dlab`, `tlab` and 10 more. It responds to DOMContentLoaded, change and click events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v3 · script
Uses
none found
Used by
none found
Produces
$, fmt, dlab, tlab, set, csvLine, loadJson, loadCsv, norm, merge, customWindow, health
Defines here
$, fmt, dlab, tlab, set, csvLine, loadJson, loadCsv, norm, merge, customWindow, health, minMax, status
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v3/price-history-ui.js:1-24 · blob 106d921ff597cdcc154e6d3ef0afa22a1692ca0e · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
(function(){
var JSON_URL='/uk_energy_tracking_v3/electricity_price_history.json',CSV_URL='/data/electricity/elexon_system_prices_half_hourly.csv';
var STATE={all:[],visible:[],meta:null};window.__v3PriceHistoryState=STATE;
function $(id){return document.getElementById(id)}
function fmt(n,d){return n==null||isNaN(n)?'—':Number(n).toLocaleString('en-GB',{minimumFractionDigits:d,maximumFractionDigits:d})}
function dlab(t){return new Date(t).toLocaleDateString('en-GB',{day:'2-digit',month:'short',year:'numeric'})}
function tlab(t){return new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}
function set(id,v){var e=$(id);if(e)e.textContent=v}
function csvLine(l){var o=[],v='',q=false;for(var i=0;i<l.length;i++){var c=l[i];if(c==='"'){if(q&&l[i+1]==='"'){v+='"';i++}else q=!q}else if(c===','&&!q){o.push(v);v=''}else v+=c}o.push(v);return o}
function parseCsv(t){t=(t||'').trim();if(!t)return[];var lines=t.split(/\r?\n/),h=csvLine(lines[0]).map(x=>x.trim());return lines.slice(1).map(function(line){var c=csvLine(line),r={};h.forEach((x,i)=>r[x]=(c[i]||'').trim());var p=r.systemBuyPriceGBPperMWh||r.systemSellPriceGBPperMWh||r.priceGBPperMWh||'';return{source:r.source||'Elexon BMRS System Prices',priceTimeUTC:r.periodStartUTC||r.priceTime  … [line shortened here: 836 characters; full line on GitHub]
function loadJson(){return fetch(JSON_URL+'?t='+Date.now(),{cache:'no-store'}).then(r=>r.ok?r.json():{rows:[]}).then(d=>d.rows||[]).catch(()=>[])}
function loadCsv(){return fetch(CSV_URL+'?t='+Date.now(),{cache:'no-store'}).then(r=>r.ok?r.text():'').then(parseCsv).catch(()=>[])}
function norm(rows){var seen={};return(rows||[]).filter(r=>r.priceTimeUTC&&r.priceGBPperMWh!==''&&!isNaN(Number(r.priceGBPperMWh))).map(function(r){var o=Object.assign({},r);o.priceGBPperMWh=Number(o.priceGBPperMWh);return o}).sort((a,b)=>new Date(a.priceTimeUTC)-new Date(b.priceTimeUTC)).filter(function(r){var k=r.priceTimeUTC+'|'+r.priceGBPperMWh;if(seen[k])return false;seen[k]=1;return true})}
function merge(sys,cap){var m={};sys.forEach(r=>{m[r.priceTimeUTC]=Object.assign({},r,{source:'Elexon BMRS System Prices',priceHealth:r.priceHealth||'historical system price'})});cap.forEach(r=>{m[r.priceTimeUTC]=Object.assign({},r,{source:r.source||'V3 captured Elexon Market Index Price'})});return Object.keys(m).sort((a,b)=>new Date(a)-new Date(b)).map(k=>m[k])}
function customWindow(){var f=$('price-history-from'),t=$('price-history-to');if(!f||!t||!f.value||!t.value)return null;var a=new Date(f.value+'T00:00:00Z'),b=new Date(t.value+'T23:59:59Z');if(isNaN(a)||isNaN(b)||b<a)return null;var max=60*86400000;if(b-a>max)b=new Date(a.getTime()+max);return{start:a,end:b,label:f.value+' to '+b.toISOString().slice(0,10),custom:true}}
function rangeWindow(range,all){var cw=customWindow();if(cw)return cw;var now=new Date(),days={"24h":1,"7d":7,"30d":30,"3m":92,"6m":183,"12m":366,"10y":3650}[range];if(range==='all'||!days){var s=all.length?new Date(all[0].priceTimeUTC):now,e=all.length?new Date(all[all.length-1].priceTimeUTC):now;return{start:s,end:e,label:'all available data',custom:false}}return{start:new Date(now.getTime()-day  … [line shortened here: 446 characters; full line on GitHub]
function health(r){if(r.priceHealth&&r.priceHealth!=='ok')return 'price: '+r.priceHealth;if(r.carbonHealth&&r.carbonHealth!=='ok')return 'carbon: '+r.carbonHealth;if(r.carbonGperKWh!==''&&r.carbonGperKWh!=null)return r.carbonGperKWh+' g/kWh';if(r.carbonIndex)return String(r.carbonIndex);return '—'}
function minMax(v){var lo=v[0],hi=v[0];v.forEach(x=>{if(x<lo)lo=x;if(x>hi)hi=x});if(lo===hi)hi=lo+1;var m=(hi-lo)*.1;return{lo:lo-m,hi:hi+m}}
function draw(rows,meta){var c=$('price-history-canvas');if(!c)return;var q=devicePixelRatio||1,r=c.getBoundingClientRect();if(r.width){c.width=Math.max(320,Math.floor(r.width*q));c.height=Math.max(190,Math.floor((r.height||240)*q))}var g=c.getContext('2d'),w=c.width,h=c.height,p=62*q,rp=22*q;g.clearRect(0,0,w,h);g.fillStyle='#05070c';g.fillRect(0,0,w,h);g.font=12*q+'px Courier New';var t0=meta?me  … [line shortened here: 1,558 characters; full line on GitHub]
function table(rows,meta){var b=$('price-history-table-body');if(!b)return;if(!rows.length){b.innerHTML='<tr><td colspan="5">No records available for selected range: '+meta.label+'. Check data source or run Elexon backfill.</td></tr>';return}b.innerHTML=rows.slice().reverse().map(r=>'<tr class="'+((r.priceHealth&&r.priceHealth!=='ok')?'price-warning':'')+'"><td>'+dlab(r.priceTimeUTC)+' '+tlab(r.pr  … [line shortened here: 600 characters; full line on GitHub]
function status(meta,all,rows){var s=$('price-history-range-status');if(!s)return;var av=all.length?dlab(all[0].priceTimeUTC)+' to '+dlab(all[all.length-1].priceTimeUTC):'no source data';s.textContent='Selected range: '+dlab(meta.start)+' to '+dlab(meta.end)+' | Available source data: '+av+' | Visible records: '+rows.length}
function load(){var rangeEl=$('price-history-range'),range=rangeEl?rangeEl.value:'7d';Promise.all([loadJson(),loadCsv()]).then(function(p){var all=merge(norm(p[1]),norm(p[0])),meta=rangeWindow(range,all);var rows=all.filter(r=>{var t=new Date(r.priceTimeUTC);return t>=meta.start&&t<=meta.end});STATE.all=all;STATE.visible=rows;STATE.meta=meta;var latest=all.length?all[all.length-1]:null;set('ph-lat  … [line shortened here: 868 characters; full line on GitHub]
document.addEventListener('DOMContentLoaded',function(){var r=$('price-history-range'),f=$('price-history-from'),t=$('price-history-to'),cl=$('price-history-clear-dates');if(r)r.addEventListener('change',load);if(f)f.addEventListener('change',load);if(t)t.addEventListener('change',load);if(cl)cl.addEventListener('click',function(){if(f)f.value='';if(t)t.value='';load()});load();setInterval(load,5*  … [line shortened here: 502 characters; full line on GitHub]
})();

Live App

A JavaScript file in GlobalGrid2050 that works with ensure archive notice (`ensureArchiveNotice`) and ensure summary style (`ensureSummaryStyle`).

renderglobalgrid2050 / uk_energy_tracking_v4/live-app.js · lines 1–60 of 60 · Not reached from any entry point (candidate for review) · pattern ensureSummaryPanel (shared by 2 files)

What it does
It draws its content. Defines ensureArchiveNotice, ensureSummaryStyle, ensureSummaryPanel, refresh. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage upstream_foresight (topic 'markets-data'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
What it achieves
It is built from the ensure archive notice helper (`ensureArchiveNotice`), the ensure summary style helper (`ensureSummaryStyle`) and the ensure summary panel helper (`ensureSummaryPanel`). V4 live tracker app boot and refresh loop. It responds to change events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
none found
Produces
ensureArchiveNotice, ensureSummaryStyle, ensureSummaryPanel, refresh
Defines here
ensureArchiveNotice, ensureSummaryStyle, ensureSummaryPanel, refresh
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-app.js:1-60 · blob 001281032b5f0a950f6ccd6459cee2de13a7aa8c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker app boot and refresh loop. Load last.
// V4 is now retired as a live page. V5 is the operational tracker.
function ensureArchiveNotice(){
  if(document.getElementById('v4-archive-notice')) return;
  var s=document.createElement('style');
  s.id='v4-archive-style';
  s.textContent='\n.v4-archive-notice{border:1px solid #ffcc00;background:rgba(255,204,0,.08);color:#f5f7fb;border-radius:6px;padding:14px 16px;margin:16px 0 20px;font-family:"Courier New",monospace;line-height:1.5;box-shadow:0 0 18px rgba(255,204,0,.08)}\n.v4-archive-notice strong{color:#ffcc00;text-transform:uppercase;letter-spacing:.12em;display:block;margin-bottom:6px}\n.v4-archive-notice a{co  … [line shortened here: 432 characters; full line on GitHub]
  document.head.appendChild(s);
  var grid=document.getElementById('scada-grid');
  if(!grid) return;
  var note=document.createElement('div');
  note.id='v4-archive-notice';
  note.className='v4-archive-notice';
  note.innerHTML='<strong>V4 archived</strong>This version is retained for reference only and is no longer the live operational tracker. Please use <a href="/uk_energy_tracking_v5/">UK Live Grid Tracker V5</a> for current electricity, price, carbon and energy data.';
  grid.insertBefore(note, grid.firstChild);
}
function ensureSummaryStyle(){
  if(document.getElementById('v4-live-summary-style')) return;
  var s=document.createElement('style');
  s.id='v4-live-summary-style';
  s.textContent='\n.scada-gauges{display:none!important;}\n.scada-live-summary{border:1px solid var(--gg-cyan,#00ffff);background:rgba(0,255,255,.04);border-radius:6px;padding:18px 16px;margin:18px 0 24px;box-shadow:0 0 18px rgba(0,255,255,.08);font-family:"Courier New",monospace;}\n.scada-summary-title{color:var(--gg-cyan,#00ffff);text-transform:uppercase;letter-spacing:.16em;font-size:13px;margi  … [line shortened here: 1,302 characters; full line on GitHub]
  document.head.appendChild(s);
}
function ensureSummaryPanel(){
  ensureSummaryStyle();
  var existing=document.getElementById('scada-live-summary');
  if(existing) return existing;
  var gauges=document.querySelector('.scada-gauges');
  var panel=document.createElement('section');
  panel.id='scada-live-summary';
  panel.className='scada-live-summary';
  panel.innerHTML='<div class="scada-summary-title">Archived electricity snapshot</div>'+ 
    '<div class="scada-summary-grid">'+
    '<div><span>Demand</span><strong id="summary-demand">—</strong><em>GW</em></div>'+ 
    '<div><span>Price</span><strong id="summary-price">—</strong><em>£/MWh</em></div>'+ 
    '<div><span>Carbon</span><strong id="summary-carbon">—</strong><em>g/kWh</em></div>'+ 
    '</div>'+ 
    '<div class="scada-summary-time" id="summary-timestamps">Archived V4 feed. Use V5 for current data.</div>';
  if(gauges&&gauges.parentNode){gauges.parentNode.insertBefore(panel,gauges);}
  else{document.getElementById('scada-grid').appendChild(panel);}
  return panel;
}
function refresh(){
    Promise.all([getJSON(ENERGY),getJSON(PRICE),getJSON(OIL),getJSON(OIL_HISTORY),getJSON(FUEL),getJSON(EV_PRICES)]).then(function(res){
      var e=res[0]||{}, p=res[1]||{}, oil=res[2]||{}, hist=res[3], fuel=res[4]||{}, ev=res[5]||{};
      ensureArchiveNotice(); ensureSummaryPanel();
      renderGauge("demand", e.demandGW); renderGauge("price", p.priceGBPperMWh); renderGauge("carbon", carbonValue(p));
      if(e.mix) renderMix(e.mix); renderCommodities(oil,fuel); renderEvPrices(ev); if(hist) drawOilTrend(hist);
      var latest=latestIso(e.updated,p.updated,oil.updated);
      setText("summary-demand",e.demandGW==null?"—":fmt(e.demandGW,2));
      setText("summary-price",p.priceGBPperMWh==null?"—":fmt(p.priceGBPperMWh,2));
      setText("summary-carbon",carbonValue(p)==null?"—":Math.round(carbonValue(p)));
      setText("summary-timestamps",latest?"Archived V4. Last stored update: "+dateLabel(latest)+" · energy "+timeLabel(e.updated)+" · price "+timeLabel(p.updated)+" · commodities "+timeLabel(oil.updated):"Archived V4 feed. Use V5 for current data.");
      var s=document.getElementById("scada-status");
      if(s){s.textContent="";s.style.display="none";}
    });
  }
  var oilRange=document.getElementById("oil-range");
  if(oilRange) oilRange.addEventListener("change", function(){ getJSON(OIL_HISTORY).then(drawOilTrend); });
  parseMarketInputs(); ensureArchiveNotice(); ensureSummaryPanel(); refresh(); setInterval(refresh, POLL);

Live Config

A JavaScript file in GlobalGrid2050 covering live grid energy, live grid price, live oil prices and oil price history.

otherglobalgrid2050 / uk_energy_tracking_v4/live-config.js · lines 1–7 of 7 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage upstream_foresight (topic 'markets-data'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file live_grid_energy.json; JSON file live_grid_price.json; JSON file live_oil_prices.json; GeoJSON file oil_price_history.geojson; JSON file live_uk_fuel_prices.json; JSON file ev_charging_prices.json.
What it achieves
V4 live tracker config.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-config.js:1-7 · blob 3acdcb67e9f79eb5bdb98d86645ff5cc8958cc39 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker config. Load first.
var ENERGY="/uk_energy_tracking_v4/live_grid_energy.json", PRICE="/uk_energy_tracking_v4/live_grid_price.json", OIL="/uk_energy_tracking_v4/live_oil_prices.json", OIL_HISTORY="/uk_energy_tracking_v4/oil_price_history.geojson", FUEL="/uk_energy_tracking_v4/live_uk_fuel_prices.json", EV_PRICES="/uk_energy_tracking_v4/ev_charging_prices.json", POLL=5*60*1000;
  var GAUGES={
    demand:{min:0,max:45,unit:"Gigawatts (GW)",colour:"#00ffff"},
    price:{min:-50,max:250,unit:"Pounds per Megawatt hour (£/MWh)",colour:"#ff00e6"},
    carbon:{min:0,max:400,unit:"Grams per Kilowatt hour (g/kWh)",colour:"#00ff88"}
  };

Live Gauges

A JavaScript file in GlobalGrid2050 that renders mix (`renderMix`). It renders gauge (`renderGauge`), renders mix (`renderMix`) and gets JSON (`getJSON`).

Set aside from the main view: Near copy of uk_energy_tracking_v5/live-gauges.js (globalgrid2050), which stays: reachable first, then the higher version. (near-copy-of, proposed by families.py). 91% of lines shared with Live Gauges; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9167 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-gauges.js:1-25 9df45f2baae65971482e7fa51fc8c4c923b91ae1
  • sha256 96b5c311e980720ddfc1c3dca4795ddf70a42378c730f6705280d500b4bb114b
  • target sha256 56ce69953e7d458c9399e2e8b1768f9ba723401db38203e77cd0b3414d2c709f
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule (was canonical)

renderglobalgrid2050 / uk_energy_tracking_v4/live-gauges.js · lines 1–25 of 25 · Not reached from any entry point (candidate for review) · pattern carbonValue (shared by 2 files)

What it does
It draws its content. Defines 9 functions or classes, including renderGauge, renderMix, ageMin, timeLabel, dateLabel. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage upstream_foresight (topic 'markets-data'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
What it achieves
V4 live tracker gauges and generation mix rendering.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
none found
Produces
renderGauge, renderMix, ageMin, timeLabel, dateLabel, latestIso, carbonValue, getJSON, setText
Defines here
renderGauge, renderMix, ageMin, timeLabel, dateLabel, latestIso, carbonValue, getJSON, setText
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-gauges.js:1-25 · blob 9df45f2baae65971482e7fa51fc8c4c923b91ae1 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker gauges and generation mix rendering.
function renderGauge(name,value){
    var cfg=GAUGES[name], svg=document.querySelector('[data-gauge="'+name+'"]'); if(!svg) return;
    var p=pct(value,cfg.min,cfg.max), end=-90+(180*p);
    var display=value===null||value===undefined||isNaN(value)?"—":(name==="carbon"?Math.round(value):fmt(value, name==="price"?0:2));
    svg.innerHTML='<path class="scada-gauge-bg" d="'+arcPath(30,115,80,-90,90)+'"></path>'+
      '<path class="scada-gauge-fill" style="color:'+cfg.colour+';stroke:'+cfg.colour+'" d="'+arcPath(30,115,80,-90,end)+'"></path>'+
      '<text class="scada-gauge-value" x="110" y="94">'+display+'</text>'+
      '<text class="scada-gauge-unit" x="110" y="120">'+cfg.unit+'</text>';
  }
  function renderMix(mix){
    var w=document.getElementById("scada-mix"); if(!Array.isArray(mix)){return;}
    w.innerHTML=mix.map(function(r){
      var width=Math.max(0,Math.min(100,Math.abs(r.pct)));
      return '<div class="scada-mini"><div class="scada-mini-top"><div class="scada-mini-name">'+r.label+'</div><div class="scada-mini-value">'+fmt(r.gw)+' Gigawatts (GW) · '+fmt(r.pct)+'%</div></div>'+
        '<div class="scada-mini-track"><div class="scada-mini-fill" style="width:'+width+'%;background:'+r.color+';box-shadow:0 0 10px '+r.color+'"></div></div></div>';
    }).join("");
  }
  function ageMin(iso){return iso?(Date.now()-new Date(iso).getTime())/60000:Infinity;}
  function timeLabel(iso){return iso?new Date(iso).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"Awaiting feed";}
  function dateLabel(iso){return iso?new Date(iso).toLocaleDateString("en-GB",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}):"";}
  function latestIso(a,b,c){ var arr=[a,b,c].filter(Boolean).sort(function(x,y){return new Date(y)-new Date(x)}); return arr[0]||null; }
  function carbonValue(p){ return p.carbonGperKWh==null ? p.carbonForecast : p.carbonGperKWh; }
  function getJSON(u){return fetch(u+"?t="+Date.now(),{cache:"no-store"}).then(function(r){if(!r.ok)throw 0;return r.json();}).catch(function(){return null;});}
  function setText(id,val){ var el=document.getElementById(id); if(el) el.textContent=val; }

Live Helpers

A JavaScript file in GlobalGrid2050 that works with arc path (`arcPath`). It is built from the fmt step (`fmt`), the pct step (`pct`) and the arc path helper (`arcPath`).

transformglobalgrid2050 / uk_energy_tracking_v4/live-helpers.js · lines 1–9 of 9 · Not reached from any entry point (candidate for review) · pattern arcPath (shared by 2 files)

What it does
It calculates its inputs. Defines fmt, pct, arcPath.
Why it exists in the grid workflow
Domain stage upstream_foresight (topic 'markets-data'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
What it achieves
V4 live tracker helpers. Depends on config.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
mentioned in Standalone (comment link)
Produces
fmt, pct, arcPath
Defines here
fmt, pct, arcPath
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-helpers.js:1-9 · blob 266f655712850c10b9ace73a62afc1f1a4626f3e · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker helpers. Depends on config.
function fmt(n,dp){return (n===null||n===undefined||isNaN(n))?"—":Number(n).toLocaleString("en-GB",{minimumFractionDigits:dp==null?2:dp,maximumFractionDigits:dp==null?2:dp});}
  function pct(n,min,max){ if(n===null||n===undefined||isNaN(n)) return 0; return Math.max(0,Math.min(1,(Number(n)-min)/(max-min))); }
  function arcPath(cx,cy,r,start,end){
    var s=(start-90)*Math.PI/180, e=(end-90)*Math.PI/180;
    var x1=cx+r*Math.cos(s), y1=cy+r*Math.sin(s), x2=cx+r*Math.cos(e), y2=cy+r*Math.sin(e);
    var large=end-start<=180?0:1;
    return "M "+x1+" "+y1+" A "+r+" "+r+" 0 "+large+" 1 "+x2+" "+y2;
  }

Live Oil Chart

A JavaScript file in GlobalGrid2050 that draws oil trend (`drawOilTrend`), binds oil tooltip (`bindOilTooltip`) and reads inputs for oil range. It draws oil trend (`drawOilTrend`) and binds oil tooltip (`bindOilTooltip`).

Set aside from the main view: Near copy of uk_energy_tracking_v5/live-oil-chart.js (globalgrid2050), which stays: reachable first, then the higher version. (near-copy-of, proposed by families.py). 97% of lines shared with Live Oil Chart; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9762 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-oil-chart.js:1-97 46866e2a7238f85ad2d1c769855a0358cefbd402
  • sha256 6a0e27ee26ccd04aadaa08a46c0262e818463e4227a935c123a748f342d0b536
  • target sha256 b3352d5e342fbe49bb2c51d4756f40390c4ff90c7c33275f4c21fc4145064dc9
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule (was canonical)

renderglobalgrid2050 / uk_energy_tracking_v4/live-oil-chart.js · lines 1–97 of 97 · Not reached from any entry point (candidate for review) · pattern bindOilTooltip (shared by 2 files)

What it does
It draws its content. Defines 8 functions or classes, including rangeCutoff, oilStats, drawOilTrend, x, line. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage upstream_foresight (topic 'markets-data'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
Out: canvas drawing.
What it achieves
V4 live tracker oil history chart. It responds to mousemove, touchmove and mouseleave events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
mentioned in Standalone (comment link)
Produces
rangeCutoff, oilStats, drawOilTrend, x, line, bindOilTooltip, show, hide
Defines here
rangeCutoff, oilStats, drawOilTrend, x, line, bindOilTooltip, show, hide
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-oil-chart.js:1-97 · blob 46866e2a7238f85ad2d1c769855a0358cefbd402 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker oil history chart.
var oilChartState = { rows: [], x: null, y: null, canvas: null, activeIndex: null, min: 0, max: 0, pad: 54 };
  function rangeCutoff(range){
    if(range === "all") return null;
    var d = new Date();
    if(range === "7d") d.setDate(d.getDate()-7);
    else if(range === "1m") d.setMonth(d.getMonth()-1);
    else if(range === "3m") d.setMonth(d.getMonth()-3);
    else if(range === "6m") d.setMonth(d.getMonth()-6);
    else if(range === "9m") d.setMonth(d.getMonth()-9);
    else if(range === "1y") d.setFullYear(d.getFullYear()-1);
    else if(range === "5y") d.setFullYear(d.getFullYear()-5);
    else if(range === "10y") d.setFullYear(d.getFullYear()-10);
    else if(range === "25y") d.setFullYear(d.getFullYear()-25);
    return d;
  }
  function oilStats(rows){
    var vals=[]; rows.forEach(function(p){ if(p.brentUSDperBarrel) vals.push(p.brentUSDperBarrel); if(p.wtiUSDperBarrel) vals.push(p.wtiUSDperBarrel); });
    var el=document.getElementById("oil-stats"); if(!el) return;
    if(!vals.length){ el.innerHTML=""; return; }
    var high=Math.max.apply(null,vals), low=Math.min.apply(null,vals), avg=vals.reduce(function(a,b){return a+b;},0)/vals.length;
    var variance=vals.reduce(function(a,b){return a+Math.pow(b-avg,2);},0)/vals.length;
    var vol=avg?Math.sqrt(variance)/avg*100:0;
    el.innerHTML = [
      ["High", "$"+fmt(high,2)], ["Low", "$"+fmt(low,2)], ["Average", "$"+fmt(avg,2)], ["Volatility", fmt(vol,1)+"%"]
    ].map(function(x){return '<div class="oil-stat"><div class="oil-stat-label">'+x[0]+'</div><div class="oil-stat-value">'+x[1]+'</div></div>';}).join("");
  }
  function drawOilTrend(geo, activeIndex){
    var canvas=document.getElementById("oil-trend-canvas"); if(!canvas||!geo||!Array.isArray(geo.features)) return;
    var ctx=canvas.getContext("2d"), range=document.getElementById("oil-range").value;
    var rows=geo.features.map(function(f){return f.properties||{};}).filter(function(p){return p.date&&(p.brentUSDperBarrel||p.wtiUSDperBarrel);});
    var cutoff=rangeCutoff(range); if(cutoff) rows=rows.filter(function(p){return new Date(p.date)>=cutoff;});
    var w=canvas.width,h=canvas.height,pad=54,rightPad=28;
    ctx.clearRect(0,0,w,h); ctx.fillStyle="#070a10"; ctx.fillRect(0,0,w,h);
    if(rows.length<2) { ctx.fillStyle="#a6adbb"; ctx.font="14px Courier New"; ctx.fillText("Waiting for oil history data", pad, 42); oilStats([]); return; }
    var vals=[]; rows.forEach(function(p){ if(p.brentUSDperBarrel) vals.push(p.brentUSDperBarrel); if(p.wtiUSDperBarrel) vals.push(p.wtiUSDperBarrel); });
    var min=Math.min.apply(null,vals), max=Math.max.apply(null,vals); if(max===min){max=min+1;}
    function x(i){return pad+(i/(rows.length-1))*(w-pad-rightPad);} function y(v){return h-pad-((v-min)/(max-min))*(h-pad*1.85);}
    ctx.strokeStyle="#252b36"; ctx.lineWidth=1;
    ctx.fillStyle="#a6adbb"; ctx.font="16px Courier New";
    for(var g=0;g<5;g++){
      var value=max-(g*(max-min)/4), yy=y(value);
      ctx.beginPath();ctx.moveTo(pad,yy);ctx.lineTo(w-rightPad,yy);ctx.stroke();
      ctx.fillText("$"+fmt(value,0), 8, yy+4);
    }
    ctx.save();
    ctx.translate(14, h/2 + 70);
    ctx.rotate(-Math.PI/2);
    ctx.fillStyle="#a6adbb";
    ctx.font="11px Courier New";
    ctx.fillText("US dollars per barrel (USD/bbl)", 0, 0);
    ctx.restore();

    function line(field,colour){
      ctx.strokeStyle=colour;ctx.lineWidth=2;ctx.beginPath();var started=false;
      rows.forEach(function(p,i){var v=p[field];if(!v)return; if(!started){ctx.moveTo(x(i),y(v));started=true;}else{ctx.lineTo(x(i),y(v));}});
      ctx.stroke();
    }
    line("brentUSDperBarrel","#ff9900"); line("wtiUSDperBarrel","#00ffff");
    ctx.fillStyle="#a6adbb"; ctx.font="12px Courier New";
    ctx.fillText("Brent",pad,18); ctx.fillStyle="#ff9900"; ctx.fillRect(pad+46,10,18,4);
    ctx.fillStyle="#a6adbb"; ctx.fillText("WTI",pad+78,18); ctx.fillStyle="#00ffff"; ctx.fillRect(pad+112,10,18,4);

    var idx = Number.isFinite(activeIndex) ? Math.max(0, Math.min(rows.length-1, activeIndex)) : null;
    if(idx !== null){
      var xx=x(idx);
      ctx.strokeStyle="rgba(255,255,255,.85)";
      ctx.lineWidth=1.5;
      ctx.beginPath(); ctx.moveTo(xx, pad*0.72); ctx.lineTo(xx, h-pad); ctx.stroke();
      var p=rows[idx];
      ["brentUSDperBarrel","wtiUSDperBarrel"].forEach(function(field){
        var v=p[field]; if(!v) return;
        ctx.fillStyle = field==="brentUSDperBarrel" ? "#ff9900" : "#00ffff";
        ctx.beginPath(); ctx.arc(xx, y(v), 4, 0, Math.PI*2); ctx.fill();
      });
    }

    oilChartState={rows:rows,x:x,y:y,canvas:canvas,activeIndex:idx,min:min,max:max,pad:pad}; oilStats(rows); bindOilTooltip();
  }
  function bindOilTooltip(){
    var canvas=document.getElementById("oil-trend-canvas"), tip=document.getElementById("oil-tooltip"); if(!canvas||!tip||canvas.__oilTipBound) return;
    canvas.__oilTipBound=true;
    function show(e){
      var rect=canvas.getBoundingClientRect();
      var clientX=(e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX);
      var px=(clientX-rect.left)*(canvas.width/rect.width);
      var rows=oilChartState.rows||[]; if(!rows.length) return;
      var pad=oilChartState.pad||54, rightPad=28;
      var idx=Math.max(0,Math.min(rows.length-1,Math.round((px-pad)/(canvas.width-pad-rightPad)*(rows.length-1))));
      drawOilTrend(window.__oilGeojsonCache, idx);
      var p=rows[idx];
      tip.innerHTML='<strong>'+p.date+'</strong><br>Brent: '+(p.brentUSDperBarrel?'$'+fmt(p.brentUSDperBarrel,2):'—')+' USD/bbl<br>WTI: '+(p.wtiUSDperBarrel?'$'+fmt(p.wtiUSDperBarrel,2):'—')+' USD/bbl';
      tip.style.display='block'; tip.style.left=Math.min(rect.width-190,Math.max(8,clientX-rect.left+12))+'px'; tip.style.top='42px';
    }
    function hide(){ tip.style.display='none'; drawOilTrend(window.__oilGeojsonCache, null); }
    canvas.addEventListener('mousemove',show); canvas.addEventListener('touchmove',show,{passive:true}); canvas.addEventListener('mouseleave',hide); canvas.addEventListener('touchend',hide);
  }

Live Transport

A JavaScript file in GlobalGrid2050 that renders commodities (`renderCommodities`) and fuel breakdown (`renderFuelBreakdown`) and parses market inputs (`parseMarketInputs`).

energy-dataglobalgrid2050 / uk_energy_tracking_v4/live-transport.js · lines 1–37 of 37 · Not reached from any entry point (candidate for review) · pattern renderFuelBreakdown (shared by 2 files)

What it does
It draws its content. Defines renderCommodities, renderFuelBreakdown, parseMarketInputs, renderEvPrices. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage sub33kv_design (voltage levels 33kV (all 33kV or below)): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: 33kV.
Inputs & outputs
Voltage levels named: 33kV.
What it achieves
It renders commodities (`renderCommodities`), renders fuel breakdown (`renderFuelBreakdown`) and parses market inputs (`parseMarketInputs`). V4 live tracker commodity, road fuel and EV rendering.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
none found
Produces
renderCommodities, renderFuelBreakdown, parseMarketInputs, renderEvPrices
Defines here
renderCommodities, renderFuelBreakdown, parseMarketInputs, renderEvPrices
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/live-transport.js:1-37 · blob 76dbaa3782ffaef77e5e6ac25a3925c4ac1ea509 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// V4 live tracker commodity, road fuel and EV rendering.
function renderCommodities(oil,fuel){
    oil=oil||{}; fuel=fuel||{};
    setText("brent-price", oil.brentUSDperBarrel==null?"—":"$"+fmt(oil.brentUSDperBarrel,2));
    setText("wti-price", oil.wtiUSDperBarrel==null?"—":"$"+fmt(oil.wtiUSDperBarrel,2));
    var latest=fuel.latest||{};
    setText("petrol-price", latest.petrolPencePerLitre==null?"—":fmt(latest.petrolPencePerLitre,2)+"p");
    setText("diesel-price", latest.dieselPencePerLitre==null?"—":fmt(latest.dieselPencePerLitre,2)+"p");
    renderFuelBreakdown(oil, latest);
  }
  function renderFuelBreakdown(oil, latest){
    var el=document.getElementById("fuel-breakdown"); if(!el) return;
    var brent=oil&&oil.brentUSDperBarrel, petrol=latest&&latest.petrolPencePerLitre;
    if(brent==null || petrol==null){ el.textContent="Awaiting Brent crude and DESNZ fuel price feed."; return; }
    var gbpUsd=1.27, litresPerBarrel=158.987, duty=52.95, vatRate=0.20;
    var crudePpl=(Number(brent)/gbpUsd/litresPerBarrel)*100;
    var preVat=Number(petrol)/(1+vatRate);
    var vat=Number(petrol)-preVat;
    var spread=preVat-duty-crudePpl;
    el.innerHTML="Brent proxy: $"+fmt(brent,2)+"/bbl divided by FX "+gbpUsd+" and 159 litres equals about "+fmt(crudePpl,1)+"p/l crude input. Petrol pump: "+fmt(petrol,2)+"p/l. VAT at 20%: "+fmt(vat,1)+"p/l. Fuel duty assumption: "+fmt(duty,2)+"p/l. Implied refining, logistics, wholesale and retail spread: "+fmt(spread,1)+"p/l. Week: "+(latest.week||"not stated")+".";
  }
  function parseMarketInputs(){
    fetch("/33kv_uk_dap_price_estimator/").then(function(r){return r.text();}).then(function(html){
      var c=html.match(/LME Copper \(USD\)[\s\S]*?USD\s*([0-9,]+)/i);
      var a=html.match(/LME Aluminium \(USD\)[\s\S]*?USD\s*([0-9,]+)/i);
      setText("copper-price", c?"$"+c[1]:"—");
      setText("aluminium-price", a?"$"+a[1]:"—");
    }).catch(function(){ setText("copper-price","—"); setText("aluminium-price","—"); });
  }

  function renderEvPrices(ev){
    var ops=(ev&&ev.operators)||[];
    var rapid=[], ultra=[];
    ops.forEach(function(o){ if(o.rapidPencePerKWh!=null) rapid.push(Number(o.rapidPencePerKWh)); if(o.ultraRapidPencePerKWh!=null) ultra.push(Number(o.ultraRapidPencePerKWh)); });
    if(rapid.length){ setText("ev-rapid-price", fmt(rapid.reduce(function(a,b){return a+b;},0)/rapid.length,1)+"p"); }
    if(ultra.length){ setText("ev-ultra-price", fmt(ultra.reduce(function(a,b){return a+b;},0)/ultra.length,1)+"p"); }
  }

Price History Fullscreen

A JavaScript file in GlobalGrid2050 that draws date tick (`drawDateTick`) and events (`drawEvents`) and syncs fs (`syncFs`). It draws date tick (`drawDateTick`), draws events (`drawEvents`) and syncs fs (`syncFs`).

energy-dataglobalgrid2050 / uk_energy_tracking_v4/price-history-fullscreen.js · lines 1–30 of 30 · Not reached from any entry point (candidate for review) · pattern eventPoints (shared by 2 files)

What it does
It draws its content. Defines 15 functions or classes, including $, fmt, mlab, slab, tlab. Side effects: changes the web page (DOM); reads or writes files.
Why it exists in the grid workflow
Domain stage hv_procurement (path word 'price'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary.
Inputs & outputs
Out: canvas drawing.
What it achieves
Defines `fmt`, `mlab`, `slab` and 10 more. It responds to click, DOMContentLoaded and keydown events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · uk_energy_tracking_v4 · script
Uses
none found
Used by
none found
Produces
$, fmt, mlab, slab, tlab, mm, niceStep, injectStyle, modeText, drawDateTick, eventPoints, drawEvents
Defines here
$, fmt, mlab, slab, tlab, mm, niceStep, injectStyle, modeText, drawDateTick, eventPoints, drawEvents, syncFs, open, close
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 uk_energy_tracking_v4/price-history-fullscreen.js:1-30 · blob eab9e8242be26fb328e798f08f8eb0a911f01410 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
(function(){
var S={rows:[],meta:null};
function $(id){return document.getElementById(id)}
function fmt(n,d){return Number(n).toLocaleString('en-GB',{minimumFractionDigits:d,maximumFractionDigits:d})}
function mlab(t){return new Date(t).toLocaleDateString('en-GB',{month:'short',year:'2-digit'})}
function slab(t){return new Date(t).toLocaleDateString('en-GB',{day:'2-digit',month:'short',year:'numeric'})}
function tlab(t){return new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}
function mm(v){var lo=0,hi=0;v.forEach(function(x){if(x<lo)lo=x;if(x>hi)hi=x});if(lo===hi)hi=lo+1;var m=(hi-lo)*0.08;return{lo:lo-m,hi:hi+m}}
function niceStep(span){var raw=span/7,p=Math.pow(10,Math.floor(Math.log10(Math.max(raw,1)))),n=raw/p;if(n<=1)return p;if(n<=2)return 2*p;if(n<=5)return 5*p;return 10*p}
function injectStyle(){
 if(document.getElementById('v4-fullscreen-graph-controls'))return;
 var s=document.createElement('style');
 s.id='v4-fullscreen-graph-controls';
 s.textContent='.price-history-fullscreen-overlay.open{display:block!important}.price-history-fullscreen-overlay{position:fixed!important;inset:0!important;z-index:99999!important;background:#000!important;padding:0!important;overflow:hidden!important}.price-history-fullscreen-shell{position:fixed!important;inset:0!important;width:100vw!important;height:100dvh!important;border:0!important;border-r  … [line shortened here: 2,206 characters; full line on GitHub]
 document.head.appendChild(s)
}
function ensureControls(){injectStyle();var o=$('price-history-fullscreen-overlay');if(!o||$('fs-mini'))return;var mini=document.createElement('div');mini.id='fs-mini';mini.className='fs-mini';mini.innerHTML='<button type="button" data-fs-mode="all" class="active">All</button><button type="button" data-fs-mode="day">Day</button><button type="button" data-fs-mode="night">Night</button>';var left=do  … [line shortened here: 853 characters; full line on GitHub]
function bindControls(){var c=window.__v4PriceHistoryControls;if(!c)return;var prev=$('fs-prev'),next=$('fs-next'),mini=$('fs-mini');if(prev)prev.addEventListener('click',function(){var st=window.__v4PriceHistoryState||{},days=c.periodDays((st.meta||{}).period||'7d'),v=c.offsetFromDate((st.meta||{}).start||new Date());c.setOffset(Math.max(0,v-days));setTimeout(open,120)});if(next)next.addEventList  … [line shortened here: 903 characters; full line on GitHub]
function modeText(){var st=window.__v4PriceHistoryState||{};var m=st.timeMode||'all';if(m==='day')return 'Day 06 to 18 UTC';if(m==='night')return 'Night 18 to 06 UTC';return 'All hours'}
function drawDateTick(g,x,y,t,q,align){g.textAlign=align||'center';g.fillStyle='#f5f7fb';g.font=11*q+'px Courier New';g.fillText(mlab(t),x,y);g.textAlign='left'}
function drawAxes(g,w,h,q,m,t0,t1,pad){var step=niceStep(m.hi-m.lo),start=Math.ceil(m.lo/step)*step;g.lineWidth=q;g.font=11*q+'px Courier New';g.textAlign='left';for(var val=start;val<=m.hi+step*.5;val+=step){var yy=pad.top+((m.hi-val)/(m.hi-m.lo))*(h-pad.top-pad.bottom);g.strokeStyle=val===0?'rgba(255,51,51,.98)':'rgba(255,255,255,.17)';g.lineWidth=val===0?2*q:q;g.beginPath();g.moveTo(pad.left,yy  … [line shortened here: 866 characters; full line on GitHub]
function eventPoints(rows){if(!rows.length)return null;var hi=rows[0],lo=rows[0];rows.forEach(function(r){if(Number(r.priceGBPperMWh)>Number(hi.priceGBPperMWh))hi=r;if(Number(r.priceGBPperMWh)<Number(lo.priceGBPperMWh))lo=r});return{hi:hi,lo:lo}}
function marker(g,label,r,x,y,q,above){var placeRight=label==='HIGH';var tx=placeRight?Math.min(g.canvas.width-118*q,x+18*q):Math.max(118*q,x-18*q);var ty=above?Math.max(62*q,y-32*q):Math.min(g.canvas.height-54*q,y+46*q);g.fillStyle='#ff3333';g.strokeStyle='#ff3333';g.lineWidth=1.3*q;g.beginPath();g.arc(x,y,3.8*q,0,Math.PI*2);g.fill();g.beginPath();g.moveTo(x,y);g.lineTo(tx,ty-10*q);g.stroke();g.f  … [line shortened here: 642 characters; full line on GitHub]
function drawEvents(g,rows,X,Y,q){var e=eventPoints(rows);if(!e)return;marker(g,'HIGH',e.hi,X(e.hi),Y(Number(e.hi.priceGBPperMWh)),q,true);marker(g,'LOW',e.lo,X(e.lo),Y(Number(e.lo.priceGBPperMWh)),q,false)}
function draw(){var c=$('price-history-fullscreen-canvas');if(!c)return;var q=devicePixelRatio||1,cssW=window.innerWidth,cssH=window.innerHeight;c.width=Math.max(320,Math.floor(cssW*q));c.height=Math.max(320,Math.floor(cssH*q));var g=c.getContext('2d'),w=c.width,h=c.height,isLandscape=w>h;var pad={left:(isLandscape?70:62)*q,right:(isLandscape?58:36)*q,top:(isLandscape?62:82)*q,bottom:(isLandscape?  … [line shortened here: 1,751 characters; full line on GitHub]
function syncFs(){var st=window.__v4PriceHistoryState||{};var mini=$('fs-mini');if(mini){mini.querySelectorAll('button').forEach(function(b){b.classList.toggle('active',b.getAttribute('data-fs-mode')===(st.timeMode||'all'))})}}
function open(){ensureControls();var o=$('price-history-fullscreen-overlay'),st=window.__v4PriceHistoryState;if(!o)return;document.documentElement.classList.add('v4-chart-open');document.body.classList.add('v4-chart-open');o.classList.add('open');S.rows=(st&&st.visible)||[];S.meta=(st&&st.meta)||null;syncFs();setTimeout(draw,40)}
function close(){var o=$('price-history-fullscreen-overlay');if(o)o.classList.remove('open');document.documentElement.classList.remove('v4-chart-open');document.body.classList.remove('v4-chart-open')}
document.addEventListener('DOMContentLoaded',function(){injectStyle();var b=$('price-history-fullscreen-btn'),c=$('price-history-fullscreen-close'),r=$('price-history-zoom-reset');if(b)b.onclick=open;if(c)c.onclick=close;if(r)r.onclick=draw;document.addEventListener('keydown',function(e){if(e.key==='Escape')close()});window.addEventListener('resize',function(){if($('price-history-fullscreen-overla  … [line shortened here: 481 characters; full line on GitHub]
})();