Untitled
unknown
plain_text
2 months ago
839 B
3
Indexable
from fastapi import FastAPI from fastapi.responses import FileResponse import matplotlib.pyplot as plt app = FastAPI() @app.get("/generate-chart") def generate_chart(): # Data for the pie chart labels = ['Closed', 'Onboarding WIP', 'BGV WIP', 'Client Approval WIP', 'Internal Review'] sizes = [130, 40, 80, 50, 50] colors = ['blue', 'orange', 'green', 'purple', 'cyan'] explode = (0.1, 0, 0, 0, 0) # explode the largest slice (optional) # Create the pie chart plt.figure(figsize=(8, 6)) plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140) plt.title("Open Positions by Phases") # Save the chart as an image chart_path = "chart.png" plt.savefig(chart_path) plt.close() # Return the chart image return FileResponse(chart_path)
Editor is loading...
Leave a Comment