Spaces:
Build error
Build error
Merge pull request #17 from buuck/show_timeseries_plot
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
from utils import duckdb_queries as dq
|
5 |
from utils.gradio import get_window_url_params
|
@@ -17,10 +18,15 @@ def toggle_metric_definition_box(text_input):
|
|
17 |
return indexgenerator.get_metric_file()
|
18 |
else:
|
19 |
return None
|
20 |
-
|
|
|
|
|
|
|
21 |
with gr.Blocks() as demo:
|
22 |
with gr.Column():
|
23 |
-
|
|
|
|
|
24 |
with gr.Row():
|
25 |
project_name = gr.Dropdown([], label="Project", value="Select project")
|
26 |
metric = gr.Dropdown(metric_names, label='Metric', value='Select metric')
|
@@ -42,6 +48,10 @@ with gr.Blocks() as demo:
|
|
42 |
indexgenerator.calculate_score,
|
43 |
inputs=[start_year, end_year],
|
44 |
outputs=results_df,
|
|
|
|
|
|
|
|
|
45 |
)
|
46 |
view_btn.click(
|
47 |
fn=indexgenerator.show_project_map,
|
@@ -67,6 +77,7 @@ with gr.Blocks() as demo:
|
|
67 |
indexgenerator.set_metric,
|
68 |
inputs=metric
|
69 |
)
|
|
|
70 |
# Toggle display of metric information
|
71 |
metric_btn.click(
|
72 |
toggle_metric_definition_box,
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
import plotly.express as px
|
4 |
|
5 |
from utils import duckdb_queries as dq
|
6 |
from utils.gradio import get_window_url_params
|
|
|
18 |
return indexgenerator.get_metric_file()
|
19 |
else:
|
20 |
return None
|
21 |
+
|
22 |
+
def make_timeseries_plot(df):
|
23 |
+
return px.line(df, x='Year', y='Score (Area * Value)', markers=True)
|
24 |
+
|
25 |
with gr.Blocks() as demo:
|
26 |
with gr.Column():
|
27 |
+
with gr.Row():
|
28 |
+
m1 = gr.Plot(label='Project Map')
|
29 |
+
ts_plot = gr.Plot(label='Metric scores over time')
|
30 |
with gr.Row():
|
31 |
project_name = gr.Dropdown([], label="Project", value="Select project")
|
32 |
metric = gr.Dropdown(metric_names, label='Metric', value='Select metric')
|
|
|
48 |
indexgenerator.calculate_score,
|
49 |
inputs=[start_year, end_year],
|
50 |
outputs=results_df,
|
51 |
+
).then(
|
52 |
+
make_timeseries_plot,
|
53 |
+
inputs=results_df,
|
54 |
+
outputs=ts_plot
|
55 |
)
|
56 |
view_btn.click(
|
57 |
fn=indexgenerator.show_project_map,
|
|
|
77 |
indexgenerator.set_metric,
|
78 |
inputs=metric
|
79 |
)
|
80 |
+
|
81 |
# Toggle display of metric information
|
82 |
metric_btn.click(
|
83 |
toggle_metric_definition_box,
|