Spaces:
Sleeping
Sleeping
kandi1clickkits
commited on
Commit
·
47e780d
1
Parent(s):
f3b2b4b
chart code with DB
Browse files
main.py
CHANGED
|
@@ -27,7 +27,11 @@ async def show_chart(data: List[dict]):
|
|
| 27 |
categories = [item["category"] for item in data]
|
| 28 |
values = [item["value"] for item in data]
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
@app.get("/visualization/", response_class=HTMLResponse)
|
| 33 |
async def show_visualization():
|
|
@@ -36,4 +40,8 @@ async def show_visualization():
|
|
| 36 |
categories = ["Category1", "Category2", "Category3"]
|
| 37 |
values = [10, 20, 30]
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
categories = [item["category"] for item in data]
|
| 28 |
values = [item["value"] for item in data]
|
| 29 |
|
| 30 |
+
chart_html = create_chart(categories, values)
|
| 31 |
+
|
| 32 |
+
# Embed the chart HTML in an iframe
|
| 33 |
+
iframe_html = f'<iframe width="600" height="400" srcdoc="{chart_html}"></iframe>'
|
| 34 |
+
return HTMLResponse(content=iframe_html, status_code=200)
|
| 35 |
|
| 36 |
@app.get("/visualization/", response_class=HTMLResponse)
|
| 37 |
async def show_visualization():
|
|
|
|
| 40 |
categories = ["Category1", "Category2", "Category3"]
|
| 41 |
values = [10, 20, 30]
|
| 42 |
|
| 43 |
+
chart_html = create_chart(categories, values)
|
| 44 |
+
|
| 45 |
+
# Embed the chart HTML in an iframe
|
| 46 |
+
iframe_html = f'<iframe width="600" height="400" srcdoc="{chart_html}"></iframe>'
|
| 47 |
+
return HTMLResponse(content=iframe_html, status_code=200)
|