Method
ipyvizzu.method
A module for working with template methods.
ipyvizzu.method.Method
A class for dumping chart independent parameters to DisplayTemplate.STORE template.
Source code in src/ipyvizzu/method.py
class Method:
"""
A class for dumping chart independent parameters to
[DisplayTemplate.STORE][ipyvizzu.template.DisplayTemplate] template.
"""
# pylint: disable=too-few-public-methods
_data: dict
def dump(self) -> dict:
"""
A method for returning the stored data.
Returns:
The stored data.
"""
return self._data
dump()
A method for returning the stored data.
Returns:
Type | Description |
---|---|
dict
|
The stored data. |
Source code in src/ipyvizzu/method.py
def dump(self) -> dict:
"""
A method for returning the stored data.
Returns:
The stored data.
"""
return self._data
ipyvizzu.method.Animate
Bases: Method
It stores and dumps chart_target
and chart_anim_opts
parameters.
Source code in src/ipyvizzu/method.py
class Animate(Method):
"""
It stores and dumps `chart_target` and `chart_anim_opts` parameters.
"""
# pylint: disable=too-few-public-methods
def __init__(
self,
chart_target: AbstractAnimation,
chart_anim_opts: Optional[dict] = None,
):
"""
Animate constructor.
Args:
chart_target:
AbstractAnimation inherited object such as
[Data][ipyvizzu.animation.Data]
[Config][ipyvizzu.animation.Config] or
[Style][ipyvizzu.animation.Style].
chart_anim_opts:
Animation options' dictionary. If it is not set, it dumps `undefined`.
"""
self._data = {
"chart_target": chart_target.dump(),
"chart_anim_opts": (
PlainAnimation(chart_anim_opts).dump()
if chart_anim_opts
else "undefined"
),
}
__init__(chart_target, chart_anim_opts=None)
Animate constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chart_target |
AbstractAnimation
|
required | |
chart_anim_opts |
Optional[dict]
|
Animation options' dictionary. If it is not set, it dumps |
None
|
Source code in src/ipyvizzu/method.py
def __init__(
self,
chart_target: AbstractAnimation,
chart_anim_opts: Optional[dict] = None,
):
"""
Animate constructor.
Args:
chart_target:
AbstractAnimation inherited object such as
[Data][ipyvizzu.animation.Data]
[Config][ipyvizzu.animation.Config] or
[Style][ipyvizzu.animation.Style].
chart_anim_opts:
Animation options' dictionary. If it is not set, it dumps `undefined`.
"""
self._data = {
"chart_target": chart_target.dump(),
"chart_anim_opts": (
PlainAnimation(chart_anim_opts).dump()
if chart_anim_opts
else "undefined"
),
}
ipyvizzu.method.Feature
Bases: Method
It stores and dumps name
and enabled
parameters.
Source code in src/ipyvizzu/method.py
class Feature(Method):
"""
It stores and dumps `name` and `enabled` parameters.
"""
# pylint: disable=too-few-public-methods
def __init__(self, name: str, enabled: bool):
"""
Feature constructor.
Args:
name: The name of a chart feature.
enabled: The new state of a chart feature.
"""
self._data = {"name": name, "enabled": json.dumps(enabled)}
__init__(name, enabled)
Feature constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of a chart feature. |
required |
enabled |
bool
|
The new state of a chart feature. |
required |
Source code in src/ipyvizzu/method.py
def __init__(self, name: str, enabled: bool):
"""
Feature constructor.
Args:
name: The name of a chart feature.
enabled: The new state of a chart feature.
"""
self._data = {"name": name, "enabled": json.dumps(enabled)}
ipyvizzu.method.Plugin
Bases: Method
It stores and dumps plugin
, options
and name
parameters.
Source code in src/ipyvizzu/method.py
class Plugin(Method):
"""
It stores and dumps `plugin`, `options` and `name` parameters.
"""
def __init__(self, plugin: str, options: Optional[dict], name: str, enabled: bool):
"""
Plugin constructor.
Args:
plugin: The package name or the url of the plugin.
options: The plugin constructor options.
name: The name of the plugin (default `default`).
enabled: The state of the plugin (default `True`).
"""
self._data = {
"plugin": Plugin.resolve_url(plugin),
"options": (
{} if options is None else json.dumps(options, cls=RawJavaScriptEncoder)
),
"name": name,
"enabled": json.dumps(enabled),
}
@staticmethod
def resolve_url(plugin: str) -> str:
"""
A static method for resolving the url of the plugin.
Args:
plugin: The package name or the url of the plugin.
Returns:
The url of the plugin.
"""
if Plugin._is_url(plugin):
return plugin
return Plugin._get_url(plugin)
@staticmethod
def _is_url(plugin: str) -> bool:
return "/" in plugin
@staticmethod
def _get_url(plugin: str) -> str:
jsdelivr = "https://cdn.jsdelivr.net/npm/@vizzu"
tag = f"vizzu-{VIZZU_VERSION}"
return f"{jsdelivr}/{plugin}@{tag}/dist/mjs/index.min.js"
__init__(plugin, options, name, enabled)
Plugin constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plugin |
str
|
The package name or the url of the plugin. |
required |
options |
Optional[dict]
|
The plugin constructor options. |
required |
name |
str
|
The name of the plugin (default |
required |
enabled |
bool
|
The state of the plugin (default |
required |
Source code in src/ipyvizzu/method.py
def __init__(self, plugin: str, options: Optional[dict], name: str, enabled: bool):
"""
Plugin constructor.
Args:
plugin: The package name or the url of the plugin.
options: The plugin constructor options.
name: The name of the plugin (default `default`).
enabled: The state of the plugin (default `True`).
"""
self._data = {
"plugin": Plugin.resolve_url(plugin),
"options": (
{} if options is None else json.dumps(options, cls=RawJavaScriptEncoder)
),
"name": name,
"enabled": json.dumps(enabled),
}
resolve_url(plugin)
staticmethod
A static method for resolving the url of the plugin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plugin |
str
|
The package name or the url of the plugin. |
required |
Returns:
Type | Description |
---|---|
str
|
The url of the plugin. |
Source code in src/ipyvizzu/method.py
@staticmethod
def resolve_url(plugin: str) -> str:
"""
A static method for resolving the url of the plugin.
Args:
plugin: The package name or the url of the plugin.
Returns:
The url of the plugin.
"""
if Plugin._is_url(plugin):
return plugin
return Plugin._get_url(plugin)
ipyvizzu.method.Store
Bases: Method
It stores and dumps snapshot_id
parameter.
Source code in src/ipyvizzu/method.py
class Store(Method):
"""
It stores and dumps `snapshot_id` parameter.
"""
# pylint: disable=too-few-public-methods
def __init__(self, snapshot_id: str):
"""
Store constructor.
Args:
snapshot_id: The id of snapshot object.
"""
self._data = {"id": snapshot_id}
__init__(snapshot_id)
Store constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_id |
str
|
The id of snapshot object. |
required |
Source code in src/ipyvizzu/method.py
def __init__(self, snapshot_id: str):
"""
Store constructor.
Args:
snapshot_id: The id of snapshot object.
"""
self._data = {"id": snapshot_id}
ipyvizzu.method.EventOn
Bases: Method
It stores and dumps the id
, the event
and the handler
of the event handler object.
Source code in src/ipyvizzu/method.py
class EventOn(Method):
"""
It stores and dumps the `id`, the `event` and the `handler` of the event handler object.
"""
# pylint: disable=too-few-public-methods
def __init__(self, event_handler: EventHandler):
"""
EventOn constructor.
Args:
event_handler: An event handler object.
"""
self._data = {
"id": event_handler.id,
"event": event_handler.event,
"handler": event_handler.handler,
}
__init__(event_handler)
EventOn constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_handler |
EventHandler
|
An event handler object. |
required |
Source code in src/ipyvizzu/method.py
def __init__(self, event_handler: EventHandler):
"""
EventOn constructor.
Args:
event_handler: An event handler object.
"""
self._data = {
"id": event_handler.id,
"event": event_handler.event,
"handler": event_handler.handler,
}
ipyvizzu.method.EventOff
Bases: Method
It stores and dumps the id
and the event
of the event handler object.
Source code in src/ipyvizzu/method.py
class EventOff(Method):
"""
It stores and dumps the `id` and the `event` of the event handler object.
"""
# pylint: disable=too-few-public-methods
def __init__(self, event_handler: EventHandler):
"""
EventOff constructor.
Args:
event_handler: An event handler object.
"""
self._data = {"id": event_handler.id, "event": event_handler.event}
__init__(event_handler)
EventOff constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_handler |
EventHandler
|
An event handler object. |
required |
Source code in src/ipyvizzu/method.py
def __init__(self, event_handler: EventHandler):
"""
EventOff constructor.
Args:
event_handler: An event handler object.
"""
self._data = {"id": event_handler.id, "event": event_handler.event}
ipyvizzu.method.Log
Bases: Method
It stores and dumps the value of the chart property object.
Source code in src/ipyvizzu/method.py
class Log(Method):
"""
It stores and dumps the value of the chart property object.
"""
# pylint: disable=too-few-public-methods
def __init__(self, chart_property: ChartProperty):
"""
Log constructor.
Args:
chart_property:
A chart property such as
[CONFIG][ipyvizzu.template.ChartProperty] and
[STYLE][ipyvizzu.template.ChartProperty].
"""
self._data = {"chart_property": chart_property.value}
__init__(chart_property)
Log constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chart_property |
ChartProperty
|
required |
Source code in src/ipyvizzu/method.py
def __init__(self, chart_property: ChartProperty):
"""
Log constructor.
Args:
chart_property:
A chart property such as
[CONFIG][ipyvizzu.template.ChartProperty] and
[STYLE][ipyvizzu.template.ChartProperty].
"""
self._data = {"chart_property": chart_property.value}