Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
d4041f6
1
Parent(s):
0cf8b26
feat: updated app.py
Browse files
app.py
CHANGED
@@ -49,21 +49,38 @@ def get_supplier_name(code):
|
|
49 |
|
50 |
# Function to create radar chart using Plotly
|
51 |
def radar_chart(categories, values, amounts, title):
|
|
|
|
|
|
|
|
|
|
|
52 |
fig = px.line_polar(
|
53 |
r=values,
|
54 |
theta=categories,
|
55 |
line_close=True,
|
56 |
labels={'r': '% Units Sold', 'theta': 'Manufacturers'},
|
57 |
-
title=title
|
58 |
)
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
)
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
return fig
|
68 |
|
69 |
# Main page design
|
|
|
49 |
|
50 |
# Function to create radar chart using Plotly
|
51 |
def radar_chart(categories, values, amounts, title):
|
52 |
+
# Ensure the first and last data points are the same to close the radar chart
|
53 |
+
values.append(values[0])
|
54 |
+
amounts.append(amounts[0])
|
55 |
+
categories.append(categories[0])
|
56 |
+
|
57 |
fig = px.line_polar(
|
58 |
r=values,
|
59 |
theta=categories,
|
60 |
line_close=True,
|
61 |
labels={'r': '% Units Sold', 'theta': 'Manufacturers'},
|
62 |
+
title=title
|
63 |
)
|
64 |
+
|
65 |
+
# Adding a second trace for the spend amounts
|
66 |
+
fig.add_trace(
|
67 |
+
go.Scatterpolar(
|
68 |
+
r=amounts,
|
69 |
+
theta=categories,
|
70 |
+
mode='lines+markers',
|
71 |
+
name="Spend (€)",
|
72 |
+
line=dict(color='blue', width=2)
|
73 |
+
)
|
74 |
)
|
75 |
+
|
76 |
+
fig.update_traces(fill='toself') # Fill the radar chart area
|
77 |
+
fig.update_layout(
|
78 |
+
polar=dict(
|
79 |
+
radialaxis=dict(visible=True, range=[0, 1])
|
80 |
+
),
|
81 |
+
showlegend=True
|
82 |
+
)
|
83 |
+
|
84 |
return fig
|
85 |
|
86 |
# Main page design
|