Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -681,89 +681,19 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
|
|
681 |
xaxis_title='Space ID',
|
682 |
yaxis_title='Rank',
|
683 |
yaxis=dict(
|
684 |
-
autorange='reversed', # Y์ถ์ ๋ฐ์
|
685 |
tickmode='linear',
|
686 |
-
tick0=
|
687 |
dtick=20,
|
688 |
-
range=[
|
|
|
|
|
689 |
),
|
690 |
height=800,
|
691 |
showlegend=False,
|
692 |
template='plotly_white',
|
693 |
xaxis_tickangle=-45
|
694 |
)
|
695 |
-
|
696 |
-
progress(0.6, desc="Creating space cards...")
|
697 |
-
|
698 |
-
# HTML ์นด๋ ์์ฑ
|
699 |
-
html_content = f"""
|
700 |
-
<div style='padding: 20px; background: #f5f5f5;'>
|
701 |
-
<h2 style='color: #2c3e50;'>{sort_type.title()} Rankings</h2>
|
702 |
-
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
703 |
-
"""
|
704 |
-
|
705 |
-
for space in spaces:
|
706 |
-
space_id = space['id']
|
707 |
-
rank = space['rank']
|
708 |
-
title = space.get('cardData', {}).get('title') or space.get('title', 'No Title')
|
709 |
-
likes = space.get('likes', 0)
|
710 |
-
|
711 |
-
html_content += f"""
|
712 |
-
<div style='
|
713 |
-
background: white;
|
714 |
-
padding: 20px;
|
715 |
-
border-radius: 10px;
|
716 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
717 |
-
transition: transform 0.2s;
|
718 |
-
'>
|
719 |
-
<h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
|
720 |
-
<h4 style='
|
721 |
-
color: #2980b9;
|
722 |
-
margin: 10px 0;
|
723 |
-
font-size: 1.2em;
|
724 |
-
font-weight: bold;
|
725 |
-
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
726 |
-
background: linear-gradient(to right, #3498db, #2980b9);
|
727 |
-
-webkit-background-clip: text;
|
728 |
-
-webkit-text-fill-color: transparent;
|
729 |
-
padding: 5px 0;
|
730 |
-
'>{title}</h4>
|
731 |
-
<p style='color: #7f8c8d; margin-bottom: 10px;'>๐ Likes: {likes}</p>
|
732 |
-
<a href='{target_spaces[space_id]}'
|
733 |
-
target='_blank'
|
734 |
-
style='
|
735 |
-
display: inline-block;
|
736 |
-
padding: 8px 16px;
|
737 |
-
background: #3498db;
|
738 |
-
color: white;
|
739 |
-
text-decoration: none;
|
740 |
-
border-radius: 5px;
|
741 |
-
transition: background 0.3s;
|
742 |
-
'>
|
743 |
-
Visit Space ๐
|
744 |
-
</a>
|
745 |
-
</div>
|
746 |
-
"""
|
747 |
-
|
748 |
-
html_content += "</div></div>"
|
749 |
-
|
750 |
-
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ
|
751 |
-
df = pd.DataFrame([{
|
752 |
-
'Rank': space['rank'],
|
753 |
-
'Space ID': space['id'],
|
754 |
-
'Title': space.get('cardData', {}).get('title') or space.get('title', 'No Title'),
|
755 |
-
'Likes': space.get('likes', 0),
|
756 |
-
'URL': target_spaces[space['id']]
|
757 |
-
} for space in spaces])
|
758 |
-
|
759 |
-
progress(1.0, desc="Complete!")
|
760 |
-
return fig, html_content, df
|
761 |
-
|
762 |
-
except Exception as e:
|
763 |
-
print(f"Error in get_spaces_data: {str(e)}")
|
764 |
-
error_html = f'<div style="color: red; padding: 20px;">Error: {str(e)}</div>'
|
765 |
-
error_plot = create_error_plot()
|
766 |
-
return error_plot, error_html, pd.DataFrame()
|
767 |
|
768 |
|
769 |
def create_trend_visualization(spaces_data):
|
|
|
681 |
xaxis_title='Space ID',
|
682 |
yaxis_title='Rank',
|
683 |
yaxis=dict(
|
684 |
+
autorange='reversed', # Y์ถ์ ๋ฐ์ (1์ด ์๋ก, 400์ด ์๋๋ก)
|
685 |
tickmode='linear',
|
686 |
+
tick0=1, # ์์๊ฐ์ 1๋ก ์ค์
|
687 |
dtick=20,
|
688 |
+
range=[1, 400], # Y์ถ ๋ฒ์๋ฅผ 1๋ถํฐ 400๊น์ง๋ก ์ค์
|
689 |
+
ticktext=[str(i) for i in range(1, 401, 20)], # 1๋ถํฐ ์์ํ๋ ๋๊ธ ๋ ์ด๋ธ
|
690 |
+
tickvals=[i for i in range(1, 401, 20)] # ๋๊ธ ์์น
|
691 |
),
|
692 |
height=800,
|
693 |
showlegend=False,
|
694 |
template='plotly_white',
|
695 |
xaxis_tickangle=-45
|
696 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
|
698 |
|
699 |
def create_trend_visualization(spaces_data):
|