aliabd HF Staff commited on
Commit
e832819
·
1 Parent(s): 5b8f965

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +6 -7
  2. requirements.txt +1 -0
  3. run.py +42 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Live Dashboard Main
3
- emoji: 🌖
4
  colorFrom: indigo
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.8.2
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: live_dashboard_main
4
+ emoji: 🔥
5
  colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.8.1
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ plotlyhttps://gradio-main-build.s3.amazonaws.com/8de8f95164c8c2a191d617fc6e4e70641be364f1/gradio-3.8.1-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ import gradio as gr
3
+ import datetime
4
+ import plotly.express as px
5
+ import numpy as np
6
+
7
+
8
+ def get_time():
9
+ return datetime.datetime.now()
10
+
11
+
12
+ plot_end = 2 * math.pi
13
+
14
+
15
+ def get_plot(period=1):
16
+ global plot_end
17
+ x = np.arange(plot_end - 2 * math.pi, plot_end, 0.02)
18
+ y = np.sin(2*math.pi*period * x)
19
+ fig = px.line(x=x, y=y)
20
+ plot_end += 2 * math.pi
21
+ return fig
22
+
23
+
24
+ with gr.Blocks() as demo:
25
+ with gr.Row():
26
+ with gr.Column():
27
+ c_time2 = gr.Textbox(label="Current Time refreshed every second")
28
+ gr.Markdown("Change the value of the slider to automatically update the plot")
29
+ period = gr.Slider(label="Period of plot", value=1, minimum=0, maximum=10, step=1)
30
+ plot = gr.Plot(label="Plot (updates every half second)")
31
+ with gr.Column():
32
+ name = gr.Textbox(label="Enter your name")
33
+ greeting = gr.Textbox(label="Greeting")
34
+ button = gr.Button(value="Greet")
35
+ button.click(lambda s: f"Hello {s}", name, greeting)
36
+
37
+ demo.load(lambda: datetime.datetime.now(), None, c_time2, every=1)
38
+ dep = demo.load(get_plot, None, plot, every=0.5)
39
+ period.change(get_plot, period, plot, every=0.5, cancels=[dep])
40
+
41
+ if __name__ == "__main__":
42
+ demo.queue().launch()