ElPierrito commited on
Commit
18cff6e
·
verified ·
1 Parent(s): 8d12bf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -63,20 +63,35 @@ def export_csv():
63
  def generate_gantt():
64
  if not campaigns:
65
  return "<i>Keine Kampagnen zum Anzeigen</i>"
 
 
66
  df = pd.DataFrame(campaigns)
67
  df["Start"] = pd.to_datetime(df["Start"])
68
  df["Ende"] = pd.to_datetime(df["Ende"])
 
69
  try:
70
- fig = px.timeline(df, x_start="Start", x_end="Ende", y="Name", color="Verantwortlich", title="📊 Kampagnenübersicht")
 
 
 
 
 
 
 
 
71
  fig.update_yaxes(autorange="reversed")
72
- fig.update_layout(height=400, margin=dict(l=20, r=20, t=30, b=20))
73
- return pio.to_html(fig, full_html=True, include_plotlyjs='cdn')
74
- print("=== HTML Output Preview ===")
75
- print(html[:500]) # Nur ein Teil
76
- return html
 
 
 
77
  except Exception as e:
78
  return f"<b>Fehler:</b> {e}"
79
 
 
80
  with gr.Blocks() as app:
81
  # Startseite
82
  with gr.Column(visible=True) as start_page:
 
63
  def generate_gantt():
64
  if not campaigns:
65
  return "<i>Keine Kampagnen zum Anzeigen</i>"
66
+
67
+ # Kampagnen-Daten in ein DataFrame umwandeln
68
  df = pd.DataFrame(campaigns)
69
  df["Start"] = pd.to_datetime(df["Start"])
70
  df["Ende"] = pd.to_datetime(df["Ende"])
71
+
72
  try:
73
+ # Gantt-Diagramm mit Plotly erstellen
74
+ fig = px.timeline(
75
+ df,
76
+ x_start="Start",
77
+ x_end="Ende",
78
+ y="Name",
79
+ color="Verantwortlich",
80
+ title="📊 Kampagnenübersicht"
81
+ )
82
  fig.update_yaxes(autorange="reversed")
83
+ fig.update_layout(
84
+ height=400,
85
+ margin=dict(l=20, r=20, t=30, b=20)
86
+ )
87
+
88
+ # Diagramm als HTML exportieren
89
+ html = pio.to_html(fig, full_html=False, include_plotlyjs='cdn')
90
+ return html # Rückgabe des HTML-Codes für Gradio
91
  except Exception as e:
92
  return f"<b>Fehler:</b> {e}"
93
 
94
+
95
  with gr.Blocks() as app:
96
  # Startseite
97
  with gr.Column(visible=True) as start_page: