Spaces:
Sleeping
Sleeping
Update app.py
Browse files211 unmodified lines21221321421521621735 unmodified lines2532542552562572582592602612621 unmodified line264265266267268269270113 unmodified lines38438538638738838939011 unmodified lines40240340440540640740840941041141249 unmodified lines46246346446546646746846947047147247317 unmodified lines49149249349449549649721 unmodified lines51952052152252352452552652752852953022 unmodified lines553554555556557558559211 unmodified linesfunction draw() {const container = document.getElementById("arc-container");container.innerHTML = "";const w = Math.min(1200, container.clientWidth || 920);35 unmodified lines.enter().append("g").attr("transform", d => `translate(${d.x},${d.y})`).style("pointer-events", "none"); // ★ FIX ADDED//--------------------------------------------------------------------// CIRCLES — FIX #2: reenable pointer events on <circle>//--------------------------------------------------------------------nodeCircleGroup.append("circle").attr("r", 16)1 unmodified line.attr("stroke", "#222").attr("stroke-width", 1).style("cursor", "pointer").style("pointer-events", "all"); // ★ FIX ADDED//--------------------------------------------------------------------// ARC drawing (unchanged)113 unmodified lines}//--------------------------------------------------------------------// LABELS — FIX #3: enable pointer events//--------------------------------------------------------------------const labelGroup = svg.append("g").attr("class", "node-labels")11 unmodified linesconst deg = (d.angle * 180 / Math.PI);return (deg>-90 && deg<90) ? "start" : "end";}).style("pointer-events", "all") // ★ FIX ADDED.text(d => d.abbrev);//--------------------------------------------------------------------// CLICK / HIGHLIGHT logic//--------------------------------------------------------------------function getConnections(nodeName){let buys = BUYS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);49 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 = `17 unmodified lines}//--------------------------------------------------------------------// CLICK HANDLERS — working now//--------------------------------------------------------------------nodeCircleGroup.on("click", function(event, d){selectNode(d);21 unmodified linesclearTimeout(rz);rz = setTimeout(draw, 120);});}, 400); // ★ delay enabling resize for 0.4 sec</script>"""def make_arc_html(nodes, node_type, buys, sells, transfers, loops):nodes_json = json.dumps(nodes)node_type_json = json.dumps(node_type)22 unmodified lineswith gr.Blocks(css=responsive_css, title="MF Churn — Semi-layer Arc Diagram (L1 labels)") as demo:gr.Markdown("## Mutual Fund Churn — Weighted Arcs (BUY top / SELL bottom) — labels outside (L1)")gr.HTML(initial_html)gr.Markdown("### Inspect Company / AMC")211 unmodified lines21221321421521621721821935 unmodified lines2552562572582592602612622632641 unmodified line266267268269270271272113 unmodified lines38638738838939039139211 unmodified lines40440540640740840941041141241341449 unmodified lines46446546646746846947047147247347447517 unmodified lines49349449549649749849921 unmodified lines52152252352452552652752852953053153253322 unmodified lines556557558559560561562211 unmodified linesfunction draw() {const container = document.getElementById("arc-container");// ★ FINAL FIX: always clear old SVG before drawingcontainer.innerHTML = "";const w = Math.min(1200, container.clientWidth || 920);35 unmodified lines.enter().append("g").attr("transform", d => `translate(${d.x},${d.y})`).style("pointer-events", "none");//--------------------------------------------------------------------// CIRCLES — FIX #2: re-enable pointer events//--------------------------------------------------------------------nodeCircleGroup.append("circle").attr("r", 16)1 unmodified line.attr("stroke", "#222").attr("stroke-width", 1).style("cursor", "pointer").style("pointer-events", "all");//--------------------------------------------------------------------// ARC drawing (unchanged)113 unmodified lines}//--------------------------------------------------------------------// LABELS — FIX #3//--------------------------------------------------------------------const labelGroup = svg.append("g").attr("class", "node-labels")11 unmodified linesconst deg = (d.angle * 180 / Math.PI);return (deg>-90 && deg<90) ? "start" : "end";}).style("pointer-events", "all").text(d => d.abbrev);//--------------------------------------------------------------------// CLICK / HIGHLIGHT logic (unchanged)//--------------------------------------------------------------------function getConnections(nodeName){let buys = BUYS.filter(x=>x[0]===nodeName || x[1]===nodeName).map(x=>x[0]===nodeName?x[1]:x[0]);49 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 = `17 unmodified lines}//--------------------------------------------------------------------// CLICK HANDLERS//--------------------------------------------------------------------nodeCircleGroup.on("click", function(event, d){selectNode(d);21 unmodified linesclearTimeout(rz);rz = setTimeout(draw, 120);});}, 400);</script>"""def make_arc_html(nodes, node_type, buys, sells, transfers, loops):nodes_json = json.dumps(nodes)node_type_json = json.dumps(node_type)22 unmodified lineswith gr.Blocks(css=responsive_css, title="MF Churn — Semi-layer Arc Diagram (L1 labels)") as demo:gr.Markdown("## Mutual Fund Churn — Weighted Arcs (BUY top / SELL bottom) — labels outside (L1)")gr.HTML(initial_html,container=False)gr.Markdown("### Inspect Company / AMC")
app.py+17-14