fruitpicker01 commited on
Commit
f154467
1 Parent(s): cbd104c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -26
app.py CHANGED
@@ -1,39 +1,42 @@
1
- import gradio as gr
2
  import plotly.graph_objects as go
 
3
 
4
- # Function to create a speedometer gauge
5
- def success_rate_gauge(success_value):
6
  fig = go.Figure(go.Indicator(
7
  mode="gauge+number",
8
- value=success_value,
9
- gauge={'axis': {'range': [0, 100]},
10
- 'bar': {'color': "green"},
11
- 'steps': [
12
- {'range': [0, 50], 'color': "red"},
13
- {'range': [50, 75], 'color': "yellow"},
14
- {'range': [75, 100], 'color': "green"}],
15
- 'threshold': {'line': {'color': "black", 'width': 4}, 'thickness': 0.75, 'value': 76}}
 
 
 
 
 
 
 
 
16
  ))
17
-
18
- fig.update_layout(height=400, width=500)
19
  return fig
20
 
21
- # Gradio interface
 
 
22
  with gr.Blocks() as demo:
23
  gr.Markdown("## Улучшенный спидометр с вероятностью успеха")
24
 
25
- # Plot output
26
- plot = gr.Plot(label="Success Rate Gauge")
27
-
28
- # Function to update the plot
29
- def update_plot():
30
- return success_rate_gauge(76)
31
-
32
- # Button to trigger the plot generation
33
- btn = gr.Button("Показать спидометр")
34
 
35
- # Associate the button with the update function
36
- btn.click(fn=update_plot, inputs=[], outputs=plot)
37
 
38
- # Launch Gradio interface
39
  demo.launch()
 
 
1
  import plotly.graph_objects as go
2
+ import gradio as gr
3
 
4
+ def create_gauge():
 
5
  fig = go.Figure(go.Indicator(
6
  mode="gauge+number",
7
+ value=76,
8
+ gauge={
9
+ 'axis': {'range': [0, 100]},
10
+ 'bar': {'color': "black"}, # Цвет стрелки
11
+ 'steps': [
12
+ {'range': [0, 40], 'color': "#55efc4"}, # Мягкий зеленый
13
+ {'range': [40, 70], 'color': "#ffeaa7"}, # Желтый
14
+ {'range': [70, 100], 'color': "#ff7675"} # Мягкий красный
15
+ ],
16
+ 'threshold': {
17
+ 'line': {'color': "black", 'width': 4},
18
+ 'thickness': 0.75,
19
+ 'value': 76
20
+ }
21
+ },
22
+ number={'font': {'size': 48}} # Размер шрифта числа
23
  ))
24
+ fig.update_layout(paper_bgcolor="#f8f9fa", # Цвет фона
25
+ font={'color': "#2d3436", 'family': "Arial"}) # Цвет текста
26
  return fig
27
 
28
+ def update_plot():
29
+ return create_gauge()
30
+
31
  with gr.Blocks() as demo:
32
  gr.Markdown("## Улучшенный спидометр с вероятностью успеха")
33
 
34
+ with gr.Row():
35
+ plot = gr.Plot(label="Success Rate Gauge")
36
+
37
+ with gr.Row():
38
+ update_button = gr.Button("Показать спидометр")
 
 
 
 
39
 
40
+ update_button.click(fn=update_plot, inputs=[], outputs=plot)
 
41
 
 
42
  demo.launch()