freddyaboulton HF Staff commited on
Commit
31427a2
·
verified ·
1 Parent(s): e9e1243

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +5 -5
  2. requirements.txt +2 -0
  3. run.ipynb +1 -0
  4. run.py +92 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Draggable Dashboard Main
3
  emoji: 🔥
4
- colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.43.1
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: draggable_dashboard_main
4
  emoji: 🔥
5
+ colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 5.43.1
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@dfc0e0305068dbd16ce905afc73d139e1e51eb46#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/dfc0e0305068dbd16ce905afc73d139e1e51eb46/gradio-5.43.1-py3-none-any.whl
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: draggable_dashboard"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np\n", "import pandas as pd\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\"# Draggable Dashboard Demo\")\n", " gr.Markdown(\"Drag the charts around to reorder them!\")\n", " \n", " x = np.linspace(0, 10, 100)\n", " data = pd.DataFrame({\n", " 'x': x,\n", " 'y1': np.random.normal(100, 20, 100) + 10 * np.sin(x),\n", " 'y2': np.random.normal(500, 100, 100) + 50 * np.cos(x),\n", " 'y3': np.random.normal(1000, 200, 100) + 100 * np.sin(x/2),\n", " 'y4': np.random.normal(0.15, 0.05, 100) + 0.05 * np.cos(x/3)\n", " })\n", " \n", " with gr.Row():\n", " with gr.Column(scale=1):\n", " gr.Markdown(\"### Horizontal Layout (orientation='row')\")\n", " with gr.Draggable(orientation=\"row\"):\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y1\",\n", " title=\"Chart 1\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y2\",\n", " title=\"Chart 2\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y3\",\n", " title=\"Chart 3\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y4\",\n", " title=\"Chart 4\",\n", " height=200,\n", " width=300\n", " )\n", " \n", " with gr.Column(scale=1):\n", " gr.Markdown(\"### Vertical Layout (orientation='column')\")\n", " with gr.Draggable(orientation=\"column\"):\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y1\",\n", " title=\"Chart 1\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y2\",\n", " title=\"Chart 2\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y3\",\n", " title=\"Chart 3\",\n", " height=200,\n", " width=300\n", " )\n", " gr.LinePlot(\n", " data,\n", " x=\"x\",\n", " y=\"y4\",\n", " title=\"Chart 4\",\n", " height=200,\n", " width=300\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import pandas as pd
4
+
5
+ with gr.Blocks() as demo:
6
+ gr.Markdown("# Draggable Dashboard Demo")
7
+ gr.Markdown("Drag the charts around to reorder them!")
8
+
9
+ x = np.linspace(0, 10, 100)
10
+ data = pd.DataFrame({
11
+ 'x': x,
12
+ 'y1': np.random.normal(100, 20, 100) + 10 * np.sin(x),
13
+ 'y2': np.random.normal(500, 100, 100) + 50 * np.cos(x),
14
+ 'y3': np.random.normal(1000, 200, 100) + 100 * np.sin(x/2),
15
+ 'y4': np.random.normal(0.15, 0.05, 100) + 0.05 * np.cos(x/3)
16
+ })
17
+
18
+ with gr.Row():
19
+ with gr.Column(scale=1):
20
+ gr.Markdown("### Horizontal Layout (orientation='row')")
21
+ with gr.Draggable(orientation="row"):
22
+ gr.LinePlot(
23
+ data,
24
+ x="x",
25
+ y="y1",
26
+ title="Chart 1",
27
+ height=200,
28
+ width=300
29
+ )
30
+ gr.LinePlot(
31
+ data,
32
+ x="x",
33
+ y="y2",
34
+ title="Chart 2",
35
+ height=200,
36
+ width=300
37
+ )
38
+ gr.LinePlot(
39
+ data,
40
+ x="x",
41
+ y="y3",
42
+ title="Chart 3",
43
+ height=200,
44
+ width=300
45
+ )
46
+ gr.LinePlot(
47
+ data,
48
+ x="x",
49
+ y="y4",
50
+ title="Chart 4",
51
+ height=200,
52
+ width=300
53
+ )
54
+
55
+ with gr.Column(scale=1):
56
+ gr.Markdown("### Vertical Layout (orientation='column')")
57
+ with gr.Draggable(orientation="column"):
58
+ gr.LinePlot(
59
+ data,
60
+ x="x",
61
+ y="y1",
62
+ title="Chart 1",
63
+ height=200,
64
+ width=300
65
+ )
66
+ gr.LinePlot(
67
+ data,
68
+ x="x",
69
+ y="y2",
70
+ title="Chart 2",
71
+ height=200,
72
+ width=300
73
+ )
74
+ gr.LinePlot(
75
+ data,
76
+ x="x",
77
+ y="y3",
78
+ title="Chart 3",
79
+ height=200,
80
+ width=300
81
+ )
82
+ gr.LinePlot(
83
+ data,
84
+ x="x",
85
+ y="y4",
86
+ title="Chart 4",
87
+ height=200,
88
+ width=300
89
+ )
90
+
91
+ if __name__ == "__main__":
92
+ demo.launch()