css#

CSS对象模型的各种抽象。

class GlobalImportedStyleSheet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

基础类:ImportedStyleSheet

一个导入的样式表,附加到 元素。

注意

无论在其他模型中使用多少次,样式表只会附加一次。

JSON Prototype
{
  "id": "p57347", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "url": {
    "name": "unset", 
    "type": "symbol"
  }
}
name = None#
Type:

Nullable(String)

此模型的任意用户提供的名称。

在查询文档以检索特定Bokeh模型时,此名称可能很有用。

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

注意

对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。

syncable = True#
Type:

Bool

指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。

注意

将此属性设置为False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。

tags = []#
Type:

List

一个可选的任意用户提供的值列表,用于附加到此模型。

在查询文档以检索特定Bokeh模型时,这些数据可能很有用:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过CustomJS回调等方式访问。

注意

对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。

url = Undefined#
Type:

Required(String)

外部样式表的位置。

apply_theme(property_values: dict[str, Any]) None#

应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。

传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和HasProps实例都不应修改它)。

Parameters:

property_values (dict) – 用于替换默认值的主题值

Returns:

classmethod clear_extensions() None#

清除当前定义的所有自定义扩展。

序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。

clone(**overrides: Any) Self#

复制一个HasProps对象。

这将创建原始模型的浅克隆,即任何可变的容器或子模型将不会被复制。允许在克隆时覆盖特定属性。

classmethod dataspecs() dict[str, DataSpec]#

收集此类上所有DataSpec属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

DataSpec 属性的名称

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

属性描述符的列表,按定义的顺序排列。

destroy() None#

清理对文档和属性的引用

equals(other: HasProps) bool#

模型的结构相等性。

Parameters:

其他 (HasProps) – 要比较的其他实例

Returns:

如果属性在结构上相等,则为True,否则为False

使用JavaScript链接两个Bokeh模型属性。

这是一个便捷的方法,简化了添加一个 CustomJS 回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。

Parameters:
  • attr (str) – 此模型上的Bokeh属性的名称

  • 其他 (Model) – 一个要链接到 self.attr 的 Bokeh 模型

  • other_attr (str) – 要链接在一起的other上的属性

  • attr_selector (int | str) – 用于链接可下标对象 attr 中项目的索引

在版本1.1中添加

Raises:

ValueError

示例

这段代码使用了 js_link:

select.js_link('value', plot, 'sizing_mode')

等同于以下内容:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

这相当于:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

将一个CustomJS回调附加到任意的BokehJS模型事件。

在BokehJS方面,模型属性的更改事件具有"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到ColumnDataSource时运行回调,可以在源上使用"stream"事件:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

在类上找到Bokeh属性的PropertyDescriptor,给定属性名称。

Parameters:
  • name (str) – 要搜索的属性的名称

  • raises (bool) – 如果缺失,是抛出异常还是返回None

Returns:

名为name的属性的描述符

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

在此对象上添加一个回调,当attr发生变化时触发。

Parameters:
  • attr (str) – 此对象上的一个属性名称

  • *callbacks (callable) – 要注册的回调函数

Returns:

示例

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

当此模型上发生指定事件时运行回调

并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。

classmethod parameters() list[Parameter]#

生成适用于从字形派生的函数的Python Parameter值。

Returns:

列表(参数)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

收集此类的属性名称。

警告

在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在list中。

Returns:

属性名称

classmethod properties_with_refs() dict[str, Property[Any]]#

收集此类上所有具有引用的属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

具有引用的属性名称

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

收集一个将属性名称映射到其值的字典。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。

Parameters:

include_defaults (bool, optional) – 是否包含自对象创建以来未明确设置的属性。(默认值:True)

Returns:

从属性名称到其值的映射

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

使用谓词查询HasProps实例的属性值。

Parameters:
  • query (callable) – 一个可调用对象,接受属性描述符并返回 True 或 False

  • include_defaults (bool, optional) – 是否包含用户未明确设置的属性(默认值:True)

Returns:

属性名称和值的映射,用于匹配属性

Return type:

dict

references() set[Model]#

返回此对象引用的所有Models

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

从此对象中移除一个回调函数

select(selector: SelectorType) Iterable[Model]#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。

Parameters:

selector (类似JSON的)

Returns:

序列[模型]

select_one(selector: SelectorType) Model | None#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like

Returns:

模型

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

从JSON设置此对象的属性值。

Parameters:
  • name (str) – 要设置的属性名称

  • value (JSON-value) – 要设置给属性的值

  • setter (ClientSessionServerSessionNone, 可选) –

    这用于防止对Bokeh应用程序的“回旋镖”更新。

    在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。

Returns:

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

使用指定的属性/值更新来更新与给定选择器匹配的对象。

Parameters:
  • selector (类似JSON的)

  • 更新 (dict)

Returns:

themed_values() dict[str, Any] | None#

获取任何主题提供的覆盖。

结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回None

Returns:

字典或无

to_serializable(serializer: Serializer) ObjectRefRep#

将此对象转换为可序列化的表示形式。

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

移除任何主题值并恢复默认设置。

Returns:

update(**kwargs: Any) None#

从给定的关键字参数更新对象的属性。

Returns:

示例

以下是等价的:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

该模型附加到的Document(可以为None

class GlobalInlineStyleSheet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

基础:InlineStyleSheet

一个内联样式表,附加到 元素。

注意

无论在其他模型中使用多少次,样式表只会附加一次。

JSON Prototype
{
  "css": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "id": "p57352", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
css = Undefined#
Type:

Required(String)

此样式表的内容。

name = None#
Type:

Nullable(String)

此模型的任意用户提供的名称。

在查询文档以检索特定Bokeh模型时,此名称可能很有用。

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

注意

对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。

syncable = True#
Type:

Bool

指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。

注意

将此属性设置为False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。

tags = []#
Type:

List

一个可选的任意用户提供的值列表,用于附加到此模型。

在查询文档以检索特定Bokeh模型时,这些数据可能很有用:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过CustomJS回调等方式访问。

注意

对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。

apply_theme(property_values: dict[str, Any]) None#

应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。

传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和HasProps实例都不应修改它)。

Parameters:

property_values (dict) – 用于替换默认值的主题值

Returns:

classmethod clear_extensions() None#

清除当前定义的所有自定义扩展。

序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。

clone(**overrides: Any) Self#

复制一个HasProps对象。

这将创建原始模型的浅克隆,即任何可变的容器或子模型将不会被复制。允许在克隆时覆盖特定属性。

classmethod dataspecs() dict[str, DataSpec]#

收集此类上所有DataSpec属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

DataSpec 属性的名称

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

属性描述符的列表,按定义的顺序排列。

destroy() None#

清理对文档和属性的引用

equals(other: HasProps) bool#

模型的结构相等性。

Parameters:

其他 (HasProps) – 要比较的其他实例

Returns:

如果属性在结构上相等,则为True,否则为False

使用JavaScript链接两个Bokeh模型属性。

这是一个便捷的方法,简化了添加一个 CustomJS 回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。

Parameters:
  • attr (str) – 此模型上的Bokeh属性的名称

  • 其他 (Model) – 一个要链接到 self.attr 的 Bokeh 模型

  • other_attr (str) – 要链接在一起的other上的属性

  • attr_selector (int | str) – 用于链接可下标对象 attr 中项目的索引

在版本1.1中添加

Raises:

ValueError

示例

这段代码使用了 js_link:

select.js_link('value', plot, 'sizing_mode')

等同于以下内容:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

这相当于:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

将一个CustomJS回调附加到任意的BokehJS模型事件。

在BokehJS方面,模型属性的更改事件具有"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到ColumnDataSource时运行回调,可以在源上使用"stream"事件:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

在类上找到Bokeh属性的PropertyDescriptor,给定属性名称。

Parameters:
  • name (str) – 要搜索的属性的名称

  • raises (bool) – 如果缺失,是抛出异常还是返回None

Returns:

名为name的属性的描述符

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

在此对象上添加一个回调,当attr发生变化时触发。

Parameters:
  • attr (str) – 此对象上的一个属性名称

  • *callbacks (callable) – 要注册的回调函数

Returns:

示例

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

当此模型上发生指定事件时运行回调

并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。

classmethod parameters() list[Parameter]#

生成适用于从字形派生的函数的Python Parameter值。

Returns:

列表(参数)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

收集此类的属性名称。

警告

在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在list中。

Returns:

属性名称

classmethod properties_with_refs() dict[str, Property[Any]]#

收集此类上所有具有引用的属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

具有引用的属性名称

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

收集一个将属性名称映射到其值的字典。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。

Parameters:

include_defaults (bool, optional) – 是否包含自对象创建以来未明确设置的属性。(默认值:True)

Returns:

从属性名称到其值的映射

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

使用谓词查询HasProps实例的属性值。

Parameters:
  • query (callable) – 一个可调用对象,接受属性描述符并返回 True 或 False

  • include_defaults (bool, optional) – 是否包含用户未明确设置的属性(默认值:True)

Returns:

属性名称和值的映射,用于匹配属性

Return type:

dict

references() set[Model]#

返回此对象引用的所有Models

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

从此对象中移除一个回调函数

select(selector: SelectorType) Iterable[Model]#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。

Parameters:

selector (类似JSON的)

Returns:

序列[模型]

select_one(selector: SelectorType) Model | None#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like

Returns:

模型

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

从JSON设置此对象的属性值。

Parameters:
  • name (str) – 要设置的属性名称

  • value (JSON-value) – 要设置给属性的值

  • setter (ClientSessionServerSessionNone, 可选) –

    这用于防止对Bokeh应用程序的“回旋镖”更新。

    在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。

Returns:

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

使用指定的属性/值更新来更新与给定选择器匹配的对象。

Parameters:
  • selector (类似JSON的)

  • 更新 (dict)

Returns:

themed_values() dict[str, Any] | None#

获取任何主题提供的覆盖。

结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回None

Returns:

字典或无

to_serializable(serializer: Serializer) ObjectRefRep#

将此对象转换为可序列化的表示形式。

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

移除任何主题值并恢复默认设置。

Returns:

update(**kwargs: Any) None#

从给定的关键字参数更新对象的属性。

Returns:

示例

以下是等价的:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

该模型附加到的Document(可以为None

class ImportedStyleSheet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

基础类:StyleSheet

导入的样式表等同于 rel="stylesheet" href="${url}">

注意

根据上下文,此样式表将附加到父级影子根(如果在组件中使用),否则附加到 元素。如果您希望无论上下文如何都全局附加,请改用GlobalImportedStyleSheet

JSON Prototype
{
  "id": "p57357", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "url": {
    "name": "unset", 
    "type": "symbol"
  }
}
name = None#
Type:

Nullable(String)

此模型的任意用户提供的名称。

在查询文档以检索特定Bokeh模型时,此名称可能很有用。

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

注意

对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。

syncable = True#
Type:

Bool

指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。

注意

将此属性设置为False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。

tags = []#
Type:

List

一个可选的任意用户提供的值列表,用于附加到此模型。

在查询文档以检索特定Bokeh模型时,这些数据可能很有用:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过CustomJS回调等方式访问。

注意

对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。

url = Undefined#
Type:

Required(String)

外部样式表的位置。

apply_theme(property_values: dict[str, Any]) None#

应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。

传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和HasProps实例都不应修改它)。

Parameters:

property_values (dict) – 用于替换默认值的主题值

Returns:

classmethod clear_extensions() None#

清除当前定义的所有自定义扩展。

序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。

clone(**overrides: Any) Self#

复制一个HasProps对象。

这将创建原始模型的浅克隆,即任何可变的容器或子模型将不会被复制。允许在克隆时覆盖特定属性。

classmethod dataspecs() dict[str, DataSpec]#

收集此类上所有DataSpec属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

DataSpec 属性的名称

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

属性描述符的列表,按定义的顺序排列。

destroy() None#

清理对文档和属性的引用

equals(other: HasProps) bool#

模型的结构相等性。

Parameters:

其他 (HasProps) – 要比较的其他实例

Returns:

如果属性在结构上相等,则为True,否则为False

使用JavaScript链接两个Bokeh模型属性。

这是一个便捷的方法,简化了添加一个 CustomJS 回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。

Parameters:
  • attr (str) – 此模型上的Bokeh属性的名称

  • 其他 (Model) – 一个要链接到 self.attr 的 Bokeh 模型

  • other_attr (str) – 要链接在一起的other上的属性

  • attr_selector (int | str) – 用于链接可下标对象 attr 中项目的索引

在版本1.1中添加

Raises:

ValueError

示例

这段代码使用了 js_link:

select.js_link('value', plot, 'sizing_mode')

等同于以下内容:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

这相当于:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

将一个CustomJS回调附加到任意的BokehJS模型事件。

在BokehJS方面,模型属性的更改事件具有"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到ColumnDataSource时运行回调,可以在源上使用"stream"事件:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

在类上找到Bokeh属性的PropertyDescriptor,给定属性名称。

Parameters:
  • name (str) – 要搜索的属性的名称

  • raises (bool) – 如果缺失,是抛出异常还是返回None

Returns:

名为name的属性的描述符

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

在此对象上添加一个回调,当attr发生变化时触发。

Parameters:
  • attr (str) – 此对象上的一个属性名称

  • *callbacks (callable) – 要注册的回调函数

Returns:

示例

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

当此模型上发生指定事件时运行回调

并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。

classmethod parameters() list[Parameter]#

生成适用于从字形派生的函数的Python Parameter值。

Returns:

列表(参数)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

收集此类的属性名称。

警告

在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在list中。

Returns:

属性名称

classmethod properties_with_refs() dict[str, Property[Any]]#

收集此类上所有具有引用的属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

具有引用的属性名称

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

收集一个将属性名称映射到其值的字典。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。

Parameters:

include_defaults (bool, optional) – 是否包含自对象创建以来未明确设置的属性。(默认值:True)

Returns:

从属性名称到其值的映射

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

使用谓词查询HasProps实例的属性值。

Parameters:
  • query (callable) – 一个可调用对象,接受属性描述符并返回 True 或 False

  • include_defaults (bool, optional) – 是否包含用户未明确设置的属性(默认值:True)

Returns:

属性名称和值的映射,用于匹配属性

Return type:

dict

references() set[Model]#

返回此对象引用的所有Models

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

从此对象中移除一个回调函数

select(selector: SelectorType) Iterable[Model]#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。

Parameters:

selector (类似JSON的)

Returns:

序列[模型]

select_one(selector: SelectorType) Model | None#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like

Returns:

模型

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

从JSON设置此对象的属性值。

Parameters:
  • name (str) – 要设置的属性名称

  • value (JSON-value) – 要设置给属性的值

  • setter (ClientSessionServerSessionNone, 可选) –

    这用于防止对Bokeh应用程序的“回旋镖”更新。

    在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。

Returns:

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

使用指定的属性/值更新来更新与给定选择器匹配的对象。

Parameters:
  • selector (类似JSON的)

  • 更新 (dict)

Returns:

themed_values() dict[str, Any] | None#

获取任何主题提供的覆盖。

结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回None

Returns:

字典或无

to_serializable(serializer: Serializer) ObjectRefRep#

将此对象转换为可序列化的表示形式。

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

移除任何主题值并恢复默认设置。

Returns:

update(**kwargs: Any) None#

从给定的关键字参数更新对象的属性。

Returns:

示例

以下是等价的:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

该模型附加到的Document(可以为None

class InlineStyleSheet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

基础:StyleSheet

内联样式表等同于 type="text/css">${css}

注意

根据上下文,此样式表将附加到父级影子根(如果在组件中使用),否则附加到 元素。如果您希望无论上下文如何都全局附加,请改用GlobalInlineStyleSheet

JSON Prototype
{
  "css": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "id": "p57362", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
css = Undefined#
Type:

Required(String)

此样式表的内容。

name = None#
Type:

Nullable(String)

此模型的任意用户提供的名称。

在查询文档以检索特定Bokeh模型时,此名称可能很有用。

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

注意

对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。

syncable = True#
Type:

Bool

指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。

注意

将此属性设置为False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。

tags = []#
Type:

List

一个可选的任意用户提供的值列表,用于附加到此模型。

在查询文档以检索特定Bokeh模型时,这些数据可能很有用:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过CustomJS回调等方式访问。

注意

对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。

apply_theme(property_values: dict[str, Any]) None#

应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。

传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和HasProps实例都不应修改它)。

Parameters:

property_values (dict) – 用于替换默认值的主题值

Returns:

classmethod clear_extensions() None#

清除当前定义的所有自定义扩展。

序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。

clone(**overrides: Any) Self#

复制一个HasProps对象。

这将创建原始模型的浅克隆,即任何可变的容器或子模型将不会被复制。允许在克隆时覆盖特定属性。

classmethod dataspecs() dict[str, DataSpec]#

收集此类上所有DataSpec属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

DataSpec 属性的名称

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

属性描述符的列表,按定义的顺序排列。

destroy() None#

清理对文档和属性的引用

equals(other: HasProps) bool#

模型的结构相等性。

Parameters:

其他 (HasProps) – 要比较的其他实例

Returns:

如果属性在结构上相等,则为True,否则为False

使用JavaScript链接两个Bokeh模型属性。

这是一个便捷的方法,简化了添加一个 CustomJS 回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。

Parameters:
  • attr (str) – 此模型上的Bokeh属性的名称

  • 其他 (Model) – 一个要链接到 self.attr 的 Bokeh 模型

  • other_attr (str) – 要链接在一起的other上的属性

  • attr_selector (int | str) – 用于链接可下标对象 attr 中项目的索引

在版本1.1中添加

Raises:

ValueError

示例

这段代码使用了 js_link:

select.js_link('value', plot, 'sizing_mode')

等同于以下内容:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

这相当于:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

将一个CustomJS回调附加到任意的BokehJS模型事件。

在BokehJS方面,模型属性的更改事件具有"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到ColumnDataSource时运行回调,可以在源上使用"stream"事件:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

在类上找到Bokeh属性的PropertyDescriptor,给定属性名称。

Parameters:
  • name (str) – 要搜索的属性的名称

  • raises (bool) – 如果缺失,是抛出异常还是返回None

Returns:

名为name的属性的描述符

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

在此对象上添加一个回调,当attr发生变化时触发。

Parameters:
  • attr (str) – 此对象上的一个属性名称

  • *callbacks (callable) – 要注册的回调函数

Returns:

示例

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

当此模型上发生指定事件时运行回调

并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。

classmethod parameters() list[Parameter]#

生成适用于从字形派生的函数的Python Parameter值。

Returns:

列表(参数)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

收集此类的属性名称。

警告

在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在list中。

Returns:

属性名称

classmethod properties_with_refs() dict[str, Property[Any]]#

收集此类上所有具有引用的属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

具有引用的属性名称

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

收集一个将属性名称映射到其值的字典。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。

Parameters:

include_defaults (bool, optional) – 是否包含自对象创建以来未明确设置的属性。(默认值:True)

Returns:

从属性名称到其值的映射

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

使用谓词查询HasProps实例的属性值。

Parameters:
  • query (callable) – 一个可调用对象,接受属性描述符并返回 True 或 False

  • include_defaults (bool, optional) – 是否包含用户未明确设置的属性(默认值:True)

Returns:

属性名称和值的映射,用于匹配属性

Return type:

dict

references() set[Model]#

返回此对象引用的所有Models

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

从此对象中移除一个回调函数

select(selector: SelectorType) Iterable[Model]#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。

Parameters:

selector (类似JSON的)

Returns:

序列[模型]

select_one(selector: SelectorType) Model | None#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like

Returns:

模型

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

从JSON设置此对象的属性值。

Parameters:
  • name (str) – 要设置的属性名称

  • value (JSON-value) – 要设置给属性的值

  • setter (ClientSessionServerSessionNone, 可选) –

    这用于防止对Bokeh应用程序的“回旋镖”更新。

    在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。

Returns:

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

使用指定的属性/值更新来更新与给定选择器匹配的对象。

Parameters:
  • selector (类似JSON的)

  • 更新 (dict)

Returns:

themed_values() dict[str, Any] | None#

获取任何主题提供的覆盖。

结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回None

Returns:

字典或无

to_serializable(serializer: Serializer) ObjectRefRep#

将此对象转换为可序列化的表示形式。

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

移除任何主题值并恢复默认设置。

Returns:

update(**kwargs: Any) None#

从给定的关键字参数更新对象的属性。

Returns:

示例

以下是等价的:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

该模型附加到的Document(可以为None

class Styles(*args: Any, id: ID | None = None, **kwargs: Any)[源代码]#

基础类:Model

允许配置DOM元素的样式属性。

JSON Prototype
{
  "align_content": null, 
  "align_items": null, 
  "align_self": null, 
  "alignment_baseline": null, 
  "all": null, 
  "animation": null, 
  "animation_delay": null, 
  "animation_direction": null, 
  "animation_duration": null, 
  "animation_fill_mode": null, 
  "animation_iteration_count": null, 
  "animation_name": null, 
  "animation_play_state": null, 
  "animation_timing_function": null, 
  "aspect_ratio": null, 
  "backface_visibility": null, 
  "background": null, 
  "background_attachment": null, 
  "background_clip": null, 
  "background_color": null, 
  "background_image": null, 
  "background_origin": null, 
  "background_position": null, 
  "background_position_x": null, 
  "background_position_y": null, 
  "background_repeat": null, 
  "background_size": null, 
  "baseline_shift": null, 
  "block_size": null, 
  "border": null, 
  "border_block_end": null, 
  "border_block_end_color": null, 
  "border_block_end_style": null, 
  "border_block_end_width": null, 
  "border_block_start": null, 
  "border_block_start_color": null, 
  "border_block_start_style": null, 
  "border_block_start_width": null, 
  "border_bottom": null, 
  "border_bottom_color": null, 
  "border_bottom_left_radius": null, 
  "border_bottom_right_radius": null, 
  "border_bottom_style": null, 
  "border_bottom_width": null, 
  "border_collapse": null, 
  "border_color": null, 
  "border_image": null, 
  "border_image_outset": null, 
  "border_image_repeat": null, 
  "border_image_slice": null, 
  "border_image_source": null, 
  "border_image_width": null, 
  "border_inline_end": null, 
  "border_inline_end_color": null, 
  "border_inline_end_style": null, 
  "border_inline_end_width": null, 
  "border_inline_start": null, 
  "border_inline_start_color": null, 
  "border_inline_start_style": null, 
  "border_inline_start_width": null, 
  "border_left": null, 
  "border_left_color": null, 
  "border_left_style": null, 
  "border_left_width": null, 
  "border_radius": null, 
  "border_right": null, 
  "border_right_color": null, 
  "border_right_style": null, 
  "border_right_width": null, 
  "border_spacing": null, 
  "border_style": null, 
  "border_top": null, 
  "border_top_color": null, 
  "border_top_left_radius": null, 
  "border_top_right_radius": null, 
  "border_top_style": null, 
  "border_top_width": null, 
  "border_width": null, 
  "bottom": null, 
  "box_shadow": null, 
  "box_sizing": null, 
  "break_after": null, 
  "break_before": null, 
  "break_inside": null, 
  "caption_side": null, 
  "caret_color": null, 
  "clear": null, 
  "clip": null, 
  "clip_path": null, 
  "clip_rule": null, 
  "color": null, 
  "color_interpolation": null, 
  "color_interpolation_filters": null, 
  "column_count": null, 
  "column_fill": null, 
  "column_gap": null, 
  "column_rule": null, 
  "column_rule_color": null, 
  "column_rule_style": null, 
  "column_rule_width": null, 
  "column_span": null, 
  "column_width": null, 
  "columns": null, 
  "content": null, 
  "counter_increment": null, 
  "counter_reset": null, 
  "cursor": null, 
  "direction": null, 
  "display": null, 
  "dominant_baseline": null, 
  "empty_cells": null, 
  "fill": null, 
  "fill_opacity": null, 
  "fill_rule": null, 
  "filter": null, 
  "flex": null, 
  "flex_basis": null, 
  "flex_direction": null, 
  "flex_flow": null, 
  "flex_grow": null, 
  "flex_shrink": null, 
  "flex_wrap": null, 
  "float": null, 
  "flood_color": null, 
  "flood_opacity": null, 
  "font": null, 
  "font_family": null, 
  "font_feature_settings": null, 
  "font_kerning": null, 
  "font_size": null, 
  "font_size_adjust": null, 
  "font_stretch": null, 
  "font_style": null, 
  "font_synthesis": null, 
  "font_variant": null, 
  "font_variant_caps": null, 
  "font_variant_east_asian": null, 
  "font_variant_ligatures": null, 
  "font_variant_numeric": null, 
  "font_variant_position": null, 
  "font_weight": null, 
  "gap": null, 
  "glyph_orientation_vertical": null, 
  "grid": null, 
  "grid_area": null, 
  "grid_auto_columns": null, 
  "grid_auto_flow": null, 
  "grid_auto_rows": null, 
  "grid_column": null, 
  "grid_column_end": null, 
  "grid_column_gap": null, 
  "grid_column_start": null, 
  "grid_gap": null, 
  "grid_row": null, 
  "grid_row_end": null, 
  "grid_row_gap": null, 
  "grid_row_start": null, 
  "grid_template": null, 
  "grid_template_areas": null, 
  "grid_template_columns": null, 
  "grid_template_rows": null, 
  "height": null, 
  "hyphens": null, 
  "id": "p57367", 
  "image_orientation": null, 
  "image_rendering": null, 
  "inline_size": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "justify_content": null, 
  "justify_items": null, 
  "justify_self": null, 
  "left": null, 
  "letter_spacing": null, 
  "lighting_color": null, 
  "line_break": null, 
  "line_height": null, 
  "list_style": null, 
  "list_style_image": null, 
  "list_style_position": null, 
  "list_style_type": null, 
  "margin": null, 
  "margin_block_end": null, 
  "margin_block_start": null, 
  "margin_bottom": null, 
  "margin_inline_end": null, 
  "margin_inline_start": null, 
  "margin_left": null, 
  "margin_right": null, 
  "margin_top": null, 
  "marker": null, 
  "marker_end": null, 
  "marker_mid": null, 
  "marker_start": null, 
  "mask": null, 
  "mask_composite": null, 
  "mask_image": null, 
  "mask_position": null, 
  "mask_repeat": null, 
  "mask_size": null, 
  "mask_type": null, 
  "max_block_size": null, 
  "max_height": null, 
  "max_inline_size": null, 
  "max_width": null, 
  "min_block_size": null, 
  "min_height": null, 
  "min_inline_size": null, 
  "min_width": null, 
  "name": null, 
  "object_fit": null, 
  "object_position": null, 
  "opacity": null, 
  "order": null, 
  "orphans": null, 
  "outline": null, 
  "outline_color": null, 
  "outline_offset": null, 
  "outline_style": null, 
  "outline_width": null, 
  "overflow": null, 
  "overflow_anchor": null, 
  "overflow_wrap": null, 
  "overflow_x": null, 
  "overflow_y": null, 
  "overscroll_behavior": null, 
  "overscroll_behavior_block": null, 
  "overscroll_behavior_inline": null, 
  "overscroll_behavior_x": null, 
  "overscroll_behavior_y": null, 
  "padding": null, 
  "padding_block_end": null, 
  "padding_block_start": null, 
  "padding_bottom": null, 
  "padding_inline_end": null, 
  "padding_inline_start": null, 
  "padding_left": null, 
  "padding_right": null, 
  "padding_top": null, 
  "page_break_after": null, 
  "page_break_before": null, 
  "page_break_inside": null, 
  "paint_order": null, 
  "perspective": null, 
  "perspective_origin": null, 
  "place_content": null, 
  "place_items": null, 
  "place_self": null, 
  "pointer_events": null, 
  "position": null, 
  "quotes": null, 
  "resize": null, 
  "right": null, 
  "rotate": null, 
  "row_gap": null, 
  "ruby_align": null, 
  "ruby_position": null, 
  "scale": null, 
  "scroll_behavior": null, 
  "shape_rendering": null, 
  "stop_color": null, 
  "stop_opacity": null, 
  "stroke": null, 
  "stroke_dasharray": null, 
  "stroke_dashoffset": null, 
  "stroke_linecap": null, 
  "stroke_linejoin": null, 
  "stroke_miterlimit": null, 
  "stroke_opacity": null, 
  "stroke_width": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tab_size": null, 
  "table_layout": null, 
  "tags": [], 
  "text_align": null, 
  "text_align_last": null, 
  "text_anchor": null, 
  "text_combine_upright": null, 
  "text_decoration": null, 
  "text_decoration_color": null, 
  "text_decoration_line": null, 
  "text_decoration_style": null, 
  "text_emphasis": null, 
  "text_emphasis_color": null, 
  "text_emphasis_position": null, 
  "text_emphasis_style": null, 
  "text_indent": null, 
  "text_justify": null, 
  "text_orientation": null, 
  "text_overflow": null, 
  "text_rendering": null, 
  "text_shadow": null, 
  "text_transform": null, 
  "text_underline_position": null, 
  "top": null, 
  "touch_action": null, 
  "transform": null, 
  "transform_box": null, 
  "transform_origin": null, 
  "transform_style": null, 
  "transition": null, 
  "transition_delay": null, 
  "transition_duration": null, 
  "transition_property": null, 
  "transition_timing_function": null, 
  "translate": null, 
  "unicode_bidi": null, 
  "user_select": null, 
  "vertical_align": null, 
  "visibility": null, 
  "white_space": null, 
  "widows": null, 
  "width": null, 
  "will_change": null, 
  "word_break": null, 
  "word_spacing": null, 
  "word_wrap": null, 
  "writing_mode": null, 
  "z_index": null
}
min_inline_size = None#
Type:

Nullable(String)

min-inline-size CSS 属性定义了元素块的水平或垂直最小尺寸,取决于其书写模式。它对应于 min-widthmin-height 属性,取决于 writing-mode 的值。

name = None#
Type:

Nullable(String)

此模型的任意用户提供的名称。

在查询文档以检索特定Bokeh模型时,此名称可能很有用。

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

注意

对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。

syncable = True#
Type:

Bool

指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。

注意

将此属性设置为False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。

tags = []#
Type:

List

一个可选的任意用户提供的值列表,用于附加到此模型。

在查询文档以检索特定Bokeh模型时,这些数据可能很有用:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过CustomJS回调等方式访问。

注意

对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。

apply_theme(property_values: dict[str, Any]) None#

应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。

传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和HasProps实例都不应修改它)。

Parameters:

property_values (dict) – 用于替换默认值的主题值

Returns:

classmethod clear_extensions() None#

清除当前定义的所有自定义扩展。

序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。

clone(**overrides: Any) Self#

复制一个HasProps对象。

这将创建原始模型的浅克隆,即任何可变的容器或子模型将不会被复制。允许在克隆时覆盖特定属性。

classmethod dataspecs() dict[str, DataSpec]#

收集此类上所有DataSpec属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

DataSpec 属性的名称

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

属性描述符的列表,按定义的顺序排列。

destroy() None#

清理对文档和属性的引用

equals(other: HasProps) bool#

模型的结构相等性。

Parameters:

其他 (HasProps) – 要比较的其他实例

Returns:

如果属性在结构上相等,则为True,否则为False

使用JavaScript链接两个Bokeh模型属性。

这是一个便捷的方法,简化了添加一个 CustomJS 回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。

Parameters:
  • attr (str) – 此模型上的Bokeh属性的名称

  • 其他 (Model) – 一个要链接到 self.attr 的 Bokeh 模型

  • other_attr (str) – 要链接在一起的other上的属性

  • attr_selector (int | str) – 用于链接可下标对象 attr 中项目的索引

在版本1.1中添加

Raises:

ValueError

示例

这段代码使用了 js_link:

select.js_link('value', plot, 'sizing_mode')

等同于以下内容:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

这相当于:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

将一个CustomJS回调附加到任意的BokehJS模型事件。

在BokehJS方面,模型属性的更改事件具有"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到ColumnDataSource时运行回调,可以在源上使用"stream"事件:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

在类上找到Bokeh属性的PropertyDescriptor,给定属性名称。

Parameters:
  • name (str) – 要搜索的属性的名称

  • raises (bool) – 如果缺失,是抛出异常还是返回None

Returns:

名为name的属性的描述符

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

在此对象上添加一个回调,当attr发生变化时触发。

Parameters:
  • attr (str) – 此对象上的一个属性名称

  • *callbacks (callable) – 要注册的回调函数

Returns:

示例

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

当此模型上发生指定事件时运行回调

并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。

classmethod parameters() list[Parameter]#

生成适用于从字形派生的函数的Python Parameter值。

Returns:

列表(参数)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

收集此类的属性名称。

警告

在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在list中。

Returns:

属性名称

classmethod properties_with_refs() dict[str, Property[Any]]#

收集此类上所有具有引用的属性的名称。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

Returns:

具有引用的属性名称

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

收集一个将属性名称映射到其值的字典。

此方法始终遍历类层次结构,并包括在任何父类上定义的属性。

不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。

Parameters:

include_defaults (bool, optional) – 是否包含自对象创建以来未明确设置的属性。(默认值:True)

Returns:

从属性名称到其值的映射

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

使用谓词查询HasProps实例的属性值。

Parameters:
  • query (callable) – 一个可调用对象,接受属性描述符并返回 True 或 False

  • include_defaults (bool, optional) – 是否包含用户未明确设置的属性(默认值:True)

Returns:

属性名称和值的映射,用于匹配属性

Return type:

dict

references() set[Model]#

返回此对象引用的所有Models

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

从此对象中移除一个回调函数

select(selector: SelectorType) Iterable[Model]#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。

Parameters:

selector (类似JSON的)

Returns:

序列[模型]

select_one(selector: SelectorType) Model | None#

查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like

Returns:

模型

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

从JSON设置此对象的属性值。

Parameters:
  • name (str) – 要设置的属性名称

  • value (JSON-value) – 要设置给属性的值

  • setter (ClientSessionServerSessionNone, 可选) –

    这用于防止对Bokeh应用程序的“回旋镖”更新。

    在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。

Returns:

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

使用指定的属性/值更新来更新与给定选择器匹配的对象。

Parameters:
  • selector (类似JSON的)

  • 更新 (dict)

Returns:

themed_values() dict[str, Any] | None#

获取任何主题提供的覆盖。

结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回None

Returns:

字典或无

to_serializable(serializer: Serializer) ObjectRefRep#

将此对象转换为可序列化的表示形式。

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

移除任何主题值并恢复默认设置。

Returns:

update(**kwargs: Any) None#

从给定的关键字参数更新对象的属性。

Returns:

示例

以下是等价的:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

该模型附加到的Document(可以为None