David Vegh commited on
Commit
d6ca999
β€’
1 Parent(s): c29033c

ipyvizzu sory demo: add basic example

Browse files
Files changed (4) hide show
  1. README.md +7 -4
  2. app.py +13 -0
  3. ipyvizzustory_demo.ipynb +115 -0
  4. requirements.txt +4 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Ipyvizzu Story Demo
3
  emoji: πŸ“Š
4
- colorFrom: red
5
- colorTo: red
6
  sdk: gradio
7
  sdk_version: 3.5
8
  app_file: app.py
@@ -10,4 +10,7 @@ pinned: false
10
  license: apache-2.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
+ title: ipyvizzu-story demo with mercury
3
  emoji: πŸ“Š
4
+ colorFrom: purple
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.5
8
  app_file: app.py
 
10
  license: apache-2.0
11
  ---
12
 
13
+ # ipyvizzu-story demo with mercury
14
+
15
+ This is an interactive ipyvizzu-story demo with mercury.
16
+ Visit our [site](https://github.com/vizzuhq/ipyvizzu-story) for more details, such as a step-by-step tutorial and examples.
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+ from subprocess import Popen
4
+ load_dotenv()
5
+
6
+
7
+ my_env = os.environ.copy()
8
+ my_env["HF_SPACE"] = "embed/veghdev/ipyvizzu-story-demo"
9
+
10
+ command = ["mercury", "run", f"0.0.0.0:{os.environ.get('PORT', 7860)}"]
11
+ print(command)
12
+ worker = Popen(command, env=my_env)
13
+ worker.wait()
ipyvizzustory_demo.ipynb ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "raw",
5
+ "id": "41022af5",
6
+ "metadata": {},
7
+ "source": [
8
+ "---\n",
9
+ "title: ipyvizzu-story demo\n",
10
+ "description: ipyvizzu-story demo with mercury\n",
11
+ "show-code: False\n",
12
+ "params:\n",
13
+ "params:\n",
14
+ " example:\n",
15
+ " input: select\n",
16
+ " label: select the example\n",
17
+ " choices: [basic, complex]\n",
18
+ " multi: False\n",
19
+ "---"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "id": "bf9e62cb",
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "# configure default value\n",
30
+ "\n",
31
+ "example = 'complex'"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "id": "1226e7e9",
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "from ipyvizzu import Data, Config\n",
42
+ "from ipyvizzustory import Slide, Step\n",
43
+ "\n",
44
+ "from ipyvizzustory import Story # or\n",
45
+ "# from ipyvizzustory.env.ipy.story import Story"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "id": "1a26e2e9",
52
+ "metadata": {},
53
+ "outputs": [],
54
+ "source": [
55
+ "basic_data = Data()\n",
56
+ "basic_data.add_series(\"Foo\", [\"Alice\", \"Bob\", \"Ted\"])\n",
57
+ "basic_data.add_series(\"Bar\", [15, 32, 12])\n",
58
+ "basic_data.add_series(\"Baz\", [5, 3, 2])\n",
59
+ "\n",
60
+ "basic_story = Story(data=basic_data)\n",
61
+ "\n",
62
+ "basic_slide1 = Slide(\n",
63
+ " Step(\n",
64
+ " Config({\"x\": \"Foo\", \"y\": \"Bar\"}),\n",
65
+ " )\n",
66
+ ")\n",
67
+ "basic_story.add_slide(basic_slide1)\n",
68
+ "\n",
69
+ "basic_slide2 = Slide(\n",
70
+ " Step(\n",
71
+ " Config({\"color\": \"Foo\", \"x\": \"Baz\", \"geometry\": \"circle\"}),\n",
72
+ " )\n",
73
+ ")\n",
74
+ "basic_story.add_slide(basic_slide2)"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "id": "1ab7ece9",
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "if example == \"basic\":\n",
85
+ " basic_story.play()"
86
+ ]
87
+ }
88
+ ],
89
+ "metadata": {
90
+ "kernelspec": {
91
+ "display_name": "Python 3.7.3 64-bit",
92
+ "language": "python",
93
+ "name": "python3"
94
+ },
95
+ "language_info": {
96
+ "codemirror_mode": {
97
+ "name": "ipython",
98
+ "version": 3
99
+ },
100
+ "file_extension": ".py",
101
+ "mimetype": "text/x-python",
102
+ "name": "python",
103
+ "nbconvert_exporter": "python",
104
+ "pygments_lexer": "ipython3",
105
+ "version": "3.7.3"
106
+ },
107
+ "vscode": {
108
+ "interpreter": {
109
+ "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
110
+ }
111
+ }
112
+ },
113
+ "nbformat": 4,
114
+ "nbformat_minor": 5
115
+ }
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ python-dotenv
2
+ mljar-mercury
3
+ ipyvizzu-story
4
+ pandas