Anaconda Enterprise: Documentation

# bokeh.core.state

Encapsulate implicit state that is useful for Bokeh plotting APIs.

Note

While `State` objects can also be manipulated explicitly, they are automatically configured when the functions `output_file()`, etc. from bokeh.io are used, so this is not necessary under typical usage.

Generating output for Bokeh plots requires coordinating several things:

`Document`
  Groups together Bokeh models that may be shared between plots (e.g., range or data source objects) into one common strucure.
`Resources`
  Control how JavaScript and CSS for the client library BokehJS are included and used in the generated output.

It is possible to handle the configuration of these things manually, and some examples of doing this can be found in `examples/models` directory. When developing sophisticated applications, it may be necessary or desirable to work at this level. However, for general use this would quickly become burdensome. This module provides a `State` class that encapsulates these objects and ensures their proper configuration in many common usage scenarios.

class `bokeh.core.state.``State`

  Manage state related to controlling Bokeh output.

  `output_file`(filename, title='Bokeh Plot', mode='cdn', root_dir=None)

    Configure output to a standalone HTML file.

    Calling `output_file` not clear the effects of any other calls to `output_notebook`, etc. It adds an additional output destination (publishing to HTML files). Any other active output modes continue to be active.

    Parameters:

    - filename (str) – a filename for saving the HTML document
    - title (str, optional) – a title for the HTML document
    - mode (str, optional) –

      how to include BokehJS (default: `'cdn'`)

      One of: `'inline'`, `'cdn'`, `'relative(-dev)'` or `'absolute(-dev)'`. See `Resources` for more details.

    - root_dir (str, optional) –

      root dir to use for absolute resources (default: None)

      This value is ignored for other resource types, e.g. `INLINE` or``CDN``.

    Warning

    The specified output file will be overwritten on every save, e.g., every time `show()` or `save()` is called.

  `output_notebook`(notebook_type='jupyter')

    Generate output in Jupyter/Zeppelin notebook cells.

    Calling `output_notebook` not clear the effects of any other calls to `output_file`, etc. It adds an additional output destination (publishing to notebook output cells). Any other active output modes continue to be active.

    Returns: | None

  `reset`()

    Deactivate all currently active output modes and set `curdoc()` to a fresh empty `Document`.

    Subsequent calls to `show()` will not render until a new output mode is activated.

    Returns: | None

  `document`

    A default `Document` to use for all output operations.

  `file`

    A dict with the default configuration for file output (READ ONLY)

    The dictionary value has the following form:

        {
            'filename'  : # filename to use when saving
            'resources' : # resources configuration
            'title'     : # a title for the HTML document
        }

  `notebook`

    Whether to generate notebook output on show operations. (READ ONLY)

  `notebook_type`

    Notebook type