Spaces:
Sleeping
Sleeping
File size: 2,743 Bytes
31427a2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import gradio as gr
import numpy as np
import pandas as pd
with gr.Blocks() as demo:
gr.Markdown("# Draggable Dashboard Demo")
gr.Markdown("Drag the charts around to reorder them!")
x = np.linspace(0, 10, 100)
data = pd.DataFrame({
'x': x,
'y1': np.random.normal(100, 20, 100) + 10 * np.sin(x),
'y2': np.random.normal(500, 100, 100) + 50 * np.cos(x),
'y3': np.random.normal(1000, 200, 100) + 100 * np.sin(x/2),
'y4': np.random.normal(0.15, 0.05, 100) + 0.05 * np.cos(x/3)
})
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("### Horizontal Layout (orientation='row')")
with gr.Draggable(orientation="row"):
gr.LinePlot(
data,
x="x",
y="y1",
title="Chart 1",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y2",
title="Chart 2",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y3",
title="Chart 3",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y4",
title="Chart 4",
height=200,
width=300
)
with gr.Column(scale=1):
gr.Markdown("### Vertical Layout (orientation='column')")
with gr.Draggable(orientation="column"):
gr.LinePlot(
data,
x="x",
y="y1",
title="Chart 1",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y2",
title="Chart 2",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y3",
title="Chart 3",
height=200,
width=300
)
gr.LinePlot(
data,
x="x",
y="y4",
title="Chart 4",
height=200,
width=300
)
if __name__ == "__main__":
demo.launch() |