Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ DEVELOPER_NAME = "黃千宥、陳奕瑄、汪于捷、李哲弘、洪寓澤"
|
|
9 |
# 初始化 pytrends
|
10 |
# hl='zh-TW' -> 繁體中文, tz=480 -> 台灣時區 (GMT+8)
|
11 |
pytrends = TrendReq(hl='zh-TW', tz=480)
|
12 |
-
|
13 |
def analyze_google_trends(keywords_str: str, timeframe: str):
|
14 |
"""
|
15 |
根據輸入的關鍵字和時間範圍,從 Google Trends 獲取並分析資料。
|
@@ -77,7 +77,7 @@ def plot_interest_over_time(df: pd.DataFrame, title: str):
|
|
77 |
"""使用 Plotly 繪製時間趨勢圖。"""
|
78 |
fig = px.line(df, x=df.index, y=df.columns, title=title, labels={'value': '相對熱度', 'date': '日期', 'variable': '關鍵字'})
|
79 |
fig.update_layout(
|
80 |
-
|
81 |
paper_bgcolor='rgba(0,0,0,0)',
|
82 |
plot_bgcolor='rgba(0,0,0,0.2)',
|
83 |
legend_title_text=''
|
@@ -88,7 +88,7 @@ def plot_interest_by_region(df: pd.DataFrame, title: str):
|
|
88 |
"""使用 Plotly 繪製區域熱度長條圖。"""
|
89 |
fig = px.bar(df, x=df.index, y=df.columns[0], title=title, labels={'y': '相對熱度', 'index': '國家/地區'})
|
90 |
fig.update_layout(
|
91 |
-
|
92 |
paper_bgcolor='rgba(0,0,0,0)',
|
93 |
plot_bgcolor='rgba(0,0,0,0.2)'
|
94 |
)
|
@@ -96,7 +96,7 @@ def plot_interest_by_region(df: pd.DataFrame, title: str):
|
|
96 |
return fig
|
97 |
|
98 |
with gr.Blocks(
|
99 |
-
theme=gr.themes.
|
100 |
primary_hue="blue",
|
101 |
secondary_hue="cyan",
|
102 |
font=["Arial", "sans-serif"]
|
|
|
9 |
# 初始化 pytrends
|
10 |
# hl='zh-TW' -> 繁體中文, tz=480 -> 台灣時區 (GMT+8)
|
11 |
pytrends = TrendReq(hl='zh-TW', tz=480)
|
12 |
+
PLOTLY_TEMPLATE = "plotly_dark"
|
13 |
def analyze_google_trends(keywords_str: str, timeframe: str):
|
14 |
"""
|
15 |
根據輸入的關鍵字和時間範圍,從 Google Trends 獲取並分析資料。
|
|
|
77 |
"""使用 Plotly 繪製時間趨勢圖。"""
|
78 |
fig = px.line(df, x=df.index, y=df.columns, title=title, labels={'value': '相對熱度', 'date': '日期', 'variable': '關鍵字'})
|
79 |
fig.update_layout(
|
80 |
+
template=PLOTLY_TEMPLATE,
|
81 |
paper_bgcolor='rgba(0,0,0,0)',
|
82 |
plot_bgcolor='rgba(0,0,0,0.2)',
|
83 |
legend_title_text=''
|
|
|
88 |
"""使用 Plotly 繪製區域熱度長條圖。"""
|
89 |
fig = px.bar(df, x=df.index, y=df.columns[0], title=title, labels={'y': '相對熱度', 'index': '國家/地區'})
|
90 |
fig.update_layout(
|
91 |
+
template=PLOTLY_TEMPLATE,
|
92 |
paper_bgcolor='rgba(0,0,0,0)',
|
93 |
plot_bgcolor='rgba(0,0,0,0.2)'
|
94 |
)
|
|
|
96 |
return fig
|
97 |
|
98 |
with gr.Blocks(
|
99 |
+
theme=gr.themes.Soft(
|
100 |
primary_hue="blue",
|
101 |
secondary_hue="cyan",
|
102 |
font=["Arial", "sans-serif"]
|