Skip to content

Commit

Permalink
Merge pull request voila-dashboards#223 from SylvainCorlay/fixup-docs
Browse files Browse the repository at this point in the history
Fixup documentation images
  • Loading branch information
SylvainCorlay committed Jun 12, 2019
2 parents 89efce1 + 6ffbce5 commit 0618f9e
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 6 deletions.
11 changes: 5 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
=====
Voila
=====
.. image:: voila.svg
:alt: voila

Create interactive dashboards with Jupyter Notebooks.
From notebooks to standalone web applications and dashboards.

Voila allows you to convert a Jupyter Notebook into an
Voilà allows you to convert a Jupyter Notebook into an
interactive dashboard that allows you to share your work with others. It
is secure and customizable, giving you control over what your readers
experience.
Expand All @@ -19,7 +18,7 @@ try it interactively at the following Binder link)

<br />

.. image:: ../../voila-won.gif
.. image:: ../../voila-basics.gif

Table of contents
=================
Expand Down
148 changes: 148 additions & 0 deletions notebooks/dashboard.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This demo uses voila to render a notebook to a custom HTML page using gridstack.js for the layout of each output. In the cell metadata you can change the default cell with and height (in grid units between 1 and 12) by specifying.\n",
" * `grid_row`\n",
" * `grid_columns`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"n = 200\n",
"\n",
"x = np.linspace(0.0, 10.0, n)\n",
"y = np.cumsum(np.random.randn(n)*10).astype(int)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"label_selected = widgets.Label(value=\"Selected: 0\")\n",
"label_selected"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"grid_columns": 8,
"grid_rows": 4
},
"outputs": [],
"source": [
"import numpy as np\n",
"from bqplot import pyplot as plt\n",
"import bqplot\n",
"\n",
"fig = plt.figure( title='Histogram')\n",
"np.random.seed(0)\n",
"hist = plt.hist(y, bins=25)\n",
"hist.scales['sample'].min = float(y.min())\n",
"hist.scales['sample'].max = float(y.max())\n",
"display(fig)\n",
"fig.layout.width = 'auto'\n",
"fig.layout.height = 'auto'\n",
"fig.layout.min_height = '300px' # so it shows nicely in the notebook\n",
"fig.layout.flex = '1'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"grid_columns": 12,
"grid_rows": 6
},
"outputs": [],
"source": [
"import numpy as np\n",
"from bqplot import pyplot as plt\n",
"import bqplot\n",
"\n",
"fig = plt.figure( title='Line Chart')\n",
"np.random.seed(0)\n",
"n = 200\n",
"p = plt.plot(x, y)\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig.layout.width = 'auto'\n",
"fig.layout.height = 'auto'\n",
"fig.layout.min_height = '300px' # so it shows nicely in the notebook\n",
"fig.layout.flex = '1'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"brushintsel = bqplot.interacts.BrushIntervalSelector(scale=p.scales['x'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def update_range(*args):\n",
" label_selected.value = \"Selected range {}\".format(brushintsel.selected)\n",
" mask = (x > brushintsel.selected[0]) & (x < brushintsel.selected[1])\n",
" hist.sample = y[mask]\n",
" \n",
"brushintsel.observe(update_range, 'selected')\n",
"fig.interaction = brushintsel"
]
}
],
"metadata": {
"celltoolbar": "Edit Metadata",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 0618f9e

Please sign in to comment.