This repository has been archived by the owner on May 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
9de07cc
commit 95aac28
Showing
8 changed files
with
150 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import streamlit as st | ||
import plotly.graph_objects as go | ||
|
||
|
||
class PointSliderSection: | ||
def __init__(self, standings_df): | ||
self.standings_df = standings_df | ||
|
||
def display(self): | ||
st.subheader("Points per Team:") | ||
# Creating the slider. | ||
points = self.standings_df["points"].tolist() | ||
points_selection = st.slider( | ||
"Select a Range of Points:", min_value=min(points), max_value=max(points), value=(min(points), max(points)) | ||
) | ||
# Picking colors to use for the bar chart. | ||
colors = [ | ||
"indigo", | ||
] * 20 | ||
# Making sure the bar chart changes with the slider. | ||
mask = self.standings_df["points"].between(*points_selection) | ||
amount_of_teams = self.standings_df[mask].shape[0] | ||
|
||
df_grouped = self.standings_df[mask] | ||
df_grouped = df_grouped.reset_index() | ||
lowest_number = df_grouped["points"].min() | ||
st.markdown(f"Number of teams with {lowest_number} or more points: {amount_of_teams}") | ||
# Creating the bar chart. | ||
points_chart = go.Figure( | ||
data=[ | ||
go.Bar( | ||
x=df_grouped["team"], | ||
y=df_grouped["points"], | ||
marker_color=colors, | ||
text=df_grouped["points"], | ||
textposition="auto", | ||
) | ||
] | ||
) | ||
# Rotating x axis lables. | ||
points_chart.update_layout( | ||
xaxis_tickangle=-35, | ||
autosize=False, | ||
margin=dict( | ||
l=0, # left | ||
r=0, # right | ||
b=0, # bottom | ||
t=0, # top | ||
), | ||
) | ||
|
||
st.plotly_chart(points_chart, use_container_width=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters