bokeh.models.sources

class AjaxDataSource(**kwargs)

Bases: bokeh.models.sources.RemoteSource

if_modified

property type: Bool

Whether to include an If-Modified-Since header in AJAX requests to the server. If this header is supported by the server, then only new data since the last request will be returned.

max_size

property type: Int

Maximum size of the data array being kept after each pull requests. Larger than that size, the data will be right shifted.

method

property type: Enum(‘POST’, ‘GET’)

http method - GET or POST

mode

property type: Enum(‘replace’, ‘append’)

Whether to append new data to existing data (up to max_size), or to replace existing data entirely.

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "data": {},
      "data_url": null,
      "doc": null,
      "id": "13219cfb-ea95-4f58-b4e7-3bf6ba4c908e",
      "if_modified": false,
      "max_size": null,
      "method": "POST",
      "mode": "replace",
      "name": null,
      "polling_interval": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": []
    },
    "id": "13219cfb-ea95-4f58-b4e7-3bf6ba4c908e",
    "type": "AjaxDataSource"
  }
]
class BlazeDataSource(**kwargs)

Bases: bokeh.models.sources.RemoteSource

from_blaze(remote_blaze_obj, local=True)
to_blaze()
expr

property type: Dict(String, Any)

blaze expression graph in json form

local

property type: Bool

Whether this data source is hosted by the bokeh server or not.

namespace

property type: Dict(String, Any)

namespace in json form for evaluating blaze expression graph

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "data": {},
      "data_url": null,
      "doc": null,
      "expr": {},
      "id": "0022199b-1e21-427f-971f-4196e5b15201",
      "local": null,
      "name": null,
      "namespace": {},
      "polling_interval": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": []
    },
    "id": "0022199b-1e21-427f-971f-4196e5b15201",
    "type": "BlazeDataSource"
  }
]
class ColumnDataSource(*args, **kw)

Bases: bokeh.models.sources.DataSource

Maps names of columns to sequences or arrays.

If the ColumnDataSource initializer is called with a single argument that is a dict or pandas.DataFrame, that argument is used as the value for the “data” attribute. For example:

ColumnDataSource(mydict) # same as ColumnDataSource(data=mydict)
ColumnDataSource(df) # same as ColumnDataSource(data=df)

Note

There is an implicit assumption that all the columns in a a given ColumnDataSource have the same length.

add(data, name=None)

Appends a new column of data to the data source.

Parameters:
  • data (seq) – new data to add
  • name (str, optional) – column name to use. If not supplied, generate a name go the form “Series ####”
Returns:

the column name used

Return type:

str

classmethod from_df(*args, **kwargs)

Create a dict of columns from a Pandas DataFrame, suitable for creating a ColumnDataSource.

Parameters:data (DataFrame) – data to convert
Returns:dict(str, list)

Deprecated in Bokeh 0.9.3; please use ColumnDataSource initializer instead.

push_notebook()

Update date for a plot in the IPthon notebook in place.

This function can be be used to update data in plot data sources in the IPython notebook, without having to use the Bokeh server.

Returns:None

Warning

The current implementation leaks memory in the IPython notebook, due to accumulating JS code. This function typically works well with light UI interactions, but should not be used for continuously updating data. See issue 1732 for more details and to track progress on potential fixes.

remove(name)

Remove a column of data.

Parameters:name (str) – name of the column to remove
Returns:None

Note

If the column name does not exist, a warning is issued.

to_df()

Convert this data source to pandas dataframe.

If column_names is set, use those. Otherwise let Pandas infer the column names. The column_names property can be used both to order and filter the columns.

Returns:DataFrame
vm_serialize(changed_only=True)
data

property type: Dict(String, Any)

Mapping of column names to sequences of data. The data can be, e.g, Python lists or tuples, NumPy arrays, etc.

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "data": {},
      "doc": null,
      "id": "9d3e38d5-d97e-4d86-bbf8-a08d28aa0d9e",
      "name": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": []
    },
    "id": "9d3e38d5-d97e-4d86-bbf8-a08d28aa0d9e",
    "type": "ColumnDataSource"
  }
]
class ColumnsRef(**properties)

A utility object to allow referring to a collection of columns from a specified data source, all together.

columns

property type: List(String)

A list of column names to reference from source.

source

property type: Instance(DataSource)

A data source to reference.

class DataSource(**kwargs)

Bases: bokeh.plot_object.PlotObject

A base class for data source types. DataSource is not generally useful to instantiate on its own.

columns(*columns)

Returns a ColumnsRef object for a column or set of columns on this data source.

Parameters:*columns
Returns:ColumnsRef
callback

property type: Instance(Callback)

A callback to run in the browser whenever the selection is changed.

column_names

property type: List(String)

An list of names for all the columns in this DataSource.

selected

property type: Dict(String, Dict(String, Any))

A dict to indicate selected indices on different dimensions on this DataSource. Keys are:

  • 0d: indicates whether a Line or Patch glyphs have been hit. Value is a

    dict with the following keys:

    • flag (boolean): true if glyph was with false otherwise
    • indices (list): indices hit (if applicable)
  • 1d: indicates whether any of all other glyph (except [multi]line or

    patches) was hit:

    • indices (list): indices that were hit/selected
  • 2d: indicates whether a [multi]line or patches) were hit:

    • indices (list(list)): indices of the lines/patches that were

      hit/selected

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "doc": null,
      "id": "1c8a9757-6e65-4fda-a177-a7fb6c106337",
      "name": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": []
    },
    "id": "1c8a9757-6e65-4fda-a177-a7fb6c106337",
    "type": "DataSource"
  }
]
class RemoteSource(**kwargs)

Bases: bokeh.models.sources.DataSource

data

property type: Dict(String, Any)

Additional data to include directly in this data source object. The columns provided here are merged with those from the Bokeh server.

data_url

property type: String

The URL to the endpoint for the data.

polling_interval

property type: Int

polling interval for updating data source in milliseconds

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "data": {},
      "data_url": null,
      "doc": null,
      "id": "98883a7e-f288-4987-96ba-22b2f4794659",
      "name": null,
      "polling_interval": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": []
    },
    "id": "98883a7e-f288-4987-96ba-22b2f4794659",
    "type": "RemoteSource"
  }
]
class ServerDataSource(**kwargs)

Bases: bokeh.models.sources.BlazeDataSource

A data source that referes to data located on a Bokeh server.

The data from the server is loaded on-demand by the client.

transform

property type: Dict(String, Either(Instance(PlotObject), Any))

Paramters of the data transformation operations.

The associated valuse is minimally a tag that says which downsample routine to use. For some downsamplers, parameters are passed this way too.

[
  {
    "attributes": {
      "callback": null,
      "column_names": [],
      "data": {},
      "data_url": null,
      "doc": null,
      "expr": {},
      "id": "190aed14-2a24-45af-b746-2b5b5e83b47f",
      "local": null,
      "name": null,
      "namespace": {},
      "polling_interval": null,
      "selected": {
        "0d": {
          "flag": false,
          "indices": []
        },
        "1d": {
          "indices": []
        },
        "2d": {
          "indices": []
        }
      },
      "tags": [],
      "transform": {}
    },
    "id": "190aed14-2a24-45af-b746-2b5b5e83b47f",
    "type": "ServerDataSource"
  }
]