Introducing Bokeh 3.2

Bokeh
4 min readJul 11, 2023

We are excited to announce the release of Bokeh 3.2! This release includes several useful updates including support for independent zoom on axes, ES module support in CustomJS callbacks, new glyphs and more WebGL support. We also address many regressions and performance issues introduced in earlier Bokeh 3.x releases.

Bokeh 3.2 Highlights

As a minor release, Bokeh 3.2 includes several large but non-breaking changes and new features. This post spotlights some improvements that we feel will be useful for most users.

New “infinite” length span and strip glyphs

New HSpan, VSpan, HStrip and VStrip glyphs were added. Those glyphs are “infinite” in one of their dimensions, i.e. they span either horizontal or vertical dimension, generalizing the concept introduced with Span annotation, however allowing for all features provided by glyphs.

Added support for Axis.axis_label_orientation property

Previously it wasn’t possible to change the default (parallel) orientation of axis’ labels. With this change, the user can configure axis’ labels the same way as one can configure axis’ major labels.

Added WebGL support to more glyphs

Annulus, Wedge and AnnularWedge now support WebGL rendering. This adds to the growing collection of glyphs that can be rendered much more efficiently with WebGL.

Added support for ES module to CustomJS callbacks

Bokeh 3.2 allows to treat CustomJS callbacks as JavaScript modules. This allows users to use static import and export syntax, besides dynamic imports that were allowed previously. The functionality of a callback is exposed via the default export, which can be a function or an arrow function, with three arguments: args, obj and data. Due to the explicit nature of this setup, no cb_ prefixes are needed anymore, nor are there any implicit variables in the scope of the callback. Caching of compiled function code was improved and support for asynchronous functions was added. BokehJS differentiates old style callbacks from new style by detecting the presence of exports, specifical default export, in the code block. Below is an example of a simple new style callback:

code=”””\

export default function({div}, obj, {source, event: {modifiers}}) {

const {shift, ctrl, alt} = modifiers

const modifiers_repr = `shift = ${shift}, ctrl = ${ctrl}, alt = ${alt}`

div.text = `${obj.toString()} modifiers: ${modifiers_repr}`

}

“””

TapTool(callback=CustomJS(

args=dict(div=Div()),

code=code,

)

See also examples/advanced/integration/d3-voronoi.py for a more advanced example, showing for example how to use third-party imported libraries.

Allowed to configure TapTool with key modifiers

TapTool now supports configuration of key modifiers. This allows users to create multiple instances of this tool with different modifiers for different functionality. Thus this feature is especially useful when using TapTool with callbacks, like CustomJS. Additionally, TapTool reports key modifiers in callbacks, so that one tool can be used to provide different behaviors depending on what modifier keys were pressed during interaction. Key modifier reporting was also added to all UI events, e.g. Tap event.

Added support for zoom of individual axes

Bokeh 3.2 adds support for wheel zoom of individual axes. Previously it was possible to zoom on axes, but only on all of them in the given dimension. In this release we improved hit testing of axes, so that tools can work on individual axes. We also added zoom_behavior property to WheelZoomTool, which allows the user to configure which axes will be zoomed during interaction. The behaviors are either the axis being interacted with, or that axis and its cross axis, or all axes in the given dimension (the old behavior). Additionally ZoomInTool and ZoomOutTool can be configured with renderers (by setting renderers property), which are used to determine which ranges (and thus axes) are to be either zoomed in or out.

Some additional updates include:

  • Correctly resolve custom host and port with server resources
  • Official support for Python 3.8 was removed

Updating to Bokeh 3.2

Bokeh 3.2 will be available through all regular channels shortly after release. In most cases, you can run either conda install bokeh or pip install bokeh to install Bokeh 3.2.

(If you want to make sure you get the most recent available version of Bokeh, you can install from the Bokeh channel at anaconda.org directly, using conda install -c bokeh bokeh.)

For more information about installing Bokeh, see the section Installation details in the Bokeh User guide.

Next Steps

If you have questions, we encourage you to visit the Bokeh Discourse! Friendly project maintainers and a community of Bokeh users are there to help you navigate any issues that arise.

Developers interested in getting involved can visit the Contribute section of the User Guide for guidance on best practices and technical considerations.

As always, we appreciate the thoughtful feedback from users and especially the work of our contributor community to make Bokeh better!

--

--

Bokeh

Bokeh is a powerful, interactive visualization library for modern web browsers.