├── .gitignore ├── LICENSE ├── README.md ├── create-widgets-in-loop.ipynb ├── display-json.ipynb ├── docs-examples ├── checkbox.ipynb ├── file.ipynb ├── multiselect-simple.ipynb ├── multiselect.ipynb ├── range.ipynb ├── slider-simple.ipynb ├── slider.ipynb ├── text-simple.ipynb └── text.ipynb ├── dynamic-widgets.ipynb ├── file-upload.ipynb ├── hello-world.ipynb ├── incement-decrement.ipynb ├── issues └── web │ ├── Gemfile │ └── README.md ├── load-large-dataset.ipynb ├── load-on-click.ipynb ├── numberbox-example.ipynb ├── numberbox.ipynb ├── outputdir.ipynb ├── pivot-table ├── .gitkeep ├── README.md ├── pivot-table.ipynb └── requirements.txt ├── pydeck ├── .gitkeep ├── README.md ├── pydeck.ipynb └── requirements.txt ├── show-hide-code.ipynb ├── static-notebook-2.ipynb ├── static-notebook.ipynb ├── stop-execution.ipynb └── use-cases ├── .gitkeep ├── altair-dashboard ├── .gitkeep ├── altair.ipynb └── requirements.txt ├── data-analyst-job ├── README.md ├── data-analyst.ipynb ├── df-job-al.zip ├── images │ ├── 10-skills.png │ ├── avg-pay-skills.png │ ├── cd-mercury.png │ ├── contract-type.png │ ├── number-of-jobs.png │ ├── remote.png │ ├── text.png │ ├── web-menu.png │ ├── web.png │ ├── what-company.png │ ├── where-to-look.png │ └── wordcloud.png ├── media │ ├── .gitkeep │ ├── banner.jpg │ ├── data-analyst-skills.gif │ ├── data-analysts-overview.png │ └── mercury-web-app.gif └── requirements.txt ├── marker-size └── marker-size.ipynb ├── matplotlib-legend ├── README.md ├── images │ ├── matplot-legend.gif │ ├── plot-01.png │ ├── plot-02.png │ ├── plot-03.png │ └── plot-04.png ├── matplotlib-legend-location-mr.ipynb ├── matplotlib-legend-location.ipynb └── media │ ├── .gitkeep │ └── banner.jpg ├── report ├── .gitkeep ├── report.ipynb └── requirements.txt └── ticker-app ├── .gitkeep ├── requirements.txt └── ticker-report.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 MLJAR 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mercury-examples 2 | Example Jupyter Notebooks showing how to use Mercury framework 3 | -------------------------------------------------------------------------------- /create-widgets-in-loop.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "7a651244", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "1d8f2cd7", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"0\",\n \"rows\": 1,\n \"label\": \"Widget 0\",\n \"model_id\": \"854548a0c21e447da53da5373c6c4649\",\n \"code_uid\": \"Text.0.40.15.3.w-0-rand3c26b313\",\n \"url_key\": \"w-0\",\n \"disabled\": false,\n \"hidden\": false\n}", 22 | "application/vnd.jupyter.widget-view+json": { 23 | "model_id": "854548a0c21e447da53da5373c6c4649", 24 | "version_major": 2, 25 | "version_minor": 0 26 | }, 27 | "text/plain": [ 28 | "mercury.Text" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | }, 34 | { 35 | "data": { 36 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"1\",\n \"rows\": 1,\n \"label\": \"Widget 1\",\n \"model_id\": \"0958235ff57349daa3a4ecce68b68db2\",\n \"code_uid\": \"Text.0.40.15.3.w-1-rande2028888\",\n \"url_key\": \"w-1\",\n \"disabled\": false,\n \"hidden\": false\n}", 37 | "application/vnd.jupyter.widget-view+json": { 38 | "model_id": "0958235ff57349daa3a4ecce68b68db2", 39 | "version_major": 2, 40 | "version_minor": 0 41 | }, 42 | "text/plain": [ 43 | "mercury.Text" 44 | ] 45 | }, 46 | "metadata": {}, 47 | "output_type": "display_data" 48 | }, 49 | { 50 | "data": { 51 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"2\",\n \"rows\": 1,\n \"label\": \"Widget 2\",\n \"model_id\": \"211e32b589854625a4da014d081dd89b\",\n \"code_uid\": \"Text.0.40.15.3.w-2-rand307ff14a\",\n \"url_key\": \"w-2\",\n \"disabled\": false,\n \"hidden\": false\n}", 52 | "application/vnd.jupyter.widget-view+json": { 53 | "model_id": "211e32b589854625a4da014d081dd89b", 54 | "version_major": 2, 55 | "version_minor": 0 56 | }, 57 | "text/plain": [ 58 | "mercury.Text" 59 | ] 60 | }, 61 | "metadata": {}, 62 | "output_type": "display_data" 63 | }, 64 | { 65 | "data": { 66 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"3\",\n \"rows\": 1,\n \"label\": \"Widget 3\",\n \"model_id\": \"9f826b3b8c354eaba9a10dd87c8e6468\",\n \"code_uid\": \"Text.0.40.15.3.w-3-rande6e0b35e\",\n \"url_key\": \"w-3\",\n \"disabled\": false,\n \"hidden\": false\n}", 67 | "application/vnd.jupyter.widget-view+json": { 68 | "model_id": "9f826b3b8c354eaba9a10dd87c8e6468", 69 | "version_major": 2, 70 | "version_minor": 0 71 | }, 72 | "text/plain": [ 73 | "mercury.Text" 74 | ] 75 | }, 76 | "metadata": {}, 77 | "output_type": "display_data" 78 | }, 79 | { 80 | "data": { 81 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"4\",\n \"rows\": 1,\n \"label\": \"Widget 4\",\n \"model_id\": \"50c2dbee0ef6458c95b8084c351d656a\",\n \"code_uid\": \"Text.0.40.15.3.w-4-rand7a0964cc\",\n \"url_key\": \"w-4\",\n \"disabled\": false,\n \"hidden\": false\n}", 82 | "application/vnd.jupyter.widget-view+json": { 83 | "model_id": "50c2dbee0ef6458c95b8084c351d656a", 84 | "version_major": 2, 85 | "version_minor": 0 86 | }, 87 | "text/plain": [ 88 | "mercury.Text" 89 | ] 90 | }, 91 | "metadata": {}, 92 | "output_type": "display_data" 93 | } 94 | ], 95 | "source": [ 96 | "texts = []\n", 97 | "for i in range(5):\n", 98 | " texts += [mr.Text(label=f\"Widget {i}\", value=f\"{i}\", url_key=f\"w-{i}\")]" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 3, 104 | "id": "79039e7b", 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "name": "stdout", 109 | "output_type": "stream", 110 | "text": [ 111 | "0\n", 112 | "1\n", 113 | "2\n", 114 | "3\n", 115 | "4\n" 116 | ] 117 | } 118 | ], 119 | "source": [ 120 | "for t in texts:\n", 121 | " print(t.value)" 122 | ] 123 | } 124 | ], 125 | "metadata": { 126 | "kernelspec": { 127 | "display_name": "menv", 128 | "language": "python", 129 | "name": "menv" 130 | }, 131 | "language_info": { 132 | "codemirror_mode": { 133 | "name": "ipython", 134 | "version": 3 135 | }, 136 | "file_extension": ".py", 137 | "mimetype": "text/x-python", 138 | "name": "python", 139 | "nbconvert_exporter": "python", 140 | "pygments_lexer": "ipython3", 141 | "version": "3.9.16" 142 | } 143 | }, 144 | "nbformat": 4, 145 | "nbformat_minor": 5 146 | } 147 | -------------------------------------------------------------------------------- /display-json.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "389c0350", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "81981081", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Display JSON\",\n \"description\": \"\",\n \"show_code\": false,\n \"show_prompt\": false,\n \"share\": \"public\",\n \"output\": \"app\",\n \"slug\": \"\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.41.23.1-rand5a7552a6\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"Display JSON\", static_notebook=True)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "id": "77f316e7", 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "data = {\n", 45 | " \"firstKey\": [\"a\", \"b\", \"c\"],\n", 46 | " \"secondKey\": [1, 2, 3, 4],\n", 47 | " \"thirdKey\": \"Hello World!\"\n", 48 | "}" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 4, 54 | "id": "e686f2a2", 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "data": { 59 | "text/html": [ 60 | "
" 70 | ], 71 | "text/plain": [ 72 | "" 73 | ] 74 | }, 75 | "metadata": {}, 76 | "output_type": "display_data" 77 | }, 78 | { 79 | "data": { 80 | "text/html": [ 81 | "" 82 | ], 83 | "text/plain": [ 84 | "" 85 | ] 86 | }, 87 | "metadata": {}, 88 | "output_type": "display_data" 89 | } 90 | ], 91 | "source": [ 92 | "mr.JSON(data)" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "d58681a2", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "mex", 107 | "language": "python", 108 | "name": "mex" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.8.0" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 5 125 | } 126 | -------------------------------------------------------------------------------- /docs-examples/checkbox.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "b05d39ae", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "11dd0e47", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Checkbox demo\",\n \"description\": \"Show Checkbox widget usage\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.2-rand39799366\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "# setup app properies\n", 35 | "app = mr.App(title=\"Checkbox\", description=\"Show Checkbox widget usage\", show_code=True)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "id": "841c5232", 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "application/mercury+json": "{\n \"widget\": \"Checkbox\",\n \"value\": true,\n \"label\": \"Switch me\",\n \"model_id\": \"204f4edc6b9a4c418f8519b4037ef0be\",\n \"code_uid\": \"Checkbox.0.40.11.2-rand5e9a7097\",\n \"url_key\": \"flag\",\n \"disabled\": false,\n \"hidden\": false\n}", 47 | "application/vnd.jupyter.widget-view+json": { 48 | "model_id": "204f4edc6b9a4c418f8519b4037ef0be", 49 | "version_major": 2, 50 | "version_minor": 0 51 | }, 52 | "text/plain": [ 53 | "mercury.Checkbox" 54 | ] 55 | }, 56 | "metadata": {}, 57 | "output_type": "display_data" 58 | } 59 | ], 60 | "source": [ 61 | "# add checkbox\n", 62 | "my_flag = mr.Checkbox(value=True, label=\"Switch me\", url_key=\"flag\")" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 4, 68 | "id": "d751ba3d", 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "Checkbox is ON\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "# read checkbox value\n", 81 | "if my_flag.value:\n", 82 | " print(\"Checkbox is ON\")\n", 83 | "else:\n", 84 | " print(\"Checkbox is OFF\")" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "id": "3cd671ad", 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [] 94 | } 95 | ], 96 | "metadata": { 97 | "kernelspec": { 98 | "display_name": "mex", 99 | "language": "python", 100 | "name": "mex" 101 | }, 102 | "language_info": { 103 | "codemirror_mode": { 104 | "name": "ipython", 105 | "version": 3 106 | }, 107 | "file_extension": ".py", 108 | "mimetype": "text/x-python", 109 | "name": "python", 110 | "nbconvert_exporter": "python", 111 | "pygments_lexer": "ipython3", 112 | "version": "3.8.10" 113 | } 114 | }, 115 | "nbformat": 4, 116 | "nbformat_minor": 5 117 | } 118 | -------------------------------------------------------------------------------- /docs-examples/file.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "4f6db62e", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "bf73b3c8", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"File\",\n \"description\": \"Show File widget usage\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.2-randeccaa7dc\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "# setup app properies\n", 35 | "app = mr.App(title=\"File\", description=\"Show File widget usage\", show_code=True)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "id": "4cea8f0b", 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "application/mercury+json": "{\n \"widget\": \"File\",\n \"max_file_size\": \"100MB\",\n \"label\": \"Please upload text file\",\n \"model_id\": \"854d3f05a5474c238724c8724257c1aa\",\n \"code_uid\": \"File.0.40.18.1-randb334d7a0\",\n \"disabled\": false,\n \"hidden\": false\n}", 47 | "application/vnd.jupyter.widget-view+json": { 48 | "model_id": "854d3f05a5474c238724c8724257c1aa", 49 | "version_major": 2, 50 | "version_minor": 0 51 | }, 52 | "text/plain": [ 53 | "mercury.File" 54 | ] 55 | }, 56 | "metadata": {}, 57 | "output_type": "display_data" 58 | } 59 | ], 60 | "source": [ 61 | "uploaded = mr.File(label=\"Please upload text file\")" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 4, 67 | "id": "61f42f53", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "# you can access file name and file path\n", 72 | "if uploaded.filepath:\n", 73 | " print(f\"Uploaded file name: {uploaded.filename}\")\n", 74 | " print(f\"Uploaded file path: {uploaded.filepath}\")" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 5, 80 | "id": "16c03474", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "# you can read file\n", 85 | "if uploaded.filepath:\n", 86 | " with open(uploaded.filepath, \"r\") as fin:\n", 87 | " print(fin.read())" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 6, 93 | "id": "330d5569", 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [ 97 | "# or you can access file content in binary format\n", 98 | "if uploaded.filepath:\n", 99 | " print(uploaded.value)" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": null, 105 | "id": "74d4a626", 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [] 109 | } 110 | ], 111 | "metadata": { 112 | "kernelspec": { 113 | "display_name": "mex", 114 | "language": "python", 115 | "name": "mex" 116 | }, 117 | "language_info": { 118 | "codemirror_mode": { 119 | "name": "ipython", 120 | "version": 3 121 | }, 122 | "file_extension": ".py", 123 | "mimetype": "text/x-python", 124 | "name": "python", 125 | "nbconvert_exporter": "python", 126 | "pygments_lexer": "ipython3", 127 | "version": "3.8.10" 128 | } 129 | }, 130 | "nbformat": 4, 131 | "nbformat_minor": 5 132 | } 133 | -------------------------------------------------------------------------------- /docs-examples/multiselect-simple.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "036eee6a", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "82c5f979", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"MultiSelect\",\n \"value\": [\n \"a\",\n \"b\"\n ],\n \"choices\": [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\"\n ],\n \"label\": \"Please select letters\",\n \"model_id\": \"a2bf60a88cb741d7a41d0589c088cfc8\",\n \"code_uid\": \"MultiSelect.0.40.16.2-rand881edec4\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 22 | "application/vnd.jupyter.widget-view+json": { 23 | "model_id": "a2bf60a88cb741d7a41d0589c088cfc8", 24 | "version_major": 2, 25 | "version_minor": 0 26 | }, 27 | "text/plain": [ 28 | "mercury.MultiSelect" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | } 34 | ], 35 | "source": [ 36 | "# add select widget\n", 37 | "selected = mr.MultiSelect(label=\"Please select letters\", \n", 38 | " value=[\"a\", \"b\"], \n", 39 | " choices=[\"a\", \"b\", \"c\", \"d\", \"e\"])" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 3, 45 | "id": "0cc1cf51", 46 | "metadata": {}, 47 | "outputs": [ 48 | { 49 | "name": "stdout", 50 | "output_type": "stream", 51 | "text": [ 52 | "['a', 'b']\n" 53 | ] 54 | } 55 | ], 56 | "source": [ 57 | "print(selected.value)" 58 | ] 59 | } 60 | ], 61 | "metadata": { 62 | "kernelspec": { 63 | "display_name": "mex", 64 | "language": "python", 65 | "name": "mex" 66 | }, 67 | "language_info": { 68 | "codemirror_mode": { 69 | "name": "ipython", 70 | "version": 3 71 | }, 72 | "file_extension": ".py", 73 | "mimetype": "text/x-python", 74 | "name": "python", 75 | "nbconvert_exporter": "python", 76 | "pygments_lexer": "ipython3", 77 | "version": "3.8.10" 78 | } 79 | }, 80 | "nbformat": 4, 81 | "nbformat_minor": 5 82 | } 83 | -------------------------------------------------------------------------------- /docs-examples/multiselect.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "157994cc", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "f2970759", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"MultiSelect\",\n \"description\": \"Demo of MutiSelect widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand52ff8045\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"MultiSelect\", description=\"Demo of MutiSelect widget\", show_code=True)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "id": "e799cfd3", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "application/mercury+json": "{\n \"widget\": \"MultiSelect\",\n \"value\": [\n \"a\",\n \"b\"\n ],\n \"choices\": [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\"\n ],\n \"label\": \"Please select letters\",\n \"model_id\": \"4bd323cd1655481fbda0eda5adef7a61\",\n \"code_uid\": \"MultiSelect.0.40.16.1-rand84903bec\",\n \"url_key\": \"selected\",\n \"disabled\": false,\n \"hidden\": false\n}", 46 | "application/vnd.jupyter.widget-view+json": { 47 | "model_id": "4bd323cd1655481fbda0eda5adef7a61", 48 | "version_major": 2, 49 | "version_minor": 0 50 | }, 51 | "text/plain": [ 52 | "mercury.MultiSelect" 53 | ] 54 | }, 55 | "metadata": {}, 56 | "output_type": "display_data" 57 | } 58 | ], 59 | "source": [ 60 | "selected = mr.MultiSelect(label=\"Please select letters\", \n", 61 | " value=[\"a\", \"b\"], \n", 62 | " choices=[\"a\", \"b\", \"c\", \"d\", \"e\"],\n", 63 | " url_key=\"selected\")" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "id": "86a9e273", 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "['a', 'b']\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "print(selected.value)" 82 | ] 83 | } 84 | ], 85 | "metadata": { 86 | "kernelspec": { 87 | "display_name": "mex", 88 | "language": "python", 89 | "name": "mex" 90 | }, 91 | "language_info": { 92 | "codemirror_mode": { 93 | "name": "ipython", 94 | "version": 3 95 | }, 96 | "file_extension": ".py", 97 | "mimetype": "text/x-python", 98 | "name": "python", 99 | "nbconvert_exporter": "python", 100 | "pygments_lexer": "ipython3", 101 | "version": "3.8.10" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 5 106 | } 107 | -------------------------------------------------------------------------------- /docs-examples/range.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "0954eef1", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "e49cd34d", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Range\",\n \"description\": \"Range widget demo\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand8e094375\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"Range\", description=\"Range widget demo\", show_code=True)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "id": "412fce10", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "application/mercury+json": "{\n \"widget\": \"Range\",\n \"value\": [\n 1,\n 6\n ],\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite range\",\n \"model_id\": \"c7bb17abbf4b49c4a5b7edf2c971803e\",\n \"code_uid\": \"Range.0.40.30.2-randc2556550\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 46 | "application/vnd.jupyter.widget-view+json": { 47 | "model_id": "c7bb17abbf4b49c4a5b7edf2c971803e", 48 | "version_major": 2, 49 | "version_minor": 0 50 | }, 51 | "text/plain": [ 52 | "mercury.Range" 53 | ] 54 | }, 55 | "metadata": {}, 56 | "output_type": "display_data" 57 | } 58 | ], 59 | "source": [ 60 | "# add range widget\n", 61 | "your_range = mr.Range(value=[1, 6], min=0, max=10, label=\"Your favourite range\", \n", 62 | " step=1, url_key=\"my-range\")" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 4, 68 | "id": "4c3147bc", 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "Your range starts at 1 ends at 6\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "# access widget value in the code\n", 81 | "print(f\"Your range starts at {your_range.value[0]} ends at {your_range.value[1]}\")" 82 | ] 83 | } 84 | ], 85 | "metadata": { 86 | "kernelspec": { 87 | "display_name": "mex", 88 | "language": "python", 89 | "name": "mex" 90 | }, 91 | "language_info": { 92 | "codemirror_mode": { 93 | "name": "ipython", 94 | "version": 3 95 | }, 96 | "file_extension": ".py", 97 | "mimetype": "text/x-python", 98 | "name": "python", 99 | "nbconvert_exporter": "python", 100 | "pygments_lexer": "ipython3", 101 | "version": "3.8.10" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 5 106 | } 107 | -------------------------------------------------------------------------------- /docs-examples/slider-simple.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "b2377049", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "data": { 11 | "application/mercury+json": "{\n \"widget\": \"Slider\",\n \"value\": 5,\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite number\",\n \"model_id\": \"3eb3b56f384f49ab99e8e17cdeb9ba96\",\n \"code_uid\": \"Slider.0.40.26.4-rand8e3693fa\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 12 | "application/vnd.jupyter.widget-view+json": { 13 | "model_id": "3eb3b56f384f49ab99e8e17cdeb9ba96", 14 | "version_major": 2, 15 | "version_minor": 0 16 | }, 17 | "text/plain": [ 18 | "mercury.Slider" 19 | ] 20 | }, 21 | "metadata": {}, 22 | "output_type": "display_data" 23 | }, 24 | { 25 | "name": "stdout", 26 | "output_type": "stream", 27 | "text": [ 28 | "Your value is 5\n" 29 | ] 30 | } 31 | ], 32 | "source": [ 33 | "import mercury as mr\n", 34 | "\n", 35 | "# add range widget\n", 36 | "your_slider = mr.Slider(value=5, min=0, max=10, label=\"Your favourite number\", step=1)\n", 37 | " \n", 38 | "# access widget value in the code\n", 39 | "print(f\"Your value is {your_slider.value}\")" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "id": "910a11c0", 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [] 49 | } 50 | ], 51 | "metadata": { 52 | "kernelspec": { 53 | "display_name": "mex", 54 | "language": "python", 55 | "name": "mex" 56 | }, 57 | "language_info": { 58 | "codemirror_mode": { 59 | "name": "ipython", 60 | "version": 3 61 | }, 62 | "file_extension": ".py", 63 | "mimetype": "text/x-python", 64 | "name": "python", 65 | "nbconvert_exporter": "python", 66 | "pygments_lexer": "ipython3", 67 | "version": "3.8.10" 68 | } 69 | }, 70 | "nbformat": 4, 71 | "nbformat_minor": 5 72 | } 73 | -------------------------------------------------------------------------------- /docs-examples/slider.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "b2377049", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "e2a239f0", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Slider\",\n \"description\": \"Demo of Slider widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand1686cc3b\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"Slider\", description=\"Demo of Slider widget\", show_code=True)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "id": "b71b36bd", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "application/mercury+json": "{\n \"widget\": \"Slider\",\n \"value\": 0,\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite number\",\n \"model_id\": \"e72d431e26ba4b39b0dd87af3f159134\",\n \"code_uid\": \"Slider.0.40.26.2-rand67b7c60c\",\n \"url_key\": \"slider\",\n \"disabled\": false,\n \"hidden\": false\n}", 46 | "application/vnd.jupyter.widget-view+json": { 47 | "model_id": "e72d431e26ba4b39b0dd87af3f159134", 48 | "version_major": 2, 49 | "version_minor": 0 50 | }, 51 | "text/plain": [ 52 | "mercury.Slider" 53 | ] 54 | }, 55 | "metadata": {}, 56 | "output_type": "display_data" 57 | } 58 | ], 59 | "source": [ 60 | "# add widget\n", 61 | "your_slider = mr.Slider(value=0, min=0, max=10, label=\"Your favourite number\", \n", 62 | " step=1, url_key=\"slider\")" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 4, 68 | "id": "13e16734", 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "Your value is 0\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "# access widget value in the code\n", 81 | "print(f\"Your value is {your_slider.value}\")" 82 | ] 83 | } 84 | ], 85 | "metadata": { 86 | "kernelspec": { 87 | "display_name": "mex", 88 | "language": "python", 89 | "name": "mex" 90 | }, 91 | "language_info": { 92 | "codemirror_mode": { 93 | "name": "ipython", 94 | "version": 3 95 | }, 96 | "file_extension": ".py", 97 | "mimetype": "text/x-python", 98 | "name": "python", 99 | "nbconvert_exporter": "python", 100 | "pygments_lexer": "ipython3", 101 | "version": "3.8.10" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 5 106 | } 107 | -------------------------------------------------------------------------------- /docs-examples/text-simple.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "10432ec2", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "data": { 11 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"Piotr\",\n \"rows\": 1,\n \"label\": \"What is your name?\",\n \"model_id\": \"b8fb1013feef47849604c9150321c9fe\",\n \"code_uid\": \"Text.0.40.15.4-rand0254bb78\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 12 | "application/vnd.jupyter.widget-view+json": { 13 | "model_id": "b8fb1013feef47849604c9150321c9fe", 14 | "version_major": 2, 15 | "version_minor": 0 16 | }, 17 | "text/plain": [ 18 | "mercury.Text" 19 | ] 20 | }, 21 | "metadata": {}, 22 | "output_type": "display_data" 23 | } 24 | ], 25 | "source": [ 26 | "import mercury as mr\n", 27 | "\n", 28 | "# add text widget\n", 29 | "your_text = mr.Text(value=\"Piotr\", label=\"What is your name?\", rows=1)\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "id": "50b071b2", 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "Hello Piotr!\n" 43 | ] 44 | } 45 | ], 46 | "source": [ 47 | "# use widget value in the code\n", 48 | "print(f\"Hello {your_text.value}!\")" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "id": "1d524fc1", 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [] 58 | } 59 | ], 60 | "metadata": { 61 | "kernelspec": { 62 | "display_name": "mex", 63 | "language": "python", 64 | "name": "mex" 65 | }, 66 | "language_info": { 67 | "codemirror_mode": { 68 | "name": "ipython", 69 | "version": 3 70 | }, 71 | "file_extension": ".py", 72 | "mimetype": "text/x-python", 73 | "name": "python", 74 | "nbconvert_exporter": "python", 75 | "pygments_lexer": "ipython3", 76 | "version": "3.8.10" 77 | } 78 | }, 79 | "nbformat": 4, 80 | "nbformat_minor": 5 81 | } 82 | -------------------------------------------------------------------------------- /docs-examples/text.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "164f76b7", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "17c4a3fd", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Text\",\n \"description\": \"Demo of Text widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rande67e72ed\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"Text\", description=\"Demo of Text widget\", show_code=True)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "id": "f3c12349", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"Piotr\",\n \"rows\": 1,\n \"label\": \"What is your name?\",\n \"model_id\": \"9dc1a4398f7a4b96abb2077f790c4f47\",\n \"code_uid\": \"Text.0.40.15.1-rande827c6e5\",\n \"url_key\": \"name\",\n \"disabled\": false,\n \"hidden\": false\n}", 46 | "application/vnd.jupyter.widget-view+json": { 47 | "model_id": "9dc1a4398f7a4b96abb2077f790c4f47", 48 | "version_major": 2, 49 | "version_minor": 0 50 | }, 51 | "text/plain": [ 52 | "mercury.Text" 53 | ] 54 | }, 55 | "metadata": {}, 56 | "output_type": "display_data" 57 | } 58 | ], 59 | "source": [ 60 | "name = mr.Text(value=\"Piotr\", label=\"What is your name?\", rows=1, url_key=\"name\")" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 4, 66 | "id": "6dadd338", 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "name": "stdout", 71 | "output_type": "stream", 72 | "text": [ 73 | "Hello Piotr!\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "print(f\"Hello {name.value}!\")" 79 | ] 80 | } 81 | ], 82 | "metadata": { 83 | "kernelspec": { 84 | "display_name": "mex", 85 | "language": "python", 86 | "name": "mex" 87 | }, 88 | "language_info": { 89 | "codemirror_mode": { 90 | "name": "ipython", 91 | "version": 3 92 | }, 93 | "file_extension": ".py", 94 | "mimetype": "text/x-python", 95 | "name": "python", 96 | "nbconvert_exporter": "python", 97 | "pygments_lexer": "ipython3", 98 | "version": "3.8.10" 99 | } 100 | }, 101 | "nbformat": 4, 102 | "nbformat_minor": 5 103 | } 104 | -------------------------------------------------------------------------------- /dynamic-widgets.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "316b5c70", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "bf1a7848", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "letters = [\"small\", \"capital\"]\n", 21 | "example_letters = {\n", 22 | " \"small\": [\"a\", \"b\", \"c\", \"d\"],\n", 23 | " \"capital\": [\"A\", \"B\", \"C\", \"D\"]\n", 24 | "}" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 3, 30 | "id": "0249060f", 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "data": { 35 | "application/mercury+json": "{\n \"widget\": \"Select\",\n \"value\": \"small\",\n \"choices\": [\n \"small\",\n \"capital\"\n ],\n \"label\": \"Small or capital?\",\n \"model_id\": \"54216051432440b3803141d78d605359\",\n \"code_uid\": \"Select.0.41.14.1-rand5107087a\"\n}", 36 | "application/vnd.jupyter.widget-view+json": { 37 | "model_id": "54216051432440b3803141d78d605359", 38 | "version_major": 2, 39 | "version_minor": 0 40 | }, 41 | "text/plain": [ 42 | "mercury.Select" 43 | ] 44 | }, 45 | "metadata": {}, 46 | "output_type": "display_data" 47 | } 48 | ], 49 | "source": [ 50 | "size = mr.Select(value=\"small\", choices=letters, label=\"Small or capital?\")" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 4, 56 | "id": "08a45795", 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "data": { 61 | "application/mercury+json": "{\n \"widget\": \"Select\",\n \"value\": \"a\",\n \"choices\": [\n \"a\",\n \"b\",\n \"c\",\n \"d\"\n ],\n \"label\": \"Select letter\",\n \"model_id\": \"5007bca0fb874fecb26ff2d91d53be0e\",\n \"code_uid\": \"Select.0.41.14.1-randefdb07c6\"\n}", 62 | "application/vnd.jupyter.widget-view+json": { 63 | "model_id": "5007bca0fb874fecb26ff2d91d53be0e", 64 | "version_major": 2, 65 | "version_minor": 0 66 | }, 67 | "text/plain": [ 68 | "mercury.Select" 69 | ] 70 | }, 71 | "metadata": {}, 72 | "output_type": "display_data" 73 | } 74 | ], 75 | "source": [ 76 | "example = mr.Select(value=example_letters[size.value][0], \n", 77 | " choices=example_letters[size.value], \n", 78 | " label=\"Select letter\")" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 5, 84 | "id": "562d2b60", 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "Example small letter is a\n" 92 | ] 93 | } 94 | ], 95 | "source": [ 96 | "print(f\"Example {size.value} letter is {example.value}\")" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": null, 102 | "id": "e3c2e85e", 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [] 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "mex", 111 | "language": "python", 112 | "name": "mex" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.8.10" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } 130 | -------------------------------------------------------------------------------- /file-upload.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "a1d7a65c", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "af978f18", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"File\",\n \"max_file_size\": \"10MB\",\n \"label\": \"File upload\",\n \"model_id\": \"1a7f099c94d84abb81e070b07fd65dd2\",\n \"code_uid\": \"File.0.41.14.1-rand3efb48c0\"\n}", 22 | "application/vnd.jupyter.widget-view+json": { 23 | "model_id": "1a7f099c94d84abb81e070b07fd65dd2", 24 | "version_major": 2, 25 | "version_minor": 0 26 | }, 27 | "text/plain": [ 28 | "mercury.File" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | } 34 | ], 35 | "source": [ 36 | "file = mr.File(label=\"File upload\", max_file_size=\"10MB\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 3, 42 | "id": "c6d901ea", 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "Uploaded file name: None\n" 50 | ] 51 | } 52 | ], 53 | "source": [ 54 | "print(f\"Uploaded file name: {file.filename}\")" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 4, 60 | "id": "78419aff", 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "Uploaded file path: None\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "print(f\"Uploaded file path: {file.filepath}\")" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 5, 78 | "id": "92d8f42b", 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [ 82 | "if file.filepath is not None:\n", 83 | " with open(file.filepath, \"r\") as fin:\n", 84 | " print(fin.read())" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "id": "f315b8a8", 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [] 94 | } 95 | ], 96 | "metadata": { 97 | "kernelspec": { 98 | "display_name": "mex", 99 | "language": "python", 100 | "name": "mex" 101 | }, 102 | "language_info": { 103 | "codemirror_mode": { 104 | "name": "ipython", 105 | "version": 3 106 | }, 107 | "file_extension": ".py", 108 | "mimetype": "text/x-python", 109 | "name": "python", 110 | "nbconvert_exporter": "python", 111 | "pygments_lexer": "ipython3", 112 | "version": "3.8.10" 113 | } 114 | }, 115 | "nbformat": 4, 116 | "nbformat_minor": 5 117 | } 118 | -------------------------------------------------------------------------------- /hello-world.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "510021ae", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "99e3dc7f", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"Piotr\",\n \"rows\": 1,\n \"label\": \"What is your name?\",\n \"model_id\": \"a6986d70a175454cb6640e4f6c5c1d6a\",\n \"code_uid\": \"Text.0.32.13.1\"\n}", 22 | "application/vnd.jupyter.widget-view+json": { 23 | "model_id": "a6986d70a175454cb6640e4f6c5c1d6a", 24 | "version_major": 2, 25 | "version_minor": 0 26 | }, 27 | "text/plain": [ 28 | "mercury.Text" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | } 34 | ], 35 | "source": [ 36 | "name = mr.Text(value=\"Piotr\", label=\"What is your name?\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 3, 42 | "id": "5d1e69d6", 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "Hello Piotr!\n" 50 | ] 51 | } 52 | ], 53 | "source": [ 54 | "print(f\"Hello {name.value}!\")" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "id": "d2a2d42e", 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [] 64 | } 65 | ], 66 | "metadata": { 67 | "kernelspec": { 68 | "display_name": "mex", 69 | "language": "python", 70 | "name": "mex" 71 | }, 72 | "language_info": { 73 | "codemirror_mode": { 74 | "name": "ipython", 75 | "version": 3 76 | }, 77 | "file_extension": ".py", 78 | "mimetype": "text/x-python", 79 | "name": "python", 80 | "nbconvert_exporter": "python", 81 | "pygments_lexer": "ipython3", 82 | "version": "3.8.10" 83 | } 84 | }, 85 | "nbformat": 4, 86 | "nbformat_minor": 5 87 | } 88 | -------------------------------------------------------------------------------- /incement-decrement.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "f3d78b93", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "f482cc0f", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "some_value = 0" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "id": "655fe8a5", 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "data": { 31 | "application/mercury+json": "{\n \"widget\": \"Button\",\n \"label\": \"Increment\",\n \"style\": \"success\",\n \"value\": false,\n \"model_id\": \"edea3d65a8f14df1aa6844775513c8b4\",\n \"code_uid\": \"Button.0.41.12.1-rand6479cf74\"\n}", 32 | "application/vnd.jupyter.widget-view+json": { 33 | "model_id": "edea3d65a8f14df1aa6844775513c8b4", 34 | "version_major": 2, 35 | "version_minor": 0 36 | }, 37 | "text/plain": [ 38 | "mercury.Button" 39 | ] 40 | }, 41 | "metadata": {}, 42 | "output_type": "display_data" 43 | } 44 | ], 45 | "source": [ 46 | "increment = mr.Button(label=\"Increment\", style=\"success\")" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 4, 52 | "id": "dd34e9a2", 53 | "metadata": {}, 54 | "outputs": [ 55 | { 56 | "data": { 57 | "application/mercury+json": "{\n \"widget\": \"Button\",\n \"label\": \"Decrement\",\n \"style\": \"danger\",\n \"value\": false,\n \"model_id\": \"e66f50dc75d1441eb3754471c7710474\",\n \"code_uid\": \"Button.0.41.12.1-rand05d0d87d\"\n}", 58 | "application/vnd.jupyter.widget-view+json": { 59 | "model_id": "e66f50dc75d1441eb3754471c7710474", 60 | "version_major": 2, 61 | "version_minor": 0 62 | }, 63 | "text/plain": [ 64 | "mercury.Button" 65 | ] 66 | }, 67 | "metadata": {}, 68 | "output_type": "display_data" 69 | } 70 | ], 71 | "source": [ 72 | "decrement = mr.Button(label=\"Decrement\", style=\"danger\")" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 5, 78 | "id": "b5b712de", 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [ 82 | "if increment.clicked:\n", 83 | " some_value += 1\n", 84 | " \n", 85 | "if decrement.clicked:\n", 86 | " some_value -= 1" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 6, 92 | "id": "16f35450", 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "name": "stdout", 97 | "output_type": "stream", 98 | "text": [ 99 | "Value is 0\n" 100 | ] 101 | } 102 | ], 103 | "source": [ 104 | "print(f\"Value is {some_value}\")" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "id": "912b2f76", 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [] 114 | } 115 | ], 116 | "metadata": { 117 | "kernelspec": { 118 | "display_name": "mex", 119 | "language": "python", 120 | "name": "mex" 121 | }, 122 | "language_info": { 123 | "codemirror_mode": { 124 | "name": "ipython", 125 | "version": 3 126 | }, 127 | "file_extension": ".py", 128 | "mimetype": "text/x-python", 129 | "name": "python", 130 | "nbconvert_exporter": "python", 131 | "pygments_lexer": "ipython3", 132 | "version": "3.8.10" 133 | } 134 | }, 135 | "nbformat": 4, 136 | "nbformat_minor": 5 137 | } 138 | -------------------------------------------------------------------------------- /issues/web/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'jekyll', '4.3.1' 4 | 5 | group :jekyll_plugins do 6 | gem 'jekyll-archives', '2.2.1' 7 | gem 'jekyll-feed', '0.15.1' 8 | gem 'jekyll-paginate', '1.1.0' 9 | gem 'jekyll-seo-tag', '2.7.1' 10 | gem 'jekyll-sitemap', '1.4.0' 11 | end 12 | 13 | gem "kramdown", "~> 2.3" 14 | 15 | gem "rouge", "~> 3.28" 16 | 17 | gem "ffi", "~> 1.14.2 " 18 | 19 | gem "tzinfo" 20 | 21 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] 22 | 23 | gem 'wdm', ">= 0.1.0" 24 | -------------------------------------------------------------------------------- /issues/web/README.md: -------------------------------------------------------------------------------- 1 | Gemfile is compatible with Ruby 3.1 or older. Removing all license files allows JEKYLL to run properly. 2 | 3 | [tested on Windows] 4 | -------------------------------------------------------------------------------- /load-large-dataset.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import pandas as pd\n", 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "df = pd.read_csv(\"https://raw.githubusercontent.com/pplonski/datasets-for-start/master/adult/data.csv\")" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 3, 25 | "metadata": {}, 26 | "outputs": [ 27 | { 28 | "data": { 29 | "application/mercury+json": "{\n \"widget\": \"Slider\",\n \"value\": 10,\n \"min\": 1,\n \"max\": 20,\n \"step\": 1,\n \"label\": \"Samples\",\n \"model_id\": \"44aa8ec3c0394e10a2040250ed2631bc\",\n \"code_uid\": \"Slider.0.41.16.1-rand7f1e68dc\"\n}", 30 | "application/vnd.jupyter.widget-view+json": { 31 | "model_id": "44aa8ec3c0394e10a2040250ed2631bc", 32 | "version_major": 2, 33 | "version_minor": 0 34 | }, 35 | "text/plain": [ 36 | "mercury.Slider" 37 | ] 38 | }, 39 | "metadata": {}, 40 | "output_type": "display_data" 41 | } 42 | ], 43 | "source": [ 44 | "samples = mr.Slider(value=10, label=\"Samples\", min=1, max=20)" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "data": { 54 | "text/html": [ 55 | "
\n", 56 | "\n", 69 | "\n", 70 | " \n", 71 | " \n", 72 | " \n", 73 | " \n", 74 | " \n", 75 | " \n", 76 | " \n", 77 | " \n", 78 | " \n", 79 | " \n", 80 | " \n", 81 | " \n", 82 | " \n", 83 | " \n", 84 | " \n", 85 | " \n", 86 | " \n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | "
ageworkclassfnlwgteducationeducation-nummarital-statusoccupationrelationshipracesexcapital-gaincapital-losshours-per-weeknative-countryincome
039State-gov77516Bachelors13Never-marriedAdm-clericalNot-in-familyWhiteMale2174040United-States<=50K
150Self-emp-not-inc83311Bachelors13Married-civ-spouseExec-managerialHusbandWhiteMale0013United-States<=50K
238Private215646HS-grad9DivorcedHandlers-cleanersNot-in-familyWhiteMale0040United-States<=50K
353Private23472111th7Married-civ-spouseHandlers-cleanersHusbandBlackMale0040United-States<=50K
428Private338409Bachelors13Married-civ-spouseProf-specialtyWifeBlackFemale0040Cuba<=50K
537Private284582Masters14Married-civ-spouseExec-managerialWifeWhiteFemale0040United-States<=50K
649Private1601879th5Married-spouse-absentOther-serviceNot-in-familyBlackFemale0016Jamaica<=50K
752Self-emp-not-inc209642HS-grad9Married-civ-spouseExec-managerialHusbandWhiteMale0045United-States>50K
831Private45781Masters14Never-marriedProf-specialtyNot-in-familyWhiteFemale14084050United-States>50K
942Private159449Bachelors13Married-civ-spouseExec-managerialHusbandWhiteMale5178040United-States>50K
\n", 273 | "
" 274 | ], 275 | "text/plain": [ 276 | " age workclass fnlwgt education education-num \\\n", 277 | "0 39 State-gov 77516 Bachelors 13 \n", 278 | "1 50 Self-emp-not-inc 83311 Bachelors 13 \n", 279 | "2 38 Private 215646 HS-grad 9 \n", 280 | "3 53 Private 234721 11th 7 \n", 281 | "4 28 Private 338409 Bachelors 13 \n", 282 | "5 37 Private 284582 Masters 14 \n", 283 | "6 49 Private 160187 9th 5 \n", 284 | "7 52 Self-emp-not-inc 209642 HS-grad 9 \n", 285 | "8 31 Private 45781 Masters 14 \n", 286 | "9 42 Private 159449 Bachelors 13 \n", 287 | "\n", 288 | " marital-status occupation relationship race \\\n", 289 | "0 Never-married Adm-clerical Not-in-family White \n", 290 | "1 Married-civ-spouse Exec-managerial Husband White \n", 291 | "2 Divorced Handlers-cleaners Not-in-family White \n", 292 | "3 Married-civ-spouse Handlers-cleaners Husband Black \n", 293 | "4 Married-civ-spouse Prof-specialty Wife Black \n", 294 | "5 Married-civ-spouse Exec-managerial Wife White \n", 295 | "6 Married-spouse-absent Other-service Not-in-family Black \n", 296 | "7 Married-civ-spouse Exec-managerial Husband White \n", 297 | "8 Never-married Prof-specialty Not-in-family White \n", 298 | "9 Married-civ-spouse Exec-managerial Husband White \n", 299 | "\n", 300 | " sex capital-gain capital-loss hours-per-week native-country \\\n", 301 | "0 Male 2174 0 40 United-States \n", 302 | "1 Male 0 0 13 United-States \n", 303 | "2 Male 0 0 40 United-States \n", 304 | "3 Male 0 0 40 United-States \n", 305 | "4 Female 0 0 40 Cuba \n", 306 | "5 Female 0 0 40 United-States \n", 307 | "6 Female 0 0 16 Jamaica \n", 308 | "7 Male 0 0 45 United-States \n", 309 | "8 Female 14084 0 50 United-States \n", 310 | "9 Male 5178 0 40 United-States \n", 311 | "\n", 312 | " income \n", 313 | "0 <=50K \n", 314 | "1 <=50K \n", 315 | "2 <=50K \n", 316 | "3 <=50K \n", 317 | "4 <=50K \n", 318 | "5 <=50K \n", 319 | "6 <=50K \n", 320 | "7 >50K \n", 321 | "8 >50K \n", 322 | "9 >50K " 323 | ] 324 | }, 325 | "execution_count": 4, 326 | "metadata": {}, 327 | "output_type": "execute_result" 328 | } 329 | ], 330 | "source": [ 331 | "df.head(samples.value)" 332 | ] 333 | }, 334 | { 335 | "cell_type": "code", 336 | "execution_count": null, 337 | "metadata": {}, 338 | "outputs": [], 339 | "source": [] 340 | } 341 | ], 342 | "metadata": { 343 | "kernelspec": { 344 | "display_name": "mex", 345 | "language": "python", 346 | "name": "mex" 347 | }, 348 | "language_info": { 349 | "codemirror_mode": { 350 | "name": "ipython", 351 | "version": 3 352 | }, 353 | "file_extension": ".py", 354 | "mimetype": "text/x-python", 355 | "name": "python", 356 | "nbconvert_exporter": "python", 357 | "pygments_lexer": "ipython3", 358 | "version": "3.8.0" 359 | } 360 | }, 361 | "nbformat": 4, 362 | "nbformat_minor": 2 363 | } 364 | -------------------------------------------------------------------------------- /load-on-click.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import pandas as pd\n", 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "metadata": {}, 17 | "outputs": [ 18 | { 19 | "data": { 20 | "application/mercury+json": "{\n \"widget\": \"Button\",\n \"label\": \"Load data\",\n \"style\": \"primary\",\n \"value\": false,\n \"model_id\": \"2a5d6ef979e04dc1922972eee3bfbad4\",\n \"code_uid\": \"Button.0.41.12.1-rand381184d7\"\n}", 21 | "application/vnd.jupyter.widget-view+json": { 22 | "model_id": "2a5d6ef979e04dc1922972eee3bfbad4", 23 | "version_major": 2, 24 | "version_minor": 0 25 | }, 26 | "text/plain": [ 27 | "mercury.Button" 28 | ] 29 | }, 30 | "metadata": {}, 31 | "output_type": "display_data" 32 | } 33 | ], 34 | "source": [ 35 | "load = mr.Button(label=\"Load data\")" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "df = None" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "if load.clicked:\n", 54 | " df = pd.read_csv(\"https://raw.githubusercontent.com/pplonski/datasets-for-start/master/adult/data.csv\")" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 5, 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Data not loaded\n" 67 | ] 68 | } 69 | ], 70 | "source": [ 71 | "df.head() if df is not None else print(\"Data not loaded\")" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [] 80 | } 81 | ], 82 | "metadata": { 83 | "kernelspec": { 84 | "display_name": "mex", 85 | "language": "python", 86 | "name": "mex" 87 | }, 88 | "language_info": { 89 | "codemirror_mode": { 90 | "name": "ipython", 91 | "version": 3 92 | }, 93 | "file_extension": ".py", 94 | "mimetype": "text/x-python", 95 | "name": "python", 96 | "nbconvert_exporter": "python", 97 | "pygments_lexer": "ipython3", 98 | "version": "3.8.0" 99 | } 100 | }, 101 | "nbformat": 4, 102 | "nbformat_minor": 2 103 | } 104 | -------------------------------------------------------------------------------- /numberbox-example.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "77832a38", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "b485845d", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "text/html": [ 22 | "
\n", 34 | "
\n", 35 | " 123\n", 36 | " \n", 37 | " +100%\n", 38 | " \n", 39 | " First number\n", 40 | "
\n", 41 | " \n", 42 | "
\n", 43 | " 456\n", 44 | " \n", 45 | " -50.1%\n", 46 | " \n", 47 | " Second number\n", 48 | "
\n", 49 | " \n", 50 | "
\n", 51 | " 🎉\n", 52 | " \n", 53 | " Third number\n", 54 | "
\n", 55 | "
" 56 | ], 57 | "text/plain": [ 58 | "" 59 | ] 60 | }, 61 | "execution_count": 2, 62 | "metadata": {}, 63 | "output_type": "execute_result" 64 | } 65 | ], 66 | "source": [ 67 | "mr.NumberBox([\n", 68 | " mr.NumberBox(data=123, title=\"First number\", percent_change=100),\n", 69 | " mr.NumberBox(data=456, title=\"Second number\", percent_change=-50.1),\n", 70 | " mr.NumberBox(data=\"🎉\", title=\"Third number\")\n", 71 | "])" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 3, 77 | "id": "75be6041", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "data": { 82 | "text/html": [ 83 | "
\n", 95 | "
\n", 96 | " 123\n", 97 | " \n", 98 | " +100%\n", 99 | " \n", 100 | " First number\n", 101 | "
\n", 102 | " \n", 103 | "
\n", 104 | " 456\n", 105 | " \n", 106 | " -50.1%\n", 107 | " \n", 108 | " Second number\n", 109 | "
\n", 110 | " \n", 111 | "
\n", 112 | " 🎉\n", 113 | " \n", 114 | " Third number\n", 115 | "
\n", 116 | "
" 117 | ], 118 | "text/plain": [ 119 | "" 120 | ] 121 | }, 122 | "execution_count": 3, 123 | "metadata": {}, 124 | "output_type": "execute_result" 125 | } 126 | ], 127 | "source": [ 128 | "colors = [\"#EA047E\", \"#FF6D28\", \"#FCE700\", \"#00F5FF\"]\n", 129 | "colors2 = [\"#FFB84C\", \"#F266AB\", \"#A459D1\", \"#2CD3E1\"]\n", 130 | "colors3 = [\"#2192FF\", \"#38E54D\", \"#9CFF2E\", \"#FDFF00\"]\n", 131 | "mr.NumberBox([\n", 132 | " mr.NumberBox(data=123, title=\"First number\", percent_change=100,\n", 133 | " background_color=colors[0], border_color=colors[1], \n", 134 | " data_color=colors[2], title_color=colors[3]),\n", 135 | " mr.NumberBox(data=456, title=\"Second number\", percent_change=-50.1,\n", 136 | " background_color=colors2[0], border_color=colors2[1], \n", 137 | " data_color=colors2[2], title_color=colors2[3]),\n", 138 | " mr.NumberBox(data=\"🎉\", title=\"Third number\",\n", 139 | " background_color=colors3[0], border_color=colors3[1], \n", 140 | " data_color=colors3[2], title_color=colors3[3])\n", 141 | "])" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "id": "f0cd5b0e", 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [] 151 | } 152 | ], 153 | "metadata": { 154 | "kernelspec": { 155 | "display_name": "menv", 156 | "language": "python", 157 | "name": "menv" 158 | }, 159 | "language_info": { 160 | "codemirror_mode": { 161 | "name": "ipython", 162 | "version": 3 163 | }, 164 | "file_extension": ".py", 165 | "mimetype": "text/x-python", 166 | "name": "python", 167 | "nbconvert_exporter": "python", 168 | "pygments_lexer": "ipython3", 169 | "version": "3.8.10" 170 | } 171 | }, 172 | "nbformat": 4, 173 | "nbformat_minor": 5 174 | } 175 | -------------------------------------------------------------------------------- /numberbox.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "b32293f2", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "12aa5a35", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "text/html": [ 22 | "\n", 23 | "
\n", 24 | " 123\n", 25 | " \n", 26 | " Large number\n", 27 | "
\n", 28 | " " 29 | ], 30 | "text/plain": [ 31 | "" 32 | ] 33 | }, 34 | "execution_count": 2, 35 | "metadata": {}, 36 | "output_type": "execute_result" 37 | } 38 | ], 39 | "source": [ 40 | "mr.NumberBox(data=123, title=\"Large number\")" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 3, 46 | "id": "fe8af13e", 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/html": [ 52 | "
\n", 64 | "
\n", 65 | " 123\n", 66 | " \n", 67 | " First number\n", 68 | "
\n", 69 | " \n", 70 | "
\n", 71 | " 456\n", 72 | " \n", 73 | " Second number\n", 74 | "
\n", 75 | " \n", 76 | "
\n", 77 | " 789\n", 78 | " \n", 79 | " Third number\n", 80 | "
\n", 81 | "
" 82 | ], 83 | "text/plain": [ 84 | "" 85 | ] 86 | }, 87 | "execution_count": 3, 88 | "metadata": {}, 89 | "output_type": "execute_result" 90 | } 91 | ], 92 | "source": [ 93 | "mr.NumberBox([\n", 94 | " mr.NumberBox(data=123, title=\"First number\"),\n", 95 | " mr.NumberBox(data=456, title=\"Second number\"),\n", 96 | " mr.NumberBox(data=789, title=\"Third number\")\n", 97 | "])" 98 | ] 99 | } 100 | ], 101 | "metadata": { 102 | "kernelspec": { 103 | "display_name": "menv", 104 | "language": "python", 105 | "name": "menv" 106 | }, 107 | "language_info": { 108 | "codemirror_mode": { 109 | "name": "ipython", 110 | "version": 3 111 | }, 112 | "file_extension": ".py", 113 | "mimetype": "text/x-python", 114 | "name": "python", 115 | "nbconvert_exporter": "python", 116 | "pygments_lexer": "ipython3", 117 | "version": "3.8.10" 118 | } 119 | }, 120 | "nbformat": 4, 121 | "nbformat_minor": 5 122 | } 123 | -------------------------------------------------------------------------------- /outputdir.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "6cf96c09", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import os\n", 11 | "import mercury as mr" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 2, 17 | "id": "205ae03c", 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"OutputDir\",\n \"description\": \"App with OutputDir\",\n \"show_code\": false,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand7d8042f3\"\n}", 23 | "text/html": [ 24 | "

Mercury Application

This output won't appear in the web app." 25 | ], 26 | "text/plain": [ 27 | "mercury.App" 28 | ] 29 | }, 30 | "metadata": {}, 31 | "output_type": "display_data" 32 | } 33 | ], 34 | "source": [ 35 | "app = mr.App(title=\"OutputDir\", description=\"App with OutputDir\")" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "id": "6754c631", 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "application/mercury+json": "{\n \"widget\": \"OutputDir\",\n \"model_id\": \"output-dir\",\n \"code_uid\": \"OutputDir.0.40.18.2-rand4d44f94b\"\n}", 47 | "text/html": [ 48 | "

Output Directory

This output won't appear in the web app." 49 | ], 50 | "text/plain": [ 51 | "mercury.OutputDir" 52 | ] 53 | }, 54 | "metadata": {}, 55 | "output_type": "display_data" 56 | } 57 | ], 58 | "source": [ 59 | "# get output directory widget\n", 60 | "my_dir = mr.OutputDir()" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 4, 66 | "id": "9fd366e9", 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "name": "stdout", 71 | "output_type": "stream", 72 | "text": [ 73 | "All files will be saved to .\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "# print output directory path\n", 79 | "print(f\"All files will be saved to {my_dir.path}\")" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 5, 85 | "id": "e54cb6af", 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "# save example file\n", 90 | "with open(os.path.join(my_dir.path, \"example-file.txt\"), \"w\") as fout:\n", 91 | " fout.write(\"Hello Mercury!\")" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 6, 97 | "id": "6acc29ef", 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "# one more example file\n", 102 | "with open(os.path.join(my_dir.path, \"second-file.txt\"), \"w\") as fout:\n", 103 | " fout.write(\"Hello again!\")" 104 | ] 105 | } 106 | ], 107 | "metadata": { 108 | "kernelspec": { 109 | "display_name": "menv", 110 | "language": "python", 111 | "name": "menv" 112 | }, 113 | "language_info": { 114 | "codemirror_mode": { 115 | "name": "ipython", 116 | "version": 3 117 | }, 118 | "file_extension": ".py", 119 | "mimetype": "text/x-python", 120 | "name": "python", 121 | "nbconvert_exporter": "python", 122 | "pygments_lexer": "ipython3", 123 | "version": "3.9.16" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 5 128 | } 129 | -------------------------------------------------------------------------------- /pivot-table/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pivot-table/README.md: -------------------------------------------------------------------------------- 1 | # Pivot Table 2 | 3 | Docs: https://runmercury.com/examples/pivot-table-jupyter-notebook/ 4 | -------------------------------------------------------------------------------- /pivot-table/pivot-table.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "56186c66", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import pandas as pd\n", 11 | "import mercury as mr\n", 12 | "from pivottablejs import pivot_ui" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "0bed8c85", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "app = mr.App(title=\"Pivot table\", \n", 23 | " description=\"Do pivot table on any CSV file\")" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "id": "a8753e0b", 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "my_file = mr.File(label=\"Upload CSV file\")" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "id": "b0fcea34", 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "if my_file.filepath is None:\n", 44 | " mr.Markdown(\"Please upload CSV file\")\n", 45 | " mr.Stop()" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "id": "a6c23ef7", 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "# load CSV data\n", 56 | "df = pd.read_csv(my_file.filepath)" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "id": "8c9aa19c", 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "# display pivot table \n", 67 | "pivot_ui(df, height=\"800px\")" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "id": "4daedfa1", 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "id": "30f131a0", 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [] 85 | } 86 | ], 87 | "metadata": { 88 | "kernelspec": { 89 | "display_name": "demo_env", 90 | "language": "python", 91 | "name": "demo_env" 92 | }, 93 | "language_info": { 94 | "codemirror_mode": { 95 | "name": "ipython", 96 | "version": 3 97 | }, 98 | "file_extension": ".py", 99 | "mimetype": "text/x-python", 100 | "name": "python", 101 | "nbconvert_exporter": "python", 102 | "pygments_lexer": "ipython3", 103 | "version": "3.8.10" 104 | } 105 | }, 106 | "nbformat": 4, 107 | "nbformat_minor": 5 108 | } 109 | -------------------------------------------------------------------------------- /pivot-table/requirements.txt: -------------------------------------------------------------------------------- 1 | mercury 2 | pandas 3 | pivottablejs 4 | -------------------------------------------------------------------------------- /pydeck/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pydeck/README.md: -------------------------------------------------------------------------------- 1 | # PyDeck in Jupyter and Mercury 2 | 3 | Docs: https://runmercury.com/examples/pydeck-jupyter-notebook/ 4 | -------------------------------------------------------------------------------- /pydeck/pydeck.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "14ace14b", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import pydeck as pdk\n", 11 | "import pandas as pd\n", 12 | "import mercury as mr\n" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 2, 18 | "id": "be470834", 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "application/mercury+json": "{\n \"widget\": \"Select\",\n \"value\": \"ArcLayer\",\n \"choices\": [\n \"ArcLayer\",\n \"GeoJsonLayer\",\n \"HexagonLayer\"\n ],\n \"label\": \"Select demo\",\n \"model_id\": \"9010e8d34e57406c95c44c8556d691e1\",\n \"code_uid\": \"Select.0.40.16.1-randc17188ab\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 24 | "application/vnd.jupyter.widget-view+json": { 25 | "model_id": "9010e8d34e57406c95c44c8556d691e1", 26 | "version_major": 2, 27 | "version_minor": 0 28 | }, 29 | "text/plain": [ 30 | "mercury.Select" 31 | ] 32 | }, 33 | "metadata": {}, 34 | "output_type": "display_data" 35 | } 36 | ], 37 | "source": [ 38 | "demo = mr.Select(label=\"Select demo\", choices=[\"ArcLayer\", \"GeoJsonLayer\", \"HexagonLayer\"])" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 3, 44 | "id": "160d2d0d", 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "if demo.value == \"ArcLayer\":\n", 49 | "\n", 50 | " DATA_URL = \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\"\n", 51 | " LAND_COVER = [[[-123.0, 49.196], [-123.0, 49.324], [-123.306, 49.324], [-123.306, 49.196]]]\n", 52 | "\n", 53 | " INITIAL_VIEW_STATE = pdk.ViewState(latitude=49.254, longitude=-123.13, zoom=11, max_zoom=16, pitch=45, bearing=0)\n", 54 | "\n", 55 | " polygon = pdk.Layer(\n", 56 | " \"PolygonLayer\",\n", 57 | " LAND_COVER,\n", 58 | " stroked=False,\n", 59 | " # processes the data as a flat longitude-latitude pair\n", 60 | " get_polygon=\"-\",\n", 61 | " get_fill_color=[0, 0, 0, 20],\n", 62 | " )\n", 63 | "\n", 64 | " geojson = pdk.Layer(\n", 65 | " \"GeoJsonLayer\",\n", 66 | " DATA_URL,\n", 67 | " opacity=0.8,\n", 68 | " stroked=False,\n", 69 | " filled=True,\n", 70 | " extruded=True,\n", 71 | " wireframe=True,\n", 72 | " get_elevation=\"properties.valuePerSqm / 20\",\n", 73 | " get_fill_color=\"[255, 255, properties.growth * 255]\",\n", 74 | " get_line_color=[255, 255, 255],\n", 75 | " )\n", 76 | "\n", 77 | " r = pdk.Deck(layers=[polygon, geojson], initial_view_state=INITIAL_VIEW_STATE)\n" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 4, 83 | "id": "c6d632e8", 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "if demo.value == \"GeoJsonLayer\":\n", 88 | " DATA_URL = \"https://raw.githubusercontent.com/ajduberstein/sf_public_data/master/bay_area_commute_routes.csv\"\n", 89 | " # A bounding box for downtown San Francisco, to help filter this commuter data\n", 90 | " DOWNTOWN_BOUNDING_BOX = [\n", 91 | " -122.43135291617365,\n", 92 | " 37.766492914983864,\n", 93 | " -122.38706428091974,\n", 94 | " 37.80583561830737,\n", 95 | " ]\n", 96 | "\n", 97 | "\n", 98 | " def in_bounding_box(point):\n", 99 | " \"\"\"Determine whether a point is in our downtown bounding box\"\"\"\n", 100 | " lng, lat = point\n", 101 | " in_lng_bounds = DOWNTOWN_BOUNDING_BOX[0] <= lng <= DOWNTOWN_BOUNDING_BOX[2]\n", 102 | " in_lat_bounds = DOWNTOWN_BOUNDING_BOX[1] <= lat <= DOWNTOWN_BOUNDING_BOX[3]\n", 103 | " return in_lng_bounds and in_lat_bounds\n", 104 | "\n", 105 | "\n", 106 | " df = pd.read_csv(DATA_URL)\n", 107 | " # Filter to bounding box\n", 108 | " df = df[df[[\"lng_w\", \"lat_w\"]].apply(lambda row: in_bounding_box(row), axis=1)]\n", 109 | "\n", 110 | " GREEN_RGB = [0, 255, 0, 40]\n", 111 | " RED_RGB = [240, 100, 0, 40]\n", 112 | "\n", 113 | " # Specify a deck.gl ArcLayer\n", 114 | " arc_layer = pdk.Layer(\n", 115 | " \"ArcLayer\",\n", 116 | " data=df,\n", 117 | " get_width=\"S000 * 2\",\n", 118 | " get_source_position=[\"lng_h\", \"lat_h\"],\n", 119 | " get_target_position=[\"lng_w\", \"lat_w\"],\n", 120 | " get_tilt=15,\n", 121 | " get_source_color=RED_RGB,\n", 122 | " get_target_color=GREEN_RGB,\n", 123 | " pickable=True,\n", 124 | " auto_highlight=True,\n", 125 | " )\n", 126 | "\n", 127 | " view_state = pdk.ViewState(\n", 128 | " latitude=37.7576171,\n", 129 | " longitude=-122.5776844,\n", 130 | " bearing=45,\n", 131 | " pitch=50,\n", 132 | " zoom=8,\n", 133 | " )\n", 134 | "\n", 135 | "\n", 136 | " TOOLTIP_TEXT = {\"html\": \"{S000} jobs
Home of commuter in red; work location in green\"}\n", 137 | " r = pdk.Deck(arc_layer, initial_view_state=view_state, tooltip=TOOLTIP_TEXT)" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 5, 143 | "id": "b64b9701", 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "if demo.value == \"HexagonLayer\":\n", 148 | " HEXAGON_LAYER_DATA = (\n", 149 | " \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv\" # noqa\n", 150 | " )\n", 151 | "\n", 152 | " # Define a layer to display on a map\n", 153 | " layer = pdk.Layer(\n", 154 | " \"HexagonLayer\",\n", 155 | " HEXAGON_LAYER_DATA,\n", 156 | " get_position=[\"lng\", \"lat\"],\n", 157 | " auto_highlight=True,\n", 158 | " elevation_scale=50,\n", 159 | " pickable=True,\n", 160 | " elevation_range=[0, 3000],\n", 161 | " extruded=True,\n", 162 | " coverage=1,\n", 163 | " )\n", 164 | "\n", 165 | " # Set the viewport location\n", 166 | " view_state = pdk.ViewState(\n", 167 | " longitude=-1.415,\n", 168 | " latitude=52.2323,\n", 169 | " zoom=6,\n", 170 | " min_zoom=5,\n", 171 | " max_zoom=15,\n", 172 | " pitch=40.5,\n", 173 | " bearing=-27.36,\n", 174 | " )\n", 175 | "\n", 176 | " # Render\n", 177 | " r = pdk.Deck(layers=[layer], initial_view_state=view_state)" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 6, 183 | "id": "4104c730", 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/html": [ 189 | "\n", 190 | " \n", 311 | " " 312 | ], 313 | "text/plain": [ 314 | "{\n", 315 | " \"initialViewState\": {\n", 316 | " \"bearing\": 0,\n", 317 | " \"latitude\": 49.254,\n", 318 | " \"longitude\": -123.13,\n", 319 | " \"maxZoom\": 16,\n", 320 | " \"pitch\": 45,\n", 321 | " \"zoom\": 11\n", 322 | " },\n", 323 | " \"layers\": [\n", 324 | " {\n", 325 | " \"@@type\": \"PolygonLayer\",\n", 326 | " \"data\": [\n", 327 | " [\n", 328 | " [\n", 329 | " -123.0,\n", 330 | " 49.196\n", 331 | " ],\n", 332 | " [\n", 333 | " -123.0,\n", 334 | " 49.324\n", 335 | " ],\n", 336 | " [\n", 337 | " -123.306,\n", 338 | " 49.324\n", 339 | " ],\n", 340 | " [\n", 341 | " -123.306,\n", 342 | " 49.196\n", 343 | " ]\n", 344 | " ]\n", 345 | " ],\n", 346 | " \"getFillColor\": [\n", 347 | " 0,\n", 348 | " 0,\n", 349 | " 0,\n", 350 | " 20\n", 351 | " ],\n", 352 | " \"getPolygon\": \"@@=-\",\n", 353 | " \"id\": \"c1b34400-6a2f-471d-b504-02a109943f55\",\n", 354 | " \"stroked\": false\n", 355 | " },\n", 356 | " {\n", 357 | " \"@@type\": \"GeoJsonLayer\",\n", 358 | " \"data\": \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\",\n", 359 | " \"extruded\": true,\n", 360 | " \"filled\": true,\n", 361 | " \"getElevation\": \"@@=properties.valuePerSqm / 20\",\n", 362 | " \"getFillColor\": \"@@=[255, 255, properties.growth * 255]\",\n", 363 | " \"getLineColor\": [\n", 364 | " 255,\n", 365 | " 255,\n", 366 | " 255\n", 367 | " ],\n", 368 | " \"id\": \"e3ebebba-2806-4bf8-937a-e2ca8b4eeeb9\",\n", 369 | " \"opacity\": 0.8,\n", 370 | " \"stroked\": false,\n", 371 | " \"wireframe\": true\n", 372 | " }\n", 373 | " ],\n", 374 | " \"mapProvider\": \"carto\",\n", 375 | " \"mapStyle\": \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\",\n", 376 | " \"views\": [\n", 377 | " {\n", 378 | " \"@@type\": \"MapView\",\n", 379 | " \"controller\": true\n", 380 | " }\n", 381 | " ]\n", 382 | "}" 383 | ] 384 | }, 385 | "execution_count": 6, 386 | "metadata": {}, 387 | "output_type": "execute_result" 388 | } 389 | ], 390 | "source": [ 391 | "r" 392 | ] 393 | }, 394 | { 395 | "cell_type": "code", 396 | "execution_count": null, 397 | "id": "8725be6d", 398 | "metadata": {}, 399 | "outputs": [], 400 | "source": [] 401 | } 402 | ], 403 | "metadata": { 404 | "kernelspec": { 405 | "display_name": "demo_env", 406 | "language": "python", 407 | "name": "demo_env" 408 | }, 409 | "language_info": { 410 | "codemirror_mode": { 411 | "name": "ipython", 412 | "version": 3 413 | }, 414 | "file_extension": ".py", 415 | "mimetype": "text/x-python", 416 | "name": "python", 417 | "nbconvert_exporter": "python", 418 | "pygments_lexer": "ipython3", 419 | "version": "3.8.10" 420 | } 421 | }, 422 | "nbformat": 4, 423 | "nbformat_minor": 5 424 | } 425 | -------------------------------------------------------------------------------- /pydeck/requirements.txt: -------------------------------------------------------------------------------- 1 | pydeck 2 | pandas 3 | mercury 4 | -------------------------------------------------------------------------------- /show-hide-code.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import mercury as mr" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "data": { 19 | "application/mercury+json": "{\n \"widget\": \"Checkbox\",\n \"value\": true,\n \"label\": \"Show code\",\n \"model_id\": \"4d103f91d61f4132a473b40571b665ae\",\n \"code_uid\": \"Checkbox.0.41.11.1-randad7d9c01\"\n}", 20 | "application/vnd.jupyter.widget-view+json": { 21 | "model_id": "4d103f91d61f4132a473b40571b665ae", 22 | "version_major": 2, 23 | "version_minor": 0 24 | }, 25 | "text/plain": [ 26 | "mercury.Checkbox" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "show_code = mr.Checkbox(value=True, label=\"Show code\")" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "metadata": {}, 41 | "outputs": [ 42 | { 43 | "data": { 44 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Show or hide code\",\n \"description\": \"You can show and hide code in this app\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"share\": \"public\",\n \"output\": \"app\",\n \"slug\": \"\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.41.23.1-rand8f323b23\"\n}", 45 | "text/html": [ 46 | "

Mercury Application

This output won't appear in the web app." 47 | ], 48 | "text/plain": [ 49 | "mercury.App" 50 | ] 51 | }, 52 | "metadata": {}, 53 | "output_type": "display_data" 54 | } 55 | ], 56 | "source": [ 57 | "app = mr.App(title=\"Show or hide code\", \n", 58 | " description=\"You can show and hide code in this app\",\n", 59 | " show_code=show_code.value)" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 4, 65 | "metadata": {}, 66 | "outputs": [ 67 | { 68 | "name": "stdout", 69 | "output_type": "stream", 70 | "text": [ 71 | "Example code ...\n" 72 | ] 73 | } 74 | ], 75 | "source": [ 76 | "print(\"Example code ...\")" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [] 92 | } 93 | ], 94 | "metadata": { 95 | "kernelspec": { 96 | "display_name": "mex", 97 | "language": "python", 98 | "name": "mex" 99 | }, 100 | "language_info": { 101 | "codemirror_mode": { 102 | "name": "ipython", 103 | "version": 3 104 | }, 105 | "file_extension": ".py", 106 | "mimetype": "text/x-python", 107 | "name": "python", 108 | "nbconvert_exporter": "python", 109 | "pygments_lexer": "ipython3", 110 | "version": "3.8.0" 111 | } 112 | }, 113 | "nbformat": 4, 114 | "nbformat_minor": 2 115 | } 116 | -------------------------------------------------------------------------------- /static-notebook.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "ab38c205", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "1f7f5383", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Static notebook\",\n \"description\": \"Display notebook as static website\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"share\": \"public\",\n \"output\": \"app\",\n \"slug\": \"\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.41.23.1-rand6d31fa70\"\n}", 22 | "text/html": [ 23 | "

Mercury Application

This output won't appear in the web app." 24 | ], 25 | "text/plain": [ 26 | "mercury.App" 27 | ] 28 | }, 29 | "metadata": {}, 30 | "output_type": "display_data" 31 | } 32 | ], 33 | "source": [ 34 | "app = mr.App(title=\"Static notebook\",\n", 35 | " description=\"Display notebook as static website\",\n", 36 | " show_code=True,\n", 37 | " static_notebook=True)" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 3, 43 | "id": "0b8ed221", 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "a = 1" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 4, 53 | "id": "d1cde10a", 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "b = 2" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 5, 63 | "id": "128171bb", 64 | "metadata": {}, 65 | "outputs": [ 66 | { 67 | "name": "stdout", 68 | "output_type": "stream", 69 | "text": [ 70 | "a + b is 3\n" 71 | ] 72 | } 73 | ], 74 | "source": [ 75 | "print(f\"a + b is {a+b}\")" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "id": "60625a47", 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [] 85 | } 86 | ], 87 | "metadata": { 88 | "kernelspec": { 89 | "display_name": "mex", 90 | "language": "python", 91 | "name": "mex" 92 | }, 93 | "language_info": { 94 | "codemirror_mode": { 95 | "name": "ipython", 96 | "version": 3 97 | }, 98 | "file_extension": ".py", 99 | "mimetype": "text/x-python", 100 | "name": "python", 101 | "nbconvert_exporter": "python", 102 | "pygments_lexer": "ipython3", 103 | "version": "3.8.10" 104 | } 105 | }, 106 | "nbformat": 4, 107 | "nbformat_minor": 5 108 | } 109 | -------------------------------------------------------------------------------- /stop-execution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "873f02ad", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import mercury as mr" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "9da9c2f4", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "application/mercury+json": "{\n \"widget\": \"Checkbox\",\n \"value\": false,\n \"label\": \"Should we stop?\",\n \"model_id\": \"4b7a698209244b0db08433d948a4fa79\",\n \"code_uid\": \"Checkbox.0.41.11.1-rand89bdfa97\"\n}", 22 | "application/vnd.jupyter.widget-view+json": { 23 | "model_id": "4b7a698209244b0db08433d948a4fa79", 24 | "version_major": 2, 25 | "version_minor": 0 26 | }, 27 | "text/plain": [ 28 | "mercury.Checkbox" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | } 34 | ], 35 | "source": [ 36 | "should_stop = mr.Checkbox(value=False, label=\"Should we stop?\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 3, 42 | "id": "c39b478e", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "if should_stop.value:\n", 47 | " print(\"We stop execution here!\")\n", 48 | " mr.Stop()" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 4, 54 | "id": "0fa1013f", 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "Some code ...\n" 62 | ] 63 | } 64 | ], 65 | "source": [ 66 | "print(\"Some code ...\")" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "id": "477343f8", 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [] 76 | } 77 | ], 78 | "metadata": { 79 | "kernelspec": { 80 | "display_name": "mex", 81 | "language": "python", 82 | "name": "mex" 83 | }, 84 | "language_info": { 85 | "codemirror_mode": { 86 | "name": "ipython", 87 | "version": 3 88 | }, 89 | "file_extension": ".py", 90 | "mimetype": "text/x-python", 91 | "name": "python", 92 | "nbconvert_exporter": "python", 93 | "pygments_lexer": "ipython3", 94 | "version": "3.8.10" 95 | } 96 | }, 97 | "nbformat": 4, 98 | "nbformat_minor": 5 99 | } 100 | -------------------------------------------------------------------------------- /use-cases/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/altair-dashboard/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/altair-dashboard/altair.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 9, 6 | "id": "d629dcd9", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import altair as alt\n", 11 | "from vega_datasets import data\n", 12 | "import mercury as mr" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 2, 18 | "id": "1b224acd", 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Airports\",\n \"description\": \"Dashboard with airports location\",\n \"show_code\": false,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand4489e373\"\n}", 24 | "text/html": [ 25 | "

Mercury Application

This output won't appear in the web app." 26 | ], 27 | "text/plain": [ 28 | "mercury.App" 29 | ] 30 | }, 31 | "metadata": {}, 32 | "output_type": "display_data" 33 | } 34 | ], 35 | "source": [ 36 | "app = mr.App(title=\"Airports ✈️\", description=\"Dashboard with airports location\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 3, 42 | "id": "143a1a20", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "airports = data.airports()\n", 47 | "states = alt.topo_feature(data.us_10m.url, feature='states')" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 4, 53 | "id": "90aec880", 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "data": { 58 | "application/mercury+json": "{\n \"widget\": \"MultiSelect\",\n \"value\": [\n \"TX\",\n \"LA\"\n ],\n \"choices\": [\n \"MS\",\n \"TX\",\n \"CO\",\n \"NY\",\n \"FL\",\n \"AL\",\n \"WI\",\n \"OH\",\n \"MO\",\n \"MN\",\n \"IN\",\n \"NV\",\n \"IL\",\n \"ND\",\n \"MI\",\n \"NE\",\n \"GA\",\n \"DC\",\n \"TN\",\n \"AK\",\n \"ME\",\n \"MA\",\n \"VT\",\n \"SD\",\n \"NM\",\n \"OK\",\n \"KS\",\n \"KY\",\n \"IA\",\n \"AR\",\n \"LA\",\n \"CA\",\n \"WA\",\n \"VA\",\n \"AZ\",\n \"PA\",\n \"NJ\",\n \"OR\",\n \"NC\",\n \"UT\",\n \"MT\",\n \"ID\",\n \"CT\",\n \"SC\",\n \"NH\",\n \"MD\",\n \"DE\",\n \"WV\",\n \"WY\",\n \"PR\",\n \"RI\",\n \"AS\",\n \"CQ\",\n \"GU\",\n \"HI\",\n \"VI\"\n ],\n \"label\": \"Select states\",\n \"model_id\": \"39d0180163094ff9bffba39b0ebace0d\",\n \"code_uid\": \"MultiSelect.0.40.16.1-rand718f029b\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", 59 | "application/vnd.jupyter.widget-view+json": { 60 | "model_id": "39d0180163094ff9bffba39b0ebace0d", 61 | "version_major": 2, 62 | "version_minor": 0 63 | }, 64 | "text/plain": [ 65 | "mercury.MultiSelect" 66 | ] 67 | }, 68 | "metadata": {}, 69 | "output_type": "display_data" 70 | } 71 | ], 72 | "source": [ 73 | "selected_states = mr.MultiSelect(label=\"Select states\", value=[\"TX\", \"LA\"], \n", 74 | " choices=[a for a in airports.state.unique() if isinstance(a, str)])" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 5, 80 | "id": "413b86fd", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "selected_airports = airports[airports.state.isin(selected_states.value)]" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 6, 90 | "id": "8673b645", 91 | "metadata": {}, 92 | "outputs": [ 93 | { 94 | "data": { 95 | "text/html": [ 96 | "
\n", 108 | "
\n", 109 | " 264\n", 110 | " \n", 111 | " # airports\n", 112 | "
\n", 113 | " \n", 114 | "
\n", 115 | " 2\n", 116 | " \n", 117 | " # states\n", 118 | "
\n", 119 | " \n", 120 | "
\n", 121 | " 241\n", 122 | " \n", 123 | " # cities\n", 124 | "
\n", 125 | "
" 126 | ], 127 | "text/plain": [ 128 | "" 129 | ] 130 | }, 131 | "execution_count": 6, 132 | "metadata": {}, 133 | "output_type": "execute_result" 134 | } 135 | ], 136 | "source": [ 137 | "mr.NumberBox([\n", 138 | " mr.NumberBox(selected_airports.shape[0], \"# airports\"),\n", 139 | " mr.NumberBox(len(selected_states.value), \"# states\"),\n", 140 | " mr.NumberBox(len(selected_airports.city.unique()), \"# cities\"),\n", 141 | " \n", 142 | "])" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 7, 148 | "id": "716e26a4", 149 | "metadata": {}, 150 | "outputs": [], 151 | "source": [ 152 | "\n", 153 | "\n", 154 | "# US states background\n", 155 | "background = (\n", 156 | " alt.Chart(states)\n", 157 | " .mark_geoshape(\n", 158 | " fill=\"#f1f5f9\",\n", 159 | " stroke=\"#2684ff\",\n", 160 | " )\n", 161 | " .project(\"albersUsa\")\n", 162 | " .properties(height=600, width=\"container\")\n", 163 | ")\n", 164 | "# airport positions on background\n", 165 | "points = alt.Chart(selected_airports).mark_circle(\n", 166 | " size=10,\n", 167 | " color='#ef6f6c'\n", 168 | ").encode(\n", 169 | " longitude='longitude:Q',\n", 170 | " latitude='latitude:Q',\n", 171 | " tooltip=['name', 'city', 'state']\n", 172 | ")\n", 173 | "\n" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 8, 179 | "id": "9f8cba1c", 180 | "metadata": {}, 181 | "outputs": [ 182 | { 183 | "data": { 184 | "text/html": [ 185 | "\n", 186 | "\n", 197 | "
\n", 198 | "" 251 | ], 252 | "text/plain": [ 253 | "alt.LayerChart(...)" 254 | ] 255 | }, 256 | "execution_count": 8, 257 | "metadata": {}, 258 | "output_type": "execute_result" 259 | } 260 | ], 261 | "source": [ 262 | "background + points" 263 | ] 264 | } 265 | ], 266 | "metadata": { 267 | "kernelspec": { 268 | "display_name": "menv", 269 | "language": "python", 270 | "name": "menv" 271 | }, 272 | "language_info": { 273 | "codemirror_mode": { 274 | "name": "ipython", 275 | "version": 3 276 | }, 277 | "file_extension": ".py", 278 | "mimetype": "text/x-python", 279 | "name": "python", 280 | "nbconvert_exporter": "python", 281 | "pygments_lexer": "ipython3", 282 | "version": "3.8.10" 283 | } 284 | }, 285 | "nbformat": 4, 286 | "nbformat_minor": 5 287 | } 288 | -------------------------------------------------------------------------------- /use-cases/altair-dashboard/requirements.txt: -------------------------------------------------------------------------------- 1 | altair 2 | vega_datasets 3 | -------------------------------------------------------------------------------- /use-cases/data-analyst-job/README.md: -------------------------------------------------------------------------------- 1 | ![](https://raw.githubusercontent.com/mljar/mercury-examples/main/use-cases/data-analyst-job/media/banner.jpg) 2 | 3 | # Python Dashboard for 15,963 Data Analyst job listings 4 | 5 | ### Full article [Python Dashboard for 15,963 Data Analyst job listings](https://mljar.com/blog/python-dashboard-data-analyst/) 6 | 7 | ![](https://raw.githubusercontent.com/mljar/mercury-examples/main/use-cases/data-analyst-job/media/data-analysts-overview.png) 8 | 9 | ### Data source 10 | 11 | Data collected from kaggle: 12 | https://www.kaggle.com/datasets/lukebarousse/data-analyst-job-postings-google-search?datasetId=2614070&sortBy=voteCount 13 | 14 | 15 | ### Web App 16 | 17 | The notebook with analysis is shared as interactvie web app at https://use-cases.runmercury.com 18 | 19 | 🧰 It is using [Mercury](https://github.com/mljar/mercury) framework to share notebook as web app. 20 | - Mercury offers interactive widgets - users can interact with your notebook without touching code (learn more from [Mercury Docs](https://runmercury.com/docs/)). 21 | - Mercury offers easy and free deployment with few clicks (read more on [Mercury Cloud](https://cloud.runmercury.com)). 22 | 23 | ![](https://raw.githubusercontent.com/mljar/mercury-examples/main/use-cases/data-analyst-job/media/mercury-web-app.gif) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /use-cases/data-analyst-job/df-job-al.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/df-job-al.zip -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/10-skills.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/10-skills.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/avg-pay-skills.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/avg-pay-skills.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/cd-mercury.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/cd-mercury.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/contract-type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/contract-type.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/number-of-jobs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/number-of-jobs.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/remote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/remote.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/text.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/web-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/web-menu.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/web.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/what-company.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/what-company.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/where-to-look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/where-to-look.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/images/wordcloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/images/wordcloud.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/media/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/data-analyst-job/media/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/media/banner.jpg -------------------------------------------------------------------------------- /use-cases/data-analyst-job/media/data-analyst-skills.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/media/data-analyst-skills.gif -------------------------------------------------------------------------------- /use-cases/data-analyst-job/media/data-analysts-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/media/data-analysts-overview.png -------------------------------------------------------------------------------- /use-cases/data-analyst-job/media/mercury-web-app.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/data-analyst-job/media/mercury-web-app.gif -------------------------------------------------------------------------------- /use-cases/data-analyst-job/requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib>=3.6.2 2 | mercury>=2.2.1 3 | numpy>=1.24.0 4 | pandas>=1.5.2 5 | wordcloud>=1.8.2.2 6 | 7 | -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/README.md: -------------------------------------------------------------------------------- 1 | ![](https://raw.githubusercontent.com/mljar/mercury-examples/main/use-cases/matplotlib-legend/media/banner.jpg) 2 | 3 | # 3 ways to set matplotlib legend location 4 | 5 | ### Article 6 | 7 | [Full article](http://127.0.0.1:4000/blog/) 8 | 9 | 10 | ### Web App 11 | Mercury app: 12 | -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/images/matplot-legend.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/images/matplot-legend.gif -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/images/plot-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/images/plot-01.png -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/images/plot-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/images/plot-02.png -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/images/plot-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/images/plot-03.png -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/images/plot-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/images/plot-04.png -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/media/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/matplotlib-legend/media/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/mercury-examples/0e0da6a22f1cc2e7089b93def7f97dd96f829119/use-cases/matplotlib-legend/media/banner.jpg -------------------------------------------------------------------------------- /use-cases/report/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/report/requirements.txt: -------------------------------------------------------------------------------- 1 | mercury 2 | altair 3 | vega_datasets 4 | pandas 5 | -------------------------------------------------------------------------------- /use-cases/ticker-app/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /use-cases/ticker-app/requirements.txt: -------------------------------------------------------------------------------- 1 | mercury 2 | mplfinance 3 | yfinance 4 | matplotlib 5 | pandas 6 | --------------------------------------------------------------------------------