Spaces:
Sleeping
Sleeping
fruitpicker01
commited on
Commit
•
f154467
1
Parent(s):
cbd104c
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,42 @@
|
|
1 |
-
import gradio as gr
|
2 |
import plotly.graph_objects as go
|
|
|
3 |
|
4 |
-
|
5 |
-
def success_rate_gauge(success_value):
|
6 |
fig = go.Figure(go.Indicator(
|
7 |
mode="gauge+number",
|
8 |
-
value=
|
9 |
-
gauge={
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
))
|
17 |
-
|
18 |
-
|
19 |
return fig
|
20 |
|
21 |
-
|
|
|
|
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("## Улучшенный спидометр с вероятностью успеха")
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
return success_rate_gauge(76)
|
31 |
-
|
32 |
-
# Button to trigger the plot generation
|
33 |
-
btn = gr.Button("Показать спидометр")
|
34 |
|
35 |
-
|
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()
|