Using Bokeh

Bokeh is a Python interactive visualization library that provides interactive plots and dashboards. There are several ways you can use Bokeh in DSS:

  • For fully-interactive interaction (multiple charts, various controls, …), by creating a Bokeh webapp
  • To display interactive (pan/zoom/…) charts within a Jupyter notebook
  • To display interactive (pan/zoom/…) charts on a Dashboard

Documentation for Bokeh is available at https://bokeh.pydata.org

Installing Bokeh

  • If you are using the DSS built-in environment, Bokeh is already installed. You don’t need to do any specific installation
  • If you are using a code environent, you need to install the bokeh package

Creating a Bokeh interactive web application

See Webapps

Displaying charts in a Jupyter notebook

To display plot.ly charts in a Jupyter notebook, use this cell once in the notebook:

from bokeh.io import output_notebook, show
output_notebook()

You can then use show() to show Bokeh figures

For example, to display a chart showing simple circles:

from bokeh.plotting import figure

f = figure()
f.circle([1,2,3], [4,5,6], size=10)

show(f)

A complete documentation for the usage of Bokeh in a Jupyter notebook can be found at https://bokeh.pydata.org/en/latest/docs/user_guide/notebook.html

Using interactive controls in the Jupyter notebook

You can use interactive controls (sliders, inputs, …) that are displayed in the notebook. When you change these controls, the Bokeh chart can react dynamically.

Documentation for this is available here: https://bokeh.pydata.org/en/latest/docs/user_guide/notebook.html#jupyter-interactors

Displaying Bokeh charts on a dashboard

Bokeh charts generated using Python code can be shared on a DSS dashboard using the “static insights” system. This does not include the capability to include controls. If you want to use Bokeh controls on a DSS Dashboard, use a Bokeh webapp.

Each Bokeh figure can become a single insight in the dashboard. Each chart will retain full zoom/pan/select/export capabilities;

To do so, create static insights

from dataiku import insights

# f is a Bokeh figure, or any object that can be passed to show()

insights.save_bokeh("my-bokeh-plot", f)

From the Dashboard, you can then add a new “Static” insight, select the my-bokeh-plot insight

Refreshing charts on a dashboard

You can refresh the charts automatically on a dashboard by using a scenario to re-run the above piece of code.

This call to dataiku.insights code can be:

  • In a DSS recipe (use a regular “Build” scenario step)
  • In a Jupyter notebook (use a “Export notebook” scenario step)
  • As a custom Python scenario step