Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,4 +26,25 @@ def app():
|
|
26 |
# Generate the data for the chart
|
27 |
values = generate_values()
|
28 |
data = pd.DataFrame({
|
29 |
-
"category": ["Category
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# Generate the data for the chart
|
27 |
values = generate_values()
|
28 |
data = pd.DataFrame({
|
29 |
+
"category": ["Category 1"] * len(game_mechanics),
|
30 |
+
"mechanic": game_mechanics,
|
31 |
+
"value": list(values.values()),
|
32 |
+
"HealthPoints": values["HealthPoints"],
|
33 |
+
"Coins": values["Coins"],
|
34 |
+
"description": ["Description"] * len(game_mechanics)
|
35 |
+
})
|
36 |
+
data["value"] = data["value"].apply(lambda x: sum(x))
|
37 |
+
|
38 |
+
# Draw the chart
|
39 |
+
fig = px.treemap(data, path=["category", "mechanic"], values="value",
|
40 |
+
color="HealthPoints", hover_data=["Coins"])
|
41 |
+
st.plotly_chart(fig)
|
42 |
+
|
43 |
+
# Display a download link for the data
|
44 |
+
csv = data.to_csv(index=False)
|
45 |
+
b64 = base64.b64encode(csv.encode()).decode()
|
46 |
+
href = f'<a href="data:file/csv;base64,{b64}" download="game_mechanics.csv">Download CSV</a>'
|
47 |
+
st.markdown(href, unsafe_allow_html=True)
|
48 |
+
|
49 |
+
if __name__ == '__main__':
|
50 |
+
app()
|