File size: 1,105 Bytes
00d1f6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
import plotly.graph_objs as go
from github_analytics.singular_analysis_chat import predict_2vars


def create_bar_chart(repo_data):
    st.subheader("Here's your data visualization of Repositories compared by stars:")
    # Extract labels and data from repo_data
    if not repo_data:
        return None

    labels = [repo['name'] for repo in repo_data]
    stars = [repo['stargazers_count'] for repo in repo_data]

    # Create a Plotly line chart
    fig = go.Figure(data=go.Bar(x=labels, y=stars))

    # Customize the chart
    fig.update_layout(
        title='Stars by Repository',
        xaxis_title='Repository',
        yaxis_title='Number of Stars',
        hovermode='closest',
        xaxis=dict(tickangle=-45), # Rotate x-axis labels
        width=800,  # Set desired width
        height=600
    )

    # Customize hover label
    fig.update_traces(
        hovertemplate='Repository: %{x}<br>Forks: %{y}'
    )
    response = predict_2vars(labels, stars, "repo names", "stars")
    return st.plotly_chart(fig), st.write(response)