bokeh.resources

The resources module provides the Resources class for easily configuring how BokehJS code and CSS resources should be located, loaded, and embedded in Bokeh documents.

Also provides some pre-configured Resources objects.

CDN

load minified BokehJS from CDN

INLINE

provide minified BokehJS from library static directory

class CSSResources(mode='inline', version=None, root_dir=None, minified=True, log_level='info', root_url=None, path_versioner=None, components=None)

The CSSResources class encapsulates information relating to loading or embedding Bokeh client-side CSS.

Parameters:
  • mode (str) –

    how should Bokeh CSS be included in output

    See below for descriptions of available modes

  • version (str, optional) –

    what version of Bokeh CSS to load

    Only valid with the 'cdn' mode

  • root_dir (str, optional) –

    root directory for loading BokehJS resources

    Only valid with 'relative' and 'relative-dev' modes

  • minified (bool, optional) – whether CSS should be minified or not (default: True)
  • root_url (str, optional) –

    URL and port of Bokeh Server to load resources from

    Only valid with 'server' and 'server-dev' modes

The following mode values are available for configuring a Resource object:

  • 'inline' configure to provide entire BokehJS code and CSS inline
  • 'cdn' configure to load Bokeh CSS from https://cdn.bokeh.org
  • 'server' configure to load from a Bokeh Server
  • 'server-dev' same as server but supports non-minified CSS
  • 'relative' configure to load relative to the given directory
  • 'relative-dev' same as relative but supports non-minified CSS
  • 'absolute' configure to load from the installed Bokeh library static directory
  • 'absolute-dev' same as absolute but supports non-minified CSS

Once configured, a Resource object exposes the following public attributes:

css_raw

any raw CSS that needs to be places inside <style> tags

css_files

URLs of any CSS files that need to be loaded by <link> tags

messages

any informational messages concerning this configuration

These attributes are often useful as template parameters when embedding Bokeh plots.

class JSResources(mode='inline', version=None, root_dir=None, minified=True, log_level='info', root_url=None, path_versioner=None, components=None)

The Resources class encapsulates information relating to loading or embedding Bokeh Javascript.

Parameters:
  • mode (str) –

    how should Bokeh JS be included in output

    See below for descriptions of available modes

  • version (str, optional) –

    what version of Bokeh JS to load

    Only valid with the 'cdn' mode

  • root_dir (str, optional) –

    root directory for loading Bokeh JS assets

    Only valid with 'relative' and 'relative-dev' modes

  • minified (bool, optional) – whether JavaScript should be minified or not (default: True)
  • root_url (str, optional) –

    URL and port of Bokeh Server to load resources from

    Only valid with 'server' and 'server-dev' modes

The following mode values are available for configuring a Resource object:

  • 'inline' configure to provide entire Bokeh JS and CSS inline
  • 'cdn' configure to load Bokeh JS and CSS from https://cdn.bokeh.org
  • 'server' configure to load from a Bokeh Server
  • 'server-dev' same as server but supports non-minified assets
  • 'relative' configure to load relative to the given directory
  • 'relative-dev' same as relative but supports non-minified assets
  • 'absolute' configure to load from the installed Bokeh library static directory
  • 'absolute-dev' same as absolute but supports non-minified assets

Once configured, a Resource object exposes the following public attributes:

css_raw

any raw CSS that needs to be places inside <style> tags

css_files

URLs of any CSS files that need to be loaded by <link> tags

messages

any informational messages concerning this configuration

These attributes are often useful as template parameters when embedding Bokeh plots.

class Resources(mode='inline', version=None, root_dir=None, minified=True, log_level='info', root_url=None, path_versioner=None, components=None)

The Resources class encapsulates information relating to loading or embedding Bokeh Javascript and CSS.

Parameters:
  • mode (str) –

    how should Bokeh JS and CSS be included in output

    See below for descriptions of available modes

  • version (str, optional) –

    what version of Bokeh JS and CSS to load

    Only valid with the 'cdn' mode

  • root_dir (str, optional) –

    root directory for loading Bokeh JS and CSS assets

    Only valid with 'relative' and 'relative-dev' modes

  • minified (bool, optional) – whether JavaScript and CSS should be minified or not (default: True)
  • root_url (str, optional) –

    URL and port of Bokeh Server to load resources from

    Only valid with 'server' and 'server-dev' modes

The following mode values are available for configuring a Resource object:

  • 'inline' configure to provide entire Bokeh JS and CSS inline
  • 'cdn' configure to load Bokeh JS and CSS from https://cdn.bokeh.org
  • 'server' configure to load from a Bokeh Server
  • 'server-dev' same as server but supports non-minified assets
  • 'relative' configure to load relative to the given directory
  • 'relative-dev' same as relative but supports non-minified assets
  • 'absolute' configure to load from the installed Bokeh library static directory
  • 'absolute-dev' same as absolute but supports non-minified assets

Once configured, a Resource object exposes the following public attributes:

js_raw

any raw JS that needs to be placed inside <script> tags

css_raw

any raw CSS that needs to be places inside <style> tags

js_files

URLs of any JS files that need to be loaded by <script> tags

css_files

URLs of any CSS files that need to be loaded by <link> tags

messages

any informational messages concerning this configuration

These attributes are often useful as template parameters when embedding Bokeh plots.