Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,25 +25,21 @@ max_year = int(taraf_s['Year'].max())
|
|
25 |
def plot_timeline(yaxis, citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
|
26 |
if min_year >= max_year:
|
27 |
raise gr.error('Min Year Cannot be Bigger than Max Year!')
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
fig.update_layout(legend_x=1, legend_y=0, title = {'x':.5})
|
31 |
return fig
|
32 |
|
33 |
-
# app = gradio.Interface(plot_timeline,
|
34 |
-
# [gradio.Dropdown(choices = ['Taraf', 'Hadith', 'Isnad', 'Ranking'], value = 'Taraf', label = 'Y Axis'), gradio.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
|
35 |
-
# gradio.Slider(min_year, max_year, value = 0, label = 'Begining', info = 'Choose the first year to display Tarafs'),
|
36 |
-
# gradio.Slider(min_year, max_year, value = 400, label = 'End', info = 'Choose the last year to display Tarafs')
|
37 |
-
|
38 |
-
# ],
|
39 |
-
# gradio.Plot()).launch()
|
40 |
-
|
41 |
|
42 |
demo = gr.Blocks()
|
43 |
with demo:
|
44 |
with gr.Row():
|
45 |
y_value = gr.Dropdown(choices = ['Taraf', 'Hadith', 'Isnad', 'Ranking'], value = 'Taraf', label = 'Y Axis')
|
46 |
-
city = gr.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True, label = 'City')
|
47 |
begining = gr.Slider(min_year, max_year, value = 0, label = 'First Year', info = 'Choose the first year to display Tarafs')
|
48 |
end = gr.Slider(min_year, max_year, value = 400, label = 'Last Year', info = 'Choose the last year to display Tarafs')
|
49 |
btn = gr.Button("Plot")
|
|
|
25 |
def plot_timeline(yaxis, citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
|
26 |
if min_year >= max_year:
|
27 |
raise gr.error('Min Year Cannot be Bigger than Max Year!')
|
28 |
+
if citi = ['All']:
|
29 |
+
filtered = taraf_s.copy()[(taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)].groupby(['Year']).sum()
|
30 |
+
fig = px.line(data_frame = filtered, x = 'Year', y = yaxis, title = f"{yaxis} per Year", color = 'City', template = 'plotly_dark' )
|
31 |
+
else:
|
32 |
+
filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)]
|
33 |
+
fig = px.line(data_frame = filtered, x = 'Year', y = yaxis, title = f"{yaxis} per Year", color = 'City', template = 'plotly_dark' )
|
34 |
fig.update_layout(legend_x=1, legend_y=0, title = {'x':.5})
|
35 |
return fig
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
demo = gr.Blocks()
|
39 |
with demo:
|
40 |
with gr.Row():
|
41 |
y_value = gr.Dropdown(choices = ['Taraf', 'Hadith', 'Isnad', 'Ranking'], value = 'Taraf', label = 'Y Axis')
|
42 |
+
city = gr.Dropdown(choices = cities + ['All'], value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True, label = 'City')
|
43 |
begining = gr.Slider(min_year, max_year, value = 0, label = 'First Year', info = 'Choose the first year to display Tarafs')
|
44 |
end = gr.Slider(min_year, max_year, value = 400, label = 'Last Year', info = 'Choose the last year to display Tarafs')
|
45 |
btn = gr.Button("Plot")
|