ralate2 commited on
Commit
1d4c87b
·
verified ·
1 Parent(s): 0972530

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -96,10 +96,33 @@ with col3:
96
  # Visualizations
97
  if viz_type == "Complaint Types":
98
  st.subheader("Interactive Complaint Types Pie Chart")
 
 
99
  complaint_counts = filtered_data['Type of Complaint'].value_counts().reset_index()
100
  complaint_counts.columns = ['Complaint Type', 'Count']
101
- fig = px.pie(complaint_counts, names='Complaint Type', values='Count', hole=0.4)
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  st.plotly_chart(fig, use_container_width=True)
 
 
 
 
 
 
 
 
103
 
104
  elif viz_type == "Geographic Distribution":
105
  st.subheader("Clustered Heatmap of Complaints")
 
96
  # Visualizations
97
  if viz_type == "Complaint Types":
98
  st.subheader("Interactive Complaint Types Pie Chart")
99
+
100
+ # Prepare data
101
  complaint_counts = filtered_data['Type of Complaint'].value_counts().reset_index()
102
  complaint_counts.columns = ['Complaint Type', 'Count']
103
+
104
+ # Create an interactive pie chart with hover tooltips
105
+ fig = px.pie(
106
+ complaint_counts,
107
+ names='Complaint Type',
108
+ values='Count',
109
+ title="Distribution of Complaint Types",
110
+ color_discrete_sequence=px.colors.qualitative.Set2,
111
+ labels={"Count": "Number of Complaints", "Complaint Type": "Type of Complaint"},
112
+ hover_data=['Count']
113
+ )
114
+ fig.update_traces(textinfo='percent+label', hovertemplate='<b>%{label}</b><br>Complaints: %{value}<br>Percentage: %{percent}')
115
+
116
+ # Display chart
117
  st.plotly_chart(fig, use_container_width=True)
118
+
119
+ # Updated write-up
120
+ st.write("""
121
+ **Write-up:** This visualization displays the distribution of complaint types using an interactive pie chart.
122
+ Hovering over each segment reveals the complaint type, the number of complaints, and its percentage of the total.
123
+ The vibrant colors highlight differences between complaint categories, providing an accessible and informative view of the data.
124
+ """)
125
+
126
 
127
  elif viz_type == "Geographic Distribution":
128
  st.subheader("Clustered Heatmap of Complaints")