wack0 commited on
Commit
7c29d0b
·
verified ·
1 Parent(s): d74c486

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -43,14 +43,17 @@ def _(mo):
43
  upload_decomp = mo.ui.file(
44
  label="Upload: Total_species_composition.xlsx", kind="button", multiple=False)
45
 
46
- # Display the UI
47
- mo.vstack([
48
  mo.md("### 📁 Please provide your data files to view the dashboard"),
49
  upload_yield,
50
  upload_species,
51
  upload_decomp
52
  ], align="center")
53
- return upload_decomp, upload_species, upload_yield
 
 
 
54
 
55
 
56
  @app.cell
@@ -233,7 +236,6 @@ def _(
233
  return f"M {p1[0]} {p1[1]} A {r_outer} {r_outer} 0 {large_arc} 1 {p2[0]} {p2[1]} L {p3[0]} {p3[1]} A {r_inner} {r_inner} 0 {large_arc} 0 {p4[0]} {p4[1]} Z"
234
 
235
  def make_tooltip(index, tx, ty, group_name, species_name, avg_yield, num_sites):
236
- # Bound the tooltip coordinates so it doesn't clip off the 1000x1000 SVG canvas
237
  tx = max(10, min(tx, 1000 - TW - 10))
238
  ty = max(10, min(ty, 1000 - TH - 10))
239
  safe_group = group_name.strip().upper()[:40]
@@ -256,7 +258,6 @@ def _(
256
  fill="#f9e2af">{sites_str}</text>
257
  </g>"""
258
 
259
- # Two separate lists — paths first, tooltips last
260
  path_elements = []
261
  tooltip_elements = []
262
  css_hover_rules = []
@@ -266,7 +267,7 @@ def _(
266
  grouped_data[s["group"]].append(s)
267
 
268
  active_tab = tabs.value
269
- seg_index = 0 # unique id counter shared across all segments
270
 
271
  for group_idx, group_name in enumerate(GROUPS):
272
  group_items = grouped_data[group_name]
@@ -338,7 +339,6 @@ def _(
338
  tip_cx, tip_cy = polar_to_cartesian(
339
  CX, CY, tip_r, angle_center)
340
 
341
- # Using the newly global TW and TH
342
  tx = tip_cx if tip_cx < CX else tip_cx - TW
343
  ty = tip_cy - TH / 2
344
 
@@ -444,9 +444,13 @@ def _(
444
  </svg>
445
  """
446
 
447
- mo.vstack([controls, mo.Html(svg_markup)], align="center", gap=8)
448
- return
 
 
 
 
449
 
450
 
451
  if __name__ == "__main__":
452
- app.run()
 
43
  upload_decomp = mo.ui.file(
44
  label="Upload: Total_species_composition.xlsx", kind="button", multiple=False)
45
 
46
+ # Assign the layout to a variable
47
+ upload_ui = mo.vstack([
48
  mo.md("### 📁 Please provide your data files to view the dashboard"),
49
  upload_yield,
50
  upload_species,
51
  upload_decomp
52
  ], align="center")
53
+
54
+ # Place it as the last line so Marimo renders it to the screen!
55
+ upload_ui
56
+ return upload_decomp, upload_species, upload_yield, upload_ui
57
 
58
 
59
  @app.cell
 
236
  return f"M {p1[0]} {p1[1]} A {r_outer} {r_outer} 0 {large_arc} 1 {p2[0]} {p2[1]} L {p3[0]} {p3[1]} A {r_inner} {r_inner} 0 {large_arc} 0 {p4[0]} {p4[1]} Z"
237
 
238
  def make_tooltip(index, tx, ty, group_name, species_name, avg_yield, num_sites):
 
239
  tx = max(10, min(tx, 1000 - TW - 10))
240
  ty = max(10, min(ty, 1000 - TH - 10))
241
  safe_group = group_name.strip().upper()[:40]
 
258
  fill="#f9e2af">{sites_str}</text>
259
  </g>"""
260
 
 
261
  path_elements = []
262
  tooltip_elements = []
263
  css_hover_rules = []
 
267
  grouped_data[s["group"]].append(s)
268
 
269
  active_tab = tabs.value
270
+ seg_index = 0
271
 
272
  for group_idx, group_name in enumerate(GROUPS):
273
  group_items = grouped_data[group_name]
 
339
  tip_cx, tip_cy = polar_to_cartesian(
340
  CX, CY, tip_r, angle_center)
341
 
 
342
  tx = tip_cx if tip_cx < CX else tip_cx - TW
343
  ty = tip_cy - TH / 2
344
 
 
444
  </svg>
445
  """
446
 
447
+ # Assign layout to variable
448
+ final_dashboard = mo.vstack([controls, mo.Html(svg_markup)], align="center", gap=8)
449
+
450
+ # Place as the last line so Marimo renders it to the screen!
451
+ final_dashboard
452
+ return final_dashboard,
453
 
454
 
455
  if __name__ == "__main__":
456
+ app.run()