ralate2 commited on
Commit
8f5dc0d
·
verified ·
1 Parent(s): e482537

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -86,26 +86,30 @@ st.subheader("Licenses by Status")
86
  category_counts = df['License Status'].value_counts().reset_index()
87
  category_counts.columns = ['License Status', 'Count']
88
 
89
- # Select top 5 categories
90
- category_counts_top5 = category_counts.head(5)
91
 
92
  if not category_counts_top5.empty:
93
  chart1 = alt.Chart(category_counts_top5).mark_bar().encode(
94
- x=alt.X(field="License Status", type="nominal", title="License Status"),
 
95
  y=alt.Y(field="Count", type="quantitative", title="Number of Licenses"),
96
  color=alt.Color(field="License Status", type="nominal", legend=alt.Legend(title="License Status"),
97
  scale=alt.Scale(scheme='pastel1')), # Pastel color scheme
98
  tooltip=['License Status', 'Count']
99
  ).properties(
100
- width=400,
101
  height=400,
102
  title="Licenses by Status (Top 5)"
 
 
103
  )
104
  st.altair_chart(chart1)
105
  else:
106
  st.write("No data available for the 'License Status' plot.")
107
 
108
 
 
109
  # Write-up for Visualization 1
110
  st.write("""
111
  **Licenses by Status**: This visualization highlights the distribution of licenses across different statuses.
 
86
  category_counts = df['License Status'].value_counts().reset_index()
87
  category_counts.columns = ['License Status', 'Count']
88
 
89
+ # Select top 5 categories and sort in descending order
90
+ category_counts_top5 = category_counts.head(5).sort_values(by='Count', ascending=False)
91
 
92
  if not category_counts_top5.empty:
93
  chart1 = alt.Chart(category_counts_top5).mark_bar().encode(
94
+ x=alt.X(field="License Status", type="nominal", title="License Status",
95
+ sort='-y'), # Sorting by count in descending order
96
  y=alt.Y(field="Count", type="quantitative", title="Number of Licenses"),
97
  color=alt.Color(field="License Status", type="nominal", legend=alt.Legend(title="License Status"),
98
  scale=alt.Scale(scheme='pastel1')), # Pastel color scheme
99
  tooltip=['License Status', 'Count']
100
  ).properties(
101
+ width=500,
102
  height=400,
103
  title="Licenses by Status (Top 5)"
104
+ ).configure_axis(
105
+ labelAngle=0 # Ensure the full name is visible
106
  )
107
  st.altair_chart(chart1)
108
  else:
109
  st.write("No data available for the 'License Status' plot.")
110
 
111
 
112
+
113
  # Write-up for Visualization 1
114
  st.write("""
115
  **Licenses by Status**: This visualization highlights the distribution of licenses across different statuses.