singhn9 commited on
Commit
4d3d4e0
·
verified ·
1 Parent(s): 071cec5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -7
app.py CHANGED
@@ -397,6 +397,11 @@ def build_flows():
397
  transfers = []
398
  for (s,b), w in TRANSFER_COUNTS.items():
399
  transfers.append((s, b, w))
 
 
 
 
 
400
 
401
  loops = []
402
  for a,c,w1 in buys:
@@ -405,9 +410,9 @@ def build_flows():
405
  loops.append((a, c, b))
406
 
407
  loops = list({(a,c,b) for (a,c,b) in loops})
408
- return buys, sells, transfers, loops
409
 
410
- BUYS, SELLS, TRANSFERS, LOOPS = build_flows()
411
 
412
  # ---------------------------
413
  # Inspector summaries
@@ -487,6 +492,7 @@ const BUYS = __BUYS__;
487
  const SELLS = __SELLS__;
488
  const TRANSFERS = __TRANSFERS__;
489
  const LOOPS = __LOOPS__;
 
490
 
491
  function draw() {
492
  const container = document.getElementById("arc-container");
@@ -617,6 +623,23 @@ function draw() {
617
  .attr("data-tgt", tname);
618
  });
619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620
  const loopGroup = svg.append("g").attr("class", "loops");
621
  LOOPS.forEach(lp => {
622
  const a = lp[0], c = lp[1], b = lp[2];
@@ -721,6 +744,10 @@ function draw() {
721
  buyGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
722
  sellGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
723
  transferGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
 
 
 
 
724
 
725
  loopGroup.selectAll("path").style("opacity", 0.9);
726
  }
@@ -757,6 +784,8 @@ function draw() {
757
  <b>Sells:</b> ${sells.length ? sells.join(", ") : "<span style='color:#777'>None</span>"}<br>
758
  <b>Transfers:</b> ${transfers.length ? transfers.join(", ") : "<span style='color:#777'>None</span>"}<br>
759
  <b>Loops:</b> ${loops.length ? loops.join(", ") : "<span style='color:#777'>None</span>"}
 
 
760
  </div>
761
  `;
762
  }
@@ -814,11 +843,13 @@ def make_arc_html(nodes, node_type, buys, sells, transfers, loops):
814
  transfers_json = json.dumps(transfers)
815
  loops_json = json.dumps(loops)
816
  html = JS_TEMPLATE.replace("__NODES__", nodes_json) \
817
- .replace("__NODE_TYPE__", node_type_json) \
818
- .replace("__BUYS__", buys_json) \
819
- .replace("__SELLS__", sells_json) \
820
- .replace("__TRANSFERS__", transfers_json) \
821
- .replace("__LOOPS__", loops_json)
 
 
822
  return html
823
 
824
  initial_html = make_arc_html(NODES, NODE_TYPE, BUYS, SELLS, TRANSFERS, LOOPS)
 
397
  transfers = []
398
  for (s,b), w in TRANSFER_COUNTS.items():
399
  transfers.append((s, b, w))
400
+
401
+ fresh_buys = []
402
+ for amc, comps in FRESH_BUY.items():
403
+ for c in comps:
404
+ fresh_buys.append((amc, c, 2)) # weight 2 or 3 as you prefer
405
 
406
  loops = []
407
  for a,c,w1 in buys:
 
410
  loops.append((a, c, b))
411
 
412
  loops = list({(a,c,b) for (a,c,b) in loops})
413
+ return buys, sells, transfers, loops,fresh_buys
414
 
415
+ BUYS, SELLS, TRANSFERS, LOOPS,FRESH_BUYS_FLOW = build_flows()
416
 
417
  # ---------------------------
418
  # Inspector summaries
 
492
  const SELLS = __SELLS__;
493
  const TRANSFERS = __TRANSFERS__;
494
  const LOOPS = __LOOPS__;
495
+ const FRESH = __FRESH__;
496
 
497
  function draw() {
498
  const container = document.getElementById("arc-container");
 
623
  .attr("data-tgt", tname);
624
  });
625
 
626
+ const freshGroup = svg.append("g").attr("class", "fresh");
627
+
628
+ FRESH.forEach(f => {
629
+ const a = f[0], c = f[1], wt = f[2];
630
+ if (!(a in nameToIndex) || !(c in nameToIndex)) return;
631
+ const s = nodePos[nameToIndex[a]];
632
+ const t = nodePos[nameToIndex[c]];
633
+ freshGroup.append("path")
634
+ .attr("d", bezierPath(s.x, s.y, t.x, t.y, true))
635
+ .attr("fill", "none")
636
+ .attr("stroke", "#1abc9c") // teal color
637
+ .attr("stroke-width", stroke(wt))
638
+ .attr("opacity", 0.95)
639
+ .attr("data-src", a)
640
+ .attr("data-tgt", c);
641
+ });
642
+
643
  const loopGroup = svg.append("g").attr("class", "loops");
644
  LOOPS.forEach(lp => {
645
  const a = lp[0], c = lp[1], b = lp[2];
 
744
  buyGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
745
  sellGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
746
  transferGroup.selectAll("path").style("opacity", function(){ return isConn(this)?0.98:0.06; });
747
+ freshGroup.selectAll("path").style("opacity", function(){
748
+ return isConn(this) ? 0.98 : 0.06;
749
+ });
750
+
751
 
752
  loopGroup.selectAll("path").style("opacity", 0.9);
753
  }
 
784
  <b>Sells:</b> ${sells.length ? sells.join(", ") : "<span style='color:#777'>None</span>"}<br>
785
  <b>Transfers:</b> ${transfers.length ? transfers.join(", ") : "<span style='color:#777'>None</span>"}<br>
786
  <b>Loops:</b> ${loops.length ? loops.join(", ") : "<span style='color:#777'>None</span>"}
787
+ <span style="display:inline-block;width:12px;height:8px;background:#1abc9c;margin-right:6px;"></span> FRESH BUY (teal)
788
+
789
  </div>
790
  `;
791
  }
 
843
  transfers_json = json.dumps(transfers)
844
  loops_json = json.dumps(loops)
845
  html = JS_TEMPLATE.replace("__NODES__", nodes_json) \
846
+ .replace("__NODE_TYPE__", node_type_json) \
847
+ .replace("__BUYS__", buys_json) \
848
+ .replace("__SELLS__", sells_json) \
849
+ .replace("__TRANSFERS__", transfers_json) \
850
+ .replace("__LOOPS__", loops_json) \
851
+ .replace("__FRESH__", json.dumps(fresh_buys))
852
+
853
  return html
854
 
855
  initial_html = make_arc_html(NODES, NODE_TYPE, BUYS, SELLS, TRANSFERS, LOOPS)