def gauge_chart(default_probability,pot_probability): value1=default_probability value1=value1*100 fig1 = go.Figure(go.Indicator( mode = "gauge+number+delta", value =float(value1), domain = {'x': [0, 1], 'y': [0, 1]}, title = {'text': "Default Confidence ", 'font': {'size': 24}}, delta = {'reference': 50, 'increasing': {'color': "RebeccaPurple"}}, gauge = { 'axis': {'range': [None, 100], 'tickwidth': 1, 'tickcolor': "darkblue"}, 'bar': {'color': "darkblue"}, 'bgcolor': "white", 'borderwidth': 2, 'bordercolor': "gray", 'steps': [ {'range': [0, 25], 'color': 'cyan'}, {'range': [25, 40], 'color': 'royalblue'}], 'threshold': { 'line': {'color': "red", 'width': 4}, 'thickness': 0.75, 'value': 40}})) fig1.update_layout(paper_bgcolor = "lavender", font = {'color': "darkblue", 'family': "Arial"}) value2=pot_probability value2=value2*100 fig2 = go.Figure(go.Indicator( mode = "gauge+number+delta", value =float(value2), domain = {'x': [0, 1], 'y': [0, 1]}, title = {'text': " Timely Payment Confidence ", 'font': {'size': 24}}, delta = {'reference': 50, 'increasing': {'color': "RebeccaPurple"}}, gauge = { 'axis': {'range': [None, 100], 'tickwidth': 1, 'tickcolor': "darkblue"}, 'bar': {'color': "darkblue"}, 'bgcolor': "white", 'borderwidth': 2, 'bordercolor': "gray", 'steps': [ {'range': [0, 25], 'color': 'cyan'}, {'range': [25, 40], 'color': 'royalblue'}], 'threshold': { 'line': {'color': "red", 'width': 4}, 'thickness': 0.75, 'value': 40}})) fig2.update_layout(paper_bgcolor = "lavender", font = {'color': "darkblue", 'family': "Arial"}) return fig1,fig2
def third_graph(): fig_sma = go.Figure() fig_sma.add_trace( go.Indicator( mode="number+delta", value=daily_cases_sma_avg_df[0].iloc[-1], title={ "text": "<span style='font-size:20;color:rgb(0, 255, 204)'>Total Cases</span>" }, number=dict(prefix="# ", font=dict(size=50)), delta=dict(position="top", reference=daily_cases_sma_avg_df.SMA_Cases.iloc[-1], relative=False, font=dict(size=30)), domain={ 'x': [0, 1], 'y': [0.5, 1] })) fig_sma.add_trace( go.Indicator( mode="number+delta", value=daily_deaths_sma_avg_df[0].iloc[-1], title={ "text": "<span style='font-size:20;color:rgb(255, 0, 0)'>Total Deaths</span>" }, number=dict(prefix="† ", font=dict(size=50)), delta=dict(position="top", reference=daily_deaths_sma_avg_df.SMA_Cases.iloc[-1], relative=False, font=dict(size=30)), domain={ 'x': [0, 1], 'y': [0, 0.5] })) fig_sma.update_layout( title_text='COVID-19 3-Num SMA', title_font_family='Arial', title_font_color='rgb(74, 160, 207)', #title_font_size=9, title={ 'x': 0.5, 'y': 0.98, }, showlegend=False, margin=dict(l=0, r=0, t=30, b=0), paper_bgcolor='rgb(0, 17, 26)', font=dict(family="Arial", color='rgb(255, 204, 51)')) return fig_sma
def get_type_totals(type_grouped, type_grouped_yesterday): # Type indicators fig_type_totals = go.Figure() fig_type_totals.add_trace(go.Indicator( mode="number+delta", value=int(type_grouped[0]), # title = {"text": f"Elementary School Total"}, domain={'x': [0, 0.1], 'y': [0, 0.25]}, align="left", delta={'reference': int(type_grouped_yesterday[0]), 'relative': True, 'position': "right"})) fig_type_totals.add_trace(go.Indicator( mode="number+delta", value=int(type_grouped[2]), # title = {"text": f"Middle School Total"}, domain={'x': [0, 0.1], 'y': [0.36, 0.62]}, align="left", delta={'reference': int(type_grouped_yesterday[2]), 'relative': True, 'position': "right"})) fig_type_totals.add_trace(go.Indicator( mode="number+delta", value=int(type_grouped[1]), # title = {"text": f"High School Total"}, domain={'x': [0, 0.1], 'y': [0.75, 1]}, align="left", delta={'reference': int(type_grouped_yesterday[1]), 'relative': True, 'position': "right"})) fig_type_totals.update_layout( title={"text": "<span style='font-size:1em;color:black'>Total Cases</span>", "yanchor": "middle", "xanchor": "center", "x": 0.4, "y": 0.85}) fig_type_totals.update_layout( annotations=[ dict(text="<span style='font-size:2em;color:black'>High School</span>", align="right", showarrow=False, x=0.9, y=0.95, ), dict(text="<span style='font-size:2em;color:black'>Middle School</span>", align="right", showarrow=False, x=0.9, y=0.48, ), dict(text="<span style='font-size:2em;color:black'>Elementary</span>", align="right", showarrow=False, x=0.9, y=0.05, )]) return fig_type_totals
def page_second(): st.title('Employee communications dashboard') df = load_data() dfs = load_sentiment() employee = st.selectbox("Select employee", df["From"].unique()) st.write('Time at company') #Create a plotly gauge indicator fig = go.Figure() fig = go.Figure(go.Indicator( mode = "gauge+number", value = 70, title = {'text': "Postive"}, domain = {'x': [0, 1], 'y': [0, 1]} )) #setting range of x-axis doesn't work fig.update_xaxes(range=[0,100]) st.plotly_chart(fig) fig = go.Figure() fig = go.Figure(go.Indicator( mode = "gauge+number", value = 30, title = {'text': "Negative"}, domain = {'x': [0, 1], 'y': [0, 1]} )) #setting range of x-axis doesn't work fig.update_xaxes(range=[0,100]) st.plotly_chart(fig) st.subheader('Overall Sentiment emails sent') st.subheader('Overall Sentiment emails received') st.subheader('Profanity emails sent') st.subheader('Profanity emails received') st.subheader('Emails sent') st.subheader('Emails received') st.subheader('Emails received') st.subheader('Out of hours emails') st.subheader('Response rate') st.subheader('Time spent on email')
def friend_stats(friend_name: str): from_friend_in_group_chat = common.conversations_df.loc[ (common.conversations_df[messages_cols.sender] == friend_name) & (common.conversations_df[messages_cols.conv_type] != "Regular" )].shape[0] in_dm = common.conversations_df.loc[common.conversations_df[ messages_cols.conversation] == friend_name] from_me_in_dm = in_dm.loc[ in_dm[messages_cols.sender] != friend_name].shape[0] from_friend_in_dm = in_dm.loc[in_dm[messages_cols.sender] == friend_name].shape[0] fig = go.Figure() fig.add_trace( go.Indicator( mode="number", value=from_me_in_dm, title={"text": "DMs you sent to them"}, domain={ "row": 0, "column": 0 }, )) fig.add_trace( go.Indicator( mode="number", value=from_friend_in_dm, title={"text": "DMs they sent to you"}, domain={ "row": 0, "column": 1 }, )) fig.add_trace( go.Indicator( mode="number", value=from_friend_in_group_chat, title={"text": "Messages sent by them to group chats"}, domain={ "row": 0, "column": 2 }, )) fig.update_layout(grid={"rows": 1, "columns": 3, "pattern": "independent"}) return dcc.Graph(figure=fig)