Spaces:
Sleeping
Sleeping
Update app.py
Browse files565 unmodified lines566567568569570571572573141 unmodified lines71571671771871972072172272344 unmodified lines7687697707717727737747757767777787797801 unmodified line782783784785786787788789790791792793794565 unmodified linesconst allW = [].concat(BUYS.map(x=>x[2]),SELLS.map(x=>x[2]),TRANSFERS.map(x=>x[2]));const stroke = d3.scaleLinear().domain([Math.min(...allW), Math.max(...allW)]).range([1,6]);141 unmodified lineslet sells = SELLS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);let transfers = TRANSFERS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);let loops = LOOPS.filter(x=>x[0]===nodeName || x[2]===nodeName).map(x=>x[0]===nodeName?x[2]:x[0]);return new Set([].concat(buys, sells, transfers, loops));}function updateLabels(selected, connected){labelGroup.text(d => {if (selected && (d.name===selected || connected.has(d.name)))44 unmodified linesfunction showInfo(nodeName){const buys = BUYS.filter(x => x[0] === nodeName || x[1] === nodeName).map(x => x[0] === nodeName ? x[1] : x[0]);const sells = SELLS.filter(x => x[0] === nodeName || x[1]===nodeName).map(x => x[0] === nodeName ? x[1] : x[0]);const transfers = TRANSFERS.filter(x => x[0]===nodeName || x[1]===nodeName).map(x => x[0]===nodeName ? x[1] : x[0]);const loops = LOOPS.filter(x => x[0]===nodeName || x[2]===nodeName).map(x => x[0]===nodeName ? x[2] : x[0]);const box = document.getElementById("info-box");box.innerHTML = `<div style="font-size:14px;"><b>${nodeName}</b></div>1 unmodified line<b>Buys:</b> ${buys.length ? buys.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Sells:</b> ${sells.length ? sells.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Transfers:</b> ${transfers.length ? transfers.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Loops:</b> ${loops.length ? loops.join(", ") : "<span style='color:#777'>None</span>"}<span style="display:inline-block;width:12px;height:8px;background:#1abc9c;margin-right:6px;"></span> FRESH BUY (teal)</div>`;}function selectNode(d){const name = d.name;setOpacityFor(name);565 unmodified lines566567568569570571572573574575141 unmodified lines71771871972072172272372472572672772872973044 unmodified lines7757767777787797807817827837847857867877887897907917927937941 unmodified line796797798799800801802803804805806807808565 unmodified linesconst allW = [].concat(BUYS.map(x=>x[2]),SELLS.map(x=>x[2]),TRANSFERS.map(x=>x[2]),(FRESH ? FRESH.map(x=>x[2]) : []));const stroke = d3.scaleLinear().domain([Math.min(...allW), Math.max(...allW)]).range([1,6]);141 unmodified lineslet sells = SELLS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);let transfers = TRANSFERS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);let loops = LOOPS.filter(x=>x[0]===nodeName || x[2]===nodeName).map(x=>x[0]===nodeName?x[2]:x[0]);// <-- NEW: include FRESH edges so teal arcs behave like real connectionslet fresh = FRESH.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);return new Set([].concat(buys, sells, transfers, loops, fresh));}function updateLabels(selected, connected){labelGroup.text(d => {if (selected && (d.name===selected || connected.has(d.name)))44 unmodified linesfunction showInfo(nodeName){const buys = BUYS.filter(x => x[0] === nodeName || x[1] === nodeName).map(x => x[0] === nodeName ? x[1] : x[0]);const sells = SELLS.filter(x => x[0] === nodeName || x[1]===nodeName).map(x => x[0] === nodeName ? x[1] : x[0]);const transfers = TRANSFERS.filter(x => x[0]===nodeName || x[1]===nodeName).map(x => x[0]===nodeName ? x[1] : x[0]);const loops = LOOPS.filter(x => x[0]===nodeName || x[2]===nodeName).map(x => x[0]===nodeName ? x[2] : x[0]);// NEW — detect Fresh Buysconst fresh = FRESH.filter(x => x[0] === nodeName || x[1] === nodeName).map(x => x[0] === nodeName ? x[1] : x[0]);const box = document.getElementById("info-box");box.innerHTML = `<div style="font-size:14px;"><b>${nodeName}</b></div>1 unmodified line<b>Buys:</b> ${buys.length ? buys.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Sells:</b> ${sells.length ? sells.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Transfers:</b> ${transfers.length ? transfers.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Loops:</b> ${loops.length ? loops.join(", ") : "<span style='color:#777'>None</span>"}<br><b>Fresh Buys:</b> ${fresh.length ? fresh.join(", ") : "<span style='color:#777'>None</span>"}</div>`;}function selectNode(d){const name = d.name;setOpacityFor(name);
app.py+20-6