Spaces:
Runtime error
Runtime error
File size: 3,446 Bytes
d6ca999 4176ac6 d6ca999 62ec136 4176ac6 62ec136 d6ca999 62ec136 4176ac6 62ec136 4176ac6 62ec136 4176ac6 62ec136 4176ac6 62ec136 d6ca999 62ec136 d6ca999 62ec136 d6ca999 62ec136 d6ca999 62ec136 d6ca999 4176ac6 62ec136 4176ac6 d6ca999 62ec136 d6ca999 4176ac6 d6ca999 |
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
{
"cells": [
{
"cell_type": "raw",
"id": "41022af5",
"metadata": {},
"source": [
"---\n",
"title: ipyvizzu-story demo\n",
"description: ipyvizzu-story demo with mercury\n",
"show-code: False\n",
"params:\n",
"params:\n",
" example:\n",
" input: select\n",
" label: select the example\n",
" choices: [basic, complex]\n",
" multi: False\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bf9e62cb",
"metadata": {},
"outputs": [],
"source": [
"# configure default value\n",
"\n",
"example = 'complex'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1226e7e9",
"metadata": {},
"outputs": [],
"source": [
"# import ipyvizzu and ipyvizzu-story\n",
"\n",
"from ipyvizzu import Data, Config\n",
"from ipyvizzustory import Slide, Step\n",
"\n",
"from ipyvizzustory import Story # or\n",
"# from ipyvizzustory.env.ipy.story import Story"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a26e2e9",
"metadata": {},
"outputs": [],
"source": [
"# create data and initialize Story with the created data\n",
"\n",
"data = Data()\n",
"data.add_series(\"Foo\", [\"Alice\", \"Bob\", \"Ted\"])\n",
"data.add_series(\"Bar\", [15, 32, 12])\n",
"data.add_series(\"Baz\", [5, 3, 2])\n",
"\n",
"# you can also add data with pandas\n",
"\n",
"# import pandas as pd\n",
"#\n",
"# data = Data()\n",
"# df = pd.read_csv(\n",
"# \"https://raw.githubusercontent.com/\" +\n",
"# \"vizzuhq/ipyvizzu-story/main/\" +\n",
"# \"docs/examples/basic/basic.csv\"\n",
"# )\n",
"# data.add_data_frame(df)\n",
"\n",
"story = Story(data=data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27b1d972",
"metadata": {},
"outputs": [],
"source": [
"# create Slides and Steps and add them to the Story\n",
"\n",
"slide1 = Slide(\n",
" Step(\n",
" Config({\"x\": \"Foo\", \"y\": \"Bar\"}),\n",
" )\n",
")\n",
"story.add_slide(slide1)\n",
"\n",
"slide2 = Slide(\n",
" Step(\n",
" Config({\"color\": \"Foo\", \"x\": \"Baz\", \"geometry\": \"circle\"}),\n",
" )\n",
")\n",
"story.add_slide(slide2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2e06c121",
"metadata": {},
"outputs": [],
"source": [
"# you can set the width and height (CSS style)\n",
"\n",
"story.set_size(width=\"400px\", height=\"240px\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ab7ece9",
"metadata": {},
"outputs": [],
"source": [
"if example == \"basic\":\n",
" story.play()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.7.3 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
},
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|